diff -Nru syncwall-1.6.0/3rdparty/3rdparty.pro syncwall-1.7.4/3rdparty/3rdparty.pro --- syncwall-1.6.0/3rdparty/3rdparty.pro 2012-01-20 14:38:04.000000000 +0000 +++ syncwall-1.7.4/3rdparty/3rdparty.pro 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -TEMPLATE = subdirs - -CONFIG += warn_on debug_and_release -SUBDIRS += qimageblitz - diff -Nru syncwall-1.6.0/3rdparty/3rdparty.sln syncwall-1.7.4/3rdparty/3rdparty.sln --- syncwall-1.6.0/3rdparty/3rdparty.sln 2012-04-15 05:35:02.000000000 +0000 +++ syncwall-1.7.4/3rdparty/3rdparty.sln 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 9.00 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "qimageblitz", "C:/Download/SyncWall-1.4.0/3rdparty/qimageblitz\qimageblitz.vcproj", "{82BF4D98-515D-3E39-A973-F29D7A705DC7}" -EndProject -Global - GlobalSection(SolutionConfiguration) = preSolution - ConfigName.0 = Debug|Win32 - ConfigName.1 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectDependencies) = postSolution - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {82BF4D98-515D-3E39-A973-F29D7A705DC7}.Debug|Win32.ActiveCfg = Debug|Win32 - {82BF4D98-515D-3E39-A973-F29D7A705DC7}.Debug|Win32.Build.0 = Debug|Win32 - {82BF4D98-515D-3E39-A973-F29D7A705DC7}.Release|Win32.ActiveCfg = Release|Win32 - {82BF4D98-515D-3E39-A973-F29D7A705DC7}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal \ No newline at end of file diff -Nru syncwall-1.6.0/3rdparty/qimageblitz/CMakeLists.txt syncwall-1.7.4/3rdparty/qimageblitz/CMakeLists.txt --- syncwall-1.6.0/3rdparty/qimageblitz/CMakeLists.txt 2012-01-08 15:07:42.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qimageblitz/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -project(blitz_lib) -include(CheckCXXSourceCompiles) -include(CheckIncludeFile) - -CMAKE_MINIMUM_REQUIRED(VERSION 2.4.4) - -if (APPLE) - set(CMAKE_INSTALL_NAME_DIR ${LIB_INSTALL_DIR}) - set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) -endif (APPLE) - -include_directories( -${CMAKE_SOURCE_DIR} -${blitz_lib_BINARY_DIR} -${QT_INCLUDE_DIR} -${QT_QTCORE_INCLUDE_DIR} -${QT_QTGUI_INCLUDE_DIR} -) - -CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H) - -if(NOT MSVC) - CHECK_CXX_SOURCE_COMPILES(" int main() { __asm__(\"pxor %mm0, %mm0\") ; }" HAVE_MMX) - CHECK_CXX_SOURCE_COMPILES(" int main() { __asm__(\"xorps %xmm0, %xmm0\"); }" HAVE_SSE) - CHECK_CXX_SOURCE_COMPILES(" int main() { __asm__(\"xorpd %xmm0, %xmm0\"); }" HAVE_SSE2) - CHECK_CXX_SOURCE_COMPILES(" int main() { __asm__(\"pi2fd %mm0, %mm0\"); }" HAVE_3DNOW) - CHECK_CXX_SOURCE_COMPILES(" int main() { __asm__(\"mtspr 256, %0; vand %%v0, %%v0, %%v0\" : : \"r\"(-1) ); }" HAVE_ALTIVEC) -endif(NOT MSVC) - -SET(BLITZ_LIB_MAJOR_VERSION "4") -SET(BLITZ_LIB_MINOR_VERSION "0") -SET(BLITZ_LIB_PATCH_VERSION "0") - -SET(BLITZ_LIB_VERSION_STRING "${BLITZ_LIB_MAJOR_VERSION}.${BLITZ_LIB_MINOR_VERSION}.${BLITZ_LIB_PATCH_VERSION}") - -set(blitz_LIB_SRCS blitz.cpp colors.cpp convolve.cpp histogram.cpp -blitzcpu.cpp scale.cpp scalefilter.cpp gradient.cpp) - -if(HAVE_MMX) - if(NOT APPLE AND NOT WIN32) - set( blitz_LIB_SRCS ${blitz_LIB_SRCS} asm_scale.S ) - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/asm_scale.o - COMMAND gcc -c ${CMAKE_CURRENT_SOURCE_DIR}/asm_scale.S - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/asm_scale.S ) - set( blitz_LIB_EXTRA_SRCS ${CMAKE_CURRENT_BINARY_DIR}/asm_scale.o ) - set(HAVE_EXTERNAL_ASM TRUE) - endif(NOT APPLE AND NOT WIN32) -endif(HAVE_MMX) -configure_file (config-processor.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-processor.h ) -configure_file (config-externalasm.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-externalasm.h ) - -add_library(qimageblitz STATIC ${blitz_LIB_SRCS} ${blitz_LIB_EXTRA_SRCS}) - -target_link_libraries(qimageblitz ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY}) - -set_target_properties(qimageblitz PROPERTIES - VERSION ${BLITZ_LIB_MAJOR_VERSION}.${BLITZ_LIB_MINOR_VERSION}.${BLITZ_LIB_PATCH_VERSION} - SOVERSION ${BLITZ_LIB_MAJOR_VERSION} - DEFINE_SYMBOL MAKE_QIMAGEBLITZ_LIB -) - - - diff -Nru syncwall-1.6.0/3rdparty/qimageblitz/asm_scale.S syncwall-1.7.4/3rdparty/qimageblitz/asm_scale.S --- syncwall-1.6.0/3rdparty/qimageblitz/asm_scale.S 2008-02-26 19:31:00.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qimageblitz/asm_scale.S 1970-01-01 00:00:00.000000000 +0000 @@ -1,816 +0,0 @@ - -#if defined(__EMX__) -/* Due to strange behaviour of as.exe we use this macros */ -/* For all OS/2 coders - please use PGCC to compile this code */ -#define PR_(foo) ___##foo -#define PT_(foo,func) ___##foo,##func -#define SIZE(sym) \ - .___end_##sym:; \ - .size ___##sym,.___end_##sym-___##sym; \ - .align 8; -#elif defined(__APPLE__) -#define PR_(foo) ___##foo -#define PT_(foo,func) ___##foo,##func -#define SIZE(sym) \ - .__end_##sym:; \ - .align 8; -#else -#define PR_(foo) __##foo -#define PT_(foo,func) __##foo,##func -#define SIZE(sym) \ - .__end_##sym:; \ - .size __##sym,.__end_##sym-__##sym; \ - .align 8; -#endif - -#if defined(__i386__) && ( defined(__GNUC__) || defined(__INTEL_COMPILER) ) - - -/*\ -|*| MMX assembly scaling routine for Imlib2 -|*| Written by Willem Monsuwe -\*/ - -.text - .align 8 -.globl PR_(qimageScale_mmx_AARGBA) -/* .type PT_(qimageScale_mmx_AARGBA,@function) */ - - -/*\ Prototype: __qimageScale_mmx_AARGBA(ImlibScaleInfo *isi, DATA32 *dest, -|*| int dxx, int dyy, int dx, int dy, int dw, int dh, int dow, int sow) -\*/ - -#define isi 8(%ebp) -#define dest 12(%ebp) -#define dxx 16(%ebp) -#define dyy 20(%ebp) -#define dx 24(%ebp) -#define dy 28(%ebp) -#define dw 32(%ebp) -#define dh 36(%ebp) -#define dow 40(%ebp) -#define sow 44(%ebp) - -/*\ Local variables that didn't fit in registers \*/ -#define y -4(%ebp) -#define yp -8(%ebp) -#define yap -12(%ebp) -#define xp -16(%ebp) -#define xap -20(%ebp) -#define Cx -24(%ebp) -#define Mx -28(%ebp) -#define Cy -32(%ebp) -#define My -36(%ebp) -#define sow_4 -40(%ebp) - -/*\ When %edx points to ImlibScaleInfo, these are the members \*/ -#define xpoints (%edx) -#define ypoints 4(%edx) -#define xapoints 8(%edx) -#define yapoints 12(%edx) -#define xup_yup 16(%edx) - -PR_(qimageScale_mmx_AARGBA): - pushl %ebp - movl %esp, %ebp - subl $40, %esp - pushl %ebx - pushl %ecx - pushl %edx - pushl %edi - pushl %esi - movl isi, %edx - - /*\ Check (dw > 0) && (dh > 0) \*/ - cmpl $0, dw - jle .scale_leave - cmpl $0, dh - jle .scale_leave - - /*\ X-based array pointers point to the end; we're looping up to 0 \*/ - /*\ %edi = dest + dow * dy + dx + dw \*/ - movl dow, %eax - imull dy, %eax - addl dx, %eax - addl dw, %eax - movl dest, %edi - leal (%edi, %eax, 4), %edi - /*\ xp = xpoints + dxx + dw \*/ - movl dxx, %ebx - addl dw, %ebx - movl xpoints, %eax - leal (%eax, %ebx, 4), %eax - movl %eax, xp - /*\ xap = xapoints + dxx + dw \*/ - movl xapoints, %eax - leal (%eax, %ebx, 4), %eax - movl %eax, xap - /*\ y = dh \*/ - movl dh, %eax - movl %eax, y - /*\ yp = ypoints + dyy \*/ - movl dyy, %ebx - movl ypoints, %eax - leal (%eax, %ebx, 4), %eax - movl %eax, yp - /*\ yap = yapoints + dyy \*/ - movl yapoints, %eax - leal (%eax, %ebx, 4), %eax - movl %eax, yap - - pxor %mm7, %mm7 - - /*\ Test xup bit \*/ - movl xup_yup, %eax - sarl $1, %eax - jnc .scale_x_down - -.scale_x_up: - /*\ Test yup bit \*/ - sarl $1, %eax - jnc .scale_x_up_y_down - - -/*\ Scaling up both ways \*/ - -.scale_x_up_y_up: - movl sow, %ebx - -.up_up_loop_y: - - /*\ x = -dw \*/ - movl dw, %ecx - negl %ecx - - /*\ %eax = *yap << 4 \*/ - movl yap, %eax - movl (%eax), %eax - sall $4, %eax - jz .up_up_yap_0 - movd %eax, %mm1 - punpcklwd %mm1, %mm1 - punpckldq %mm1, %mm1 - -.up_up_loop1_x: - /*\ %esi = *yp + xp[x] \*/ - movl yp, %eax - movl (%eax), %esi - movl xp, %eax - movl (%eax, %ecx, 4), %eax - leal (%esi, %eax, 4), %esi - - /*\ %eax = xap[x] << 4 \*/ - movl xap, %eax - movl (%eax, %ecx, 4), %eax - sall $4, %eax - jz .up_up_xap_0 - - /*\ %mm0 = xap[x] << 4 \*/ - movd %eax, %mm0 - punpcklwd %mm0, %mm0 - punpckldq %mm0, %mm0 - - /*\ Load and unpack four pixels in parralel - |*| %mm2 = ptr[0], %mm3 = ptr[1] - |*| %mm4 = ptr[sow], %mm5 = ptr[sow + 1] - \*/ - movq (%esi), %mm2 - movq (%esi, %ebx, 4), %mm4 - movq %mm2, %mm3 - movq %mm4, %mm5 - punpcklbw %mm7, %mm2 - punpcklbw %mm7, %mm4 - punpckhbw %mm7, %mm3 - punpckhbw %mm7, %mm5 - - /*\ X interpolation: r = l + (r - l) * xap \*/ - psubw %mm2, %mm3 - psubw %mm4, %mm5 - psllw $4, %mm3 - psllw $4, %mm5 - pmulhw %mm0, %mm3 - pmulhw %mm0, %mm5 - paddw %mm2, %mm3 - paddw %mm4, %mm5 - /*\ Now %mm3 = I(ptr[0], ptr[1]), %mm5 = I(ptr[sow], ptr[sow + 1]) \*/ - jmp .up_up_common -.up_up_xap_0: - /*\ Load and unpack two pixels - |*| %mm3 = ptr[0], %mm5 = ptr[sow] - \*/ - movd (%esi), %mm3 - movd (%esi, %ebx, 4), %mm5 - punpcklbw %mm7, %mm3 - punpcklbw %mm7, %mm5 -.up_up_common: - /*\ Y interpolation: d = u + (d - u) * yap \*/ - psubw %mm3, %mm5 - psllw $4, %mm5 - pmulhw %mm1, %mm5 - paddw %mm3, %mm5 - packuswb %mm5, %mm5 - movd %mm5, (%edi, %ecx, 4) - - /*\ while (++x) \*/ - incl %ecx - jnz .up_up_loop1_x - jmp .up_up_yap_end -.up_up_yap_0: - -.up_up_loop2_x: - /*\ %esi = *yp + xp[x] \*/ - movl yp, %eax - movl (%eax), %esi - movl xp, %eax - movl (%eax, %ecx, 4), %eax - leal (%esi, %eax, 4), %esi - - /*\ %eax = xap[x] << 4 \*/ - movl xap, %eax - movl (%eax, %ecx, 4), %eax - sall $4, %eax - jz .up_up_0 - - /*\ %mm0 = xap[x] << 4 \*/ - movd %eax, %mm0 - punpcklwd %mm0, %mm0 - punpckldq %mm0, %mm0 - - /*\ Load and unpack two pixels in parralel - |*| %mm2 = ptr[0], %mm3 = ptr[1] - \*/ - movq (%esi), %mm2 - movq %mm2, %mm3 - punpcklbw %mm7, %mm2 - punpckhbw %mm7, %mm3 - - /*\ X interpolation: r = l + (r - l) * xap \*/ - psubw %mm2, %mm3 - psllw $4, %mm3 - pmulhw %mm0, %mm3 - paddw %mm2, %mm3 - packuswb %mm3, %mm3 - movd %mm3, (%edi, %ecx, 4) - jmp .up_up_1 -.up_up_0: - /*\ dptr[x] = *sptr \*/ - movl (%esi), %eax - movl %eax, (%edi, %ecx, 4) -.up_up_1: - incl %ecx - jnz .up_up_loop2_x - -.up_up_yap_end: - /*\ dptr += dow \*/ - movl dow, %eax - leal (%edi, %eax, 4), %edi - /*\ yap++; yp++ \*/ - addl $4, yap - addl $4, yp - /*\ while (y--) \*/ - decl y - jnz .up_up_loop_y - - jmp .scale_leave - - -/*\ Scaling down vertically \*/ - -.scale_x_up_y_down: - /*\ sow_4 = sow * 4 \*/ - movl sow, %eax - sall $2, %eax - movl %eax, sow_4 - -.up_down_loop_y: - - /*\ Setup My and Cy \*/ - movl yap, %eax - movzwl (%eax), %ebx - movl %ebx, My - movzwl 2(%eax), %eax - movl %eax, Cy - - /*\ mm4 = Cy \*/ - movd %eax, %mm4 - punpcklwd %mm4, %mm4 - punpckldq %mm4, %mm4 - /*\ mm5 = My \*/ - movd %ebx, %mm5 - punpcklwd %mm5, %mm5 - punpckldq %mm5, %mm5 - - /*\ x = -dw \*/ - movl dw, %ecx - negl %ecx -.up_down_loop_x: - /*\ %esi = *yp + xp[x] \*/ - movl yp, %eax - movl (%eax), %esi - movl xp, %eax - movl (%eax, %ecx, 4), %eax - leal (%esi, %eax, 4), %esi - - movl %esi, %eax - /*\ v = (*p * My) >> 10 \*/ - movd (%eax), %mm0 - punpcklbw %mm7, %mm0 - psllw $6, %mm0 - pmulhw %mm5, %mm0 - - /*\ i = 0x4000 - My \*/ - movl $0x4000, %ebx - subl My, %ebx - jbe 5f - jmp 2f -1: - /*\ p += sow; v += (*p * Cy) >> 10 \*/ - addl sow_4, %eax - movd (%eax), %mm1 - punpcklbw %mm7, %mm1 - psllw $6, %mm1 - pmulhw %mm4, %mm1 - paddw %mm1, %mm0 - - /*\ i -= Cy; while (i > Cy) \*/ - subl Cy, %ebx -2: - cmpl Cy, %ebx - jg 1b - - /*\ mm6 = i \*/ - movd %ebx, %mm6 - punpcklwd %mm6, %mm6 - punpckldq %mm6, %mm6 - - /*\ p += sow; v += (*p * i) >> 10 \*/ - addl sow_4, %eax - movd (%eax), %mm1 - punpcklbw %mm7, %mm1 - psllw $6, %mm1 - pmulhw %mm6, %mm1 - paddw %mm1, %mm0 -5: - /*\ %eax = xap[x] << 5 \*/ - movl xap, %eax - movl (%eax, %ecx, 4), %eax - sall $5, %eax - jz 6f - /*\ mm3 = xap[x] << 5 \*/ - movd %eax, %mm3 - punpcklwd %mm3, %mm3 - punpckldq %mm3, %mm3 - - /*\ p + 1 \*/ - movl %esi, %eax - addl $4, %eax - /*\ vv = (*p * My) >> 10 \*/ - movd (%eax), %mm2 - punpcklbw %mm7, %mm2 - psllw $6, %mm2 - pmulhw %mm5, %mm2 - - /*\ i = 0x4000 - My \*/ - movl $0x4000, %ebx - subl My, %ebx - jbe 5f - jmp 2f -1: - /*\ p += sow; vv += (*p * Cy) >> 10 \*/ - addl sow_4, %eax - movd (%eax), %mm1 - punpcklbw %mm7, %mm1 - psllw $6, %mm1 - pmulhw %mm4, %mm1 - paddw %mm1, %mm2 - - /*\ i -= Cy; while (i > Cy) \*/ - subl Cy, %ebx -2: - cmpl Cy, %ebx - jg 1b - - /*\ p += sow; v += (*p * i) >> 10 \*/ - addl sow_4, %eax - movd (%eax), %mm1 - punpcklbw %mm7, %mm1 - psllw $6, %mm1 - pmulhw %mm6, %mm1 - paddw %mm1, %mm2 -5: - /*\ v = v + (vv - v) * xap \*/ - psubw %mm0, %mm2 - psllw $3, %mm2 - pmulhw %mm3, %mm2 - paddw %mm2, %mm0 -6: - /*\ dest[x] = v >> 4 \*/ - psrlw $4, %mm0 - packuswb %mm0, %mm0 - movd %mm0, (%edi, %ecx, 4) - - /*\ while (++x) \*/ - incl %ecx - jnz .up_down_loop_x - - /*\ dptr += dow \*/ - movl dow, %eax - leal (%edi, %eax, 4), %edi - /*\ yap++; yp++ \*/ - addl $4, yap - addl $4, yp - /*\ while (y--) \*/ - decl y - jnz .up_down_loop_y - - jmp .scale_leave - -.scale_x_down: - /*\ Test yup bit \*/ - sarl $1, %eax - jnc .scale_x_down_y_down - - -/*\ Scaling down horizontally \*/ - -.scale_x_down_y_up: - /*\ sow_4 = sow * 4 \*/ - movl sow, %eax - sall $2, %eax - movl %eax, sow_4 - -.down_up_loop_y: - - /*\ %eax = *yap << 5 \*/ - movl yap, %eax - movl (%eax), %eax - sall $5, %eax - /*\ mm3 = *yap << 5 \*/ - movd %eax, %mm3 - punpcklwd %mm3, %mm3 - punpckldq %mm3, %mm3 - - /*\ x = -dw \*/ - movl dw, %ecx - negl %ecx -.down_up_loop_x: - /*\ %esi = *yp + xp[x] \*/ - movl yp, %eax - movl (%eax), %esi - movl xp, %eax - movl (%eax, %ecx, 4), %eax - leal (%esi, %eax, 4), %esi - - /*\ Setup Mx and Cx \*/ - movl xap, %eax - movzwl (%eax, %ecx, 4), %ebx - movl %ebx, Mx - movzwl 2(%eax, %ecx, 4), %eax - movl %eax, Cx - - /*\ mm4 = Cx \*/ - movd %eax, %mm4 - punpcklwd %mm4, %mm4 - punpckldq %mm4, %mm4 - /*\ mm5 = Mx \*/ - movd %ebx, %mm5 - punpcklwd %mm5, %mm5 - punpckldq %mm5, %mm5 - - movl %esi, %eax - /*\ v = (*p * Mx) >> 10 \*/ - movd (%eax), %mm0 - punpcklbw %mm7, %mm0 - psllw $6, %mm0 - pmulhw %mm5, %mm0 - - /*\ i = 0x4000 - Mx \*/ - movl $0x4000, %ebx - subl Mx, %ebx - jbe 5f - jmp 2f -1: - /*\ p += sow; v += (*p * Cx) >> 10 \*/ - addl $4, %eax - movd (%eax), %mm1 - punpcklbw %mm7, %mm1 - psllw $6, %mm1 - pmulhw %mm4, %mm1 - paddw %mm1, %mm0 - - /*\ i -= Cx; while (i > Cx) \*/ - subl Cx, %ebx -2: - cmpl Cx, %ebx - jg 1b - - /*\ mm6 = i \*/ - movd %ebx, %mm6 - punpcklwd %mm6, %mm6 - punpckldq %mm6, %mm6 - - /*\ p += sow; v += (*p * i) >> 10 \*/ - addl $4, %eax - movd (%eax), %mm1 - punpcklbw %mm7, %mm1 - psllw $6, %mm1 - pmulhw %mm6, %mm1 - paddw %mm1, %mm0 -5: - movd %mm3, %eax - testl %eax, %eax - jz 6f - /*\ p + sow \*/ - movl %esi, %eax - addl sow_4, %eax - /*\ vv = (*p * Mx) >> 10 \*/ - movd (%eax), %mm2 - punpcklbw %mm7, %mm2 - psllw $6, %mm2 - pmulhw %mm5, %mm2 - - /*\ i = 0x4000 - Mx \*/ - movl $0x4000, %ebx - subl Mx, %ebx - jbe 5f - jmp 2f -1: - /*\ p += sow; vv += (*p * Cx) >> 10 \*/ - addl $4, %eax - movd (%eax), %mm1 - punpcklbw %mm7, %mm1 - psllw $6, %mm1 - pmulhw %mm4, %mm1 - paddw %mm1, %mm2 - - /*\ i -= Cx; while (i > Cx) \*/ - subl Cx, %ebx -2: - cmpl Cx, %ebx - jg 1b - - /*\ p += sow; v += (*p * i) >> 10 \*/ - addl $4, %eax - movd (%eax), %mm1 - punpcklbw %mm7, %mm1 - psllw $6, %mm1 - pmulhw %mm6, %mm1 - paddw %mm1, %mm2 -5: - /*\ v = v + (vv - v) * yap \*/ - psubw %mm0, %mm2 - psllw $3, %mm2 - pmulhw %mm3, %mm2 - paddw %mm2, %mm0 -6: - /*\ dest[x] = v >> 4 \*/ - psrlw $4, %mm0 - packuswb %mm0, %mm0 - movd %mm0, (%edi, %ecx, 4) - - /*\ while (++x) \*/ - incl %ecx - jnz .down_up_loop_x - - /*\ dptr += dow \*/ - movl dow, %eax - leal (%edi, %eax, 4), %edi - /*\ yap++; yp++ \*/ - addl $4, yap - addl $4, yp - /*\ while (y--) \*/ - decl y - jnz .down_up_loop_y - - jmp .scale_leave - - -/*\ Scaling down both ways \*/ - -.scale_x_down_y_down: - /*\ sow_4 = sow * 4 \*/ - movl sow, %eax - sall $2, %eax - movl %eax, sow_4 - -.down_down_loop_y: - - /*\ Setup My and Cy \*/ - movl yap, %eax - movzwl (%eax), %ebx - movl %ebx, My - movzwl 2(%eax), %eax - movl %eax, Cy - - /*\ x = -dw \*/ - movl dw, %ecx - negl %ecx -.down_down_loop_x: - /*\ %esi = *yp + xp[x] \*/ - movl yp, %eax - movl (%eax), %esi - movl xp, %eax - movl (%eax, %ecx, 4), %eax - leal (%esi, %eax, 4), %esi - - /*\ Setup Mx and Cx \*/ - movl xap, %eax - movzwl (%eax, %ecx, 4), %ebx - movl %ebx, Mx - movzwl 2(%eax, %ecx, 4), %eax - movl %eax, Cx - - /*\ mm3 = Cx \*/ - movd %eax, %mm3 - punpcklwd %mm3, %mm3 - punpckldq %mm3, %mm3 - /*\ mm5 = Mx \*/ - movd %ebx, %mm5 - punpcklwd %mm5, %mm5 - punpckldq %mm5, %mm5 - - /*\ p = sptr; v = (*p * Mx) >> 9 \*/ - movl %esi, %eax - movd (%eax), %mm0 - punpcklbw %mm7, %mm0 - psllw $7, %mm0 - pmulhw %mm5, %mm0 - - /*\ i = 0x4000 - Mx \*/ - movl $0x4000, %ebx - subl Mx, %ebx - jbe 5f - jmp 2f -1: - /*\ v += (*++p * Cx) >> 9 \*/ - addl $4, %eax - movd (%eax), %mm1 - punpcklbw %mm7, %mm1 - psllw $7, %mm1 - pmulhw %mm3, %mm1 - paddw %mm1, %mm0 - - /*\ i -= Cx; while (i > Cx) \*/ - subl Cx, %ebx -2: - cmpl Cx, %ebx - jg 1b - - /*\ mm6 = i \*/ - movd %ebx, %mm6 - punpcklwd %mm6, %mm6 - punpckldq %mm6, %mm6 - - /*\ v += (*++p * i) >> 9 \*/ - addl $4, %eax - movd (%eax), %mm1 - punpcklbw %mm7, %mm1 - psllw $7, %mm1 - pmulhw %mm6, %mm1 - paddw %mm1, %mm0 -5: - /*\ v *= My \*/ - movd My, %mm4 - punpcklwd %mm4, %mm4 - punpckldq %mm4, %mm4 - psllw $2, %mm0 - pmulhw %mm4, %mm0 - - /*\ j = 0x4000 - My \*/ - movl $0x4000, %edx - subl My, %edx - jbe 6f - jmp 4f -3: - /*\ sptr += sow; p = sptr \*/ - addl sow_4, %esi - movl %esi, %eax - /*\ vx = (*p * Mx) >> 9 \*/ - movd (%eax), %mm1 - punpcklbw %mm7, %mm1 - psllw $7, %mm1 - pmulhw %mm5, %mm1 - - /*\ i = 0x4000 - Mx \*/ - movl $0x4000, %ebx - subl Mx, %ebx - jbe 5f - jmp 2f -1: - /*\ vx += (*++p * Cx) >> 9 \*/ - addl $4, %eax - movd (%eax), %mm2 - punpcklbw %mm7, %mm2 - psllw $7, %mm2 - pmulhw %mm3, %mm2 - paddw %mm2, %mm1 - - /*\ i -= Cx; while (i > Cx) \*/ - subl Cx, %ebx -2: - cmpl Cx, %ebx - jg 1b - - /*\ vx += (*++p * i) >> 9 \*/ - addl $4, %eax - movd (%eax), %mm2 - punpcklbw %mm7, %mm2 - psllw $7, %mm2 - pmulhw %mm6, %mm2 - paddw %mm2, %mm1 -5: - /*\ v += (vx * Cy) >> 14 \*/ - movd Cy, %mm4 - punpcklwd %mm4, %mm4 - punpckldq %mm4, %mm4 - psllw $2, %mm1 - pmulhw %mm4, %mm1 - paddw %mm1, %mm0 - - /*\ j -= Cy; while (j > Cy) \*/ - subl Cy, %edx -4: - cmpl Cy, %edx - jg 3b - - /*\ sptr += sow; p = sptr \*/ - addl sow_4, %esi - movl %esi, %eax - /*\ vx = (*p * Mx) >> 9 \*/ - movd (%eax), %mm1 - punpcklbw %mm7, %mm1 - psllw $7, %mm1 - pmulhw %mm5, %mm1 - - /*\ i = 0x4000 - Mx \*/ - movl $0x4000, %ebx - subl Mx, %ebx - jbe 5f - jmp 2f -1: - /*\ vx += (*++p * Cx) >> 9 \*/ - addl $4, %eax - movd (%eax), %mm2 - punpcklbw %mm7, %mm2 - psllw $7, %mm2 - pmulhw %mm3, %mm2 - paddw %mm2, %mm1 - - /*\ i -= Cx; while (i > Cx) \*/ - subl Cx, %ebx -2: - cmpl Cx, %ebx - jg 1b - - /*\ vx += (*++p * i) >> 9 \*/ - addl $4, %eax - movd (%eax), %mm2 - punpcklbw %mm7, %mm2 - psllw $7, %mm2 - pmulhw %mm6, %mm2 - paddw %mm2, %mm1 -5: - /*\ v += (vx * j) >> 14 \*/ - movd %edx, %mm4 - punpcklwd %mm4, %mm4 - punpckldq %mm4, %mm4 - psllw $2, %mm1 - pmulhw %mm4, %mm1 - paddw %mm1, %mm0 -6: - /*\ dptr[x] = mm0 >> 5 \*/ - psrlw $5, %mm0 - packuswb %mm0, %mm0 - movd %mm0, (%edi, %ecx, 4) - - /*\ while (++x) \*/ - incl %ecx - jnz .down_down_loop_x - - /*\ dptr += dow \*/ - movl dow, %eax - leal (%edi, %eax, 4), %edi - /*\ yap++; yp++ \*/ - addl $4, yap - addl $4, yp - /*\ while (y--) \*/ - decl y - jnz .down_down_loop_y - - jmp .scale_leave - -.scale_leave: - emms - popl %esi - popl %edi - popl %edx - popl %ecx - popl %ebx - movl %ebp, %esp - popl %ebp - ret - -SIZE(qimageScale_mmx_AARGBA) - -#endif diff -Nru syncwall-1.6.0/3rdparty/qimageblitz/blitz.cpp syncwall-1.7.4/3rdparty/qimageblitz/blitz.cpp --- syncwall-1.6.0/3rdparty/qimageblitz/blitz.cpp 2012-01-15 04:35:02.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qimageblitz/blitz.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,1054 +0,0 @@ -/* - Copyright (C) 1998, 1999, 2001, 2002, 2004, 2005, 2007 - Daniel M. Duley - (C) 2004 Zack Rusin - (C) 2000 Josef Weidendorfer - (C) 1999 Geert Jansen - (C) 1998, 1999 Christian Tibirna - (C) 1998, 1999 Dirk Mueller - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -/* - Portions of this software are were originally based on ImageMagick's - algorithms. ImageMagick is copyrighted under the following conditions: - -Copyright (C) 2003 ImageMagick Studio, a non-profit organization dedicated to -making software imaging solutions freely available. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files ("ImageMagick"), to deal -in ImageMagick without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of ImageMagick, and to permit persons to whom the ImageMagick is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of ImageMagick. - -The software is provided "as is", without warranty of any kind, express or -implied, including but not limited to the warranties of merchantability, -fitness for a particular purpose and noninfringement. In no event shall -ImageMagick Studio be liable for any claim, damages or other liability, -whether in an action of contract, tort or otherwise, arising from, out of or -in connection with ImageMagick or the use or other dealings in ImageMagick. - -Except as contained in this notice, the name of the ImageMagick Studio shall -not be used in advertising or otherwise to promote the sale, use or other -dealings in ImageMagick without prior written authorization from the -ImageMagick Studio. -*/ - -#define _USE_MATH_DEFINES // for msvc - -#include "qimageblitz.h" -#include "private/blitz_p.h" -#include -#include "blitzcpu.h" -#include "private/interpolate.h" -#include "private/inlinehsv.h" -#include -#ifndef M_PI -// Some cmath doesn't define it, try from the older source -#include "math.h" -#endif -#include -#include -#include - -#if defined(__i386__) && ( defined(__GNUC__) || defined(__INTEL_COMPILER) ) -# if defined(HAVE_MMX ) -# define USE_MMX_INLINE_ASM -# endif -#endif - -QImage& Blitz::despeckle(QImage &img) -{ - if(img.isNull()) - return(img); - - int length, x, y, j, i; - QRgb *src, *dest; - unsigned char *buffer, *pixels; - int w = img.width(); - int h = img.height(); - - static const int - X[4]= {0, 1, 1,-1}, - Y[4]= {1, 0, 1, 1}; - - length = (img.width()+2)*(img.height()+2); - pixels = new unsigned char[length]; - buffer = new unsigned char[length]; - - if(img.depth() != 32){ - img = img.convertToFormat(img.hasAlphaChannel() ? - QImage::Format_ARGB32 : - QImage::Format_RGB32); - } - else if(img.format() == QImage::Format_ARGB32_Premultiplied) - img = img.convertToFormat(QImage::Format_ARGB32); - - // Do each channel. This originally was in one loop with an "if" statement - // for each channel, but I unrolled it because a lot goes on and it needs - // any speed help it can get >:/ (mosfet) - - // Red - (void)memset(pixels, 0, length); - j = w+2; - for(y=0; y < h; ++y, ++j){ - src = (QRgb *)img.scanLine(y); - ++j; - for(x=w-1; x >= 0; --x, ++src, ++j) - pixels[j] = qRed(*src); - } - (void)memset(buffer, 0, length); - for(i=0; i < 4; ++i){ - BlitzPrivate::hull(X[i], Y[i], w, h, pixels, buffer, 1); - BlitzPrivate::hull(-X[i], -Y[i], w, h, pixels, buffer, 1); - BlitzPrivate::hull(-X[i], -Y[i], w, h, pixels, buffer, -1); - BlitzPrivate::hull(X[i], Y[i], w, h, pixels, buffer, -1); - } - j = w+2; - for(y=0; y < h; ++y, ++j){ - dest = (QRgb *)img.scanLine(y); - ++j; - for(x=w-1; x >= 0; --x, ++dest, ++j) - *dest = qRgba(pixels[j], qGreen(*dest), qBlue(*dest), - qAlpha(*dest)); - } - - // Green - (void)memset(pixels, 0, length); - j = w+2; - for(y=0; y < h; ++y, ++j){ - src = (QRgb *)img.scanLine(y); - ++j; - for(x=w-1; x >= 0; --x, ++src, ++j) - pixels[j] = qGreen(*src); - } - (void)memset(buffer, 0, length); - for(i=0; i < 4; ++i){ - BlitzPrivate::hull(X[i], Y[i], w, h, pixels, buffer, 1); - BlitzPrivate::hull(-X[i], -Y[i], w, h, pixels, buffer, 1); - BlitzPrivate::hull(-X[i], -Y[i], w, h, pixels, buffer, -1); - BlitzPrivate::hull(X[i], Y[i], w, h, pixels, buffer, -1); - } - j = w+2; - for(y=0; y < h; ++y, ++j){ - dest = (QRgb *)img.scanLine(y); - ++j; - for(x=w-1; x >= 0; --x, ++dest, ++j) - *dest = qRgba(qRed(*dest), pixels[j], qBlue(*dest), - qAlpha(*dest)); - } - - // Blue - (void)memset(pixels, 0, length); - j = w+2; - for(y=0; y < h; ++y, ++j){ - src = (QRgb *)img.scanLine(y); - ++j; - for(x=w-1; x >= 0; --x, ++src, ++j) - pixels[j] = qBlue(*src); - } - (void)memset(buffer, 0, length); - for(i=0; i < 4; ++i){ - BlitzPrivate::hull(X[i], Y[i], w, h, pixels, buffer, 1); - BlitzPrivate::hull(-X[i], -Y[i], w, h, pixels, buffer, 1); - BlitzPrivate::hull(-X[i], -Y[i], w, h, pixels, buffer, -1); - BlitzPrivate::hull(X[i], Y[i], w, h, pixels, buffer, -1); - } - j = w+2; - for(y=0; y < h; ++y, ++j){ - dest = (QRgb *)img.scanLine(y); - ++j; - for(x=w-1; x >= 0; --x, ++dest, ++j) - *dest = qRgba(qRed(*dest), qGreen(*dest), pixels[j], - qAlpha(*dest)); - } - - delete[] pixels; - delete[] buffer; - return(img); -} - -QImage Blitz::blur(QImage &img, int radius) -{ - QRgb *p1, *p2; - int x, y, w, h, mx, my, mw, mh, mt, xx, yy; - int a, r, g, b; - int *as, *rs, *gs, *bs; - - if(radius < 1 || img.isNull() || img.width() < (radius << 1)) - return(img); - - w = img.width(); - h = img.height(); - - if(img.depth() < 8) - img = img.convertToFormat(QImage::Format_Indexed8); - QImage buffer(w, h, img.hasAlphaChannel() ? - QImage::Format_ARGB32 : QImage::Format_RGB32); - - as = new int[w]; - rs = new int[w]; - gs = new int[w]; - bs = new int[w]; - - QVector colorTable; - if(img.format() == QImage::Format_Indexed8) - colorTable = img.colorTable(); - - for(y = 0; y < h; y++){ - my = y - radius; - mh = (radius << 1) + 1; - if(my < 0){ - mh += my; - my = 0; - } - if((my + mh) > h) - mh = h - my; - - p1 = (QRgb *)buffer.scanLine(y); - memset(as, 0, w * sizeof(int)); - memset(rs, 0, w * sizeof(int)); - memset(gs, 0, w * sizeof(int)); - memset(bs, 0, w * sizeof(int)); - - if(img.format() == QImage::Format_ARGB32_Premultiplied){ - QRgb pixel; - for(yy = 0; yy < mh; yy++){ - p2 = (QRgb *)img.scanLine(yy + my); - for(x = 0; x < w; x++, p2++){ - pixel = BlitzPrivate::convertFromPremult(*p2); - as[x] += qAlpha(pixel); - rs[x] += qRed(pixel); - gs[x] += qGreen(pixel); - bs[x] += qBlue(pixel); - } - } - } - else if(img.format() == QImage::Format_Indexed8){ - QRgb pixel; - unsigned char *ptr; - for(yy = 0; yy < mh; yy++){ - ptr = (unsigned char *)img.scanLine(yy + my); - for(x = 0; x < w; x++, ptr++){ - pixel = colorTable[*ptr]; - as[x] += qAlpha(pixel); - rs[x] += qRed(pixel); - gs[x] += qGreen(pixel); - bs[x] += qBlue(pixel); - } - } - } - else{ - for(yy = 0; yy < mh; yy++){ - p2 = (QRgb *)img.scanLine(yy + my); - for(x = 0; x < w; x++, p2++){ - as[x] += qAlpha(*p2); - rs[x] += qRed(*p2); - gs[x] += qGreen(*p2); - bs[x] += qBlue(*p2); - } - } - } - - for(x = 0; x < w; x++){ - a = r = g = b = 0; - mx = x - radius; - mw = (radius << 1) + 1; - if(mx < 0){ - mw += mx; - mx = 0; - } - if((mx + mw) > w) - mw = w - mx; - mt = mw * mh; - for(xx = mx; xx < (mw + mx); xx++){ - a += as[xx]; - r += rs[xx]; - g += gs[xx]; - b += bs[xx]; - } - a = a / mt; - r = r / mt; - g = g / mt; - b = b / mt; - *p1++ = qRgba(r, g, b, a); - } - } - delete[] as; - delete[] rs; - delete[] gs; - delete[] bs; - - return(buffer); -} - -QImage Blitz::sharpen(QImage &img, int radius) -{ - if(img.isNull() || radius < 1) - return(img); - if(img.depth() != 32){ - img = img.convertToFormat(img.hasAlphaChannel() ? - QImage::Format_ARGB32 : - QImage::Format_RGB32); - } - else if(img.format() == QImage::Format_ARGB32_Premultiplied) - img = img.convertToFormat(QImage::Format_ARGB32); - - QImage buffer(img.width(), img.height(), img.format()); - int a, r, g, b, x, y; - int w = img.width(); - int h = img.height(); - QRgb *src, *dest; - - memcpy(buffer.scanLine(0), img.scanLine(0), img.bytesPerLine()); - for(y=1; y < h-1; ++y){ - src = (QRgb *)img.scanLine(y); - dest = (QRgb *)buffer.scanLine(y); - *dest++ = *src++; - for(x=1; x < w-1; ++x){ - r = qRed(*src)*5; - g = qGreen(*src)*5; - b = qBlue(*src)*5; - a = qAlpha(*src)*5; - - r -= qRed(*(src-1)); - g -= qGreen(*(src-1)); - b -= qBlue(*(src-1)); - a -= qAlpha(*(src-1)); - r -= qRed(*(src+1)); - g -= qGreen(*(src+1)); - b -= qBlue(*(src+1)); - a -= qAlpha(*(src+1)); - - r -= qRed(*(src-w)); - g -= qGreen(*(src-w)); - b -= qBlue(*(src-w)); - a -= qAlpha(*(src-w)); - r -= qRed(*(src+w)); - g -= qGreen(*(src+w)); - b -= qBlue(*(src+w)); - a -= qAlpha(*(src+w)); - - r = (r & ((~r) >> 16)); - r = ((r | ((r & 256) - ((r & 256) >> 8)))); - g = (g & ((~g) >> 16)); - g = ((g | ((g & 256) - ((g & 256) >> 8)))); - b = (b & ((~b) >> 16)); - b = ((b | ((b & 256) - ((b & 256) >> 8)))); - a = (a & ((~a) >> 16)); - a = ((a | ((a & 256) - ((a & 256) >> 8)))); - - *dest = qRgba(r, g, b, a); - ++src; ++dest; - } - *dest++ = *src++; - } - memcpy(buffer.scanLine(h-1), img.scanLine(h-1), img.bytesPerLine()); - return(buffer); -} - -/* - * I was looking for a quick way to do edge detection and found - * the Sobel method. This is a gradient method that applies two 3x3 - * matrixes. These matrixes are: - * - * x: -1, 0, 1 y: 1, 2, 1 - * -2, 0, 2 0, 0, 0 - * -1, 0, 1 -1, -2, -1 - * - * After the matrix is applied you simply calculate the magnitude by - * |x| + |y|. - * - * The one problem w/ this is most descriptions of the algorithm I've - * seen assume grayscale data so your working with the intensity of the - * pixel. We do each color channel separately. This is probably wrong, - * but all the implementations I've seen do this... - * (mosfet) - */ - -// Accumulates the results of applying x and y Sobel masks -#define SOBEL(xm, ym, pixel) \ - xR += qRed((pixel))*(xm); xG += qGreen((pixel))*(xm); \ - xB += qBlue((pixel))*(xm); \ - yR += qRed((pixel))*(ym); yG += qGreen((pixel))*(ym); \ - yB += qBlue((pixel))*(ym); - -QImage Blitz::edge(QImage &img) -{ - - int x, y, w = img.width(), h = img.height(); - if(w < 3 || h < 3){ - qWarning("Blitz::edge(): Image is too small!"); - return(img); - } - if(img.isNull()) - return(img); - - if(img.depth() != 32){ - img = img.convertToFormat(img.hasAlphaChannel() ? - QImage::Format_ARGB32 : - QImage::Format_RGB32); - } - else if(img.format() == QImage::Format_ARGB32_Premultiplied) - img = img.convertToFormat(QImage::Format_ARGB32); - - QImage buffer(w, h, QImage::Format_RGB32); - QRgb *dest; - QRgb *s, *scanblock[3]; - - -#ifdef USE_MMX_INLINE_ASM -#ifdef __GNUC__ -#warning Using MMX sobel edge -#endif - if(BlitzCPUInfo::haveExtension(BlitzCPUInfo::MMX)){ - int xmatrix[] = {-1, 0, 1, -2, 0, 2, -1, 0, 1}; - int ymatrix[] = {1, 2, 1, 0, 0, 0, -1, -2, -1}; - int i, *xm, *ym; - - for(y=0; y < h; ++y){ - scanblock[1] = (QRgb *)img.scanLine(y); - dest = (QRgb *)buffer.scanLine(y); - if(y == 0){ - scanblock[0] = (QRgb *)img.scanLine(y); - scanblock[2] = (QRgb *)img.scanLine(y+1); - } - else if(y == h-1){ - scanblock[0] = (QRgb *)img.scanLine(y-1); - scanblock[2] = (QRgb *)img.scanLine(y); - } - else{ - scanblock[0] = (QRgb *)img.scanLine(y-1); - scanblock[2] = (QRgb *)img.scanLine(y+1); - } - // - // x == 0, double over first pixel - // - __asm__ __volatile__ - ("pxor %%mm7, %%mm7\n\t" // used for unpacking - "pxor %%mm5, %%mm5\n\t" // clear accumulator - "pxor %%mm6, %%mm6\n\t" // "" - : : ); - for(i=0, xm=xmatrix, ym=ymatrix; i < 3; ++i, xm+=3, ym+=3){ - s = scanblock[i]; - __asm__ __volatile__ - (// first pixel - "movd (%0), %%mm0\n\t" // load pixel into mm0 - "punpcklbw %%mm7, %%mm0\n\t" // upgrade to quad - "movq %%mm0, %%mm1\n\t" // copy pixel to mm1 - "movq %%mm0, %%mm4\n\t" // and mm4 since we are doubling over - "movd 0(%1), %%mm2\n\t" // load x matrix into mm2 - "punpckldq %%mm2, %%mm2\n\t" // expand to all words - "packssdw %%mm2, %%mm2\n\t" - "movd 0(%2), %%mm3\n\t" // load y matrix into mm3 - "punpckldq %%mm3, %%mm3\n\t" // expand - "packssdw %%mm3, %%mm3\n\t" - "pmullw %%mm2, %%mm0\n\t" // multiply pixel w/ x matrix - "pmullw %%mm3, %%mm1\n\t" // and multiply copy w/ y matrix - "paddw %%mm0, %%mm5\n\t" // add to accumulators - "paddw %%mm1, %%mm6\n\t" - // second pixel (doubled over) - "movq %%mm4, %%mm1\n\t" // copy saved pixel to mm1 - "movd 4(%1), %%mm2\n\t" // load x matrix into mm2 - "punpckldq %%mm2, %%mm2\n\t" // expand to all words - "packssdw %%mm2, %%mm2\n\t" - "movd 4(%2), %%mm3\n\t" // load y matrix into mm3 - "punpckldq %%mm3, %%mm3\n\t" // expand - "packssdw %%mm3, %%mm3\n\t" - "pmullw %%mm2, %%mm4\n\t" // multiply pixel w/ x matrix - "pmullw %%mm3, %%mm1\n\t" // and multiply copy w/ y matrix - "paddw %%mm4, %%mm5\n\t" // add to accumulators - "paddw %%mm1, %%mm6\n\t" - // third pixel - "movd 4(%0), %%mm0\n\t" // load pixel into mm0 - "punpcklbw %%mm7, %%mm0\n\t" // upgrade to quad - "movq %%mm0, %%mm1\n\t" // copy pixel to mm1 - "movd 8(%1), %%mm2\n\t" // load x matrix into mm2 - "punpckldq %%mm2, %%mm2\n\t" // expand to all words - "packssdw %%mm2, %%mm2\n\t" - "movd 8(%2), %%mm3\n\t" // load y matrix into mm3 - "punpckldq %%mm3, %%mm3\n\t" // expand - "packssdw %%mm3, %%mm3\n\t" - "pmullw %%mm2, %%mm0\n\t" // multiply pixel w/ x matrix - "pmullw %%mm3, %%mm1\n\t" // and multiply copy w/ y matrix - "paddw %%mm0, %%mm5\n\t" // add to accumulators - "paddw %%mm1, %%mm6\n\t" - : : "r"(s), "r"(xm), "r"(ym)); - } - __asm__ __volatile__ - (// calculate abs, sum, and write - "movq %%mm5, %%mm0\n\t" // calculate abs of x accumulator - "psraw $15, %%mm0\n\t" - "pxor %%mm0, %%mm5\n\t" - "psubw %%mm0, %%mm5\n\t" - "movq %%mm6, %%mm0\n\t" // calculate abs of y accumulator - "psraw $15, %%mm0\n\t" - "pxor %%mm0, %%mm6\n\t" - "psubw %%mm0, %%mm6\n\t" - "paddw %%mm5, %%mm6\n\t" // add together - "packuswb %%mm6, %%mm6\n\t" // and write - "movd %%mm6, (%0)\n\t" - : : "r"(dest)); - dest++; - - // - // Now x == 1, process middle of image - // - - for(x=1; x < w-1; ++x){ - __asm__ __volatile__ - ("pxor %%mm5, %%mm5\n\t" // clear accumulator - "pxor %%mm6, %%mm6\n\t" - : : ); - for(i=0, xm=xmatrix, ym=ymatrix; i < 3; ++i, xm+=3, ym+=3){ - s = scanblock[i]; - __asm__ __volatile__ - (// first pixel - "movd (%0), %%mm0\n\t" // load pixel into mm0 - "punpcklbw %%mm7, %%mm0\n\t" // upgrade to quad - "movq %%mm0, %%mm1\n\t" // copy pixel to mm1 - "movd (%1), %%mm2\n\t" // load x matrix into mm2 - "punpckldq %%mm2, %%mm2\n\t" // expand to all words - "packssdw %%mm2, %%mm2\n\t" - "movd (%2), %%mm3\n\t" // load y matrix into mm3 - "punpckldq %%mm3, %%mm3\n\t" // expand - "packssdw %%mm3, %%mm3\n\t" - "pmullw %%mm2, %%mm0\n\t" // multiply pixel w/ x matrix - "pmullw %%mm3, %%mm1\n\t" // and multiply copy w/ y matrix - "paddw %%mm0, %%mm5\n\t" // add to accumulators - "paddw %%mm1, %%mm6\n\t" - // second pixel - "movd 4(%0), %%mm0\n\t" // load pixel into mm0 - "punpcklbw %%mm7, %%mm0\n\t" // upgrade to quad - "movq %%mm0, %%mm1\n\t" // copy pixel to mm1 - "movd 4(%1), %%mm2\n\t" // load x matrix into mm2 - "punpckldq %%mm2, %%mm2\n\t" // expand to all words - "packssdw %%mm2, %%mm2\n\t" - "movd 4(%2), %%mm3\n\t" // load y matrix into mm3 - "punpckldq %%mm3, %%mm3\n\t" // expand - "packssdw %%mm3, %%mm3\n\t" - "pmullw %%mm2, %%mm0\n\t" // multiply pixel w/ x matrix - "pmullw %%mm3, %%mm1\n\t" // and multiply copy w/ y matrix - "paddw %%mm0, %%mm5\n\t" // add to accumulators - "paddw %%mm1, %%mm6\n\t" - // third pixel - "movd 8(%0), %%mm0\n\t" // load pixel into mm0 - "punpcklbw %%mm7, %%mm0\n\t" // upgrade to quad - "movq %%mm0, %%mm1\n\t" // copy pixel to mm1 - "movd 8(%1), %%mm2\n\t" // load x matrix into mm2 - "punpckldq %%mm2, %%mm2\n\t" // expand to all words - "packssdw %%mm2, %%mm2\n\t" - "movd 8(%2), %%mm3\n\t" // load y matrix into mm3 - "punpckldq %%mm3, %%mm3\n\t" // expand - "packssdw %%mm3, %%mm3\n\t" - "pmullw %%mm2, %%mm0\n\t" // multiply pixel w/ x matrix - "pmullw %%mm3, %%mm1\n\t" // and multiply copy w/ y matrix - "paddw %%mm0, %%mm5\n\t" // add to accumulators - "paddw %%mm1, %%mm6\n\t" - : : "r"(s), "r"(xm), "r"(ym)); - } - __asm__ __volatile__ - (// calculate abs, sum, and write - "movq %%mm5, %%mm0\n\t" // calculate abs of x accumulator - "psraw $15, %%mm0\n\t" - "pxor %%mm0, %%mm5\n\t" - "psubw %%mm0, %%mm5\n\t" - "movq %%mm6, %%mm0\n\t" // calculate abs of y accumulator - "psraw $15, %%mm0\n\t" - "pxor %%mm0, %%mm6\n\t" - "psubw %%mm0, %%mm6\n\t" - "paddw %%mm5, %%mm6\n\t" // add together - "packuswb %%mm6, %%mm6\n\t" // and write - "movd %%mm6, (%0)\n\t" - : : "r"(dest)); - dest++; - ++scanblock[0], ++scanblock[1], ++scanblock[2]; - } - - // - // x = w-1, double over last pixel - // - - __asm__ __volatile__ - ("pxor %%mm5, %%mm5\n\t" // clear accumulator - "pxor %%mm6, %%mm6\n\t" - : : ); - for(i=0, xm=xmatrix, ym=ymatrix; i < 3; ++i, xm+=3, ym+=3){ - s = scanblock[i]; - __asm__ __volatile__ - (// first pixel - "movd (%0), %%mm0\n\t" // load pixel into mm0 - "punpcklbw %%mm7, %%mm0\n\t" // upgrade to quad - "movq %%mm0, %%mm1\n\t" // copy pixel to mm1 - "movd (%1), %%mm2\n\t" // load x matrix into mm2 - "punpckldq %%mm2, %%mm2\n\t" // expand to all words - "packssdw %%mm2, %%mm2\n\t" - "movd (%2), %%mm3\n\t" // load y matrix into mm3 - "punpckldq %%mm3, %%mm3\n\t" // expand - "packssdw %%mm3, %%mm3\n\t" - "pmullw %%mm2, %%mm0\n\t" // multiply pixel w/ x matrix - "pmullw %%mm3, %%mm1\n\t" // and multiply copy w/ y matrix - "paddw %%mm0, %%mm5\n\t" // add to accumulators - "paddw %%mm1, %%mm6\n\t" - // second pixel - "movd 4(%0), %%mm0\n\t" // load pixel into mm0 - "punpcklbw %%mm7, %%mm0\n\t" // upgrade to quad - "movq %%mm0, %%mm1\n\t" // copy pixel to mm1 - "movd 4(%1), %%mm2\n\t" // load x matrix into mm2 - "punpckldq %%mm2, %%mm2\n\t" // expand to all words - "packssdw %%mm2, %%mm2\n\t" - "movd 4(%2), %%mm3\n\t" // load y matrix into mm3 - "punpckldq %%mm3, %%mm3\n\t" // expand - "packssdw %%mm3, %%mm3\n\t" - "pmullw %%mm2, %%mm0\n\t" // multiply pixel w/ x matrix - "pmullw %%mm3, %%mm1\n\t" // and multiply copy w/ y matrix - "paddw %%mm0, %%mm5\n\t" // add to accumulators - "paddw %%mm1, %%mm6\n\t" - // third pixel - "movd 4(%0), %%mm0\n\t" // load pixel into mm0 - "punpcklbw %%mm7, %%mm0\n\t" // upgrade to quad - "movq %%mm0, %%mm1\n\t" // copy pixel to mm1 - "movd 8(%1), %%mm2\n\t" // load x matrix into mm2 - "punpckldq %%mm2, %%mm2\n\t" // expand to all words - "packssdw %%mm2, %%mm2\n\t" - "movd 8(%2), %%mm3\n\t" // load y matrix into mm3 - "punpckldq %%mm3, %%mm3\n\t" // expand - "packssdw %%mm3, %%mm3\n\t" - "pmullw %%mm2, %%mm0\n\t" // multiply pixel w/ x matrix - "pmullw %%mm3, %%mm1\n\t" // and multiply copy w/ y matrix - "paddw %%mm0, %%mm5\n\t" // add to accumulators - "paddw %%mm1, %%mm6\n\t" - : : "r"(s), "r"(xm), "r"(ym)); - } - __asm__ __volatile__ - (// calculate abs, sum, and write - "movq %%mm5, %%mm0\n\t" // calculate abs of x accumulator - "psraw $15, %%mm0\n\t" - "pxor %%mm0, %%mm5\n\t" - "psubw %%mm0, %%mm5\n\t" - "movq %%mm6, %%mm0\n\t" // calculate abs of y accumulator - "psraw $15, %%mm0\n\t" - "pxor %%mm0, %%mm6\n\t" - "psubw %%mm0, %%mm6\n\t" - "paddw %%mm5, %%mm6\n\t" // add together - "packuswb %%mm6, %%mm6\n\t" // and write - "movd %%mm6, (%0)\n\t" - : : "r"(dest)); - dest++; - } - __asm__ __volatile__ ("emms\n\t" : :); - } - else -#endif - { - int xR, xG, xB, yR, yG, yB; - for(y=0; y < h; ++y){ - scanblock[1] = (QRgb *)img.scanLine(y); - dest = (QRgb *)buffer.scanLine(y); - if(y == 0){ - scanblock[0] = (QRgb *)img.scanLine(y); - scanblock[2] = (QRgb *)img.scanLine(y+1); - } - else if(y == h-1){ - scanblock[0] = (QRgb *)img.scanLine(y-1); - scanblock[2] = (QRgb *)img.scanLine(y); - } - else{ - scanblock[0] = (QRgb *)img.scanLine(y-1); - scanblock[2] = (QRgb *)img.scanLine(y+1); - } - - // x == 0, double over first pixel - xR = xG = xB = yR = yG = yB = 0; - s = scanblock[0]; - SOBEL(-1, 1, *s); SOBEL(0, 2, *s); ++s; SOBEL(1, 1, *s); - s = scanblock[1]; - SOBEL(-2, 0, *s); SOBEL(0, 0, *s); ++s; SOBEL(2, 0, *s); - s = scanblock[2]; - SOBEL(-1, -1, *s); SOBEL(0, -2, *s); ++s; SOBEL(1, -1, *s); - xR = qAbs(xR)+qAbs(yR); xG = qAbs(xG)+qAbs(yG); - xB = qAbs(xB)+qAbs(yB); - *dest++ = qRgb(qMin(xR, 255), qMin(xG, 255), qMin(xB, 255)); - - // x == 1, process middle of image - for(x=1; x < w-1; ++x){ - xR = xG = xB = yR = yG = yB = 0; - s = scanblock[0]; - SOBEL(-1, 1, *s); ++s; SOBEL(0, 2, *s); ++s; SOBEL(1, 1, *s); - s = scanblock[1]; - SOBEL(-2, 0, *s); ++s; SOBEL(0, 0, *s); ++s; SOBEL(2, 0, *s); - s = scanblock[2]; - SOBEL(-1, -1, *s); ++s; SOBEL(0, -2, *s); ++s; SOBEL(1, -1, *s); - ++scanblock[0]; ++scanblock[1]; ++scanblock[2]; - xR = qAbs(xR)+qAbs(yR); xG = qAbs(xG)+qAbs(yG); - xB = qAbs(xB)+qAbs(yB); - *dest++ = qRgb(qMin(xR, 255), qMin(xG, 255), qMin(xB, 255)); - } - - // x == w-1, double over last pixel - xR = xG = xB = yR = yG = yB = 0; - s = scanblock[0]; - SOBEL(-1, 1, *s); ++s; SOBEL(0, 2, *s); SOBEL(1, 1, *s); - s = scanblock[1]; - SOBEL(-2, 0, *s); ++s; SOBEL(0, 0, *s); SOBEL(2, 0, *s); - s = scanblock[2]; - SOBEL(-1, -1, *s); ++s; SOBEL(0, -2, *s); SOBEL(1, -1, *s); - xR = qAbs(xR)+qAbs(yR); xG = qAbs(xG)+qAbs(yG); - xB = qAbs(xB)+qAbs(yB); - *dest++ = qRgb(qMin(xR, 255), qMin(xG, 255), qMin(xB, 255)); - } - } - return(buffer); -} - -QImage Blitz::charcoal(QImage &img) -{ - QImage buffer(edge(img)); - buffer = blur(buffer, 1); - normalize(buffer); - buffer.invertPixels(); - grayscale(buffer, true); - return(buffer); -} - -QImage Blitz::swirl(QImage &img, float degrees) -{ - float sine, cosine, distance, radius, factor; - float x_center, x_distance, x_scale; - float y_center, y_distance, y_scale; - int x, y, w, h; - QRgb *dest; - - w = img.width(); - h = img.height(); - - if(img.format() == QImage::Format_ARGB32_Premultiplied) - img = img.convertToFormat(QImage::Format_ARGB32); - else if(img.depth() < 8) - img = img.convertToFormat(QImage::Format_Indexed8); - - QImage buffer(w, h, img.hasAlphaChannel() ? - QImage::Format_ARGB32 : QImage::Format_RGB32); - - x_center = w/2.0; - y_center = h/2.0; - radius = qMax(x_center, y_center); - x_scale = y_scale = 1.0; - if(w > h) - y_scale = (float)(w/h); - else if(w < h) - x_scale = (float)(h/w); - degrees = (M_PI*degrees)/180.0; - - InlineInterpolate interpolate(&img, 0); - if(img.depth() > 8){ - QRgb *src; - for(y=0; y < h; ++y){ - src = (QRgb *)img.scanLine(y); - dest = (QRgb *)buffer.scanLine(y); - y_distance = y_scale*(y-y_center); - for(x=0; x < w; ++x){ - x_distance = x_scale*(x-x_center); - distance = x_distance*x_distance + y_distance*y_distance; - if(distance >= (radius*radius)) - *dest = src[x]; - else{ - factor = 1.0-std::sqrt(distance)/radius; - sine = std::sin(degrees*factor*factor); - cosine = std::cos(degrees*factor*factor); - *dest = interpolate. - interpolate((cosine*x_distance-sine*y_distance)/ - x_scale+x_center, - (sine*x_distance+cosine*y_distance)/ - y_scale+y_center); - } - ++dest; - } - } - } - else{ - QVector cTable(img.colorTable()); - unsigned char *src; - for(y=0; y < h; ++y){ - src = img.scanLine(y); - dest = (QRgb *)buffer.scanLine(y); - y_distance = y_scale*(y-y_center); - for(x=0; x < w; ++x){ - x_distance = x_scale*(x-x_center); - distance = x_distance*x_distance + y_distance*y_distance; - if(distance >= (radius*radius)) - *dest = cTable.at(src[x]); - else{ - factor = 1.0-std::sqrt(distance)/radius; - sine = std::sin(degrees*factor*factor); - cosine = std::cos(degrees*factor*factor); - *dest = interpolate. - interpolate((cosine*x_distance-sine*y_distance)/ - x_scale+x_center, - (sine*x_distance+cosine*y_distance)/ - y_scale+y_center); - } - ++dest; - } - } - } - return(buffer); -} - -QImage Blitz::implode(QImage &img, float amount) -{ - float distance, radius, factor; - float x_center, x_distance, x_scale; - float y_center, y_distance, y_scale; - int x, y, w, h; - QRgb *dest; - - w = img.width(); - h = img.height(); - - if(img.format() == QImage::Format_ARGB32_Premultiplied) - img = img.convertToFormat(QImage::Format_ARGB32); - else if(img.depth() < 8) - img = img.convertToFormat(QImage::Format_Indexed8); - - QImage buffer(w, h, img.hasAlphaChannel() ? - QImage::Format_ARGB32 : QImage::Format_RGB32); - - x_scale = y_scale = 1.0; - x_center = 0.5*w; - y_center = 0.5*h; - radius = x_center; - if(w > h) - y_scale = (float)(w/h); - else if(w < h){ - x_scale = (float)(h/w); - radius = y_center; - } - - InlineInterpolate interpolate(&img, 0); - if(img.depth() > 8){ - QRgb *src; - for(y=0; y < h; ++y){ - src = (QRgb *)img.scanLine(y); - dest = (QRgb *)buffer.scanLine(y); - y_distance = y_scale*(y-y_center); - for(x=0; x < w; ++x){ - x_distance = x_scale*(x-x_center); - distance = x_distance*x_distance + y_distance*y_distance; - if(distance >= (radius*radius)) - *dest = src[x]; - else{ - factor = 1.0; - if(distance > 0.0) - factor = std::pow(std::sin(((float)M_PI)* - std::sqrt(distance)/ - radius/2), -amount); - *dest = interpolate. - interpolate(factor*x_distance/x_scale+x_center, - factor*y_distance/y_scale+y_center); - } - ++dest; - } - } - } - else{ - QVector cTable(img.colorTable()); - unsigned char *src; - for(y=0; y < h; ++y){ - src = img.scanLine(y); - dest = (QRgb *)buffer.scanLine(y); - y_distance = y_scale*(y-y_center); - for(x=0; x < w; ++x){ - x_distance = x_scale*(x-x_center); - distance = x_distance*x_distance + y_distance*y_distance; - if(distance >= (radius*radius)) - *dest = cTable.at(src[x]); - else{ - factor = 1.0; - if(distance > 0.0) - factor = std::pow(std::sin(((float)M_PI)* - std::sqrt(distance)/ - radius/2), -amount); - *dest = interpolate. - interpolate(factor*x_distance/x_scale+x_center, - factor*y_distance/y_scale+y_center); - } - ++dest; - } - } - } - return(buffer); -} - -QImage Blitz::wave(QImage &img, float amplitude, float length, - unsigned int background) -{ - int x, y, w, h; - QRgb *dest; - float *sine_map; - - if(img.format() == QImage::Format_ARGB32_Premultiplied) - img = img.convertToFormat(QImage::Format_ARGB32); - else if(img.depth() < 8) - img = img.convertToFormat(QImage::Format_Indexed8); - - QImage buffer(img.width(), (int)(img.height()+2.0*std::abs(amplitude)), - QImage::Format_RGB32); - w = buffer.width(); - h = buffer.height(); - - sine_map = new float[w]; - for(x=0; x < w; ++x) - sine_map[x] = std::abs(amplitude)+amplitude*std::sin((2*M_PI*x)/length); - - InlineInterpolate interpolate(&img, background); - for(y=0; y < h; ++y){ - dest = (QRgb *)buffer.scanLine(y); - for(x=0; x < w; ++x) - *dest++ = interpolate. - interpolateBackground(x, y-sine_map[x]); - } - delete[] sine_map; - return(buffer); -} - -QImage& Blitz::modulate(QImage &img, QImage &modImg, bool reverse, - ModulationType type, int factor, RGBChannel channel) -{ - if(img.isNull() || modImg.isNull()) - return(img); - - // for image, we handle only depth 32 - if(img.depth() < 32 || img.format() == QImage::Format_ARGB32_Premultiplied) - img = img.convertToFormat(img.hasAlphaChannel() ? - QImage::Format_ARGB32 : - QImage::Format_RGB32); - - // for modImage, we handle depth 8 and 32 - if(modImg.depth() < 8) - modImg = modImg.convertToFormat(QImage::Format_Indexed8); - else if(modImg.format() == QImage::Format_ARGB32_Premultiplied) - modImg = modImg.convertToFormat(QImage::Format_ARGB32); - - unsigned int x1 = img.width(), y1 = img.height(); - unsigned int x2 = modImg.width(), y2 = modImg.height(); - unsigned int x, y; - unsigned int *src, *modulation_colorTable; - unsigned char *modulation_src; - int r, g, b, mod = 0; - QRgb color1, color2; - InlineHSV hsv; - - QVector cTable; - if(modImg.format() == QImage::Format_Indexed8){ - cTable = modImg.colorTable(); - modulation_colorTable = cTable.data(); - } - else - modulation_colorTable = NULL; - - for(y=0; y < y1; ++y){ - src = (QRgb *)img.scanLine(y); - modulation_src = modImg.scanLine(y%y2); - x=0; - while(x < x1){ - color2 = (!modulation_colorTable) ? - *((QRgb *)modulation_src) : - modulation_colorTable[*modulation_src]; - if(reverse){ - color1 = color2; - color2 = *src; - } - else - color1 = *src; - - if(type == Intensity || type == Contrast){ - r = qRed(color1); g = qGreen(color1); b = qBlue(color1); - if(channel != All){ - mod = (channel == Red) ? qRed(color2) : - (channel == Green) ? qGreen(color2) : - (channel == Blue) ? qBlue(color2) : - (channel == Grayscale) ? qGray(color2) : 0; - mod = mod*factor/50; - } - - if(type == Intensity){ - if(channel == All){ - r += r * factor/50 * qRed(color2)/256; - g += g * factor/50 * qGreen(color2)/256; - b += b * factor/50 * qBlue(color2)/256; - } - else{ - r += r * mod/256; - g += g * mod/256; - b += b * mod/256; - } - } - else{ // Contrast - if(channel == All){ - r += (r-128) * factor/50 * qRed(color2)/128; - g += (g-128) * factor/50 * qGreen(color2)/128; - b += (b-128) * factor/50 * qBlue(color2)/128; - } - else{ - r += (r-128) * mod/128; - g += (g-128) * mod/128; - b += (b-128) * mod/128; - } - } - *src = qRgba(qBound(0, r, 255), qBound(0, g, 255), - qBound(0, b, 255), qAlpha(*src)); - } - else if(type == Saturation || type == HueShift){ - mod = (channel == Red) ? qRed(color2) : - (channel == Green) ? qGreen(color2) : - (channel == Blue) ? qBlue(color2) : - (channel == Grayscale||channel == All) ? qGray(color2) : 0; - mod = mod*factor/50; - hsv.convertRGB2HSV(color1); - if(type == Saturation) - hsv.setSaturation(qBound(0, hsv.saturation()- - hsv.saturation()*mod/256, 255)); - else{ - int h = hsv.hue() + mod; - while(h<0) h+=360; - hsv.setHue(h %= 360); - } - hsv.convertHSV2RGB(); - *src = qRgba(hsv.red(), hsv.green(), hsv.blue(), qAlpha(*src)); - } - ++src; ++x; - modulation_src += (!modulation_colorTable) ? 4 : 1; - - if((x%x2) == 0) - modulation_src -= (!modulation_colorTable) ? x2*4 : x2; - } - } - return(img); -} diff -Nru syncwall-1.6.0/3rdparty/qimageblitz/blitz.pri syncwall-1.7.4/3rdparty/qimageblitz/blitz.pri --- syncwall-1.6.0/3rdparty/qimageblitz/blitz.pri 2008-02-26 19:31:00.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qimageblitz/blitz.pri 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ - -INCLUDEPATH += $$BLITZ_DIR -LIBS += -lqimageblitz diff -Nru syncwall-1.6.0/3rdparty/qimageblitz/blitzcpu.cpp syncwall-1.7.4/3rdparty/qimageblitz/blitzcpu.cpp --- syncwall-1.6.0/3rdparty/qimageblitz/blitzcpu.cpp 2008-02-26 19:31:00.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qimageblitz/blitzcpu.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,193 +0,0 @@ -#include "blitzcpu.h" -#include -#include -#include - -/** - * CPUID code: This tests the CPU id flags for MMX, SSE, 3dnow, etc... - * support. This is based on KCPUInfo by Fredrik Hoglund. - * - * Copyright (C) 2003 Fredrik Hoglund - * Copyright (C) 2004 Daniel M. Duley - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if defined(__i386__) && ( defined(__GNUC__) || defined(__INTEL_COMPILER) ) -# if defined(HAVE_MMX) -# define USE_MMX_INLINE_ASM -# endif -#endif - -#ifdef USE_MMX_INLINE_ASM -// Sighandler for the SSE OS support check -typedef void (*blitz_sighandler_t)(int); -static jmp_buf env; -static void blitz_sighandler(int) -{ - std::longjmp(env, 1); -} -#elif defined __PPC__ && defined HAVE_PPC_ALTIVEC -// Sighandler for PPC AltiVec check -static sigjmp_buf jmpbuf; -static sig_atomic_t canjump = 0; -static void blitz_sighandler(int sig) -{ - if(!canjump) { - signal(sig, SIG_DFL); - raise(sig); - } - canjump = 0; - siglongjmp(jmpbuf, 1); -} -#endif - -static unsigned int checkCPUID() -{ - volatile unsigned int flags = 0; -#ifdef USE_MMX_INLINE_ASM // Intel/AMD checks - bool hasCPUID = false; - unsigned int result = 0; - - __asm__ __volatile__ - (// Try to toggle the CPUID bit in the EFLAGS register - "pushf \n\t" // Push the EFLAGS register onto the stack - "popl %%ecx \n\t" // Pop the value into ECX - "movl %%ecx, %%edx \n\t" // Copy ECX to EDX - "xorl $0x00200000, %%ecx \n\t" // Toggle bit 21 (CPUID) in ECX - "pushl %%ecx \n\t" // Push the modified value onto the stack - "popf \n\t" // Pop it back into EFLAGS - - // Check if the CPUID bit was successfully toggled - "pushf \n\t" // Push EFLAGS back onto the stack - "popl %%ecx \n\t" // Pop the value into ECX - "xorl %%eax, %%eax \n\t" // Zero out the EAX register - "cmpl %%ecx, %%edx \n\t" // Compare ECX with EDX - "je .Lno_cpuid_support%= \n\t" // Jump if they're identical - "movl $1, %%eax \n\t" // Set EAX to true - ".Lno_cpuid_support%=: \n\t" - : "=a"(hasCPUID) : : "%ecx", "%edx" ); - if(!hasCPUID) - return(flags); - - // Execute CPUID with the feature request bit set - __asm__ __volatile__ - ("pushl %%ebx \n\t" // Save EBX - "movl $1, %%eax \n\t" // Set EAX to 1 (features request) - "cpuid \n\t" // Call CPUID - "popl %%ebx \n\t" // Restore EBX - : "=d"(result) : : "%eax", "%ecx"); - - // Test bit 23 (MMX support) - // 25: SSE - // 26: SSE2 - if(result & 0x00800000) - flags |= BlitzCPUInfo::MMX; - if(result & 0x00200000) - flags |= BlitzCPUInfo::SSE; - if(result & 0x00400000) - flags |= BlitzCPUInfo::SSE2; - - // Now try extended feature request - result = 0; - __asm__ __volatile__ - ("pushl %%ebx \n\t" - "movl $0x80000000, %%eax \n\t" - "cpuid \n\t" - "cmpl $0x80000000, %%eax \n\t" - "jbe .Lno_extended%= \n\t" - "movl $0x80000001, %%eax \n\t" - "cpuid \n\t" - ".Lno_extended%=: \n\t" - "popl %%ebx \n\t" // Restore EBX - : "=d"(result) : : "%eax", "%ecx"); - - // Bit 31: 3dNow - // Bit 30: 3dNow+ - // Bit 22: MMX SSE (Integer SSE) - AMD Only - if(result & 0x80000000){ - flags |= BlitzCPUInfo::AMD3DNOW; - if(result & 0x40000000) - flags |= BlitzCPUInfo::AMD3DNOW2; - if(result & 0x00400000) // This is only valid on AMD cpu's w/ 3dnow - flags |= BlitzCPUInfo::IntegerSSE; - } - else if(flags & BlitzCPUInfo::SSE) - flags |= BlitzCPUInfo::IntegerSSE; - - if((flags & BlitzCPUInfo::SSE) || (flags & BlitzCPUInfo::SSE2)){ - // SSE OS support check - // Install our own sighandler for SIGILL. - blitz_sighandler_t oldhandler = - std::signal(SIGILL, blitz_sighandler); - - // Try executing an SSE insn to see if we get a SIGILL - if(setjmp(env)){ - // No go. MMX-SSE should still be okay, tho. - if(flags & BlitzCPUInfo::SSE) - flags -= BlitzCPUInfo::SSE; - if(flags & BlitzCPUInfo::SSE2) - flags -= BlitzCPUInfo::SSE2; - } - else - __asm__ __volatile__("xorps %xmm0, %xmm0"); - - // Restore the default sighandler - std::signal( SIGILL, oldhandler ); - } - -#elif defined __PPC__ && defined HAVE_PPC_ALTIVEC - signal(SIGILL, blitz_sighandler); - if(sigsetjmp(jmpbuf, 1)){ - signal(SIGILL, SIG_DFL); - } - else{ - canjump = 1; - __asm__ __volatile__( "mtspr 256, %0\n\t" - "vand %%v0, %%v0, %%v0" - : /* none */ - : "r" (-1) ); - signal(SIGILL, SIG_DFL); - flags |= BlitzCPUInfo::AltiVec; - } -#endif - return(flags); -} - -bool BlitzCPUInfo::haveExtension(unsigned int extension) -{ - static bool checked = false; - static unsigned int flags = 0; - if(!checked){ - flags = checkCPUID(); - checked = true; - qWarning("MMX: %d, SSE: %d, SSE2: %d, MMX-SSE: %d, 3dNow: %d, 3dNow+: %d", - haveExtension(BlitzCPUInfo::MMX), - haveExtension(BlitzCPUInfo::SSE), - haveExtension(BlitzCPUInfo::SSE2), - haveExtension(BlitzCPUInfo::IntegerSSE), - haveExtension(BlitzCPUInfo::AMD3DNOW), - haveExtension(BlitzCPUInfo::AMD3DNOW2)); - } - return(flags & extension); -} - diff -Nru syncwall-1.6.0/3rdparty/qimageblitz/blitzcpu.h syncwall-1.7.4/3rdparty/qimageblitz/blitzcpu.h --- syncwall-1.6.0/3rdparty/qimageblitz/blitzcpu.h 2008-02-26 19:31:00.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qimageblitz/blitzcpu.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ -#ifndef __BLITZ_CPU_H -#define __BLITZ_CPU_H - -/** - * CPUID code: This tests the CPU id flags for MMX, SSE, 3dnow, etc... - * support. This is based on KCPUInfo by Fredrik Hoglund. - * - * Copyright (C) 2003 Fredrik Hoglund - * Copyright (C) 2004 Daniel M. Duley - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "qimageblitz_export.h" -#include - -/** - * MMX packed value data types. If you don't write MMX assembler code you - * can ignore these. - * - * @author Daniel M. Duley - * @short MMX data types - */ -namespace MMX{ - typedef struct { quint32 d[2]; } Pack2; - typedef struct { quint16 d[4]; } Pack4; - typedef struct { quint8 d[8]; } Pack8; -} - -/** - * This class determines what extensions the computer's CPU supports. These - * include MMX, SSE, 3dnow, and AltiVec. If you don't write assembler code - * you probably can ignore this class. - * - * @short CPU features identification - * @author Fredrik Hoglund - * @author Daniel M. Duley - */ -class BlitzCPUInfo{ -public: - enum Extension { - MMX = 1 << 0, - IntegerSSE = 1 << 1, - SSE = 1 << 2, - SSE2 = 1 << 3, - AMD3DNOW = 1 << 4, - AMD3DNOW2 = 1 << 5, - AltiVec = 1 << 6 - }; - /** - * Returns true if the CPU supports the given extension. - */ - static bool haveExtension(unsigned int extension); -}; - - -#endif - diff -Nru syncwall-1.6.0/3rdparty/qimageblitz/colors.cpp syncwall-1.7.4/3rdparty/qimageblitz/colors.cpp --- syncwall-1.6.0/3rdparty/qimageblitz/colors.cpp 2008-02-26 19:31:00.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qimageblitz/colors.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,1051 +0,0 @@ -/* - Copyright (C) 1998, 1999, 2001, 2002, 2004, 2005, 2007 - Daniel M. Duley - (C) 2000 Josef Weidendorfer - (C) 1999 Geert Jansen - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -#include "qimageblitz.h" -#include -#include "private/inlinehsv.h" -#include "private/blitz_p.h" -#include "blitzcpu.h" -#include - -#if defined(__i386__) && ( defined(__GNUC__) || defined(__INTEL_COMPILER) ) -# if defined(HAVE_MMX ) -# define USE_MMX_INLINE_ASM -# endif -#endif - -/** - * Precalculated increment values for HSV contrast. Saves some expensive - * floating point math. These are half the integer results of: - * - * alpha*(alpha*(sin(M_PI*(brightness-alpha))+1.0)-brightness) - * - * where alpha is 0.5+M_EPSILON and brightness is the percentage for values - * ranging from 0 to 255, (Qt compatible HSV brightness values). The other - * half of the lookup table is the inverse of these values. I am so clever :) - * (mosfet) - */ -static char contrast_table[128] = { - 0, 1, 1, 2, 3, 3, 4, 4, 5, 5, 6, 7, 7, 8, 8, 9, 9, - 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, - 17, 18, 18, 19, 19, 19, 20, 20, 21, 21, 21, 22, 22, 22, 23, - 23, 23, 24, 24, 24, 24, 25, 25, 25, 25, 25, 26, 26, 26, 26, - 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, - 27, 26, 26, 26, 26, 26, 26, 26, 25, 25, 25, 25, 24, 24, 24, - 23, 23, 23, 22, 22, 21, 21, 20, 20, 20, 19, 18, 18, 17, 17, - 16, 16, 15, 14, 14, 13, 12, 11, 11, 10, 9, 8, 7, 7, 6, 5, - 4, 3, 2, 1, 0 -}; - -bool Blitz::grayscale(QImage &img, bool reduceDepth) -{ - if(img.isNull()) - return(false); - - if(img.format() == QImage::Format_ARGB32_Premultiplied) - img = img.convertToFormat(QImage::Format_ARGB32); - else if(img.depth() < 8) - img = img.convertToFormat(QImage::Format_Indexed8); - -#ifdef USE_MMX_INLINE_ASM -#ifdef __GNUC__ -#warning Using MMX grayscale -#endif - if(BlitzCPUInfo::haveExtension(BlitzCPUInfo::IntegerSSE)){ - MMX::Pack4 packedmult = {{5, 16, 11, 1}}; - MMX::Pack4 alphamask = {{0x0000, 0x0000, 0x0000, 0xFFFF}}; - MMX::Pack4 noalphamask = {{0xFFFF, 0xFFFF, 0xFFFF, 0x0000}}; - - if(reduceDepth && !img.hasAlphaChannel()){ - int y, w = img.width(), h = img.height(); - QImage buffer(w, h, QImage::Format_Indexed8); - - QVector cTable(256); - unsigned int *src = cTable.data(); - for(y=0; y < 256; ++y) - *src++ = qRgb(y, y, y); - buffer.setColorTable(cTable); - - src = (unsigned int *)img.scanLine(0); - unsigned char *end, *dest; - - __asm__ __volatile__ - ("pxor %%mm7, %%mm7\n\t" - "movq (%0), %%mm4\n\t" - "movq (%1), %%mm5\n\t" - "movq (%2), %%mm6\n\t" - : : "r"(&packedmult), "r"(&alphamask), "r"(&noalphamask)); - for(y=0; y < h; ++y){ - dest = buffer.scanLine(y); - end = dest+w; - while(dest != end){ - __asm__ __volatile__ - ("movd (%0), %%mm0\n\t" // load pixel - "punpcklbw %%mm7, %%mm0\n\t" // upgrade to quad - "pand %%mm6, %%mm0\n\t" // zero alpha so we can use pmaddwd - - "pmaddwd %%mm4, %%mm0\n\t" // 2 multiplies and sum BG, RA - "pshufw $0xE4, %%mm0, %%mm1\n\t" - "punpckhwd %%mm7, %%mm1\n\t" // sum R - "paddw %%mm1, %%mm0\n\t" - "psrlw $0x05, %%mm0\n\t" // divide by 32 - "movd %%mm0, %%eax\n\t" - "movb %%al, (%1)\n\t" - : : "r"(src), "r"(dest) : "%eax"); - ++src; - ++dest; - } - } - __asm__ __volatile__ ("emms\n\t" : :); - img = buffer; - } - else{ - // 8bpp or 32bpp w/ no conversion - int count = img.depth() > 8 ? img.width()*img.height() : img.numColors(); - - QVector cTable; - if(img.depth() == 8) - cTable = img.colorTable(); - - unsigned int *data = (img.depth() > 8) ? - (unsigned int *)img.scanLine(0) : cTable.data(); - unsigned int *end = data+count; - - __asm__ __volatile__ - ("pxor %%mm7, %%mm7\n\t" - "movq (%0), %%mm4\n\t" - "movq (%1), %%mm5\n\t" - "movq (%2), %%mm6\n\t" - : : "r"(&packedmult), "r"(&alphamask), "r"(&noalphamask)); - while(data != end){ - __asm__ __volatile__ - ("movd (%0), %%mm0\n\t" // load pixel - "punpcklbw %%mm7, %%mm0\n\t" // upgrade to quad - "pshufw $0xE4, %%mm0, %%mm2\n\t" // copy for alpha later - "pand %%mm6, %%mm0\n\t" // zero alpha so we can use pmaddwd - - "pmaddwd %%mm4, %%mm0\n\t" // 2 multiplies and sum BG, RA - "pshufw $0xE4, %%mm0, %%mm1\n\t" - "punpckhwd %%mm7, %%mm1\n\t" // sum R - "paddw %%mm1, %%mm0\n\t" - "psrlw $0x05, %%mm0\n\t" // divide by 32 - - "pshufw $0x00, %%mm0, %%mm0\n\t" // copy to all pixels - "pand %%mm6, %%mm0\n\t" // reset original alpha - "pand %%mm5, %%mm2\n\t" - "por %%mm2, %%mm0\n\t" - - "packuswb %%mm0, %%mm0\n\t" // pack and write - "movd %%mm0, (%0)\n\t" - : : "r"(data)); - ++data; - } - __asm__ __volatile__ ("emms\n\t" : :); - if(img.depth() == 8) - img.setColorTable(cTable); - } - } - else -#endif - { - // Non MMX version - if(reduceDepth && img.format() == QImage::Format_RGB32){ - // 32bpp w/ conversion to palette - int y, w = img.width(), h = img.height(); - QImage buffer(w, h, QImage::Format_Indexed8); - - QVector cTable(256); - unsigned int *src = cTable.data(); - for(y=0; y < 256; ++y) - *src++ = qRgb(y, y, y); - buffer.setColorTable(cTable); - - src = (unsigned int *)img.scanLine(0); - unsigned char *end, *dest; - unsigned int pixel; - for(y=0; y < h; ++y){ - dest = buffer.scanLine(y); - end = dest+w; - while(dest != end){ - pixel = *src++; - *dest++ = qGray(qRed(pixel), qGreen(pixel), qBlue(pixel)); - } - } - img = buffer; - } - else{ - // 8bpp or 32bpp w/ no conversion - int count = img.depth() > 8 ? img.width()*img.height() : img.numColors(); - - QVector cTable; - if(img.depth() == 8) - cTable = img.colorTable(); - - unsigned int *data = (img.depth() > 8) ? - (unsigned int *)img.scanLine(0) : cTable.data(); - unsigned int *end = data+count; - unsigned int pixel; - unsigned char c; - while(data != end){ - pixel = *data; - c = qGray(qRed(pixel), qGreen(pixel), qBlue(pixel)); - *data++ = qRgba(c, c, c, qAlpha(pixel)); - } - if(img.depth() == 8) - img.setColorTable(cTable); - } - } - return(true); -} - -bool Blitz::invert(QImage &img, QImage::InvertMode mode) -{ - if(img.isNull()) - return(false); - -#ifdef USE_MMX_INLINE_ASM -#ifdef __GNUC__ -#warning Using MMX invert -#endif - if(BlitzCPUInfo::haveExtension(BlitzCPUInfo::MMX)){ - if(img.format() == QImage::Format_ARGB32_Premultiplied) - img = img.convertToFormat(QImage::Format_ARGB32); - else if(img.depth() < 8) - img = img.convertToFormat(QImage::Format_Indexed8); - - unsigned int mask = (mode == QImage::InvertRgba ? 0xFFFFFFFF : - 0x00FFFFFF); - MMX::Pack2 packedmask = {{mask, mask}}; - - int remainder, count; - unsigned int *data, *end; - QVector cTable; - - if(img.depth() <= 8){ - cTable = img.colorTable(); - remainder = img.numColors() % 4; - count = img.numColors()-remainder; - data = (unsigned int *)cTable.data(); - } - else{ - remainder = (img.width()*img.height()) % 4; - count = (img.width()*img.height())-remainder; - data = (unsigned int *)img.scanLine(0); - } - end = data+count; - - __asm__ __volatile__ ("movq (%0), %%mm7\n\t" : : "r"(&packedmask)); - while(data != end){ - __asm__ __volatile__ - ("movq (%0), %%mm0\n\t" - "pxor %%mm7, %%mm0\n\t" - "movq %%mm0, (%0)\n\t" - : : "r"(data)); - data += 2; - } - end += remainder; - while(data != end){ - __asm__ __volatile__ - ("movd (%0), %%mm0\n\t" - "pxor %%mm7, %%mm0\n\t" - "movd %%mm0, (%0)\n\t" - : : "r"(data)); - ++data; - } - __asm__ __volatile__ ("emms\n\t" : :); - if(img.depth() <= 8) - img.setColorTable(cTable); - } - else -#endif - { - img.invertPixels(mode); - } - return(true); -} - -QImage& Blitz::contrast(QImage &img, bool sharpen, int weight) -{ - if(img.isNull()) - return(img); - - if(img.format() == QImage::Format_ARGB32_Premultiplied) - img = img.convertToFormat(QImage::Format_ARGB32); - else if(img.depth() < 8) - img = img.convertToFormat(QImage::Format_Indexed8); - - QVector cTable; - if(img.depth() == 8) - cTable = img.colorTable(); - - unsigned int *end, *data; - int count; - if(img.depth() > 8){ - count = img.width()*img.height(); - data = (unsigned int *)img.scanLine(0); - } - else{ - count = img.numColors(); - data = (unsigned int *)cTable.data(); - } - end = data+count; - - InlineHSV hsv; - int v; - if(sharpen){ - while(data != end){ - hsv.convertRGB2HSV(*data); - v = hsv.value(); - if(v > 127){ - v += contrast_table[v-128]+weight; - if(v > 255) v = 255; - } - else{ - v -= contrast_table[v]+weight; - if(v < 0) v = 0; - } - hsv.setValue(v); - hsv.convertHSV2RGB(); - *data = qRgba(hsv.red(), hsv.green(), hsv.blue(), qAlpha(*data)); - ++data; - } - } - else{ - while(data != end){ - hsv.convertRGB2HSV(*data); - v = hsv.value(); - if(v > 127){ - v -= contrast_table[v-128]+weight; - if(v < 0) v = 0; - } - else{ - v += contrast_table[v]+weight; - if(v > 255) v = 255; - } - hsv.setValue(v); - hsv.convertHSV2RGB(); - *data = qRgba(hsv.red(), hsv.green(), hsv.blue(), qAlpha(*data)); - ++data; - } - } - - if(img.depth() == 8) - img.setColorTable(cTable); - return(img); -} - -QImage& Blitz::intensity(QImage &img, float percent) -{ - if(img.isNull()) - return(img); - - if(img.format() == QImage::Format_ARGB32_Premultiplied) - img = img.convertToFormat(QImage::Format_ARGB32); - else if(img.depth() < 8) - img = img.convertToFormat(QImage::Format_Indexed8); - - QVector colorTable; - int segmentColors, pixels; - unsigned int *data; - - if(img.format() == QImage::Format_Indexed8){ - segmentColors = pixels = img.numColors(); - colorTable = img.colorTable(); - data = colorTable.data(); - } - else{ - segmentColors = 256; - pixels = img.width()*img.height(); - data = (unsigned int *)img.scanLine(0); - } - - percent = qBound(-1.0f, percent, 1.0f); - bool brighten = (percent >= 0); - if(percent < 0) - percent = -percent; - -#ifdef USE_MMX_INLINE_ASM -#ifdef __GNUC__ -#warning Using MMX intensity -#endif - if(BlitzCPUInfo::haveExtension(BlitzCPUInfo::IntegerSSE)){ - unsigned int rem = pixels % 4; - pixels -= rem; - quint32 *end = ( data + pixels ); - - quint16 p = (quint16)(256.0f*(percent)); - MMX::Pack4 mult = {{p,p,p,0}}; - - __asm__ __volatile__( - "pxor %%mm7, %%mm7\n\t" // zero mm7 for unpacking - "movq (%0), %%mm6\n\t" // copy intensity change to mm6 - : : "r"(&mult), "m"(mult)); - if (brighten) - { - while ( data != end ) { - __asm__ __volatile__( - "movq (%0), %%mm0\n\t" - "movq 8(%0), %%mm4\n\t" // copy 4 pixels of data to mm0 and mm4 - "movq %%mm0, %%mm1\n\t" - "movq %%mm0, %%mm3\n\t" - "movq %%mm4, %%mm5\n\t" // copy to registers for unpacking - "punpcklbw %%mm7, %%mm0\n\t" - "punpckhbw %%mm7, %%mm1\n\t" // unpack the two pixels from mm0 - "pmullw %%mm6, %%mm0\n\t" - "punpcklbw %%mm7, %%mm4\n\t" - "pmullw %%mm6, %%mm1\n\t" // multiply by intensity*256 - "psrlw $8, %%mm0\n\t" // divide by 256 - "pmullw %%mm6, %%mm4\n\t" - "psrlw $8, %%mm1\n\t" - "psrlw $8, %%mm4\n\t" - "packuswb %%mm1, %%mm0\n\t" // pack solution into mm0. saturates at 255 - "movq %%mm5, %%mm1\n\t" - - "punpckhbw %%mm7, %%mm1\n\t" // unpack 4th pixel in mm1 - - "pmullw %%mm6, %%mm1\n\t" - "paddusb %%mm3, %%mm0\n\t" // add intesity result to original of mm0 - "psrlw $8, %%mm1\n\t" - "packuswb %%mm1, %%mm4\n\t" // pack upper two pixels into mm4 - - "movq %%mm0, (%0)\n\t" // rewrite to memory lower two pixels - "paddusb %%mm5, %%mm4\n\t" - "movq %%mm4, 8(%0)\n\t" // rewrite upper two pixels - : : "r"(data) ); - data += 4; - } - - end += rem; - while ( data != end ) { - __asm__ __volatile__( - "movd (%0), %%mm0\n\t" // repeat above but for - "punpcklbw %%mm7, %%mm0\n\t" // one pixel at a time - "movq %%mm0, %%mm3\n\t" - "pmullw %%mm6, %%mm0\n\t" - "psrlw $8, %%mm0\n\t" - "paddw %%mm3, %%mm0\n\t" - "packuswb %%mm0, %%mm0\n\t" - "movd %%mm0, (%0)\n\t" - : : "r"(data) ); - data++; - } - } - else - { - while ( data != end ) { - __asm__ __volatile__( - "movq (%0), %%mm0\n\t" - "movq 8(%0), %%mm4\n\t" - "movq %%mm0, %%mm1\n\t" - "movq %%mm0, %%mm3\n\t" - - "movq %%mm4, %%mm5\n\t" - - "punpcklbw %%mm7, %%mm0\n\t" - "punpckhbw %%mm7, %%mm1\n\t" - "pmullw %%mm6, %%mm0\n\t" - "punpcklbw %%mm7, %%mm4\n\t" - "pmullw %%mm6, %%mm1\n\t" - "psrlw $8, %%mm0\n\t" - "pmullw %%mm6, %%mm4\n\t" - "psrlw $8, %%mm1\n\t" - "psrlw $8, %%mm4\n\t" - "packuswb %%mm1, %%mm0\n\t" - "movq %%mm5, %%mm1\n\t" - - "punpckhbw %%mm7, %%mm1\n\t" - - "pmullw %%mm6, %%mm1\n\t" - "psubusb %%mm0, %%mm3\n\t" // subtract darkening amount - "psrlw $8, %%mm1\n\t" - "packuswb %%mm1, %%mm4\n\t" - - "movq %%mm3, (%0)\n\t" - "psubusb %%mm4, %%mm5\n\t" // only change for this version is - "movq %%mm5, 8(%0)\n\t" // subtraction here as we are darkening image - : : "r"(data) ); - data += 4; - } - - end += rem; - while ( data != end ) { - __asm__ __volatile__( - "movd (%0), %%mm0\n\t" - "punpcklbw %%mm7, %%mm0\n\t" - "movq %%mm0, %%mm3\n\t" - "pmullw %%mm6, %%mm0\n\t" - "psrlw $8, %%mm0\n\t" - "psubusw %%mm0, %%mm3\n\t" - "packuswb %%mm3, %%mm3\n\t" - "movd %%mm3, (%0)\n\t" - : : "r"(data) ); - data++; - } - } - __asm__ __volatile__("emms"); // clear mmx state - } - else -#endif // USE_MMX_INLINE_ASM - { - unsigned char *segmentTable = new unsigned char[segmentColors]; - if(brighten){ - for(int i=0; i < segmentColors; ++i) - segmentTable[i] = qMin((int)(i*percent), 255); - - int r, g, b; - for(int i=0; i < pixels; ++i){ - r = qRed(data[i]); - g = qGreen(data[i]); - b = qBlue(data[i]); - data[i] = qRgba(qMin(255, r+segmentTable[r]), - qMin(255, g+segmentTable[g]), - qMin(255, b+segmentTable[b]), qAlpha(data[i])); - } - } - else{ - for(int i=0; i < segmentColors; ++i) - segmentTable[i] = qMax((int)(i*percent), 0); - - int r, g, b; - for(int i=0; i < pixels; ++i){ - r = qRed(data[i]); - g = qGreen(data[i]); - b = qBlue(data[i]); - data[i] = qRgba(qMax(0, r-segmentTable[r]), - qMax(0, g-segmentTable[g]), - qMax(0, b-segmentTable[b]), qAlpha(data[i])); - } - } - delete[] segmentTable; - } - - if(img.depth() == 8) - img.setColorTable(colorTable); - return(img); -} - -QImage& Blitz::channelIntensity(QImage &img, float percent, RGBChannel channel) -{ - if(img.isNull() || (channel != Red && channel != Blue && - channel != Green)) - return(img); - if(img.format() == QImage::Format_ARGB32_Premultiplied) - img = img.convertToFormat(QImage::Format_ARGB32); - else if(img.depth() < 8) - img = img.convertToFormat(QImage::Format_Indexed8); - - QVector colorTable; - int segmentColors, pixels; - unsigned int *data; - - if(img.format() == QImage::Format_Indexed8){ - segmentColors = pixels = img.numColors(); - colorTable = img.colorTable(); - data = colorTable.data(); - } - else{ - segmentColors = 256; - pixels = img.width()*img.height(); - data = (unsigned int *)img.scanLine(0); - } - - percent = qBound(-1.0f, percent, 1.0f); - bool brighten = (percent >= 0); - if(percent < 0) - percent = -percent; - - unsigned char *segmentTable = new unsigned char[segmentColors]; - if(brighten){ - for(int i=0; i < segmentColors; ++i) - segmentTable[i] = qMin((int)(i*percent), 255); - - int color; - if(channel == Red){ // and here ;-) - for(int i=0; i < pixels; ++i){ - color = qRed(data[i]); - data[i] = qRgba(qMin(255, color+segmentTable[color]), - qGreen(data[i]), qBlue(data[i]), - qAlpha(data[i])); - } - } - else if(channel == Green){ - for(int i=0; i < pixels; ++i){ - color = qGreen(data[i]); - data[i] = qRgba(qRed(data[i]), - qMin(255, color+segmentTable[color]), - qBlue(data[i]), qAlpha(data[i])); - } - } - else{ - for(int i=0; i < pixels; ++i){ - color = qBlue(data[i]); - data[i] = qRgba(qRed(data[i]), qGreen(data[i]), - qMin(255, color+segmentTable[color]), - qAlpha(data[i])); - } - } - } - else{ - for(int i=0; i < segmentColors; ++i) - segmentTable[i] = qMax((int)(i*percent), 0); - - int color; - if(channel == Red){ - for(int i=0; i < pixels; ++i){ - color = qRed(data[i]); - data[i] = qRgba(qMax(0, color-segmentTable[color]), - qGreen(data[i]), qBlue(data[i]), - qAlpha(data[i])); - } - } - else if(channel == Green){ - for(int i=0; i < pixels; ++i){ - color = qGreen(data[i]); - data[i] = qRgba(qRed(data[i]), - qMax(0, color-segmentTable[color]), - qBlue(data[i]), qAlpha(data[i])); - } - } - else{ - for(int i=0; i < pixels; ++i){ - color = qBlue(data[i]); - data[i] = qRgba(qRed(data[i]), qGreen(data[i]), - qMax(0, color-segmentTable[color]), - qAlpha(data[i])); - } - } - } - delete[] segmentTable; - if(img.format() == QImage::Format_Indexed8) - img.setColorTable(colorTable); - return(img); -} - -QImage& Blitz::desaturate(QImage &img, float desat) -{ - if(img.isNull()) - return(img); - if(img.depth() < 8) - img = img.convertToFormat(QImage::Format_Indexed8); - - desat = qBound(0.0f, desat, 1.0f); - - unsigned int *data, *end; - InlineHSV hsv; - if(img.format() == QImage::Format_ARGB32 || - img.format() == QImage::Format_RGB32 || - img.format() == QImage::Format_Indexed8){ - QVector cTable; - if(img.format() == QImage::Format_Indexed8){ - cTable = img.colorTable(); - data = (unsigned int *)cTable.data(); - end = data + img.numColors(); - - } - else{ - data = (unsigned int *)img.scanLine(0); - end = data + (img.width()*img.height()); - } - while(data != end){ - hsv.convertRGB2HSV(*data); - hsv.setSaturation((int)(hsv.saturation() * (1.0 - desat))); - hsv.convertHSV2RGB(); - *data = qRgba(hsv.red(), hsv.green(), hsv.blue(), qAlpha(*data)); - ++data; - } - if(img.format() == QImage::Format_Indexed8) - img.setColorTable(cTable); - - } - else if(img.format() == QImage::Format_ARGB32_Premultiplied){ - data = (unsigned int *)img.scanLine(0); - end = data + (img.width()*img.height()); - while(data != end){ - hsv.convertRGB2HSV(BlitzPrivate::convertFromPremult(*data)); - hsv.setSaturation((int)(hsv.saturation() * (1.0 - desat))); - hsv.convertHSV2RGB(); - *data = BlitzPrivate::convertToPremult(qRgba(hsv.red(), hsv.green(), - hsv.blue(), qAlpha(*data))); - ++data; - } - } - return(img); -} - - -QImage Blitz::threshold(QImage &img, unsigned char thresholdValue, - RGBChannel channel, unsigned int c_on, - unsigned int c_off) -{ - if(img.isNull()) - return(img); - else if(img.depth() < 8) - img = img.convertToFormat(QImage::Format_Indexed8); - - int x, y, w, h; - w = img.width(); h = img.height(); - QImage buffer(img.width(), img.height(), QImage::Format_Indexed8); - - QVector cTable(2); - cTable[0] = c_off; cTable[1] = c_on; - buffer.setColorTable(cTable); - - unsigned char *dest; - if(img.format() == QImage::Format_RGB32 || - img.format() == QImage::Format_ARGB32){ - QRgb *src = (QRgb *)img.scanLine(0); - switch(channel){ - case Grayscale: - case All:{ - for(y=0; y < h; ++y){ - dest = buffer.scanLine(y); - for(x=0; x < w; ++x) - *dest++ = (qGray(*src++) >= thresholdValue) ? 1 : 0; - } - break; - } - case Brightness:{ - for(y=0; y < h; ++y){ - dest = buffer.scanLine(y); - for(x=0; x < w; ++x) - *dest++ = (BlitzPrivate::brightness(*src++) >= thresholdValue) ? 1 : 0; - } - break; - } - case Red:{ - for(y=0; y < h; ++y){ - dest = buffer.scanLine(y); - for(x=0; x < w; ++x) - *dest++ = (qRed(*src++) >= thresholdValue) ? 1 : 0; - } - break; - } - case Green:{ - for(y=0; y < h; ++y){ - dest = buffer.scanLine(y); - for(x=0; x < w; ++x) - *dest++ = (qGreen(*src++) >= thresholdValue) ? 1 : 0; - } - break; - } - case Blue:{ - for(y=0; y < h; ++y){ - dest = buffer.scanLine(y); - for(x=0; x < w; ++x) - *dest++ = (qBlue(*src++) >= thresholdValue) ? 1 : 0; - } - break; - } - case Alpha:{ - for(y=0; y < h; ++y){ - dest = buffer.scanLine(y); - for(x=0; x < w; ++x) - *dest++ = (qAlpha(*src++) >= thresholdValue) ? 1 : 0; - } - break; - } - } - } - else if(img.format() == QImage::Format_ARGB32_Premultiplied){ - QRgb *src = (QRgb *)img.scanLine(0); - switch(channel){ - case Grayscale: - case All:{ - for(y=0; y < h; ++y){ - dest = buffer.scanLine(y); - for(x=0; x < w; ++x, ++src) - *dest++ = (qGray(BlitzPrivate::convertFromPremult(*src)) >= - thresholdValue) ? 1 : 0; - } - break; - } - case Brightness:{ - for(y=0; y < h; ++y){ - dest = buffer.scanLine(y); - for(x=0; x < w; ++x, ++src) - *dest++ = (BlitzPrivate::brightness(BlitzPrivate::convertFromPremult(*src)) >= - thresholdValue) ? 1 : 0; - } - break; - } - case Red:{ - for(y=0; y < h; ++y){ - dest = buffer.scanLine(y); - for(x=0; x < w; ++x, ++src) - *dest++ = (qRed(BlitzPrivate::convertFromPremult(*src)) >= - thresholdValue) ? 1 : 0; - } - break; - } - case Green:{ - for(y=0; y < h; ++y){ - dest = buffer.scanLine(y); - for(x=0; x < w; ++x, ++src) - *dest++ = (qGreen(BlitzPrivate::convertFromPremult(*src)) >= - thresholdValue) ? 1 : 0; - } - break; - } - case Blue:{ - for(y=0; y < h; ++y){ - dest = buffer.scanLine(y); - for(x=0; x < w; ++x, ++src) - *dest++ = (qBlue(BlitzPrivate::convertFromPremult(*src)) >= - thresholdValue) ? 1 : 0; - } - break; - } - case Alpha:{ - for(y=0; y < h; ++y){ - dest = buffer.scanLine(y); - for(x=0; x < w; ++x, ++src) - *dest++ = (qAlpha(BlitzPrivate::convertFromPremult(*src)) >= - thresholdValue) ? 1 : 0; - } - break; - } - } - } - else{ - // would be quicker to just threshold the color table, but we return - // images w/ only 2 colors for easy conversion to bitmap - QVector srcTable(img.colorTable()); - unsigned char *src; - switch(channel){ - case Grayscale: - case All:{ - for(y=0; y < h; ++y){ - src = img.scanLine(y); dest = buffer.scanLine(y); - for(x=0; x < w; ++x){ - *dest++ = (qGray(srcTable[*src++]) >= thresholdValue) ? - 1 : 0; - } - } - break; - } - case Brightness:{ - for(y=0; y < h; ++y){ - src = img.scanLine(y); dest = buffer.scanLine(y); - for(x=0; x < w; ++x){ - *dest++ = (BlitzPrivate::brightness(srcTable[*src++]) >= thresholdValue) ? - 1 : 0; - } - } - break; - } - case Red:{ - for(y=0; y < h; ++y){ - src = img.scanLine(y); dest = buffer.scanLine(y); - for(x=0; x < w; ++x){ - *dest++ = (qRed(srcTable[*src++]) >= thresholdValue) ? - 1 : 0; - } - } - break; - } - case Green:{ - for(y=0; y < h; ++y){ - src = img.scanLine(y); dest = buffer.scanLine(y); - for(x=0; x < w; ++x){ - *dest++ = (qGreen(srcTable[*src++]) >= thresholdValue) ? - 1 : 0; - } - } - break; - } - case Blue:{ - for(y=0; y < h; ++y){ - src = img.scanLine(y); dest = buffer.scanLine(y); - for(x=0; x < w; ++x){ - *dest++ = (qBlue(srcTable[*src++]) >= thresholdValue) ? - 1 : 0; - } - } - break; - } - case Alpha:{ - for(y=0; y < h; ++y){ - src = img.scanLine(y); dest = buffer.scanLine(y); - for(x=0; x < w; ++x){ - *dest++ = (qAlpha(srcTable[*src++]) >= thresholdValue) ? - 1 : 0; - } - } - break; - } - } - } - return(buffer); - -} - -QImage& Blitz::fade(QImage &img, float val, const QColor &color) -{ - if(img.isNull() || img.depth() == 1) - return(img); - - val = qBound(0.0f, val, 1.0f); - unsigned char tbl[256]; - for(int i=0; i < 256; ++i) - tbl[i] = (int)(val * i + 0.5); - - int red = color.red(); - int green = color.green(); - int blue = color.blue(); - - int r, g, b; - QRgb *data, *end; - QVector cTable; - - if(img.format() == QImage::Format_Indexed8){ - cTable = img.colorTable(); - data = (unsigned int *)cTable.data(); - end = data + img.numColors(); - - } - else{ - data = (unsigned int *)img.scanLine(0); - end = data + (img.width()*img.height()); - } - - if(img.format() == QImage::Format_ARGB32_Premultiplied){ - QRgb col; - while(data != end){ - col = BlitzPrivate::convertFromPremult(*data); - r = qRed(col); g = qGreen(col); b = qBlue(col); - *data++ = - BlitzPrivate::convertToPremult(qRgba((r > red) ? r - tbl[r - red] : r + tbl[red - r], - (g > green) ? g - tbl[g - green] : g + tbl[green - g], - (b > blue) ? b - tbl[b - blue] : b + tbl[blue - b], - qAlpha(col))); - } - } - else{ - while(data != end){ - r = qRed(*data); g = qGreen(*data); b = qBlue(*data); - *data = qRgba((r > red) ? r - tbl[r - red] : r + tbl[red - r], - (g > green) ? g - tbl[g - green] : g + tbl[green - g], - (b > blue) ? b - tbl[b - blue] : b + tbl[blue - b], - qAlpha(*data)); - ++data; - } - } - if(img.format() == QImage::Format_Indexed8) - img.setColorTable(cTable); - return(img); -} - -QImage& Blitz::flatten(QImage &img, const QColor &ca, const QColor &cb) -{ - if(img.isNull()) - return(img); - - if(img.depth() == 1) { - img.setColor(0, ca.rgb()); - img.setColor(1, cb.rgb()); - return(img); - } - - int r1 = ca.red(); int r2 = cb.red(); - int g1 = ca.green(); int g2 = cb.green(); - int b1 = ca.blue(); int b2 = cb.blue(); - int min = 0, max = 255; - - QRgb *data, *end; - QVector cTable; - if(img.format() == QImage::Format_Indexed8){ - cTable = img.colorTable(); - data = (unsigned int *)cTable.data(); - end = data + img.numColors(); - - } - else{ - data = (unsigned int *)img.scanLine(0); - end = data + (img.width()*img.height()); - } - - // get minimum and maximum graylevel - QRgb *ptr = data; - int mean; - - if(img.format() != QImage::Format_ARGB32_Premultiplied){ - while(ptr != end){ - mean = (qRed(*ptr) + qGreen(*ptr) + qBlue(*ptr)) / 3; - min = qMin(min, mean); - max = qMax(max, mean); - ++ptr; - } - } - else{ - QRgb pixel; - while(ptr != end){ - pixel = BlitzPrivate::convertFromPremult(*ptr); - mean = (qRed(pixel) + qGreen(pixel) + qBlue(pixel)) / 3; - min = qMin(min, mean); - max = qMax(max, mean); - ++ptr; - } - } - - // conversion factors - float sr = ((float) r2 - r1) / (max - min); - float sg = ((float) g2 - g1) / (max - min); - float sb = ((float) b2 - b1) / (max - min); - - if(img.format() != QImage::Format_ARGB32_Premultiplied){ - while(data != end){ - mean = (qRed(*data) + qGreen(*data) + qBlue(*data)) / 3; - *data = qRgba((unsigned char)(sr * (mean - min) + r1 + 0.5), - (unsigned char)(sg * (mean - min) + g1 + 0.5), - (unsigned char)(sb * (mean - min) + b1 + 0.5), - qAlpha(*data)); - ++data; - } - } - else{ - QRgb pixel; - while(data != end){ - pixel = BlitzPrivate::convertFromPremult(*data); - mean = (qRed(pixel) + qGreen(pixel) + qBlue(pixel)) / 3; - *data = - BlitzPrivate:: - convertToPremult(qRgba((unsigned char)(sr * (mean - min) + r1 + 0.5), - (unsigned char)(sg * (mean - min) + g1 + 0.5), - (unsigned char)(sb * (mean - min) + b1 + 0.5), - qAlpha(*data))); - ++data; - } - } - - if(img.format() == QImage::Format_Indexed8) - img.setColorTable(cTable); - return(img); -} - - diff -Nru syncwall-1.6.0/3rdparty/qimageblitz/config-externalasm.h syncwall-1.7.4/3rdparty/qimageblitz/config-externalasm.h --- syncwall-1.6.0/3rdparty/qimageblitz/config-externalasm.h 2012-01-08 14:28:14.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qimageblitz/config-externalasm.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -/* #undef HAVE_EXTERNAL_ASM */ - diff -Nru syncwall-1.6.0/3rdparty/qimageblitz/config-externalasm.h.cmake syncwall-1.7.4/3rdparty/qimageblitz/config-externalasm.h.cmake --- syncwall-1.6.0/3rdparty/qimageblitz/config-externalasm.h.cmake 2007-11-07 04:58:44.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qimageblitz/config-externalasm.h.cmake 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -#cmakedefine HAVE_EXTERNAL_ASM 1 - diff -Nru syncwall-1.6.0/3rdparty/qimageblitz/config-processor.h syncwall-1.7.4/3rdparty/qimageblitz/config-processor.h --- syncwall-1.6.0/3rdparty/qimageblitz/config-processor.h 2012-01-08 14:28:14.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qimageblitz/config-processor.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -/********** processor stuff *************/ - -/* Defined to 1 if the assembler supports MMX instructions. */ -/* #undef HAVE_MMX */ - -/* Defined to 1 if the assembler supports SSE instructions. */ -/* #undef HAVE_SSE */ - -/* Defined to 1 if the assembler supports SSE2 instructions. */ -/* #undef HAVE_SSE2 */ - -/* Defined to 1 if the assembler supports 3DNow instructions. */ -/* #undef HAVE_3DNOW */ - -/* Defined to 1 if the assembler supports AltiVec instructions. */ -/* #undef HAVE_PPC_ALTIVEC */ - -/* Defined to 1 if you have stdint.h */ -/* #undef HAVE_STDINT_H */ - diff -Nru syncwall-1.6.0/3rdparty/qimageblitz/config-processor.h.cmake syncwall-1.7.4/3rdparty/qimageblitz/config-processor.h.cmake --- syncwall-1.6.0/3rdparty/qimageblitz/config-processor.h.cmake 2007-11-07 04:58:44.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qimageblitz/config-processor.h.cmake 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -/********** processor stuff *************/ - -/* Defined to 1 if the assembler supports MMX instructions. */ -#cmakedefine HAVE_MMX 1 - -/* Defined to 1 if the assembler supports SSE instructions. */ -#cmakedefine HAVE_SSE 1 - -/* Defined to 1 if the assembler supports SSE2 instructions. */ -#cmakedefine HAVE_SSE2 1 - -/* Defined to 1 if the assembler supports 3DNow instructions. */ -#cmakedefine HAVE_3DNOW 1 - -/* Defined to 1 if the assembler supports AltiVec instructions. */ -#cmakedefine HAVE_PPC_ALTIVEC 1 - -/* Defined to 1 if you have stdint.h */ -#cmakedefine HAVE_STDINT_H 1 - diff -Nru syncwall-1.6.0/3rdparty/qimageblitz/convolve.cpp syncwall-1.7.4/3rdparty/qimageblitz/convolve.cpp --- syncwall-1.6.0/3rdparty/qimageblitz/convolve.cpp 2011-12-17 13:07:04.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qimageblitz/convolve.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,1387 +0,0 @@ -/* - Copyright (C) 2004, 2005, 2007 Daniel M. Duley - - Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -/* - Portions of this software are were originally based on ImageMagick's - algorithms. ImageMagick is copyrighted under the following conditions: - -Copyright (C) 2003 ImageMagick Studio, a non-profit organization dedicated to -making software imaging solutions freely available. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files ("ImageMagick"), to deal -in ImageMagick without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of ImageMagick, and to permit persons to whom the ImageMagick is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of ImageMagick. - -The software is provided "as is", without warranty of any kind, express or -implied, including but not limited to the warranties of merchantability, -fitness for a particular purpose and noninfringement. In no event shall -ImageMagick Studio be liable for any claim, damages or other liability, -whether in an action of contract, tort or otherwise, arising from, out of or -in connection with ImageMagick or the use or other dealings in ImageMagick. - -Except as contained in this notice, the name of the ImageMagick Studio shall -not be used in advertising or otherwise to promote the sale, use or other -dealings in ImageMagick without prior written authorization from the -ImageMagick Studio. -*/ - -#include "qimageblitz.h" -#include "private/blitz_p.h" -#include -#include "blitzcpu.h" -#include -#include -#include -#include -#ifdef HAVE_STDINT_H - #include -#endif - -#if defined(__i386__) && ( defined(__GNUC__) || defined(__INTEL_COMPILER) ) -# if defined(HAVE_MMX ) -# define USE_MMX_INLINE_ASM -# endif -#endif - -#define M_EPSILON 1.0e-6 -#define M_SQ2PI 2.50662827463100024161235523934010416269302368164062 -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -#define RoundToPixel(value) ((unsigned char) ((value) < 0.0 ? 0.0 : \ - ((value) > (float) 255) ? (float) 255 : (value)+0.5)) - -typedef struct -{ - float red, green, blue, alpha; -} FloatPixel; - - -#define CONVOLVE_ACC(weight, pixel) \ - r+=((weight))*(qRed((pixel))); g+=((weight))*(qGreen((pixel))); \ - b+=((weight))*(qBlue((pixel))); - - -QImage Blitz::convolve(QImage &img, int matrix_size, float *matrix) -{ - int i, x, y, w, h, matrix_x, matrix_y; - int edge = matrix_size/2; - QRgb *dest, *src, *s, **scanblock; - float *m, *normalize_matrix, normalize; - bool overflow = false; - - if(!(matrix_size % 2)){ - qWarning("Blitz::convolve(): kernel width must be an odd number!"); - return(img); - } - - w = img.width(); - h = img.height(); - if(w < 3 || h < 3){ - qWarning("Blitz::convolve(): Image is too small!"); - return(img); - } - - if(img.format() == QImage::Format_ARGB32_Premultiplied) - img = img.convertToFormat(QImage::Format_ARGB32); - else if(img.depth() < 32){ - img = img.convertToFormat(img.hasAlphaChannel() ? - QImage::Format_ARGB32 : - QImage::Format_RGB32); - } - QImage buffer(w, h, img.format()); - - scanblock = new QRgb* [matrix_size]; - normalize_matrix = new float[matrix_size*matrix_size]; - - // create normalized matrix - normalize = 0.0; - for(i=0; i < matrix_size*matrix_size; ++i) - normalize += matrix[i]; - if(std::abs(normalize) <= M_EPSILON) - normalize = 1.0; - normalize = 1.0/normalize; - for(i=0; i < matrix_size*matrix_size; ++i){ - normalize_matrix[i] = normalize*matrix[i]; - if(normalize_matrix[i] < 0.0) - overflow = true; - } - - // apply - -#ifdef USE_MMX_INLINE_ASM -#ifdef __GNUC__ -#warning Using MMX floating point convolve -#endif - if(BlitzCPUInfo::haveExtension(BlitzCPUInfo::AMD3DNOW) && - BlitzCPUInfo::haveExtension(BlitzCPUInfo::IntegerSSE)){ - // - // - // MMX/3dnow version - // - // - - __asm__ __volatile__ - ("pxor %%mm7, %%mm7\n\t" : :); // clear for unpacking - for(y=0; y < h; ++y){ - dest = (QRgb *)buffer.scanLine(y); - src = (QRgb *)img.scanLine(y); - // Read in scanlines to pixel neighborhood. If the scanline is outside - // the image use the top or bottom edge. - for(x=y-edge, i=0; x <= y+edge; ++i, ++x){ - scanblock[i] = (QRgb *) - img.scanLine((x < 0) ? 0 : (x > h-1) ? h-1 : x); - } - // Now we are about to start processing scanlines. First handle the - // part where the pixel neighborhood extends off the left edge. - for(x=0; x-edge < 0 ; ++x){ - m = normalize_matrix; - __asm__ __volatile__ - ("pxor %%mm0, %%mm0\n\t" - "pxor %%mm1, %%mm1\n\t" - : :); - for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ - s = scanblock[matrix_y]; - matrix_x = -edge; - while(x+matrix_x < 0){ - __asm__ __volatile__ - ("movd (%0), %%mm2\n\t" // mm2: m doubleword - "punpckldq %%mm2, %%mm2\n\t" - "movd (%1), %%mm3\n\t" // load pixel - "punpcklbw %%mm7, %%mm3\n\t" - "pshufw $0xE4, %%mm3, %%mm4\n\t" - "punpcklwd %%mm7, %%mm3\n\t" // mm3: BG - "punpckhwd %%mm7, %%mm4\n\t" // mm4: RA - - "pi2fd %%mm3, %%mm3\n\t" // convert to fp... - "pi2fd %%mm4, %%mm4\n\t" - "pfmul %%mm2, %%mm3\n\t" // ...and multiply - "pfmul %%mm2, %%mm4\n\t" - - "pfadd %%mm3, %%mm0\n\t" // add to accumulator - "pfadd %%mm4, %%mm1\n\t" - : : "r"(m), "r"(s)); - ++matrix_x; ++m; - } - while(matrix_x <= edge){ - __asm__ __volatile__ - ("movd (%0), %%mm2\n\t" // mm2: m doubleword - "punpckldq %%mm2, %%mm2\n\t" - "movd (%1), %%mm3\n\t" // load pixel - "punpcklbw %%mm7, %%mm3\n\t" - "pshufw $0xE4, %%mm3, %%mm4\n\t" - "punpcklwd %%mm7, %%mm3\n\t" // mm3: BG - "punpckhwd %%mm7, %%mm4\n\t" // mm4: RA - - "pi2fd %%mm3, %%mm3\n\t" // convert to fp... - "pi2fd %%mm4, %%mm4\n\t" - "pfmul %%mm2, %%mm3\n\t" // ...and multiply - "pfmul %%mm2, %%mm4\n\t" - - "pfadd %%mm3, %%mm0\n\t" // add to accumulator - "pfadd %%mm4, %%mm1\n\t" - : : "r"(m), "r"(s)); - ++matrix_x; ++m; ++s; - } - } - __asm__ __volatile__ - ("pf2id %%mm0, %%mm0\n\t" - "pf2id %%mm1, %%mm1\n\t" - - "packssdw %%mm0, %%mm1\n\t" - "pshufw $0x4E, %%mm1, %%mm1\n\t" - "packuswb %%mm7, %%mm1\n\t" - "movd %%mm1, (%0)\n\t" - : : "r"(dest)); - *dest = BlitzPrivate::setAlpha(*dest, qAlpha(*src++)); - ++dest; - } - // Okay, now process the middle part where the entire neighborhood - // is on the image. - for(; x+edge < w; ++x){ - m = normalize_matrix; - __asm__ __volatile__ - ("pxor %%mm0, %%mm0\n\t" - "pxor %%mm1, %%mm1\n\t" - : :); - for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ - s = scanblock[matrix_y] + (x-edge); - for(matrix_x = -edge; matrix_x <= edge; ++matrix_x, ++m, ++s){ - __asm__ __volatile__ - ("movd (%0), %%mm2\n\t" // mm2: m doubleword - "punpckldq %%mm2, %%mm2\n\t" - "movd (%1), %%mm3\n\t" // load pixel - "punpcklbw %%mm7, %%mm3\n\t" - "pshufw $0xE4, %%mm3, %%mm4\n\t" - "punpcklwd %%mm7, %%mm3\n\t" // mm3: BG - "punpckhwd %%mm7, %%mm4\n\t" // mm4: RA - - "pi2fd %%mm3, %%mm3\n\t" // convert to fp... - "pi2fd %%mm4, %%mm4\n\t" - "pfmul %%mm2, %%mm3\n\t" // ...and multiply - "pfmul %%mm2, %%mm4\n\t" - - "pfadd %%mm3, %%mm0\n\t" // add to accumulator - "pfadd %%mm4, %%mm1\n\t" - : : "r"(m), "r"(s)); - } - } - __asm__ __volatile__ - ("pf2id %%mm0, %%mm0\n\t" - "pf2id %%mm1, %%mm1\n\t" - - "packssdw %%mm0, %%mm1\n\t" - "pshufw $0x4E, %%mm1, %%mm1\n\t" - "packuswb %%mm7, %%mm1\n\t" - "movd %%mm1, (%0)\n\t" - : : "r"(dest)); - *dest = BlitzPrivate::setAlpha(*dest, qAlpha(*src++)); - ++dest; - } - // Finally process the right part where the neighborhood extends off - // the right edge of the image - for(; x < w; ++x){ - m = normalize_matrix; - __asm__ __volatile__ - ("pxor %%mm0, %%mm0\n\t" - "pxor %%mm1, %%mm1\n\t" - : :); - for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ - s = scanblock[matrix_y]; - s += x-edge; - matrix_x = -edge; - while(x+matrix_x < w){ - __asm__ __volatile__ - ("movd (%0), %%mm2\n\t" // mm2: m doubleword - "punpckldq %%mm2, %%mm2\n\t" - "movd (%1), %%mm3\n\t" // load pixel - "punpcklbw %%mm7, %%mm3\n\t" - "pshufw $0xE4, %%mm3, %%mm4\n\t" - "punpcklwd %%mm7, %%mm3\n\t" // mm3: BG - "punpckhwd %%mm7, %%mm4\n\t" // mm4: RA - - "pi2fd %%mm3, %%mm3\n\t" // convert to fp... - "pi2fd %%mm4, %%mm4\n\t" - "pfmul %%mm2, %%mm3\n\t" // ...and multiply - "pfmul %%mm2, %%mm4\n\t" - - "pfadd %%mm3, %%mm0\n\t" // add to accumulator - "pfadd %%mm4, %%mm1\n\t" - : : "r"(m), "r"(s)); - ++matrix_x, ++m, ++s; - } - --s; - while(matrix_x <= edge){ - __asm__ __volatile__ - ("movd (%0), %%mm2\n\t" // mm2: m doubleword - "punpckldq %%mm2, %%mm2\n\t" - "movd (%1), %%mm3\n\t" // load pixel - "punpcklbw %%mm7, %%mm3\n\t" - "pshufw $0xE4, %%mm3, %%mm4\n\t" - "punpcklwd %%mm7, %%mm3\n\t" // mm3: BG - "punpckhwd %%mm7, %%mm4\n\t" // mm4: RA - - "pi2fd %%mm3, %%mm3\n\t" // convert to fp... - "pi2fd %%mm4, %%mm4\n\t" - "pfmul %%mm2, %%mm3\n\t" // ...and multiply - "pfmul %%mm2, %%mm4\n\t" - - "pfadd %%mm3, %%mm0\n\t" // add to accumulator - "pfadd %%mm4, %%mm1\n\t" - : : "r"(m), "r"(s)); - ++matrix_x, ++m; - } - } - __asm__ __volatile__ - ("pf2id %%mm0, %%mm0\n\t" - "pf2id %%mm1, %%mm1\n\t" - - "packssdw %%mm0, %%mm1\n\t" - "pshufw $0x4E, %%mm1, %%mm1\n\t" - "packuswb %%mm7, %%mm1\n\t" - "movd %%mm1, (%0)\n\t" - : : "r"(dest)); - *dest = BlitzPrivate::setAlpha(*dest, qAlpha(*src++)); - ++dest; - } - } - __asm__ __volatile__ ("emms\n\t" : :); - } - else -#endif - { - // - // - // Non-MMX version - // - // - - float r, g, b; - for(y=0; y < h; ++y){ - src = (QRgb *)img.scanLine(y); - dest = (QRgb *)buffer.scanLine(y); - // Read in scanlines to pixel neighborhood. If the scanline is outside - // the image use the top or bottom edge. - for(x=y-edge, i=0; x <= y+edge; ++i, ++x){ - scanblock[i] = (QRgb *) - img.scanLine((x < 0) ? 0 : (x > h-1) ? h-1 : x); - } - // Now we are about to start processing scanlines. First handle the - // part where the pixel neighborhood extends off the left edge. - for(x=0; x-edge < 0 ; ++x){ - r = g = b = 0.0; - m = normalize_matrix; - for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ - s = scanblock[matrix_y]; - matrix_x = -edge; - while(x+matrix_x < 0){ - CONVOLVE_ACC(*m, *s); - ++matrix_x; ++m; - } - while(matrix_x <= edge){ - CONVOLVE_ACC(*m, *s); - ++matrix_x; ++m; ++s; - } - } - r = r < 0.0 ? 0.0 : r > 255.0 ? 255.0 : r+0.5; - g = g < 0.0 ? 0.0 : g > 255.0 ? 255.0 : g+0.5; - b = b < 0.0 ? 0.0 : b > 255.0 ? 255.0 : b+0.5; - *dest++ = qRgba((unsigned char)r, (unsigned char)g, - (unsigned char)b, qAlpha(*src++)); - } - // Okay, now process the middle part where the entire neighborhood - // is on the image. - for(; x+edge < w; ++x){ - m = normalize_matrix; - r = g = b = 0.0; - for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ - s = scanblock[matrix_y] + (x-edge); - for(matrix_x = -edge; matrix_x <= edge; ++matrix_x, ++m, ++s){ - CONVOLVE_ACC(*m, *s); - } - } - r = r < 0.0 ? 0.0 : r > 255.0 ? 255.0 : r+0.5; - g = g < 0.0 ? 0.0 : g > 255.0 ? 255.0 : g+0.5; - b = b < 0.0 ? 0.0 : b > 255.0 ? 255.0 : b+0.5; - *dest++ = qRgba((unsigned char)r, (unsigned char)g, - (unsigned char)b, qAlpha(*src++)); - } - // Finally process the right part where the neighborhood extends off - // the right edge of the image - for(; x < w; ++x){ - r = g = b = 0.0; - m = normalize_matrix; - for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ - s = scanblock[matrix_y]; - s += x-edge; - matrix_x = -edge; - while(x+matrix_x < w){ - CONVOLVE_ACC(*m, *s); - ++matrix_x, ++m, ++s; - } - --s; - while(matrix_x <= edge){ - CONVOLVE_ACC(*m, *s); - ++matrix_x, ++m; - } - } - r = r < 0.0 ? 0.0 : r > 255.0 ? 255.0 : r+0.5; - g = g < 0.0 ? 0.0 : g > 255.0 ? 255.0 : g+0.5; - b = b < 0.0 ? 0.0 : b > 255.0 ? 255.0 : b+0.5; - *dest++ = qRgba((unsigned char)r, (unsigned char)g, - (unsigned char)b, qAlpha(*src++)); - } - } - } - - delete[] scanblock; - delete[] normalize_matrix; - return(buffer); -} - -QImage Blitz::convolveInteger(QImage &img, int matrix_size, - int *matrix, int divisor) -{ - int i, x, y, w, h, matrix_x, matrix_y, *m; - int edge = matrix_size/2; - QRgb *dest, *src, *s, **scanblock; - - if(!(matrix_size % 2)){ - qWarning("Blitz::convolve(): kernel width must be an odd number!"); - return(img); - } - - w = img.width(); - h = img.height(); - if(w < 3 || h < 3){ - qWarning("Blitz::convolve(): Image is too small!"); - return(img); - } - - if(img.format() == QImage::Format_ARGB32_Premultiplied) - img = img.convertToFormat(QImage::Format_ARGB32); - else if(img.depth() < 32){ - img = img.convertToFormat(img.hasAlphaChannel() ? - QImage::Format_ARGB32 : - QImage::Format_RGB32); - } - - QImage buffer(w, h, img.format()); - scanblock = new QRgb* [matrix_size]; - - if(!divisor){ -#ifdef USE_MMX_INLINE_ASM -#ifdef __GNUC__ -#warning Using MMX integer convolve -#endif - if(BlitzCPUInfo::haveExtension(BlitzCPUInfo::MMX)){ - // - // No divisor MMX version - // - __asm__ __volatile__ - ("pxor %%mm7, %%mm7\n\t" : :); // clear for unpacking - for(y=0; y < h; ++y){ - src = (QRgb *)img.scanLine(y); - dest = (QRgb *)buffer.scanLine(y); - // Read in scanlines to pixel neighborhood. If the scanline is outside - // the image use the top or bottom edge. - for(x=y-edge, i=0; x <= y+edge; ++i, ++x){ - scanblock[i] = (QRgb *) - img.scanLine((x < 0) ? 0 : (x > h-1) ? h-1 : x); - } - // Now we are about to start processing scanlines. First handle the - // part where the pixel neighborhood extends off the left edge. - for(x=0; x-edge < 0 ; ++x){ - m = matrix; - __asm__ __volatile__ - ("pxor %%mm0, %%mm0\n\t" : :); // clear acc - - for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ - s = scanblock[matrix_y]; - matrix_x = -edge; - while(x+matrix_x < 0){ - __asm__ __volatile__ - ("movd (%0), %%mm1\n\t" // mm1: matrix - "punpckldq %%mm1, %%mm1\n\t" - "packssdw %%mm1, %%mm1\n\t" - "movd (%1), %%mm2\n\t" // mm2: pixel - "punpcklbw %%mm7, %%mm2\n\t" - "pmullw %%mm1, %%mm2\n\t" // multiply - "paddsw %%mm2, %%mm0\n\t" // add to acc - : : "r"(m), "r"(s)); - ++matrix_x; ++m; - } - while(matrix_x <= edge){ - __asm__ __volatile__ - ("movd (%0), %%mm1\n\t" // mm1: matrix - "punpckldq %%mm1, %%mm1\n\t" - "packssdw %%mm1, %%mm1\n\t" - "movd (%1), %%mm2\n\t" // mm2: pixel - "punpcklbw %%mm7, %%mm2\n\t" - "pmullw %%mm1, %%mm2\n\t" // multiply - "paddsw %%mm2, %%mm0\n\t" // add to acc - : : "r"(m), "r"(s)); - ++matrix_x; ++m; ++s; - } - } - __asm__ __volatile__ - ("packuswb %%mm0, %%mm0\n\t" // pack and write - "movd %%mm0, (%0)\n\t" - : : "r"(dest)); - *dest = BlitzPrivate::setAlpha(*dest, qAlpha(*src++)); - ++dest; - } - // Okay, now process the middle part where the entire neighborhood - // is on the image. - for(; x+edge < w; ++x){ - m = matrix; - __asm__ __volatile__ - ("pxor %%mm0, %%mm0\n\t" : :); // clear acc - for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ - s = scanblock[matrix_y] + (x-edge); - for(matrix_x = -edge; matrix_x <= edge; ++matrix_x, ++m, ++s){ - __asm__ __volatile__ - ("movd (%0), %%mm1\n\t" // mm1: matrix - "punpckldq %%mm1, %%mm1\n\t" - "packssdw %%mm1, %%mm1\n\t" - "movd (%1), %%mm2\n\t" // mm2: pixel - "punpcklbw %%mm7, %%mm2\n\t" - "pmullw %%mm1, %%mm2\n\t" // multiply - "paddsw %%mm2, %%mm0\n\t" // add to acc - : : "r"(m), "r"(s)); - } - } - - __asm__ __volatile__ - ("packuswb %%mm0, %%mm0\n\t" // pack and write - "movd %%mm0, (%0)\n\t" - : : "r"(dest)); - *dest = BlitzPrivate::setAlpha(*dest, qAlpha(*src++)); - ++dest; - } - // Finally process the right part where the neighborhood extends off - // the right edge of the image - for(; x < w; ++x){ - m = matrix; - __asm__ __volatile__ - ("pxor %%mm0, %%mm0\n\t" : :); // clear acc - for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ - s = scanblock[matrix_y]; - s += x-edge; - matrix_x = -edge; - while(x+matrix_x < w){ - __asm__ __volatile__ - ("movd (%0), %%mm1\n\t" // mm1: matrix - "punpckldq %%mm1, %%mm1\n\t" - "packssdw %%mm1, %%mm1\n\t" - "movd (%1), %%mm2\n\t" // mm2: pixel - "punpcklbw %%mm7, %%mm2\n\t" - "pmullw %%mm1, %%mm2\n\t" // multiply - "paddsw %%mm2, %%mm0\n\t" // add to acc - : : "r"(m), "r"(s)); - ++matrix_x, ++m, ++s; - } - --s; - while(matrix_x <= edge){ - __asm__ __volatile__ - ("movd (%0), %%mm1\n\t" // mm1: matrix - "punpckldq %%mm1, %%mm1\n\t" - "packssdw %%mm1, %%mm1\n\t" - "movd (%1), %%mm2\n\t" // mm2: pixel - "punpcklbw %%mm7, %%mm2\n\t" - "pmullw %%mm1, %%mm2\n\t" // multiply - "paddsw %%mm2, %%mm0\n\t" // add to acc - : : "r"(m), "r"(s)); - ++matrix_x, ++m; - } - } - __asm__ __volatile__ - ("packuswb %%mm0, %%mm0\n\t" // pack and write - "movd %%mm0, (%0)\n\t" - : : "r"(dest)); - *dest = BlitzPrivate::setAlpha(*dest, qAlpha(*src++)); - ++dest; - } - } - __asm__ __volatile__ ("emms\n\t" : :); - } - else -#endif - { - // - // No divisor non-MMX version - // - int r, g, b; - for(y=0; y < h; ++y){ - src = (QRgb *)img.scanLine(y); - dest = (QRgb *)buffer.scanLine(y); - // Read in scanlines to pixel neighborhood. If the scanline is outside - // the image use the top or bottom edge. - for(x=y-edge, i=0; x <= y+edge; ++i, ++x){ - scanblock[i] = (QRgb *) - img.scanLine((x < 0) ? 0 : (x > h-1) ? h-1 : x); - } - // Now we are about to start processing scanlines. First handle the - // part where the pixel neighborhood extends off the left edge. - for(x=0; x-edge < 0 ; ++x){ - r = g = b = 0; - m = matrix; - for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ - s = scanblock[matrix_y]; - matrix_x = -edge; - while(x+matrix_x < 0){ - CONVOLVE_ACC(*m, *s); - ++matrix_x; ++m; - } - while(matrix_x <= edge){ - CONVOLVE_ACC(*m, *s); - ++matrix_x; ++m; ++s; - } - } - *dest++ = qRgba((unsigned char)qBound(0, r, 255), - (unsigned char)qBound(0, g, 255), - (unsigned char)qBound(0, b, 255), - qAlpha(*src++)); - } - // Okay, now process the middle part where the entire neighborhood - // is on the image. - for(; x+edge < w; ++x){ - r = g = b = 0; - m = matrix; - for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ - s = scanblock[matrix_y] + (x-edge); - for(matrix_x = -edge; matrix_x <= edge; ++matrix_x, ++m, ++s){ - CONVOLVE_ACC(*m, *s); - } - } - *dest++ = qRgba((unsigned char)qBound(0, r, 255), - (unsigned char)qBound(0, g, 255), - (unsigned char)qBound(0, b, 255), - qAlpha(*src++)); - } - // Finally process the right part where the neighborhood extends off - // the right edge of the image - for(; x < w; ++x){ - r = g = b = 0; - m = matrix; - for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ - s = scanblock[matrix_y]; - s += x-edge; - matrix_x = -edge; - while(x+matrix_x < w){ - CONVOLVE_ACC(*m, *s); - ++matrix_x, ++m, ++s; - } - --s; - while(matrix_x <= edge){ - CONVOLVE_ACC(*m, *s); - ++matrix_x, ++m; - } - } - *dest++ = qRgba((unsigned char)qBound(0, r, 255), - (unsigned char)qBound(0, g, 255), - (unsigned char)qBound(0, b, 255), - qAlpha(*src++)); - } - } - } - } - else{ -#ifdef USE_MMX_INLINE_ASM - // FIXME: TODO - if(/*BlitzCPUInfo::haveExtension(BlitzCPUInfo::AMD3DNOW)*/false){ - // - // Divisor 3dnow version - // - __asm__ __volatile__ - ("pxor %%mm7, %%mm7\n\t" : :); // clear for unpacking - - for(y=0; y < h; ++y){ - src = (QRgb *)img.scanLine(y); - dest = (QRgb *)buffer.scanLine(y); - // Read in scanlines to pixel neighborhood. If the scanline is outside - // the image use the top or bottom edge. - for(x=y-edge, i=0; x <= y+edge; ++i, ++x){ - scanblock[i] = (QRgb *) - img.scanLine((x < 0) ? 0 : (x > h-1) ? h-1 : x); - } - // Now we are about to start processing scanlines. First handle the - // part where the pixel neighborhood extends off the left edge. - for(x=0; x-edge < 0 ; ++x){ - m = matrix; - __asm__ __volatile__ - ("pxor %%mm0, %%mm0\n\t" : :); // clear acc - - for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ - s = scanblock[matrix_y]; - matrix_x = -edge; - while(x+matrix_x < 0){ - __asm__ __volatile__ - ("movd (%0), %%mm1\n\t" // mm1: matrix - "punpckldq %%mm1, %%mm1\n\t" - "packssdw %%mm1, %%mm1\n\t" - "movd (%1), %%mm2\n\t" // mm2: pixel - "punpcklbw %%mm7, %%mm2\n\t" - "pmullw %%mm1, %%mm2\n\t" // multiply - "paddsw %%mm2, %%mm0\n\t" // add to acc - : : "r"(m), "r"(s)); - ++matrix_x; ++m; - } - while(matrix_x <= edge){ - __asm__ __volatile__ - ("movd (%0), %%mm1\n\t" // mm1: matrix - "punpckldq %%mm1, %%mm1\n\t" - "packssdw %%mm1, %%mm1\n\t" - "movd (%1), %%mm2\n\t" // mm2: pixel - "punpcklbw %%mm7, %%mm2\n\t" - "pmullw %%mm1, %%mm2\n\t" // multiply - "paddsw %%mm2, %%mm0\n\t" // add to acc - : : "r"(m), "r"(s)); - ++matrix_x; ++m; ++s; - } - } - __asm__ __volatile__ - ("packuswb %%mm0, %%mm0\n\t" // pack and write - "movd %%mm0, (%0)\n\t" - : : "r"(dest)); - *dest = BlitzPrivate::setAlpha(*dest, qAlpha(*src++)); - ++dest; - } - // Okay, now process the middle part where the entire neighborhood - // is on the image. - for(; x+edge < w; ++x){ - m = matrix; - __asm__ __volatile__ - ("pxor %%mm0, %%mm0\n\t" : :); // clear acc - for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ - s = scanblock[matrix_y] + (x-edge); - for(matrix_x = -edge; matrix_x <= edge; ++matrix_x, ++m, ++s){ - __asm__ __volatile__ - ("movd (%0), %%mm1\n\t" // mm1: matrix - "punpckldq %%mm1, %%mm1\n\t" - "packssdw %%mm1, %%mm1\n\t" - "movd (%1), %%mm2\n\t" // mm2: pixel - "punpcklbw %%mm7, %%mm2\n\t" - "pmullw %%mm1, %%mm2\n\t" // multiply - "paddsw %%mm2, %%mm0\n\t" // add to acc - : : "r"(m), "r"(s)); - } - } - - __asm__ __volatile__ - ("packuswb %%mm0, %%mm0\n\t" // pack and write - "movd %%mm0, (%0)\n\t" - : : "r"(dest)); - *dest = BlitzPrivate::setAlpha(*dest, qAlpha(*src++)); - ++dest; - } - // Finally process the right part where the neighborhood extends off - // the right edge of the image - for(; x < w; ++x){ - m = matrix; - __asm__ __volatile__ - ("pxor %%mm0, %%mm0\n\t" : :); // clear acc - for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ - s = scanblock[matrix_y]; - s += x-edge; - matrix_x = -edge; - while(x+matrix_x < w){ - __asm__ __volatile__ - ("movd (%0), %%mm1\n\t" // mm1: matrix - "punpckldq %%mm1, %%mm1\n\t" - "packssdw %%mm1, %%mm1\n\t" - "movd (%1), %%mm2\n\t" // mm2: pixel - "punpcklbw %%mm7, %%mm2\n\t" - "pmullw %%mm1, %%mm2\n\t" // multiply - "paddsw %%mm2, %%mm0\n\t" // add to acc - : : "r"(m), "r"(s)); - ++matrix_x, ++m, ++s; - } - --s; - while(matrix_x <= edge){ - __asm__ __volatile__ - ("movd (%0), %%mm1\n\t" // mm1: matrix - "punpckldq %%mm1, %%mm1\n\t" - "packssdw %%mm1, %%mm1\n\t" - "movd (%1), %%mm2\n\t" // mm2: pixel - "punpcklbw %%mm7, %%mm2\n\t" - "pmullw %%mm1, %%mm2\n\t" // multiply - "paddsw %%mm2, %%mm0\n\t" // add to acc - : : "r"(m), "r"(s)); - ++matrix_x, ++m; - } - } - __asm__ __volatile__ - ("packuswb %%mm0, %%mm0\n\t" // pack and write - "movd %%mm0, (%0)\n\t" - : : "r"(dest)); - *dest = BlitzPrivate::setAlpha(*dest, qAlpha(*src++)); - ++dest; - } - } - __asm__ __volatile__ ("emms\n\t" : :); - } - else -#endif - { - // - // Divisor, no 3dnow - // - int r, g, b; - for(y=0; y < h; ++y){ - src = (QRgb *)img.scanLine(y); - dest = (QRgb *)buffer.scanLine(y); - // Read in scanlines to pixel neighborhood. If the scanline is outside - // the image use the top or bottom edge. - for(x=y-edge, i=0; x <= y+edge; ++i, ++x){ - scanblock[i] = (QRgb *) - img.scanLine((x < 0) ? 0 : (x > h-1) ? h-1 : x); - } - // Now we are about to start processing scanlines. First handle the - // part where the pixel neighborhood extends off the left edge. - for(x=0; x-edge < 0 ; ++x){ - r = g = b = 0; - m = matrix; - for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ - s = scanblock[matrix_y]; - matrix_x = -edge; - while(x+matrix_x < 0){ - CONVOLVE_ACC(*m, *s); - ++matrix_x; ++m; - } - while(matrix_x <= edge){ - CONVOLVE_ACC(*m, *s); - ++matrix_x; ++m; ++s; - } - } - r /= divisor; g /= divisor; b /= divisor; - *dest++ = qRgba((unsigned char)qBound(0, r, 255), - (unsigned char)qBound(0, g, 255), - (unsigned char)qBound(0, b, 255), - qAlpha(*src++)); - } - // Okay, now process the middle part where the entire neighborhood - // is on the image. - for(; x+edge < w; ++x){ - r = g = b = 0; - m = matrix; - for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ - s = scanblock[matrix_y] + (x-edge); - for(matrix_x = -edge; matrix_x <= edge; ++matrix_x, ++m, ++s){ - CONVOLVE_ACC(*m, *s); - } - } - r /= divisor; g /= divisor; b /= divisor; - *dest++ = qRgba((unsigned char)qBound(0, r, 255), - (unsigned char)qBound(0, g, 255), - (unsigned char)qBound(0, b, 255), - qAlpha(*src++)); - } - // Finally process the right part where the neighborhood extends off - // the right edge of the image - for(; x < w; ++x){ - r = g = b = 0; - m = matrix; - for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ - s = scanblock[matrix_y]; - s += x-edge; - matrix_x = -edge; - while(x+matrix_x < w){ - CONVOLVE_ACC(*m, *s); - ++matrix_x, ++m, ++s; - } - --s; - while(matrix_x <= edge){ - CONVOLVE_ACC(*m, *s); - ++matrix_x, ++m; - } - } - r /= divisor; g /= divisor; b /= divisor; - *dest++ = qRgba((unsigned char)qBound(0, r, 255), - (unsigned char)qBound(0, g, 255), - (unsigned char)qBound(0, b, 255), - qAlpha(*src++)); - } - } - } - } - - delete[] scanblock; - return(buffer); -} - -int BlitzPrivate::defaultConvolveMatrixSize(float radius, float sigma, - bool quality) -{ - int i, matrix_size; - float normalize, value; - float sigma2 = sigma*sigma*2.0; - float sigmaSQ2PI = M_SQ2PI*sigma; - int max = quality ? 65535 : 255; - - if(sigma == 0.0){ - qWarning("Blitz::convolve(): Zero sigma is invalid!"); - return(5); - } - - if(radius > 0.0) - return((int)(2.0*std::ceil(radius)+1.0)); - - matrix_size = 5; - do{ - normalize = 0.0; - for(i=(-matrix_size/2); i <= (matrix_size/2); ++i) - normalize += std::exp(-((float) i*i)/sigma2) / sigmaSQ2PI; - i = matrix_size/2; - value = std::exp(-((float) i*i)/sigma2) / sigmaSQ2PI / normalize; - matrix_size += 2; - } while((int)(max*value) > 0); - - matrix_size-=4; - return(matrix_size); -} - -float* BlitzPrivate::getBlurKernel(int &kernel_width, float sigma) -{ -#define KernelRank 3 - - float alpha, normalize, *kernel; - int bias; - long i; - - if(sigma == 0.0) - return(false); - if(kernel_width == 0) - kernel_width = 3; - - kernel = new float[kernel_width+1]; - memset(kernel, 0, (kernel_width+1)*sizeof(float)); - bias = KernelRank*kernel_width/2; - for(i=(-bias); i <= bias; ++i){ - alpha = std::exp(-((float) i*i)/(2.0*KernelRank*KernelRank*sigma*sigma)); - kernel[(i+bias)/KernelRank] += alpha/(M_SQ2PI*sigma); - } - - normalize = 0; - for(i=0; i < kernel_width; ++i) - normalize += kernel[i]; - for(i=0; i < kernel_width; ++i) - kernel[i] /= normalize; - return(kernel); -} - -void BlitzPrivate::blurScanLine(float *kernel, int kern_width, - QRgb *source, QRgb *destination, - int columns, int offset) -{ - FloatPixel aggregate, zero; - float scale, *k; - QRgb *src, *dest; - int i, x; - -#ifdef USE_MMX_INLINE_ASM -#ifdef __GNUC__ -#warning Using MMX gaussian blur -#endif - // - // - // MMX Version - // - // - - if(BlitzCPUInfo::haveExtension(BlitzCPUInfo::AMD3DNOW) && - BlitzCPUInfo::haveExtension(BlitzCPUInfo::IntegerSSE)){ - if(kern_width > columns){ - memset(&zero, 0, sizeof(FloatPixel)); - for(dest=destination, x=0; x < columns; ++x, dest+=offset){ - aggregate = zero; - scale = 0.0; - k = kernel; - src = source; - for(i=0; i < columns; ++k, src+=offset){ - if((i >= (x-kern_width/2)) && (i <= (x+kern_width/2))){ - aggregate.red += (*k)*qRed(*src); - aggregate.green += (*k)*qGreen(*src); - aggregate.blue += (*k)*qBlue(*src); - aggregate.alpha += (*k)*qAlpha(*src); - } - - if(((i+kern_width/2-x) >= 0) && ((i+kern_width/2-x) < kern_width)) - scale += kernel[i+kern_width/2-x]; - } - scale = 1.0/scale; - *dest = qRgba((unsigned char)(scale*(aggregate.red+0.5)), - (unsigned char)(scale*(aggregate.green+0.5)), - (unsigned char)(scale*(aggregate.blue+0.5)), - (unsigned char)(scale*(aggregate.alpha+0.5))); - } - return; - } - - // blur - __asm__ __volatile__ ("pxor %%mm7, %%mm7\n\t" : : ); // for unpacking - for(dest=destination, x=0; x < kern_width/2; ++x, dest+=offset){ - k = kernel+kern_width/2-x; - src = source; - __asm__ __volatile__ ("pxor %%mm0, %%mm0\n\t" // mm0: BG acc - "pxor %%mm1, %%mm1\n\t" // mm1: RA acc - "pxor %%mm6, %%mm6\n\t" // mm6: scale - : : ); - for(i=kern_width/2-x; i < kern_width; ++i, ++k, src+=offset){ - __asm__ __volatile__ - ("movd (%0), %%mm2\n\t" // mm2: k doubleword - "punpckldq %%mm2, %%mm2\n\t" - "pfadd %%mm2, %%mm6\n\t" // add to scale - - "movd (%1), %%mm3\n\t" // load pixel - "punpcklbw %%mm7, %%mm3\n\t" - "pshufw $0xE4, %%mm3, %%mm4\n\t" - "punpcklwd %%mm7, %%mm3\n\t" // mm3: BG - "punpckhwd %%mm7, %%mm4\n\t" // mm4: RA - - "pi2fd %%mm3, %%mm3\n\t" // convert to fp... - "pi2fd %%mm4, %%mm4\n\t" - "pfmul %%mm2, %%mm3\n\t" // ...and multiply - "pfmul %%mm2, %%mm4\n\t" - - "pfadd %%mm3, %%mm0\n\t" // add to accumulator - "pfadd %%mm4, %%mm1\n\t" - : : "r"(k), "r"(src)); - } - __asm__ __volatile__ - ("pfrcp %%mm6, %%mm5\n\t" // reciprocal - "pfrcpit1 %%mm5, %%mm6\n\t" // expand to 24bit - "pfrcpit2 %%mm5, %%mm6\n\t" - - "pfmul %%mm6, %%mm0\n\t" // multiply - "pfmul %%mm6, %%mm1\n\t" - - "pf2id %%mm0, %%mm0\n\t" // and write - "pf2id %%mm1, %%mm1\n\t" - "packssdw %%mm0, %%mm1\n\t" - "pshufw $0x4E, %%mm1, %%mm1\n\t" - "packuswb %%mm7, %%mm1\n\t" - "movd %%mm1, (%0)\n\t" - : : "r"(dest)); - } - for(; x < (columns-kern_width/2); ++x, dest+=offset){ - __asm__ __volatile__ ("pxor %%mm0, %%mm0\n\t" // mm0: BG acc - "pxor %%mm1, %%mm1\n\t" // mm1: RA acc - : : ); - k = kernel; - src = source+((x-kern_width/2)*offset); - for(i=0; i < kern_width; ++i, ++k, src+=offset){ - __asm__ __volatile__ - ("movd (%0), %%mm2\n\t" // mm2: k doubleword - "punpckldq %%mm2, %%mm2\n\t" - - "movd (%1), %%mm3\n\t" // load pixel - "punpcklbw %%mm7, %%mm3\n\t" - "pshufw $0xE4, %%mm3, %%mm4\n\t" - "punpcklwd %%mm7, %%mm3\n\t" // mm3: BG - "punpckhwd %%mm7, %%mm4\n\t" // mm4: RA - - "pi2fd %%mm3, %%mm3\n\t" // convert to fp... - "pi2fd %%mm4, %%mm4\n\t" - "pfmul %%mm2, %%mm3\n\t" // ...and multiply - "pfmul %%mm2, %%mm4\n\t" - - "pfadd %%mm3, %%mm0\n\t" // add to accumulator - "pfadd %%mm4, %%mm1\n\t" - : : "r"(k), "r"(src)); - } - __asm__ __volatile__ - ("pf2id %%mm0, %%mm0\n\t" // write - "pf2id %%mm1, %%mm1\n\t" - "packssdw %%mm0, %%mm1\n\t" - "pshufw $0x4E, %%mm1, %%mm1\n\t" - "packuswb %%mm7, %%mm1\n\t" - "movd %%mm1, (%0)\n\t" - : : "r"(dest)); - } - for(; x < columns; ++x, dest+=offset){ - k = kernel; - src = source+((x-kern_width/2)*offset); - __asm__ __volatile__ ("pxor %%mm0, %%mm0\n\t" // mm0: BG acc - "pxor %%mm1, %%mm1\n\t" // mm1: RA acc - "pxor %%mm6, %%mm6\n\t" // mm6: scale - : : ); - for(i=0; i < (columns-x+kern_width/2); ++i, ++k, src+=offset){ - __asm__ __volatile__ - ("movd (%0), %%mm2\n\t" // mm2: k doubleword - "punpckldq %%mm2, %%mm2\n\t" - "pfadd %%mm2, %%mm6\n\t" // add to scale - - "movd (%1), %%mm3\n\t" // load pixel - "punpcklbw %%mm7, %%mm3\n\t" - "pshufw $0xE4, %%mm3, %%mm4\n\t" - "punpcklwd %%mm7, %%mm3\n\t" // mm3: BG - "punpckhwd %%mm7, %%mm4\n\t" // mm4: RA - - "pi2fd %%mm3, %%mm3\n\t" // convert to fp... - "pi2fd %%mm4, %%mm4\n\t" - "pfmul %%mm2, %%mm3\n\t" // ...and multiply - "pfmul %%mm2, %%mm4\n\t" - - "pfadd %%mm3, %%mm0\n\t" // add to accumulator - "pfadd %%mm4, %%mm1\n\t" - : : "r"(k), "r"(src)); - } - __asm__ __volatile__ - ("pfrcp %%mm6, %%mm5\n\t" // reciprocal - "pfrcpit1 %%mm5, %%mm6\n\t" // expand to 24bit - "pfrcpit2 %%mm5, %%mm6\n\t" - - "pfmul %%mm6, %%mm0\n\t" // multiply - "pfmul %%mm6, %%mm1\n\t" - - "pf2id %%mm0, %%mm0\n\t" // and write - "pf2id %%mm1, %%mm1\n\t" - "packssdw %%mm0, %%mm1\n\t" - "pshufw $0x4E, %%mm1, %%mm1\n\t" - "packuswb %%mm7, %%mm1\n\t" - "movd %%mm1, (%0)\n\t" - : : "r"(dest)); - } - - __asm__ __volatile__ ("emms\n\t" : :); - } - else -#endif - { - // - // - // Non-MMX version - // - // - - memset(&zero, 0, sizeof(FloatPixel)); - if(kern_width > columns){ - for(dest=destination, x=0; x < columns; ++x, dest+=offset){ - aggregate = zero; - scale = 0.0; - k = kernel; - src = source; - for(i=0; i < columns; ++k, src+=offset){ - if((i >= (x-kern_width/2)) && (i <= (x+kern_width/2))){ - aggregate.red += (*k)*qRed(*src); - aggregate.green += (*k)*qGreen(*src); - aggregate.blue += (*k)*qBlue(*src); - aggregate.alpha += (*k)*qAlpha(*src); - } - - if(((i+kern_width/2-x) >= 0) && ((i+kern_width/2-x) < kern_width)) - scale += kernel[i+kern_width/2-x]; - } - scale = 1.0/scale; - *dest = qRgba((unsigned char)(scale*(aggregate.red+0.5)), - (unsigned char)(scale*(aggregate.green+0.5)), - (unsigned char)(scale*(aggregate.blue+0.5)), - (unsigned char)(scale*(aggregate.alpha+0.5))); - } - return; - } - - // blur - for(dest=destination, x=0; x < kern_width/2; ++x, dest+=offset){ - aggregate = zero; // put this stuff in loop initializer once tested - scale = 0.0; - k = kernel+kern_width/2-x; - src = source; - for(i=kern_width/2-x; i < kern_width; ++i, ++k, src+=offset){ - aggregate.red += (*k)*qRed(*src); - aggregate.green += (*k)*qGreen(*src); - aggregate.blue += (*k)*qBlue(*src); - aggregate.alpha += (*k)*qAlpha(*src); - scale += (*k); - } - scale = 1.0/scale; - *dest = qRgba((unsigned char)(scale*(aggregate.red+0.5)), - (unsigned char)(scale*(aggregate.green+0.5)), - (unsigned char)(scale*(aggregate.blue+0.5)), - (unsigned char)(scale*(aggregate.alpha+0.5))); - } - for(; x < (columns-kern_width/2); ++x, dest+=offset){ - aggregate = zero; - k = kernel; - src = source+((x-kern_width/2)*offset); - for(i=0; i < kern_width; ++i, ++k, src+=offset){ - aggregate.red += (*k)*qRed(*src); - aggregate.green += (*k)*qGreen(*src); - aggregate.blue += (*k)*qBlue(*src); - aggregate.alpha += (*k)*qAlpha(*src); - } - *dest = qRgba((unsigned char)(aggregate.red+0.5), - (unsigned char)(aggregate.green+0.5), - (unsigned char)(aggregate.blue+0.5), - (unsigned char)(aggregate.alpha+0.5)); - } - for(; x < columns; ++x, dest+=offset){ - aggregate = zero; - scale = 0; - k = kernel; - src = source+((x-kern_width/2)*offset); - for(i=0; i < (columns-x+kern_width/2); ++i, ++k, src+=offset){ - aggregate.red += (*k)*qRed(*src); - aggregate.green += (*k)*qGreen(*src); - aggregate.blue += (*k)*qBlue(*src); - aggregate.alpha += (*k)*qAlpha(*src); - scale += (*k); - } - scale = 1.0/scale; - *dest = qRgba((unsigned char)(scale*(aggregate.red+0.5)), - (unsigned char)(scale*(aggregate.green+0.5)), - (unsigned char)(scale*(aggregate.blue+0.5)), - (unsigned char)(scale*(aggregate.alpha+0.5))); - } - } -} - -QImage Blitz::gaussianBlur(QImage &img, float radius, float sigma) -{ - int kern_width, x, y, w, h; - QRgb *src; - float *k = NULL; - - if(sigma == 0.0){ - qWarning("Blitz::gaussianBlur(): Zero sigma is not valid!"); - return(img); - } - - // figure out optimal kernel width - if(radius > 0){ - kern_width = (int)(2*std::ceil(radius)+1); - k = BlitzPrivate::getBlurKernel(kern_width, sigma); - } - else{ - float *last_kernel = NULL; - kern_width = 3; - k = BlitzPrivate::getBlurKernel(kern_width, sigma); - while((long)(255*k[0]) > 0){ - if(last_kernel != NULL) - delete[] last_kernel; - last_kernel = k; - kern_width += 2; - k = BlitzPrivate::getBlurKernel(kern_width, sigma); - } - if(last_kernel != NULL){ - delete[] k; - kern_width -= 2; - k = last_kernel; - } - } - - if(kern_width < 3){ - qWarning("Blitz::gaussianBlur(): radius is too small!"); - return(img); - } - - // allocate destination image - w = img.width(); - h = img.height(); - if(img.format() == QImage::Format_ARGB32_Premultiplied) - img = img.convertToFormat(QImage::Format_ARGB32); - else if(img.depth() < 32){ - img = img.convertToFormat(img.hasAlphaChannel() ? - QImage::Format_ARGB32 : - QImage::Format_RGB32); - } - QImage buffer(w, h, img.format()); - - //blur image rows - for(y=0; y < h; ++y) - BlitzPrivate::blurScanLine(k, kern_width, (QRgb *)img.scanLine(y), - (QRgb *)buffer.scanLine(y), img.width(), 1); - - // blur image columns - src = (QRgb *)buffer.scanLine(0); - for(x=0; x < w; ++x) - BlitzPrivate::blurScanLine(k, kern_width, src+x, src+x, img.height(), - img.width()); - // finish up - delete[] k; - return(buffer); -} - -QImage Blitz::gaussianSharpen(QImage &img, float radius, float sigma, - EffectQuality quality) -{ - if(sigma == 0.0){ - qWarning("Blitz::gaussianSharpen(): Zero sigma is invalid!"); - return(img); - } - - int matrix_size = BlitzPrivate::defaultConvolveMatrixSize(radius, sigma, - quality == High); - int len = matrix_size*matrix_size; - float alpha, *matrix = new float[len]; - float sigma2 = sigma*sigma*2.0; - float sigmaPI2 = 2.0*M_PI*sigma*sigma; - - int half = matrix_size/2; - int x, y, i=0, j=half; - float normalize=0.0; - for(y=(-half); y <= half; ++y, --j){ - for(x=(-half); x <= half; ++x, ++i){ - alpha = std::exp(-((float)x*x+y*y)/sigma2); - matrix[i] = alpha/sigmaPI2; - normalize += matrix[i]; - } - } - - matrix[i/2]=(-2.0)*normalize; - QImage result(convolve(img, matrix_size, matrix)); - delete[] matrix; - return(result); -} - -QImage Blitz::antialias(QImage &img) -{ - // nice little example method - int matrix[] = { - 1, 2, 1, - 2, 8, 2, - 1, 2, 1 - }; - return(convolveInteger(img, 3, matrix, 20)); -} - -QImage Blitz::emboss(QImage &img, float radius, float sigma, - EffectQuality quality) -{ - if(sigma == 0.0){ - qWarning("Blitz::emboss(): Zero sigma is invalid!"); - return(img); - } - - int matrix_size = BlitzPrivate::defaultConvolveMatrixSize(radius, sigma, - quality == High); - int len = matrix_size*matrix_size; - - float alpha, *matrix = new float[len]; - float sigma2 = sigma*sigma*2.0; - float sigmaPI2 = 2.0*M_PI*sigma*sigma; - - int half = matrix_size/2; - int x, y, i=0, j=half; - for(y=(-half); y <= half; ++y, --j){ - for(x=(-half); x <= half; ++x, ++i){ - alpha = std::exp(-((float)x*x+y*y)/sigma2); - matrix[i]=((x < 0) || (y < 0) ? -8.0 : 8.0)*alpha/sigmaPI2; - if(x == j) - matrix[i]=0.0; - } - } - QImage result(convolve(img, matrix_size, matrix)); - delete[] matrix; - equalize(result); - return(result); -} - -QImage Blitz::convolveEdge(QImage &img, float radius, - EffectQuality quality) -{ - int i, matrix_size = BlitzPrivate::defaultConvolveMatrixSize(radius, 0.5, - quality == High); - int len = matrix_size*matrix_size; - int *matrix = new int[len]; - for(i=0; i < len; ++i) - matrix[i] = -1; - matrix[i/2] = len-1; - - QImage result(convolveInteger(img, matrix_size, matrix, 0)); - delete[] matrix; - return(result); -} - - diff -Nru syncwall-1.6.0/3rdparty/qimageblitz/gradient.cpp syncwall-1.7.4/3rdparty/qimageblitz/gradient.cpp --- syncwall-1.6.0/3rdparty/qimageblitz/gradient.cpp 2008-02-26 19:31:00.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qimageblitz/gradient.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,602 +0,0 @@ -/* - Copyright (C) 1998, 1999, 2001, 2002, 2004, 2005, 2007 - Daniel M. Duley - (C) 2004 Zack Rusin - (C) 2000 Josef Weidendorfer - (C) 1999 Geert Jansen - (C) 1998, 1999 Christian Tibirna - (C) 1998, 1999 Dirk Mueller - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - Diagonal gradient code was inspired by BlackBox. BlackBox gradients are - (C) Brad Hughes, and Mike Cole . - */ - -#define _USE_MATH_DEFINES // for msvc - -#include "qimageblitz.h" -#include -#include -#include - -QImage Blitz::gradient(const QSize &size, const QColor &ca, - const QColor &cb, GradientType eff) -{ - QImage image(size, QImage::Format_RGB32); - if(!size.isValid()) - return(image); - - int rca, gca, bca, rcb, gcb, bcb; - int rDiff = (rcb = cb.red()) - (rca = ca.red()); - int gDiff = (gcb = cb.green()) - (gca = ca.green()); - int bDiff = (bcb = cb.blue()) - (bca = ca.blue()); - int x, y; - QRgb rgb; - - if(eff == VerticalGradient || eff == HorizontalGradient){ - register int rl = rca << 16; - register int gl = gca << 16; - register int bl = bca << 16; - QRgb *p; - if(eff == VerticalGradient){ - int rcdelta = ((1<<16) / size.height()) * rDiff; - int gcdelta = ((1<<16) / size.height()) * gDiff; - int bcdelta = ((1<<16) / size.height()) * bDiff; - for(y=0; y < size.height(); ++y){ - rl += rcdelta; - gl += gcdelta; - bl += bcdelta; - rgb = qRgb( (rl>>16), (gl>>16), (bl>>16) ); - - p = (QRgb *)image.scanLine(y); - for(x = 0; x < size.width(); ++x) - *p++ = rgb; - } - } - else{ // must be HorizontalGradient - int rcdelta = ((1<<16) / size.width()) * rDiff; - int gcdelta = ((1<<16) / size.width()) * gDiff; - int bcdelta = ((1<<16) / size.width()) * bDiff; - p = (QRgb *)image.scanLine(0); - for(x = 0; x < size.width(); ++x){ - rl += rcdelta; - gl += gcdelta; - bl += bcdelta; - *p++ = qRgb((rl>>16), (gl>>16), (bl>>16)); - } - p = (QRgb *)image.scanLine(0); - for(y = 1; y < size.height(); ++y) - memcpy(image.scanLine(y), p, size.width()*sizeof(QRgb)); - } - } - else{ - float rfd, gfd, bfd; - float rd = rca, gd = gca, bd = bca; - - int w = size.width(), h = size.height(); - int dw = w*2, dh = h*2; - unsigned char *xtable = new unsigned char[w*3]; - unsigned char *ytable = new unsigned char[h*3]; - - if(eff == DiagonalGradient || eff == CrossDiagonalGradient){ - rfd = (float)rDiff/dw; - gfd = (float)gDiff/dw; - bfd = (float)bDiff/dw; - - int dir; - for(x=0; x < w; x++, rd+=rfd, gd+=gfd, bd+=bfd) { - dir = eff == DiagonalGradient? x : w - x - 1; - xtable[dir*3] = (unsigned char) rd; - xtable[dir*3+1] = (unsigned char) gd; - xtable[dir*3+2] = (unsigned char) bd; - } - rfd = (float)rDiff/dh; - gfd = (float)gDiff/dh; - bfd = (float)bDiff/dh; - rd = gd = bd = 0; - for(y = 0; y < h; y++, rd+=rfd, gd+=gfd, bd+=bfd){ - ytable[y*3] = (unsigned char) rd; - ytable[y*3+1] = (unsigned char) gd; - ytable[y*3+2] = (unsigned char) bd; - } - - for(y = 0; y < h; y++){ - QRgb *p = (QRgb *)image.scanLine(y); - for(x = 0; x < w; x++){ - *p++ = qRgb(xtable[x*3] + ytable[y*3], - xtable[x*3+1] + ytable[y*3+1], - xtable[x*3+2] + ytable[y*3+2]); - } - } - } - else{ - int rSign = rDiff>0? 1: -1; - int gSign = gDiff>0? 1: -1; - int bSign = bDiff>0? 1: -1; - - rfd = (float)rDiff/w; - gfd = (float)gDiff/w; - bfd = (float)bDiff/w; - - rd = (float)rDiff/2; - gd = (float)gDiff/2; - bd = (float)bDiff/2; - - for(x=0; x < w; x++, rd-=rfd, gd-=gfd, bd-=bfd){ - xtable[x*3] = (unsigned char) qAbs((int)rd); - xtable[x*3+1] = (unsigned char) qAbs((int)gd); - xtable[x*3+2] = (unsigned char) qAbs((int)bd); - } - - rfd = (float)rDiff/h; - gfd = (float)gDiff/h; - bfd = (float)bDiff/h; - - rd = (float)rDiff/2; - gd = (float)gDiff/2; - bd = (float)bDiff/2; - - for(y=0; y < h; y++, rd-=rfd, gd-=gfd, bd-=bfd){ - ytable[y*3] = (unsigned char) qAbs((int)rd); - ytable[y*3+1] = (unsigned char) qAbs((int)gd); - ytable[y*3+2] = (unsigned char) qAbs((int)bd); - } - - dw = (w+1)>>1; - dh = (h+1)>>1; - int x2; - QRgb *sl1, *sl2; - for(y = 0; y < dh; y++){ - sl1 = (QRgb *)image.scanLine(y); - sl2 = (QRgb *)image.scanLine(qMax(h-y-1, y)); - for(x = 0, x2 = w-1; x < dw; x++, x2--){ - switch(eff){ - case PyramidGradient: - rgb = qRgb(rcb-rSign*(xtable[x*3]+ytable[y*3]), - gcb-gSign*(xtable[x*3+1]+ytable[y*3+1]), - bcb-bSign*(xtable[x*3+2]+ytable[y*3+2])); - break; - case RectangleGradient: - rgb = qRgb(rcb - rSign * - qMax(xtable[x*3], ytable[y*3]) * 2, - gcb - gSign * - qMax(xtable[x*3+1], ytable[y*3+1]) * 2, - bcb - bSign * - qMax(xtable[x*3+2], ytable[y*3+2]) * 2); - break; - case PipeCrossGradient: - rgb = qRgb(rcb - rSign * - qMin(xtable[x*3], ytable[y*3]) * 2, - gcb - gSign * - qMin(xtable[x*3+1], ytable[y*3+1]) * 2, - bcb - bSign * - qMin(xtable[x*3+2], ytable[y*3+2]) * 2); - break; - case EllipticGradient: - default: - rgb = qRgb(rcb - rSign * - (int)std::sqrt((xtable[x*3]*xtable[x*3] + - ytable[y*3]*ytable[y*3])*2.0f), - gcb - gSign * - (int)std::sqrt((xtable[x*3+1]*xtable[x*3+1] + - ytable[y*3+1]*ytable[y*3+1])*2.0f), - bcb - bSign * - (int)std::sqrt((xtable[x*3+2]*xtable[x*3+2] + - ytable[y*3+2]*ytable[y*3+2])*2.0f)); - break; - } - sl1[x] = sl2[x] = rgb; - sl1[x2] = sl2[x2] = rgb; - } - } - } - delete [] xtable; - delete [] ytable; - } - return(image); -} - -QImage Blitz::grayGradient(const QSize &size, unsigned char ca, - unsigned char cb, GradientType eff) -{ - QImage image(size, QImage::Format_Indexed8); - if(!size.isValid()) - return(image); - QVector colorTable(256); - for(int i=0; i < 256; ++i) - colorTable[i] = qRgba(i, i, i, 255); - image.setColorTable(colorTable); - - int diff = cb - ca; - int x, y; - unsigned char idx; - - if(eff == VerticalGradient || eff == HorizontalGradient){ - register int val = ca << 16; - unsigned char *p; - if(eff == VerticalGradient){ - int delta = ((1<<16) / size.height()) * diff; - for(y=0; y < size.height(); ++y){ - val += delta; - idx = val >> 16; - p = image.scanLine(y); - for(x = 0; x < size.width(); ++x) - *p++ = idx; - } - } - else{ // must be HorizontalGradient - int delta = ((1<<16) / size.width()) * diff; - p = image.scanLine(0); - for(x = 0; x < size.width(); ++x){ - val += delta; - *p++ = val >> 16; - } - p = image.scanLine(0); - for(y = 1; y < size.height(); ++y) - memcpy(image.scanLine(y), p, image.bytesPerLine()); - } - } - else{ - float delta, val=ca; - - unsigned int w = size.width(), h = size.height(); - unsigned char *xtable = new unsigned char[w]; - unsigned char *ytable = new unsigned char[h]; - w*=2, h*=2; - - if(eff == DiagonalGradient || eff == CrossDiagonalGradient){ - delta = (float)diff/w; - int dir; - for(x=0; x < size.width(); x++, val+=delta){ - dir = eff == DiagonalGradient? x : size.width() - x - 1; - xtable[dir] = (unsigned char) val; - } - delta = (float)diff/h; - val = 0; - for(y = 0; y < size.height(); y++, val+=delta) - ytable[y] = (unsigned char) val; - - for(y = 0; y < size.height(); y++){ - unsigned char *p = image.scanLine(y); - for(x = 0; x < size.width(); x++) - *p++ = xtable[x] + ytable[y]; - } - } - else{ - int sign = diff>0? 1: -1; - delta = (float)diff / size.width(); - val = (float)diff/2; - for(x=0; x < size.width(); x++, val-=delta) - xtable[x] = (unsigned char) qAbs((int)val); - - delta = (float)diff/size.height(); - val = (float)diff/2; - for(y=0; y < size.height(); y++, val-=delta) - ytable[y] = (unsigned char) qAbs((int)val); - - int w = (size.width()+1)>>1; - int h = (size.height()+1)>>1; - int x2; - unsigned char *sl1, *sl2; - for(y = 0; y < h; y++){ - sl1 = image.scanLine(y); - sl2 = image.scanLine(qMax(size.height()-y-1, y)); - for(x = 0, x2 = size.width()-1; x < w; x++, x2--){ - switch(eff){ - case PyramidGradient: - idx = cb-sign*(xtable[x]+ytable[y]); - break; - case RectangleGradient: - idx = cb-sign*qMax(xtable[x], ytable[y])*2; - break; - case PipeCrossGradient: - idx = cb-sign*qMin(xtable[x], ytable[y])*2; - break; - case EllipticGradient: - default: - idx = cb - sign * - (int)std::sqrt((xtable[x]*xtable[x] + - ytable[y]*ytable[y])*2.0f); - break; - } - sl1[x] = sl2[x] = idx; - sl1[x2] = sl2[x2] = idx; - } - } - } - delete [] xtable; - delete [] ytable; - } - return(image); -} - -QImage Blitz::unbalancedGradient(const QSize &size, const QColor &ca, - const QColor &cb, GradientType eff, - int xfactor, int yfactor) -{ - QImage image(size, QImage::Format_RGB32); - if(!size.isValid()) - return image; - - int dir; // general parameter used for direction switches - bool _xanti = (xfactor < 0); // negative on X direction - bool _yanti = (yfactor < 0); // negative on Y direction - xfactor = qBound(1, qAbs(xfactor), 200); - yfactor = qBound(1, qAbs(yfactor), 200); - // float xbal = xfactor/5000.; - // float ybal = yfactor/5000.; - float xbal = xfactor/30.0f/size.width(); - float ybal = yfactor/30.0f/size.height(); - float rat; - - register int x, y; - int rca, gca, bca, rcb, gcb, bcb; - int rDiff = (rcb = cb.red()) - (rca = ca.red()); - int gDiff = (gcb = cb.green()) - (gca = ca.green()); - int bDiff = (bcb = cb.blue()) - (bca = ca.blue()); - - if(eff == VerticalGradient || eff == HorizontalGradient){ - QRgb *p; - if(eff == VerticalGradient){ - QRgb rgbRow; - for(y=0; y < size.height(); y++){ - dir = _yanti ? y : size.height() - 1 - y; - rat = 1 - std::exp( - (float)y * ybal ); - p = (QRgb *) image.scanLine(dir); - rgbRow = qRgb(rcb - (int) ( rDiff * rat ), - gcb - (int) ( gDiff * rat ), - bcb - (int) ( bDiff * rat )); - for(x = 0; x < size.width(); x++) - *p++ = rgbRow; - } - } - else{ - p = (QRgb *)image.scanLine(0); - for(x = 0; x < size.width(); x++){ - dir = _xanti ? x : size.width() - 1 - x; - rat = 1 - std::exp( - (float)x * xbal ); - p[dir] = qRgb(rcb - (int) ( rDiff * rat ), - gcb - (int) ( gDiff * rat ), - bcb - (int) ( bDiff * rat )); - } - - p = (QRgb *)image.scanLine(0); - for(y = 1; y < size.height(); ++y){ - memcpy(image.scanLine(y), p, - size.width()*sizeof(QRgb)); - } - } - } - else{ - int w=size.width(), h=size.height(); - unsigned char *xtable = new unsigned char[w*3]; - unsigned char *ytable = new unsigned char[h*3]; - QRgb *p; - - if(eff == DiagonalGradient || eff == CrossDiagonalGradient){ - for(x = 0; x < w; x++){ - dir = _xanti ? x : w - 1 - x; - rat = 1 - std::exp( - (float)x * xbal ); - - xtable[dir*3] = (unsigned char) ( rDiff/2 * rat ); - xtable[dir*3+1] = (unsigned char) ( gDiff/2 * rat ); - xtable[dir*3+2] = (unsigned char) ( bDiff/2 * rat ); - } - - for(y = 0; y < h; y++){ - dir = _yanti ? y : h - 1 - y; - rat = 1 - std::exp( - (float)y * ybal ); - - ytable[dir*3] = (unsigned char) ( rDiff/2 * rat ); - ytable[dir*3+1] = (unsigned char) ( gDiff/2 * rat ); - ytable[dir*3+2] = (unsigned char) ( bDiff/2 * rat ); - } - - for(y = 0; y < h; y++){ - p = (QRgb *)image.scanLine(y); - for(x = 0; x < w; x++){ - *p++ = qRgb(rcb - (xtable[x*3] + ytable[y*3]), - gcb - (xtable[x*3+1] + ytable[y*3+1]), - bcb - (xtable[x*3+2] + ytable[y*3+2])); - } - } - } - else{ - int rSign = rDiff>0? 1: -1; - int gSign = gDiff>0? 1: -1; - int bSign = bDiff>0? 1: -1; - - for(x = 0; x < w; x++){ - dir = _xanti ? x : w - 1 - x; - rat = 1 - std::exp( - (float)x * xbal ); - - xtable[dir*3] = (unsigned char) qAbs((int)(rDiff*(0.5-rat))); - xtable[dir*3+1] = (unsigned char) qAbs((int)(gDiff*(0.5-rat))); - xtable[dir*3+2] = (unsigned char) qAbs((int)(bDiff*(0.5-rat))); - } - - for(y = 0; y < h; y++){ - dir = _yanti ? y : h - 1 - y; - rat = 1 - std::exp( - (float)y * ybal ); - - ytable[dir*3] = (unsigned char) qAbs((int)(rDiff*(0.5-rat))); - ytable[dir*3+1] = (unsigned char) qAbs((int)(gDiff*(0.5-rat))); - ytable[dir*3+2] = (unsigned char) qAbs((int)(bDiff*(0.5-rat))); - } - - for(y = 0; y < h; y++){ - p = (QRgb *)image.scanLine(y); - for(x = 0; x < w; x++) { - if (eff == PyramidGradient){ - *p++ = qRgb(rcb-rSign*(xtable[x*3]+ytable[y*3]), - gcb-gSign*(xtable[x*3+1]+ytable[y*3+1]), - bcb-bSign*(xtable[x*3+2]+ytable[y*3+2])); - } - else if (eff == RectangleGradient){ - *p++ = qRgb(rcb - rSign * - qMax(xtable[x*3], ytable[y*3]) * 2, - gcb - gSign * - qMax(xtable[x*3+1], ytable[y*3+1]) * 2, - bcb - bSign * - qMax(xtable[x*3+2], ytable[y*3+2]) * 2); - } - else if (eff == PipeCrossGradient){ - *p++ = qRgb(rcb - rSign * - qMin(xtable[x*3], ytable[y*3]) * 2, - gcb - gSign * - qMin(xtable[x*3+1], ytable[y*3+1]) * 2, - bcb - bSign * - qMin(xtable[x*3+2], ytable[y*3+2]) * 2); - } - else if (eff == EllipticGradient){ - *p++ = qRgb(rcb - rSign * - (int)std::sqrt((xtable[x*3]*xtable[x*3] + - ytable[y*3]*ytable[y*3])*2.0), - gcb - gSign * - (int)std::sqrt((xtable[x*3+1]*xtable[x*3+1] + - ytable[y*3+1]*ytable[y*3+1])*2.0), - bcb - bSign * - (int)std::sqrt((xtable[x*3+2]*xtable[x*3+2] + - ytable[y*3+2]*ytable[y*3+2])*2.0)); - } - } - } - } - delete [] xtable; - delete [] ytable; - } - return(image); -} - -QImage Blitz::grayUnbalancedGradient(const QSize &size, unsigned char ca, - unsigned char cb, GradientType eff, - int xfactor, int yfactor) -{ - QImage image(size, QImage::Format_Indexed8); - if(!size.isValid()) - return(image); - QVector colorTable(256); - for(int i=0; i < 256; ++i) - colorTable[i] = qRgba(i, i, i, 255); - image.setColorTable(colorTable); - - int dir; // general parameter used for direction switches - bool _xanti = (xfactor < 0); // negative on X direction - bool _yanti = (yfactor < 0); // negative on Y direction - xfactor = qBound(1, qAbs(xfactor), 200); - yfactor = qBound(1, qAbs(yfactor), 200); - float xbal = xfactor/30.0f/size.width(); - float ybal = yfactor/30.0f/size.height(); - float rat; - - register int x, y; - int diff = cb-ca; - - if(eff == VerticalGradient || eff == HorizontalGradient){ - unsigned char *p; - if(eff == VerticalGradient){ - unsigned char idx; - for(y=0; y < size.height(); y++){ - dir = _yanti ? y : size.height() - 1 - y; - rat = 1 - std::exp( - (float)y * ybal ); - p = image.scanLine(dir); - idx = cb - (int)( diff * rat ); - for(x = 0; x < size.width(); x++) - *p++ = idx; - } - } - else{ - p = image.scanLine(0); - for(x = 0; x < size.width(); x++){ - dir = _xanti ? x : size.width() - 1 - x; - rat = 1 - std::exp( - (float)x * xbal ); - p[dir] = cb - (int)( diff * rat ); - } - - p = image.scanLine(0); - for(y = 1; y < size.height(); ++y) - memcpy(image.scanLine(y), p, image.bytesPerLine()); - } - } - else{ - int w=size.width(), h=size.height(); - unsigned char *xtable = new unsigned char[w]; - unsigned char *ytable = new unsigned char[h]; - unsigned char *p; - - if(eff == DiagonalGradient || eff == CrossDiagonalGradient){ - for(x = 0; x < w; x++){ - dir = _xanti ? x : w - 1 - x; - rat = 1 - std::exp( - (float)x * xbal ); - xtable[dir] = (unsigned char) ( diff/2 * rat ); - } - - for(y = 0; y < h; y++){ - dir = _yanti ? y : h - 1 - y; - rat = 1 - std::exp( - (float)y * ybal ); - ytable[dir] = (unsigned char) ( diff/2 * rat ); - } - - for(y = 0; y < h; y++){ - p = image.scanLine(y); - for(x = 0; x < w; x++) - *p++ = cb - (xtable[x] + ytable[y]); - } - } - else{ - int sign = diff>0? 1: -1; - for(x = 0; x < w; x++){ - dir = _xanti ? x : w - 1 - x; - rat = 1 - std::exp( - (float)x * xbal ); - xtable[dir] = (unsigned char) qAbs((int)(diff*(0.5-rat))); - } - - for(y = 0; y < h; y++){ - dir = _yanti ? y : h - 1 - y; - rat = 1 - std::exp( - (float)y * ybal ); - ytable[dir] = (unsigned char) qAbs((int)(diff*(0.5-rat))); - } - - for(y = 0; y < h; y++){ - p = image.scanLine(y); - for(x = 0; x < w; x++) { - if (eff == PyramidGradient) - *p++ = cb-sign*(xtable[x]+ytable[y]); - else if (eff == RectangleGradient) - *p++ = cb -sign*qMax(xtable[x], ytable[y])*2; - else if (eff == PipeCrossGradient) - *p++ = cb-sign*qMin(xtable[x], ytable[y])*2; - else if (eff == EllipticGradient) - *p++ = cb-sign * (int)std::sqrt((xtable[x]*xtable[x] + - ytable[y]*ytable[y])*2.0); - } - } - } - delete [] xtable; - delete [] ytable; - } - return(image); -} - diff -Nru syncwall-1.6.0/3rdparty/qimageblitz/histogram.cpp syncwall-1.7.4/3rdparty/qimageblitz/histogram.cpp --- syncwall-1.6.0/3rdparty/qimageblitz/histogram.cpp 2012-01-01 04:36:36.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qimageblitz/histogram.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,472 +0,0 @@ -/* - Copyright (C) 1998, 1999, 2001, 2002, 2004, 2005, 2007 - Daniel M. Duley - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -/* - Portions of this software are were originally based on ImageMagick's - algorithms. ImageMagick is copyrighted under the following conditions: - -Copyright (C) 2003 ImageMagick Studio, a non-profit organization dedicated to -making software imaging solutions freely available. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files ("ImageMagick"), to deal -in ImageMagick without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of ImageMagick, and to permit persons to whom the ImageMagick is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of ImageMagick. - -The software is provided "as is", without warranty of any kind, express or -implied, including but not limited to the warranties of merchantability, -fitness for a particular purpose and noninfringement. In no event shall -ImageMagick Studio be liable for any claim, damages or other liability, -whether in an action of contract, tort or otherwise, arising from, out of or -in connection with ImageMagick or the use or other dealings in ImageMagick. - -Except as contained in this notice, the name of the ImageMagick Studio shall -not be used in advertising or otherwise to promote the sale, use or other -dealings in ImageMagick without prior written authorization from the -ImageMagick Studio. -*/ - - -#include "qimageblitz.h" -#include "private/blitz_p.h" -#include -#include - -// These are used as accumulators - -typedef struct -{ - qint32 red, green, blue, alpha; -} IntegerPixel; - -typedef struct -{ - qint16 red, green, blue, alpha; -} ShortPixel; - -typedef struct -{ - // Yes, a normal pixel can be used instead but this is easier to read - // and no shifts to get components. - qint8 red, green, blue, alpha; -} CharPixel; - -typedef struct -{ - quint32 red, green, blue, alpha; -} HistogramListItem; - - -bool Blitz::equalize(QImage &img) -{ - if(img.isNull()) - return(false); - - HistogramListItem *histogram; - IntegerPixel *map; - IntegerPixel intensity, high, low; - CharPixel *equalize_map; - int i, count; - QRgb pixel, *dest; - unsigned char r, g, b; - - if(img.depth() < 32){ - img = img.convertToFormat(img.hasAlphaChannel() ? - QImage::Format_ARGB32 : - QImage::Format_RGB32); - } - count = img.width()*img.height(); - - map = new IntegerPixel[256]; - histogram = new HistogramListItem[256]; - equalize_map = new CharPixel[256]; - - // form histogram - memset(histogram, 0, 256*sizeof(HistogramListItem)); - dest = (QRgb *)img.bits(); - - if(img.format() == QImage::Format_ARGB32_Premultiplied){ - for(i=0; i < count; ++i, ++dest){ - pixel = BlitzPrivate::convertFromPremult(*dest); - histogram[qRed(pixel)].red++; - histogram[qGreen(pixel)].green++; - histogram[qBlue(pixel)].blue++; - histogram[qAlpha(pixel)].alpha++; - } - } - else{ - for(i=0; i < count; ++i){ - pixel = *dest++; - histogram[qRed(pixel)].red++; - histogram[qGreen(pixel)].green++; - histogram[qBlue(pixel)].blue++; - histogram[qAlpha(pixel)].alpha++; - } - } - - // integrate the histogram to get the equalization map - memset(&intensity, 0, sizeof(IntegerPixel)); - for(i=0; i < 256; ++i){ - intensity.red += histogram[i].red; - intensity.green += histogram[i].green; - intensity.blue += histogram[i].blue; - map[i] = intensity; - } - - low = map[0]; - high = map[255]; - memset(equalize_map, 0, 256*sizeof(CharPixel)); - for(i=0; i < 256; ++i){ - if(high.red != low.red) - equalize_map[i].red=(unsigned char) - ((255*(map[i].red-low.red))/(high.red-low.red)); - if(high.green != low.green) - equalize_map[i].green=(unsigned char) - ((255*(map[i].green-low.green))/(high.green-low.green)); - if(high.blue != low.blue) - equalize_map[i].blue=(unsigned char) - ((255*(map[i].blue-low.blue))/(high.blue-low.blue)); - } - - // stretch the histogram and write - dest = (QRgb *)img.bits(); - if(img.format() == QImage::Format_ARGB32_Premultiplied){ - for(i=0; i < count; ++i, ++dest){ - pixel = BlitzPrivate::convertFromPremult(*dest); - r = (low.red != high.red) ? equalize_map[qRed(pixel)].red : - qRed(pixel); - g = (low.green != high.green) ? equalize_map[qGreen(pixel)].green : - qGreen(pixel); - b = (low.blue != high.blue) ? equalize_map[qBlue(pixel)].blue : - qBlue(pixel); - *dest = BlitzPrivate::convertToPremult(qRgba(r, g, b, qAlpha(pixel))); - } - } - else{ - for(i=0; i < count; ++i){ - pixel = *dest; - r = (low.red != high.red) ? equalize_map[qRed(pixel)].red : - qRed(pixel); - g = (low.green != high.green) ? equalize_map[qGreen(pixel)].green : - qGreen(pixel); - b = (low.blue != high.blue) ? equalize_map[qBlue(pixel)].blue : - qBlue(pixel); - *dest++ = qRgba(r, g, b, qAlpha(pixel)); - } - } - - delete[] histogram; - delete[] map; - delete[] equalize_map; - return(true); -} - -bool Blitz::normalize(QImage &img) -{ - if(img.isNull()) - return(false); - - IntegerPixel intensity; - HistogramListItem *histogram; - CharPixel *normalize_map; - ShortPixel high, low; - - int threshold_intensity; - int i, count; - QRgb pixel, *dest; - unsigned char r, g, b; - - if(img.depth() < 32){ - img = img.convertToFormat(img.hasAlphaChannel() ? - QImage::Format_ARGB32 : - QImage::Format_RGB32); - } - count = img.width()*img.height(); - - histogram = new HistogramListItem[256]; - normalize_map = new CharPixel[256]; - - // form histogram - memset(histogram, 0, 256*sizeof(HistogramListItem)); - dest = (QRgb *)img.bits(); - - if(img.format() == QImage::Format_ARGB32_Premultiplied){ - for(i=0; i < count; ++i, ++dest){ - pixel = BlitzPrivate::convertFromPremult(*dest); - histogram[qRed(pixel)].red++; - histogram[qGreen(pixel)].green++; - histogram[qBlue(pixel)].blue++; - histogram[qAlpha(pixel)].alpha++; - } - } - else{ - for(i=0; i < count; ++i){ - pixel = *dest++; - histogram[qRed(pixel)].red++; - histogram[qGreen(pixel)].green++; - histogram[qBlue(pixel)].blue++; - histogram[qAlpha(pixel)].alpha++; - } - } - - // find the histogram boundaries by locating the .01 percent levels. - threshold_intensity = count/1000; - - memset(&intensity, 0, sizeof(IntegerPixel)); - for(low.red=0; low.red < 256; ++low.red){ - intensity.red += histogram[low.red].red; - if(intensity.red > threshold_intensity) - break; - } - memset(&intensity, 0, sizeof(IntegerPixel)); - for(high.red=255; high.red >= 0; --high.red){ - intensity.red += histogram[high.red].red; - if(intensity.red > threshold_intensity) - break; - } - memset(&intensity, 0, sizeof(IntegerPixel)); - for(low.green=low.red; low.green < high.red; ++low.green){ - intensity.green += histogram[low.green].green; - if(intensity.green > threshold_intensity) - break; - } - memset(&intensity, 0, sizeof(IntegerPixel)); - for(high.green=high.red; high.green != low.red; --high.green){ - intensity.green += histogram[high.green].green; - if(intensity.green > threshold_intensity) - break; - } - memset(&intensity, 0, sizeof(IntegerPixel)); - for(low.blue=low.green; low.blue < high.green; ++low.blue){ - intensity.blue += histogram[low.blue].blue; - if(intensity.blue > threshold_intensity) - break; - } - memset(&intensity, 0, sizeof(IntegerPixel)); - for(high.blue=high.green; high.blue != low.green; --high.blue){ - intensity.blue += histogram[high.blue].blue; - if(intensity.blue > threshold_intensity) - break; - } - - delete[] histogram; - - // stretch the histogram to create the normalized image mapping. - for(i=0; i < 256; i++){ - if(i < low.red) - normalize_map[i].red = 0; - else{ - if(i > high.red) - normalize_map[i].red = (qint8)255; - else if(low.red != high.red) - normalize_map[i].red = (255*(i-low.red))/ - (high.red-low.red); - } - - if(i < low.green) - normalize_map[i].green = 0; - else{ - if(i > high.green) - normalize_map[i].green = (qint8)255; - else if(low.green != high.green) - normalize_map[i].green = (255*(i-low.green))/ - (high.green-low.green); - } - - if(i < low.blue) - normalize_map[i].blue = 0; - else{ - if(i > high.blue) - normalize_map[i].blue = (qint8)255; - else if(low.blue != high.blue) - normalize_map[i].blue = (255*(i-low.blue))/ - (high.blue-low.blue); - } - } - - // write - dest = (QRgb *)img.bits(); - if(img.format() == QImage::Format_ARGB32_Premultiplied){ - for(i=0; i < count; ++i, ++dest){ - pixel = BlitzPrivate::convertFromPremult(*dest); - r = (low.red != high.red) ? normalize_map[qRed(pixel)].red : - qRed(pixel); - g = (low.green != high.green) ? normalize_map[qGreen(pixel)].green : - qGreen(pixel); - b = (low.blue != high.blue) ? normalize_map[qBlue(pixel)].blue : - qBlue(pixel); - *dest = BlitzPrivate::convertToPremult(qRgba(r, g, b, qAlpha(pixel))); - } - } - else{ - for(i=0; i < count; ++i){ - pixel = *dest; - r = (low.red != high.red) ? normalize_map[qRed(pixel)].red : - qRed(pixel); - g = (low.green != high.green) ? normalize_map[qGreen(pixel)].green : - qGreen(pixel); - b = (low.blue != high.blue) ? normalize_map[qBlue(pixel)].blue : - qBlue(pixel); - *dest++ = qRgba(r, g, b, qAlpha(pixel)); - } - } - - delete[] normalize_map; - return(true); -} - -QImage Blitz::oilPaint(QImage &img, float radius, - EffectQuality quality) -{ - int matrix_size = BlitzPrivate::defaultConvolveMatrixSize(radius, 0.5, - quality == High); - int i, x, y, w, h, matrix_x, matrix_y; - int edge = matrix_size/2; - unsigned int max, value; - QRgb *dest, *src, *s, **scanblock; - - w = img.width(); - h = img.height(); - if(w < 3 || h < 3){ - qWarning("Blitz::oilPaint(): Image is too small!"); - return(img); - } - - if(img.format() == QImage::Format_ARGB32_Premultiplied) - img = img.convertToFormat(QImage::Format_ARGB32); - else if(img.depth() < 32){ - img = img.convertToFormat(img.hasAlphaChannel() ? - QImage::Format_ARGB32 : - QImage::Format_RGB32); - } - QImage buffer(w, h, img.format()); - - scanblock = new QRgb* [matrix_size]; - unsigned int *histogram = new unsigned int[256]; - - for(y=0; y < h; ++y){ - src = (QRgb *)img.scanLine(y); - dest = (QRgb *)buffer.scanLine(y); - // Read in scanlines to pixel neighborhood. If the scanline is outside - // the image use the top or bottom edge. - for(x=y-edge, i=0; x <= y+edge; ++i, ++x){ - scanblock[i] = (QRgb *) - img.scanLine((x < 0) ? 0 : (x > h-1) ? h-1 : x); - } - - // Now we are about to start processing scanlines. First handle the - // part where the pixel neighborhood extends off the left edge. - for(x=0; x-edge < 0 ; ++x){ - (void)memset(histogram, 0, 256*sizeof(unsigned int)); - max = 0; - for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ - s = scanblock[matrix_y]; - matrix_x = -edge; - while(x+matrix_x < 0){ - value = qGray(*s); - histogram[value]++; - if(histogram[value] > max){ - max = histogram[value]; - *dest = *s; - } - ++matrix_x; - } - while(matrix_x <= edge){ - value = qGray(*s); - histogram[value]++; - if(histogram[value] > max){ - max = histogram[value]; - *dest = *s; - } - ++matrix_x; ++s; - } - } - ++dest; - } - - // Okay, now process the middle part where the entire neighborhood - // is on the image. - for(; x+edge < w; ++x){ - (void)memset(histogram, 0, 256*sizeof(unsigned int)); - max = 0; - for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ - s = scanblock[matrix_y] + (x-edge); - for(matrix_x = -edge; matrix_x <= edge; ++matrix_x, ++s){ - value = qGray(*s); - histogram[value]++; - if(histogram[value] > max){ - max = histogram[value]; - *dest = *s; - } - } - } - ++dest; - } - - // Finally process the right part where the neighborhood extends off - // the right edge of the image - for(; x < w; ++x){ - (void)memset(histogram, 0, 256*sizeof(unsigned int)); - max = 0; - for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ - s = scanblock[matrix_y]; - s += x-edge; - matrix_x = -edge; - while(x+matrix_x < w){ - value = qGray(*s); - histogram[value]++; - if(histogram[value] > max){ - max = histogram[value]; - *dest = *s; - } - ++matrix_x, ++s; - } - --s; - while(matrix_x <= edge){ - value = qGray(*s); - histogram[value]++; - if(histogram[value] > max){ - max = histogram[value]; - *dest = *s; - } - ++matrix_x; - } - } - ++dest; - } - } - - delete[] histogram; - delete[] scanblock; - return(buffer); -} - diff -Nru syncwall-1.6.0/3rdparty/qimageblitz/private/blitz_p.h syncwall-1.7.4/3rdparty/qimageblitz/private/blitz_p.h --- syncwall-1.6.0/3rdparty/qimageblitz/private/blitz_p.h 2008-02-26 19:31:00.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qimageblitz/private/blitz_p.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,159 +0,0 @@ -#ifndef __BLITZ_PRIVATE_H -#define __BLITZ_PRIVATE_H - -/* - Copyright (C) 1998, 1999, 2001, 2002, 2004, 2005, 2007 - Daniel M. Duley - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include - -class BlitzPrivate -{ -public: - static inline QRgb convertFromPremult(QRgb); - static inline QRgb convertToPremult(QRgb); - static inline QRgb byteMul(QRgb x, unsigned int a); - static inline QRgb interpolate255(QRgb x, unsigned int a, - QRgb y, unsigned int b); - static inline QRgb setAlpha(QRgb rgb, unsigned int a); - static inline int brightness(QRgb rgb); - static inline void hull(int x_offset, int y_offset, int w, int h, - unsigned char *f, unsigned char *g, int polarity); - static int defaultConvolveMatrixSize(float radius, float sigma, - bool quality); - static float* getBlurKernel(int &kernel_width, float sigma); - static void blurScanLine(float *kernel, int kern_width, - QRgb *source, QRgb *destination, - int columns, int offset); -}; - -inline QRgb BlitzPrivate::byteMul(QRgb x, unsigned int a) -{ - unsigned int t = (x & 0xff00ff) * a; - t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8; - t &= 0xff00ff; - - x = ((x >> 8) & 0xff00ff) * a; - x = (x + ((x >> 8) & 0xff00ff) + 0x800080); - x &= 0xff00ff00; - x |= t; - return(x); -} - -inline QRgb BlitzPrivate::interpolate255(QRgb x, unsigned int a, - QRgb y, unsigned int b) -{ - unsigned int t = (x & 0xff00ff) * a + (y & 0xff00ff) * b; - t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8; - t &= 0xff00ff; - - x = ((x >> 8) & 0xff00ff) * a + ((y >> 8) & 0xff00ff) * b; - x = (x + ((x >> 8) & 0xff00ff) + 0x800080); - x &= 0xff00ff00; - x |= t; - return(x); -} - -inline QRgb BlitzPrivate::convertFromPremult(QRgb p) -{ - int alpha = qAlpha(p); - return(!alpha ? 0 : qRgba(255*qRed(p)/alpha, - 255*qGreen(p)/alpha, - 255*qBlue(p)/alpha, - alpha)); -} - -inline QRgb BlitzPrivate::convertToPremult(QRgb p) -{ - unsigned int a = p >> 24; - unsigned int t = (p & 0xff00ff) * a; - t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8; - t &= 0xff00ff; - - p = ((p >> 8) & 0xff) * a; - p = (p + ((p >> 8) & 0xff) + 0x80); - p &= 0xff00; - p |= t | (a << 24); - return(p); -} - -inline void BlitzPrivate::hull(int x_offset, int y_offset, int w, int h, - unsigned char *f, unsigned char *g, - int polarity) -{ - int x, y, v; - unsigned char *p, *q, *r, *s; - p = f+(w+2); q = g+(w+2); - r = p+(y_offset*(w+2)+x_offset); - for(y=0; y < h; ++y, ++p, ++q, ++r){ - ++p; ++q; ++r; - if(polarity > 0){ - for(x=w; x > 0; --x, ++p, ++q, ++r){ - v = (*p); - if((int)*r >= (v+2)) v += 1; - *q = (unsigned char)v; - } - } - else{ - for(x=w; x > 0; --x, ++p, ++q, ++r){ - v = (*p); - if((int)*r <= (v-2)) v -= 1; - *q = (unsigned char)v; - } - } - } - p = f+(w+2); q = g+(w+2); - r = q+(y_offset*(w+2)+x_offset); s = q-(y_offset*(w+2)+x_offset); - for(y=0; y < h; ++y, ++p, ++q, ++r, ++s){ - ++p; ++q; ++r; ++s; - if(polarity > 0){ - for(x=w; x > 0; --x, ++p, ++q, ++r, ++s){ - v = (*q); - if(((int)*s >= (v+2)) && ((int)*r > v)) v+=1; - *p = (unsigned char)v; - } - } - else{ - for(x=w; x > 0; --x, ++p, ++q, ++r, ++s){ - v = (int)(*q); - if (((int)*s <= (v-2)) && ((int)*r < v)) v -= 1; - *p = (unsigned char)v; - } - } - } -} - -inline int BlitzPrivate::brightness(QRgb rgb) -{ - return(qMax(qRed((rgb)), qMax(qBlue((rgb)), qGreen((rgb))))); -} - -inline QRgb BlitzPrivate::setAlpha(QRgb rgb, unsigned int a) -{ - return(((a & 0xFF) << 24) | (rgb & 0x00FFFFFF)); -} - -#endif - diff -Nru syncwall-1.6.0/3rdparty/qimageblitz/private/inlinehsv.h syncwall-1.7.4/3rdparty/qimageblitz/private/inlinehsv.h --- syncwall-1.6.0/3rdparty/qimageblitz/private/inlinehsv.h 2008-02-26 19:31:00.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qimageblitz/private/inlinehsv.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,163 +0,0 @@ -#ifndef __PIXIE_INLINEHSV_H -#define __PIXIE_INLINEHSV_H - -/* - Copyright (C) 2005, 2007 Daniel M. Duley - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -#include - -/** - * HSV to RGB conversion is required often for some algorithms. This - * class inlines, (at least with gcc), most of the code required for this - * conversion in order to increase performance in loops. The idea is you - * create an instance of this class outside your main loop then call - * convertRGB2HSV() and convertHSV2RGB when you need it. - * - * @author Daniel M. Duley - * @short Inline HSV conversion - */ -class InlineHSV -{ -public: - InlineHSV(){;} - /** - * Converts the given RGB value to HSV. The hue(), saturation(), and - * value() methods will be valid after calling this. The red, green, - * and blue items are also set the the supplied values. - */ - inline void convertRGB2HSV(unsigned int rgb); - inline void convertRGB2HSV(int red, int green, int blue); - /** - * Converts the given HSV value to RGB. The red(), green(), and - * blue() methods will be valid after calling this. The hue, - * saturation, and value methods are also set to the supplied values. - */ - inline void convertHSV2RGB(int hue, int saturation, int value); - /** - * Converts the current hue, saturation, and value settings to RGB. - */ - inline void convertHSV2RGB(); - - inline void setHSV(int hue, int saturation, int value) - {h = hue; s = saturation; v = value;} - inline void setHue(int hue){h = hue;} - inline void setSaturation(int saturation){s = saturation;} - inline void setValue(int value){v = value;} - inline int hue(){return(h);} - inline int saturation(){return(s);} - inline int value(){return(v);} - - inline void setRGB(int red, int green, int blue) - {r = red; g = green; b=blue;} - inline void setRed(int red){r = red;} - inline void setGreen(int green){g = green;} - inline void setBlue(int blue){b = blue;} - inline int red(){return(r);} - inline int green(){return(g);} - inline int blue(){return(b);} -private: - int h, s, v; - int r, g, b; - int max, whatmax, min, delta; - unsigned int f, p, q, t; -}; - -inline void InlineHSV::convertRGB2HSV(unsigned int pixel) -{ - convertRGB2HSV(qRed(pixel), qGreen(pixel), qBlue(pixel)); -} - -inline void InlineHSV::convertRGB2HSV(int red, int green, int blue) -{ - r = red; g = green; b = blue; - h = 0; - max = r; // maximum RGB component - whatmax = 0; // r=>0, g=>1, b=>2 - if(g > max) { max = g; whatmax = 1; } - if(b > max) { max = b; whatmax = 2; } - min = r; // find minimum value - if(g < min) min = g; - if(b < min) min = b; - delta = max-min; - v = max; // calc value - s = max ? (510*delta+max)/(2*max) : 0; - if(s == 0) - h = -1; // undefined hue - else{ - switch(whatmax){ - case 0: // red is max component - h = (g >= b) ? (120*(g-b)+delta)/(2*delta) : - (120*(g-b+delta)+delta)/(2*delta) + 300; - break; - case 1: // green is max component - h = (b > r) ? h = 120 + (120*(b-r)+delta)/(2*delta) : - 60 + (120*(b-r+delta)+delta)/(2*delta); - break; - case 2: // blue is max component - h = (r > g) ? h = 240 + (120*(r-g)+delta)/(2*delta) : - h = 180 + (120*(r-g+delta)+delta)/(2*delta); - break; - } - } -} - -inline void InlineHSV::convertHSV2RGB(int hue, int saturation, int value) -{ - h = hue; s = saturation; v = value; - convertHSV2RGB(); -} - -inline void InlineHSV::convertHSV2RGB() -{ - if(h < -1 || s > 255 || v > 255) - return; - - r = g = b = v; - if(s > 0 && h != -1){ - if(h >= 360) h %= 360; - f = h%60; - h /= 60; - p = (2*v*(255-s)+255)/510; - if(h&1){ - q = (2*v*(15300-s*f)+15300)/30600; - switch( h ) { - case 1: r=q; g=v, b=p; break; - case 3: r=p; g=q, b=v; break; - case 5: r=v; g=p, b=q; break; - } - } else { - t = (2*v*(15300-(s*(60-f)))+15300)/30600; - switch( h ) { - case 0: r=v; g=t, b=p; break; - case 2: r=p; g=v, b=t; break; - case 4: r=t; g=p, b=v; break; - } - } - } -} - -#endif - diff -Nru syncwall-1.6.0/3rdparty/qimageblitz/private/interpolate.h syncwall-1.7.4/3rdparty/qimageblitz/private/interpolate.h --- syncwall-1.6.0/3rdparty/qimageblitz/private/interpolate.h 2008-02-26 19:31:00.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qimageblitz/private/interpolate.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,143 +0,0 @@ -#ifndef __PIXIE_INTERPOLATE_H -#define __PIXIE_INTERPOLATE_H - -/* - Copyright (C) 2005, 2007 Daniel M. Duley - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -#include -#include -#include - -/** - * Performs interpolation between a pixel's colors and it's neighbors. - * Handles 32bpp and 8bpp source images transparently. - * - * @short Inline interpolation - * @author Daniel M. Duley - */ -class InlineInterpolate -{ -public: - /** - * Constructs an interpolation object. Do this outside your main loop then - * call the inline interpolate methods when you need them. - * - * @param image The image whose pixels you will be interpolating. Once - * you have created an interpolation object you can change the image's - * pixel data, but do not resize or reset it. - * @param background The background color to use if a pixel's neighbor - * is off the edge of the image. - */ - InlineInterpolate(QImage *image, unsigned int background){ - img = image; ptr = img->bits(); - colorTable = img->colorTable(); - w=img->width(); h=img->height(); - bg=background; truecolor = img->depth() > 8; - } - /** - * Interpolates the pixel at the given x,y position. If the pixel's - * neighbor is off the edge of the image the last pixel is extended. - */ - inline unsigned int interpolate(float x_offset, float y_offset); - /** - * Interpolates the pixel at the given x,y position. If the pixel's - * neighbor is off the edge of the image the background color is used. - */ - inline unsigned int interpolateBackground(float x_offset, float y_offset); -private: - int w, h; - unsigned int p, q, r, s, bg; - unsigned char *ptr; - QVector colorTable; - bool truecolor; - QImage *img; -}; - -inline unsigned int InlineInterpolate::interpolate(float x_offset, - float y_offset) -{ - int x = qBound(0, (int)x_offset, w-2); - int y = qBound(0, (int)y_offset, h-2); - - if(truecolor){ - p = *(((QRgb *)ptr)+(y*w)+x); - q = *(((QRgb *)ptr)+(y*w)+x+1); - r = *(((QRgb *)ptr)+((y+1)*w)+x); - s = *(((QRgb *)ptr)+((y+1)*w)+x+1); - } - else{ - p = colorTable[*(ptr+(y*w)+x)]; - q = colorTable[*(ptr+(y*w)+x+1)]; - r = colorTable[*(ptr+((y+1)*w)+x)]; - s = colorTable[*(ptr+((y+1)*w)+x+1)]; - } - x_offset -= std::floor(x_offset); y_offset -= std::floor(y_offset); - unsigned int alpha = (unsigned int)(255*x_offset); - unsigned int beta = (unsigned int)(255*y_offset); - - p = BlitzPrivate::interpolate255(p, 255-alpha, q, alpha); - r = BlitzPrivate::interpolate255(r, 255-alpha, s, alpha); - return(BlitzPrivate::interpolate255(p, 255-beta, r, beta)); -} - -inline unsigned int InlineInterpolate::interpolateBackground(float x_offset, - float y_offset) -{ - int x = (int)x_offset; - int y = (int)y_offset; - p = q = r = s = bg; - - if(truecolor){ - if(y >= 0 && y < h && x >= 0 && x < w){ - p = *(((QRgb *)ptr)+(y*w)+x); - if(y+1 < h) r = *(((QRgb *)ptr)+((y+1)*w)+x); - if(x+1 < w){ - q = *(((QRgb *)ptr)+(y*w)+x+1); - if(y+1 < h) q = *(((QRgb *)ptr)+((y+1)*w)+x+1); - } - } - } - else{ - if(y >= 0 && y < h && x >= 0 && x < w){ - p = colorTable[*(ptr+(y*w)+x)]; - if(y+1 < h) r = colorTable[*(ptr+((y+1)*w)+x)]; - if(x+1 < w){ - q = colorTable[*(ptr+(y*w)+x+1)]; - if(y+1 < h) s = colorTable[*(ptr+((y+1)*w)+x+1)]; - } - } - } - x_offset -= std::floor(x_offset); y_offset -= std::floor(y_offset); - unsigned int alpha = (unsigned int)(255*x_offset); - unsigned int beta = (unsigned int)(255*y_offset); - - p = BlitzPrivate::interpolate255(p, 255-alpha, q, alpha); - r = BlitzPrivate::interpolate255(r, 255-alpha, s, alpha); - return(BlitzPrivate::interpolate255(p, 255-beta, r, beta)); -} - -#endif - diff -Nru syncwall-1.6.0/3rdparty/qimageblitz/qimageblitz.h syncwall-1.7.4/3rdparty/qimageblitz/qimageblitz.h --- syncwall-1.6.0/3rdparty/qimageblitz/qimageblitz.h 2011-12-17 13:07:04.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qimageblitz/qimageblitz.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,440 +0,0 @@ -#ifndef __BLITZ_H -#define __BLITZ_H - -/* - Copyright (C) 1998, 1999, 2001, 2002, 2004, 2005, 2007 - Daniel M. Duley - (C) 2004 Zack Rusin - (C) 2000 Josef Weidendorfer - (C) 1999 Geert Jansen - (C) 1998, 1999 Christian Tibirna - (C) 1998, 1999 Dirk Mueller - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -#include -#include "qimageblitz_export.h" - -class QIMAGEBLITZ_EXPORT Blitz -{ -public: - enum GradientType {VerticalGradient=0, HorizontalGradient, DiagonalGradient, - CrossDiagonalGradient, PyramidGradient, RectangleGradient, - PipeCrossGradient, EllipticGradient}; - - enum RGBChannel{Grayscale=0, Brightness, Red, Green, Blue, Alpha, All}; - enum EffectQuality{Low=0, High}; - - enum ScaleFilterType{UndefinedFilter=0, PointFilter, BoxFilter, - TriangleFilter, HermiteFilter, HanningFilter, HammingFilter, - BlackmanFilter, GaussianFilter, QuadraticFilter, CubicFilter, - CatromFilter, MitchellFilter, LanczosFilter, BesselFilter, - SincFilter}; - - enum ModulationType{Intensity=0, Saturation, HueShift, Contrast}; - - /** - * Inverts an image. If the machine supports MMX this can do two pixels - * at a time, otherwise it's the same as QImage::invertPixels(). - * - * @param img The image to invert. - * @param mode If to invert the alpha channel or not. - * @author Daniel M. Duley (mosfet) - */ - static bool invert(QImage &img, QImage::InvertMode mode = - QImage::InvertRgb); - /** - * Grayscales an image. - * - * @param img The image to grayscale. - * @param reduceDepth If true the result will be an 8bit palette image. - * @author Daniel M. Duley (mosfet) - */ - static bool grayscale(QImage &img, bool reduceDepth=false); - /** - * A fast smoothscale method with MMX support. - * - * @param img The image to smoothscale. - * @param sz The size to scale to. - * @param aspectRatio What aspect ratio to use, if any. - * @return The processed image. The original is not changed. - * @author Daniel M. Duley (mosfet) - */ - static QImage smoothScale(QImage &img, const QSize &sz, - Qt::AspectRatioMode aspectRatio = - Qt::IgnoreAspectRatio); - static QImage smoothScale(QImage &img, int dw, int dh, - Qt::AspectRatioMode aspectRatio = - Qt::IgnoreAspectRatio); - /** - * Smoothscales an image using a high-quality filter. - * - * @param img The image to smoothscale. - * @param sz The size to scale to. - * @param blur A blur factor. Values greater than 1.0 blur while values - * less than 1.0 sharpen. - * @param filter The filter type. - * @param aspectRatio What aspect ratio to use, if any. - * @return The processed image. The original is not changed. - * @author Daniel M. Duley (mosfet) - */ - static QImage smoothScaleFilter(QImage &img, const QSize &sz, - float blur=1.0, - ScaleFilterType filter=BlackmanFilter, - Qt::AspectRatioMode aspectRatio = - Qt::IgnoreAspectRatio); - static QImage smoothScaleFilter(QImage &img, int dwX, int dwY, - float blur=1.0, - ScaleFilterType filter=BlackmanFilter, - Qt::AspectRatioMode aspectRatio = - Qt::IgnoreAspectRatio); - - /** - * Convolves an image using a convolution matrix, (kernel), and provides - * the basis for many different image filters and effects. - * - * @param img The image to process. - * @param matrix_size The size of one side of the convolution matrix, ie: - * a 3x3 matrix would be 3, not 9. - * @param matrix The convolution matrix. - * @return The processed image. The original is not changed. - * @author Daniel M. Duley (mosfet) - */ - static QImage convolve(QImage &img, int matrix_size, float *matrix); - /** - * Same as above but with a faster integer matrix. - */ - static QImage convolveInteger(QImage &img, int matrix_size, int *matrix, - int divisor=0); - /** - * A fast blur algorithm. - * - * @param img The image to process. - * @param radius The radius of the blur. Larger values blur more. - * @return The processed image. The original is not changed. - * @author Daniel M. Duley (mosfet) - */ - static QImage blur(QImage &img, int radius=3); - /** - * A high quality gaussian/convolve-based blur. - * - * @param img The image to process. - * @param radius The radius of the gaussian, not counting the center - * pixel. Use 0, (recommended), and an appropriate one will be used. - * @param sigma The standard deviation of the gaussian in pixels. Use - * 1.0, (recommended), for the default value. - * @return The processed image. The original is not changed. - * @author Daniel M. Duley (mosfet) - */ - static QImage gaussianBlur(QImage &img, float radius=0.0, float sigma=1.0); - /** - * Detects edges in an image using the Sobel algorithm. - * - * @param img The image to process. - * @return The processed image. The original is not changed. - * @author Daniel M. Duley (mosfet) - */ - static QImage edge(QImage &img); - /** - * Detects edges in an image using a convolution matrix. - * - * @param img The image to process. - * @param radius The radius of the gaussian, not counting the center - * pixel. Use 0, (recommended), and an appropriate one will be used. - * @param quality Determines if to use a small or large convolution matrix. - * @return The processed image. The original is not changed. - * @author Daniel M. Duley (mosfet) - */ - static QImage convolveEdge(QImage &img, float radius=0.0, - EffectQuality quality=High); - /** - * Sharpens an image. - * - * @param img The image to process. - * @param radius The radius of the gaussian, not counting the center - * pixel. Use 0, (recommended), and an appropriate one will be used. - * @param sigma The standard deviation of the gaussian in pixels. Use - * 1.0, (recommended), for the default value. - * @param quality Determines if to use a small or large convolution matrix. - * @return The processed image. The original is not changed. - * @author Daniel M. Duley (mosfet) - */ - static QImage gaussianSharpen(QImage &img, float radius=0.0, float sigma=1.0, - EffectQuality quality=High); - /** - * A cheap, fast sharpen. - * - * @param radius The radius. Larger values sharpen more. - * @return The processed image. The original is not changed. - * @author Daniel M. Duley (mosfet) - */ - static QImage sharpen(QImage &img, int radius=3); - /** - * Embosses an image. - * - * @param img The image to process. - * @param radius The radius of the gaussian, not counting the center - * pixel. Use 0, (recommended), and an appropriate one will be used. - * @param sigma The standard deviation of the gaussian in pixels. Use - * 1.0, (recommended), for the default value. - * @param quality Determines if to use a small or large convolution matrix. - * @return The processed image. The original is not changed. - * @author Daniel M. Duley (mosfet) - */ - static QImage emboss(QImage &img, float radius=0.0, float sigma=1.0, - EffectQuality quality=High); - /** - * Antialiases an image. - * - * @param img The image to process. - * @return The processed image. The original is not changed. - * @author Daniel M. Duley (mosfet) - */ - static QImage antialias(QImage &img); - /** - * Minimizes speckle noise in the source image using the 8 hull - * algorithm. - * - * @param img The image to process. - * @return A reference to the image for convenience. - * @author Daniel M. Duley (mosfet) - */ - static QImage& despeckle(QImage &img); - /** - * High quality, fast HSV contrast. - * - * @param img The image to process. - * @param sharpen If true sharpness is increase, (spiffed). Otherwise - * it is decreased, (dulled). - * @param weight How much to spiff or dull. - * @return A reference to the image for convenience. - * @author Daniel M. Duley (mosfet) - */ - static QImage& contrast(QImage &img, bool sharpen, int weight=3); - /** - * Performs histogram equalization. - * - * @param img The image to equalize. - * @author Daniel M. Duley (mosfet) - */ - static bool equalize(QImage &img); - /** - * Normalizes the pixel values to span the full range of color values. - * This is a contrast enhancement technique. - * - * @param img The image to normalize - * @author Daniel M. Duley (mosfet) - */ - static bool normalize(QImage &img); - /** - * Either brighten or dim the image by a specified percent. For example, - * 0.50 will modify the colors by 50%. - * - * @param img The image to process. - * @param percent The percent value. Use a negative value to dim. - * @return A reference to the image for convenience. - * @author Daniel M. Duley (mosfet) - * @author Benjamin Roe (ben@benroe.com) - */ - static QImage& intensity(QImage &img, float percent); - /** - * Modifies the intensity of an image's RGB channel. - * - * @param img The image to process. - * @param percent Percent value. Use a negative value to dim. - * @param channel Which channel(s) should be modified. Only Red, Green, - * and Blue are valid. - * @return A reference to the image for convenience. - * @author Daniel M. Duley (mosfet) - */ - static QImage& channelIntensity(QImage &img, float percent, - RGBChannel channel); - /** - * Desaturate an image evenly. - * - * @param img The image to process. - * @param desat A value between 0 and 1 setting the degree of desaturation - * @return A reference to the image for convenience. - * @author Daniel M. Duley (mosfet) - */ - static QImage& desaturate(QImage &img, float desat = 0.5); - /** - * Fade an image to a certain background color. The number of colors will - * not be changed. - * - * @param img The image to process. - * @param val The strength of the effect. 0 <= val <= 1. - * @param color The background color. - * @return A reference to the image for convenience. - */ - static QImage& fade(QImage &img, float val, const QColor &color); - - /** - * This recolors a pixmap. The most dark color will become color a, - * the most bright one color b, and in between. - * - * @param img The image to process. - * @param ca Color a - * @param cb Color b - */ - static QImage& flatten(QImage &img, const QColor &ca, const QColor &cb); - /** - * Thresholds an image based on a given channel and threshold value. - * - * @param img The image to process. - * @param thresholdValue The value that separates "on" colors from "off" - * ones. - * @param channel The channel to use when thresholding. - * @param aboveColor The color to use for values at or above the threshold. - * @param belowColor The color to use for values below the threshold. - * @return The processed image. The original is not changed. - * @author Daniel M. Duley (mosfet) - */ - static QImage threshold(QImage &img, unsigned char thresholdValue=127, - RGBChannel channel=Grayscale, - unsigned int aboveColor=qRgb(255, 255, 255), - unsigned int belowColor=qRgb(0, 0, 0)); - /** - * Swirls the image by a specified amount - * - * @param img The image to process. - * @param degrees The tightness of the swirl. - * @return The processed image. The original is not changed. - * @author Daniel M. Duley (mosfet) - */ - static QImage swirl(QImage &img, float degrees=60.0); - /** - * Implodes an image by a specified percent. - * - * @param img The QImage to process. - * @param amount The extent of the implosion. - * @return The processed image. The original is not changed. - * @author Daniel M. Duley (mosfet) - */ - static QImage implode(QImage &img, float amount=0.3); - /** - * Modifies the pixels along a sine wave. - * - * @param img The image to process. - * @param amplitude The amplitude of the sine wave. - * @param frequency The frequency of the sine wave. - * @param background An RGBA value to use for the background. After the - * effect some pixels may be "empty". This value is used for those pixels. - * @return The processed image. The original is not changed. - * @author Daniel M. Duley (mosfet) - */ - static QImage wave(QImage &img, float amplitude=25.0, float frequency=150.0, - unsigned int background=0); - /** - * Produces an oil painting effect. - * - * @param img The image to process. - * @param radius The radius of the gaussian, not counting the center - * pixel. Use 0, (recommended), and an appropriate one will be used. - * @param quality Determines if to use a small or large convolution matrix. - * @return The processed image. The original is not changed. - * @author Daniel M. Duley (mosfet) - */ - static QImage oilPaint(QImage &img, float radius=0.0, - EffectQuality quality=High); - /** - * Produces a "charcoal" image effect. - * - * @param img The image to process. - * @return The processed image. The original is not changed. - * @author Daniel M. Duley (mosfet) - */ - static QImage charcoal(QImage &img); - /** - * Create a gradient from color a to color b of the specified type. - * - * @param size The desired size of the gradient. - * @param ca Color a - * @param cb Color b - * @param type The type of gradient. - * @return The gradient. - */ - static QImage gradient(const QSize &size, const QColor &ca, - const QColor &cb, GradientType type); - /** - * Creates an 8bit grayscale gradient suitable for use as an alpha channel - * using QImage::setAlphaChannel(). - * - * @param size The desired size of the gradient. - * @param ca The grayscale start value. - * @param cb The grayscale end value. - * @param type The type of gradient. - * @return The gradient. - */ - static QImage grayGradient(const QSize &size, unsigned char ca, - unsigned char cb, GradientType type); - /** - * Create an unbalanced gradient. An unbalanced gradient is a gradient - * where the transition from color a to color b is not linear, but in this - * case exponential. - * - * @param size The desired size of the gradient. - * @param ca Color a - * @param cb Color b - * @param type The type of gradient. - * @param xfactor The x decay length. Use a value between -200 and 200. - * @param yfactor The y decay length. - * @return The gradient. - */ - static QImage unbalancedGradient(const QSize &size, const QColor &ca, - const QColor &cb, GradientType type, - int xfactor=100, int yfactor=100); - /** - * Creates an 8bit grayscale gradient suitable for use as an alpha channel - * using QImage::setAlphaChannel(). - * - * @param size The desired size of the gradient. - * @param type The type of gradient. - * @param ca The grayscale start value. - * @param cb The grayscale end value. - * @param xfactor The x decay length. Use a value between -200 and 200. - * @param yfactor The y decay length. - * @return The gradient. - */ - static QImage grayUnbalancedGradient(const QSize &size, unsigned char ca, - unsigned char cb, GradientType type, - int xfactor=100, int yfactor=100); - /** - * Modulate the image with a color channel of another image. - * - * @param img The QImage to modulate and result. - * @param modImg The QImage to use for modulation. - * @param reverse Invert the meaning of image/modImage; result is image! - * @param type The modulation Type to use. - * @param factor The modulation amplitude; with 0 no effect [-200;200]. - * @param channel The RBG channel of image2 to use for modulation. - * @return Returns the image(), provided for convenience. - */ - static QImage& modulate(QImage &img, QImage &modImg, bool reverse, - ModulationType type, int factor, - RGBChannel channel); -}; - -#endif - diff -Nru syncwall-1.6.0/3rdparty/qimageblitz/qimageblitz.pc.cmake syncwall-1.7.4/3rdparty/qimageblitz/qimageblitz.pc.cmake --- syncwall-1.6.0/3rdparty/qimageblitz/qimageblitz.pc.cmake 2007-11-07 04:58:44.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qimageblitz/qimageblitz.pc.cmake 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -prefix=@CMAKE_INSTALL_PREFIX@ -exec_prefix=@CMAKE_INSTALL_PREFIX@ -libdir=@LIB_INSTALL_DIR@ -includedir=@INCLUDE_INSTALL_DIR@ - -Name: Blitz -Description: Blitz image effect and filter library -Version: @BLITZ_LIB_VERSION_STRING@ -Requires: QtGui -Libs: -L${libdir} -lqimageblitz -Cflags: -I${includedir} diff -Nru syncwall-1.6.0/3rdparty/qimageblitz/qimageblitz.pro syncwall-1.7.4/3rdparty/qimageblitz/qimageblitz.pro --- syncwall-1.6.0/3rdparty/qimageblitz/qimageblitz.pro 2012-01-24 04:13:50.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qimageblitz/qimageblitz.pro 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Mon Sep 17 09:51:23 2007 -###################################################################### - -TARGET = qimageblitz -TEMPLATE = lib - -win32 { -INSTALLS += target -target.path = /lib/ -} - -CONFIG += staticlib - -DEFINES += MAKE_QIMAGEBLITZ_LIB - -DEPENDPATH += . private -INCLUDEPATH += . private - -# Input -HEADERS += blitzcpu.h \ - config-externalasm.h \ - config-processor.h \ - qimageblitz.h \ - qimageblitz_export.h \ - private/blitz_p.h \ - private/inlinehsv.h \ - private/interpolate.h -SOURCES += blitz.cpp \ - blitzcpu.cpp \ - colors.cpp \ - convolve.cpp \ - gradient.cpp \ - histogram.cpp \ - scale.cpp \ - scalefilter.cpp - - -!win32 { -!macx { - -contains(QONF_FEATURES, mmx) { -SOURCES += asm_scale.S -} - -} -} - - - diff -Nru syncwall-1.6.0/3rdparty/qimageblitz/qimageblitz_export.h syncwall-1.7.4/3rdparty/qimageblitz/qimageblitz_export.h --- syncwall-1.6.0/3rdparty/qimageblitz/qimageblitz_export.h 2008-02-26 19:31:00.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qimageblitz/qimageblitz_export.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/* - Copyright (C) 2007 Christian Ehrlicher - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -#ifndef QIMAGEBLITZ_EXPORT_H -#define QIMAGEBLITZ_EXPORT_H - -#include - -#ifndef QIMAGEBLITZ_EXPORT -# ifdef Q_OS_WIN -# ifdef MAKE_QIMAGEBLITZ_LIB -# define QIMAGEBLITZ_EXPORT Q_DECL_EXPORT -# else -# define QIMAGEBLITZ_EXPORT Q_DECL_IMPORT -# endif -# else -# define QIMAGEBLITZ_EXPORT Q_DECL_EXPORT -# endif -#endif - -#endif // QIMAGEBLITZ_EXPORT_H diff -Nru syncwall-1.6.0/3rdparty/qimageblitz/scale.cpp syncwall-1.7.4/3rdparty/qimageblitz/scale.cpp --- syncwall-1.6.0/3rdparty/qimageblitz/scale.cpp 2008-02-26 19:31:00.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qimageblitz/scale.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,301 +0,0 @@ -#include -#include -#include "blitzcpu.h" -#include "qimageblitz.h" -#include -#include - -/* - * Copyright (C) 2004, 2005, 2007 Daniel M. Duley - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -/* OTHER CREDITS: - * - * This is the normal smoothscale method, based on Imlib2's smoothscale. - * - * Originally I took the algorithm used in NetPBM and Qt and added MMX/3dnow - * optimizations. It ran in about 1/2 the time as Qt. Then I ported Imlib's - * C algorithm and it ran at about the same speed as my MMX optimized one... - * Finally I ported Imlib's MMX version and it ran in less than half the - * time as my MMX algorithm, (taking only a quarter of the time Qt did). - * After further optimization it seems to run at around 1/6th. - * - * Changes include formatting, namespaces and other C++'ings, removal of old - * #ifdef'ed code, and removal of unneeded border calculation code. - * - * Imlib2 is (C) Carsten Haitzler and various contributors. The MMX code - * is by Willem Monsuwe . All other modifications are - * (C) Daniel M. Duley. - */ - -#if defined(__i386__) && ( defined(__GNUC__) || defined(__INTEL_COMPILER) ) -# if defined(HAVE_MMX) && defined(HAVE_EXTERNAL_ASM) -# define USE_MMX_INLINE_ASM -# endif -#endif - -namespace QImageScale{ - typedef struct __qimage_scale_info - { - int *xpoints; - unsigned int **ypoints; - int *xapoints, *yapoints; - int xup_yup; - } QImageScaleInfo; - - unsigned int** qimageCalcYPoints(unsigned int *src, int sw, int sh, - int dh); - int* qimageCalcXPoints(int sw, int dw); - int* qimageCalcApoints(int s, int d, int up); - QImageScaleInfo* qimageFreeScaleInfo(QImageScaleInfo *isi); - QImageScaleInfo *qimageCalcScaleInfo(const QImage &img, int sw, int sh, - int dw, int dh, char aa); -} - -#ifdef USE_MMX_INLINE_ASM -extern "C" { - void __qimageScale_mmx_AARGBA(QImageScale::QImageScaleInfo *isi, - unsigned int *dest, int dxx, int dyy, - int dx, int dy, int dw, int dh, - int dow, int sow); -} -#endif - -using namespace QImageScale; - -QImage Blitz::smoothScale(QImage &src, int w, int h, - Qt::AspectRatioMode aspectRatio) -{ - return(smoothScale(src, QSize(w, h), aspectRatio)); -} - -QImage Blitz::smoothScale(QImage &src, const QSize &sz, - Qt::AspectRatioMode aspectRatio) -{ -#ifdef USE_MMX_INLINE_ASM -#ifdef __GNUC__ -#warning Using MMX smoothscaling -#endif - if(BlitzCPUInfo::haveExtension(BlitzCPUInfo::MMX)){ - QImage buffer; - QSize destSize(src.size()); - destSize.scale(sz, aspectRatio); - if(src.isNull() || !destSize.isValid()) - return(buffer); - if(src.depth() != 32){ - src = src.convertToFormat(src.hasAlphaChannel() ? - QImage::Format_ARGB32 : - QImage::Format_RGB32); - } - else if(src.format() == QImage::Format_ARGB32_Premultiplied) - src = src.convertToFormat(QImage::Format_ARGB32); - - QImageScaleInfo *scaleinfo = - qimageCalcScaleInfo(src, src.width(), src.height(), - destSize.width(), destSize.height(), true); - if(!scaleinfo) - return(buffer); - - buffer = QImage(destSize, src.format()); - __qimageScale_mmx_AARGBA(scaleinfo, (unsigned int *)buffer.scanLine(0), 0, 0, - 0, 0, destSize.width(), destSize.height(), - destSize.width(), src.width()); - qimageFreeScaleInfo(scaleinfo); - return(buffer); - } - else -#endif - { - return(src.scaled(sz, aspectRatio, Qt::SmoothTransformation)); - } -} - -// -// Code ported from Imlib... -// - -// FIXME: replace with qRed, etc... These work on pointers to pixels, not -// pixel values -#define A_VAL(p) ((unsigned char *)(p))[3] -#define R_VAL(p) ((unsigned char *)(p))[2] -#define G_VAL(p) ((unsigned char *)(p))[1] -#define B_VAL(p) ((unsigned char *)(p))[0] - -#define INV_XAP (256 - xapoints[x]) -#define XAP (xapoints[x]) -#define INV_YAP (256 - yapoints[dyy + y]) -#define YAP (yapoints[dyy + y]) - -unsigned int** QImageScale::qimageCalcYPoints(unsigned int *src, - int sw, int sh, int dh) -{ - unsigned int **p; - int i, j = 0; - int val, inc, rv = 0; - - if(dh < 0){ - dh = -dh; - rv = 1; - } - p = new unsigned int* [dh+1]; - - val = 0; - inc = (sh << 16) / dh; - for(i = 0; i < dh; i++){ - p[j++] = src + ((val >> 16) * sw); - val += inc; - } - if(rv){ - for(i = dh / 2; --i >= 0; ){ - unsigned int *tmp = p[i]; - p[i] = p[dh - i - 1]; - p[dh - i - 1] = tmp; - } - } - return(p); -} - -int* QImageScale::qimageCalcXPoints(int sw, int dw) -{ - int *p, i, j = 0; - int val, inc, rv = 0; - - if(dw < 0){ - dw = -dw; - rv = 1; - } - p = new int[dw+1]; - - val = 0; - inc = (sw << 16) / dw; - for(i = 0; i < dw; i++){ - p[j++] = (val >> 16); - val += inc; - } - - if(rv){ - for(i = dw / 2; --i >= 0; ){ - int tmp = p[i]; - p[i] = p[dw - i - 1]; - p[dw - i - 1] = tmp; - } - } - return(p); -} - -int* QImageScale::qimageCalcApoints(int s, int d, int up) -{ - int *p, i, j = 0, rv = 0; - - if(d < 0){ - rv = 1; - d = -d; - } - p = new int[d]; - - /* scaling up */ - if(up){ - int val, inc; - - val = 0; - inc = (s << 16) / d; - for(i = 0; i < d; i++){ - p[j++] = (val >> 8) - ((val >> 8) & 0xffffff00); - if((val >> 16) >= (s - 1)) - p[j - 1] = 0; - val += inc; - } - } - /* scaling down */ - else{ - int val, inc, ap, Cp; - val = 0; - inc = (s << 16) / d; - Cp = ((d << 14) / s) + 1; - for(i = 0; i < d; i++){ - ap = ((0x100 - ((val >> 8) & 0xff)) * Cp) >> 8; - p[j] = ap | (Cp << 16); - j++; - val += inc; - } - } - if(rv){ - int tmp; - for(i = d / 2; --i >= 0; ){ - tmp = p[i]; - p[i] = p[d - i - 1]; - p[d - i - 1] = tmp; - } - } - return(p); -} - -QImageScaleInfo* QImageScale::qimageFreeScaleInfo(QImageScaleInfo *isi) -{ - if(isi){ - delete[] isi->xpoints; - delete[] isi->ypoints; - delete[] isi->xapoints; - delete[] isi->yapoints; - delete isi; - } - return(NULL); -} - -QImageScaleInfo* QImageScale::qimageCalcScaleInfo(const QImage &img, - int sw, int sh, - int dw, int dh, char aa) -{ - QImageScaleInfo *isi; - int scw, sch; - - scw = dw * img.width() / sw; - sch = dh * img.height() / sh; - - isi = new QImageScaleInfo; - if(!isi) - return(NULL); - memset(isi, 0, sizeof(QImageScaleInfo)); - - isi->xup_yup = (qAbs(dw) >= sw) + ((qAbs(dh) >= sh) << 1); - - isi->xpoints = qimageCalcXPoints(img.width(), scw); - if(!isi->xpoints) - return(qimageFreeScaleInfo(isi)); - isi->ypoints = qimageCalcYPoints((unsigned int *)img.scanLine(0), - img.width(), img.height(), sch); - if (!isi->ypoints) - return(qimageFreeScaleInfo(isi)); - if(aa){ - isi->xapoints = qimageCalcApoints(img.width(), scw, isi->xup_yup & 1); - if(!isi->xapoints) - return(qimageFreeScaleInfo(isi)); - isi->yapoints = qimageCalcApoints(img.height(), sch, isi->xup_yup & 2); - if(!isi->yapoints) - return(qimageFreeScaleInfo(isi)); - } - return(isi); -} - diff -Nru syncwall-1.6.0/3rdparty/qimageblitz/scalefilter.cpp syncwall-1.7.4/3rdparty/qimageblitz/scalefilter.cpp --- syncwall-1.6.0/3rdparty/qimageblitz/scalefilter.cpp 2012-01-01 04:35:46.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qimageblitz/scalefilter.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,726 +0,0 @@ -/* - Copyright (C) 2004, 2005, 2007 - Daniel M. Duley - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -/* - Portions of this software are were originally based on ImageMagick's - algorithms. ImageMagick is copyrighted under the following conditions: - -Copyright (C) 2003 ImageMagick Studio, a non-profit organization dedicated to -making software imaging solutions freely available. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files ("ImageMagick"), to deal -in ImageMagick without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of ImageMagick, and to permit persons to whom the ImageMagick is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of ImageMagick. - -The software is provided "as is", without warranty of any kind, express or -implied, including but not limited to the warranties of merchantability, -fitness for a particular purpose and noninfringement. In no event shall -ImageMagick Studio be liable for any claim, damages or other liability, -whether in an action of contract, tort or otherwise, arising from, out of or -in connection with ImageMagick or the use or other dealings in ImageMagick. - -Except as contained in this notice, the name of the ImageMagick Studio shall -not be used in advertising or otherwise to promote the sale, use or other -dealings in ImageMagick without prior written authorization from the -ImageMagick Studio. -*/ - -#include "qimageblitz.h" -#include - -/** - * This is a port of the ImageMagick scaling functions from resize.c. - * - * The most signficant change is ImageMagick uses a function pointer for the - * filter type. This is called usually a couple times in a loop for each - * horizontal and vertical coordinate. I changed this into a switch statement - * that does each type with inline functions. More code but faster. - */ - -#define MagickEpsilon 1.0e-6 -#define MagickPI 3.14159265358979323846264338327950288419716939937510 - -namespace BlitzScaleFilter{ - typedef struct{ - float weight; - unsigned int pixel; - } ContributionInfo; - - bool horizontalFilter(QImage *srcImg, QImage *destImg, - float x_factor, float blur, - ContributionInfo *contribution, - Blitz::ScaleFilterType filter); - bool verticalFilter(QImage *srcImg, QImage *destImg, - float y_factor, float blur, - ContributionInfo *contribution, - Blitz::ScaleFilterType filter); - - // These arrays were moved from their respective functions because they - // are inline - static const float - J1Pone[] = { - 0.581199354001606143928050809e+21f, - -0.6672106568924916298020941484e+20f, - 0.2316433580634002297931815435e+19f, - -0.3588817569910106050743641413e+17f, - 0.2908795263834775409737601689e+15f, - -0.1322983480332126453125473247e+13f, - 0.3413234182301700539091292655e+10f, - -0.4695753530642995859767162166e+7f, - 0.270112271089232341485679099e+4f - }, - J1Qone[] = { - 0.11623987080032122878585294e+22f, - 0.1185770712190320999837113348e+20f, - 0.6092061398917521746105196863e+17f, - 0.2081661221307607351240184229e+15f, - 0.5243710262167649715406728642e+12f, - 0.1013863514358673989967045588e+10f, - 0.1501793594998585505921097578e+7f, - 0.1606931573481487801970916749e+4f, - 0.1e+1 - }; - - static const float - P1Pone[] = { - 0.352246649133679798341724373e+5f, - 0.62758845247161281269005675e+5f, - 0.313539631109159574238669888e+5f, - 0.49854832060594338434500455e+4f, - 0.2111529182853962382105718e+3f, - 0.12571716929145341558495e+1f - }, - P1Qone[] = { - 0.352246649133679798068390431e+5f, - 0.626943469593560511888833731e+5f, - 0.312404063819041039923015703e+5f, - 0.4930396490181088979386097e+4f, - 0.2030775189134759322293574e+3f, - 0.1e+1 - }; - - static const float - Q1Pone[] = { - 0.3511751914303552822533318e+3f, - 0.7210391804904475039280863e+3f, - 0.4259873011654442389886993e+3f, - 0.831898957673850827325226e+2f, - 0.45681716295512267064405e+1f, - 0.3532840052740123642735e-1f - }, - Q1Qone[] = { - 0.74917374171809127714519505e+4f, - 0.154141773392650970499848051e+5f, - 0.91522317015169922705904727e+4f, - 0.18111867005523513506724158e+4f, - 0.1038187585462133728776636e+3f, - 0.1e+1 - }; - - static const float filterSupport[Blitz::SincFilter+1] = { - /*Undefined*/ 0.0f, - /*Point*/ 0.0f, - /*Box*/ 0.5f, - /*Triangle*/ 1.0f, - /*Hermite*/ 1.0f, - /*Hanning*/ 1.0f, - /*Hamming*/ 1.0f, - /*Blackman*/ 1.0f, - /*Gaussian*/ 1.25f, - /*Quadratic*/ 1.5f, - /*Cubic*/ 2.0f, - /*Catrom*/ 2.0f, - /*Mitchell*/ 2.0f, - /*Lanczos*/ 3.0f, - /*BlackmanBessel*/ 3.2383f, - /*BlackmanSinc*/ 4.0f - }; - - inline float J1(float x){ - float p, q; - p=J1Pone[8]; q=J1Qone[8]; - for(int i=7; i >= 0; i--){ - p=p*x*x+J1Pone[i]; - q=q*x*x+J1Qone[i]; - } - return(p/q); - } - - inline float P1(float x){ - float p, q; - p=P1Pone[5]; q=P1Qone[5]; - for(int i=4; i >= 0; i--){ - p=p*(8.0/x)*(8.0/x)+P1Pone[i]; - q=q*(8.0/x)*(8.0/x)+P1Qone[i]; - } - return(p/q); - } - - inline float Q1(float x){ - float p, q; - p=Q1Pone[5]; q=Q1Qone[5]; - for(int i=4; i >= 0; i--){ - p=p*(8.0/x)*(8.0/x)+Q1Pone[i]; - q=q*(8.0/x)*(8.0/x)+Q1Qone[i]; - } - return(p/q); - } - - inline float BesselOrderOne(float x){ - float p, q; - if(x == 0.0) - return(0.0); - p = x; - if(x < 0.0) - x = (-x); - if(x < 8.0) - return(p*J1(x)); - q = std::sqrt((float) (2.0/(MagickPI*x)))*(P1(x)*(1.0/std::sqrt(2.0)*(std::sin(x)- - std::cos(x)))-8.0/x*Q1(x)*(-1.0/std::sqrt(2.0)*(std::sin(x)+ - std::cos(x)))); - if (p < 0.0) - q=(-q); - return(q); - } - - inline float Bessel(const float x, const float /*support*/){ - if(x == 0.0) - return((float)(MagickPI/4.0)); - return(BesselOrderOne(MagickPI*x)/(2.0*x)); - } - - inline float Sinc(const float x, const float /*support*/){ - if(x == 0.0) - return(1.0); - return(std::sin(MagickPI*x)/(MagickPI*x)); - } - - inline float Blackman(const float x, const float /*support*/){ - return(0.42+0.5*std::cos(MagickPI*x)+0.08*std::cos(2*MagickPI*x)); - } - - inline float BlackmanBessel(const float x,const float support){ - return(Blackman(x/support,support)*Bessel(x,support)); - } - - inline float BlackmanSinc(const float x, const float support){ - return(Blackman(x/support,support)*Sinc(x,support)); - } - - inline float Box(const float x, const float /*support*/){ - if(x < -0.5) - return(0.0); - if(x < 0.5) - return(1.0); - return(0.0); - } - - inline float Catrom(const float x, const float /*support*/){ - if(x < -2.0) - return(0.0); - if(x < -1.0) - return(0.5*(4.0+x*(8.0+x*(5.0+x)))); - if(x < 0.0) - return(0.5*(2.0+x*x*(-5.0-3.0*x))); - if(x < 1.0) - return(0.5*(2.0+x*x*(-5.0+3.0*x))); - if(x < 2.0) - return(0.5*(4.0+x*(-8.0+x*(5.0-x)))); - return(0.0); - } - - inline float Cubic(const float x, const float /*support*/){ - if(x < -2.0) - return(0.0); - if(x < -1.0) - return((2.0+x)*(2.0+x)*(2.0+x)/6.0); - if(x < 0.0) - return((4.0+x*x*(-6.0-3.0*x))/6.0); - if(x < 1.0) - return((4.0+x*x*(-6.0+3.0*x))/6.0); - if(x < 2.0) - return((2.0-x)*(2.0-x)*(2.0-x)/6.0); - return(0.0); - } - - inline float Gaussian(const float x, const float /*support*/){ - return(std::exp((float)(-2.0*x*x))*std::sqrt(2.0/MagickPI)); - } - - inline float Hanning(const float x, const float /*support*/){ - return(0.5+0.5*std::cos(MagickPI*(double) x)); - } - - inline float Hamming(const float x, const float /*support*/){ - return(0.54+0.46*std::cos(MagickPI*(double) x)); - } - - inline float Hermite(const float x, const float /*support*/){ - if(x < -1.0) - return(0.0); - if(x < 0.0) - return((2.0*(-x)-3.0)*(-x)*(-x)+1.0); - if(x < 1.0) - return((2.0*x-3.0)*x*x+1.0); - return(0.0); - } - - inline float Lanczos(const float x, const float support){ - if(x < -3.0) - return(0.0); - if(x < 0.0) - return(Sinc(-x,support)*Sinc(-x/3.0,support)); - if(x < 3.0) - return(Sinc(x,support)*Sinc(x/3.0,support)); - return(0.0); - } - - inline float Mitchell(const float x, const float /*support*/){ -#define B (1.0/3.0) -#define C (1.0/3.0) -#define P0 (( 6.0- 2.0*B )/6.0) -#define P2 ((-18.0+12.0*B+ 6.0*C)/6.0) -#define P3 (( 12.0- 9.0*B- 6.0*C)/6.0) -#define Q0 (( 8.0*B+24.0*C)/6.0) -#define Q1 (( -12.0*B-48.0*C)/6.0) -#define Q2 (( 6.0*B+30.0*C)/6.0) -#define Q3 (( - 1.0*B- 6.0*C)/6.0) - if(x < -2.0) - return(0.0); - if(x < -1.0) - return(Q0-x*(Q1-x*(Q2-x*Q3))); - if(x < 0.0) - return(P0+x*x*(P2-x*P3)); - if(x < 1.0) - return(P0+x*x*(P2+x*P3)); - if(x < 2.0) - return(Q0+x*(Q1+x*(Q2+x*Q3))); - return(0.0); - } - - inline float Quadratic(const float x, const float /*support*/){ - if(x < -1.5) - return(0.0); - if(x < -0.5) - return(0.5*(x+1.5)*(x+1.5)); - if(x < 0.5) - return(0.75-x*x); - if(x < 1.5) - return(0.5*(x-1.5)*(x-1.5)); - return(0.0); - } - - inline float Triangle(const float x, const float /*support*/){ - if(x < -1.0) - return(0.0); - if(x < 0.0) - return(1.0+x); - if(x < 1.0) - return(1.0-x); - return(0.0); - } -} - -using namespace BlitzScaleFilter; - - -// -// Horizontal and vertical filters -// - -bool BlitzScaleFilter::horizontalFilter(QImage *srcImg, - QImage *destImg, - float x_factor, float blur, - ContributionInfo *contribution, - Blitz::ScaleFilterType filter) -{ - int n, start, stop, i, x, y; - float center, density, scale, support; - float r, g, b, a; - QRgb *srcData = (QRgb *)srcImg->bits(); - QRgb *destData = (QRgb *)destImg->bits(); - int sw = srcImg->width(); - int dw = destImg->width(); - QRgb pixel; - - scale = blur*qMax(1.0/x_factor, 1.0); - support = scale*filterSupport[filter]; - if(support <= 0.5){ - support = float(0.5+MagickEpsilon); - scale = 1.0; - } - scale = 1.0/scale; - - for(x=0; x < destImg->width(); ++x){ - center = (float) (x+0.5)/x_factor; - start = (int)qMax((double)center-support+0.5, (double)0.0); - stop = (int)qMin((double)center+support+0.5, (double)srcImg->width()); - density=0.0; - - for(n=0; n < (stop-start); ++n){ - contribution[n].pixel = start+n; - switch(filter){ - case Blitz::UndefinedFilter: - default: - contribution[n].weight = - Box(scale*((float)(start+n)-center+0.5), - filterSupport[filter]); - break; - case Blitz::PointFilter: - contribution[n].weight = - Box(scale*((float)(start+n)-center+0.5), - filterSupport[filter]); - break; - case Blitz::BoxFilter: - contribution[n].weight = - Box(scale*((float)(start+n)-center+0.5), - filterSupport[filter]); - break; - case Blitz::TriangleFilter: - contribution[n].weight = - Triangle(scale*((float)(start+n)-center+0.5), - filterSupport[filter]); - break; - case Blitz::HermiteFilter: - contribution[n].weight = - Hermite(scale*((float)(start+n)-center+0.5), - filterSupport[filter]); - break; - case Blitz::HanningFilter: - contribution[n].weight = - Hanning(scale*((float)(start+n)-center+0.5), - filterSupport[filter]); - break; - case Blitz::HammingFilter: - contribution[n].weight = - Hamming(scale*((float)(start+n)-center+0.5), - filterSupport[filter]); - break; - case Blitz::BlackmanFilter: - contribution[n].weight = - Blackman(scale*((float)(start+n)-center+0.5), - filterSupport[filter]); - break; - case Blitz::GaussianFilter: - contribution[n].weight = - Gaussian(scale*((float)(start+n)-center+0.5), - filterSupport[filter]); - break; - case Blitz::QuadraticFilter: - contribution[n].weight = - Quadratic(scale*((float)(start+n)-center+0.5), - filterSupport[filter]); - break; - case Blitz::CubicFilter: - contribution[n].weight = - Cubic(scale*((float)(start+n)-center+0.5), - filterSupport[filter]); - break; - case Blitz::CatromFilter: - contribution[n].weight = - Catrom(scale*((float)(start+n)-center+0.5), - filterSupport[filter]); - break; - case Blitz::MitchellFilter: - contribution[n].weight = - Mitchell(scale*((float)(start+n)-center+0.5), - filterSupport[filter]); - break; - case Blitz::LanczosFilter: - contribution[n].weight = - Lanczos(scale*((float)(start+n)-center+0.5), - filterSupport[filter]); - break; - case Blitz::BesselFilter: - contribution[n].weight = - BlackmanBessel(scale*((float)(start+n)-center+0.5), - filterSupport[filter]); - break; - case Blitz::SincFilter: - contribution[n].weight = - BlackmanSinc(scale*((float)(start+n)-center+0.5), - filterSupport[filter]); - break; - } - density += contribution[n].weight; - } - - if((density != 0.0) && (density != 1.0)){ - // Normalize - density = 1.0/density; - for(i=0; i < n; ++i) - contribution[i].weight *= density; - } - - for(y=0; y < destImg->height(); ++y){ - r = g = b = a = 0; - for(i=0; i < n; ++i){ - pixel = *(srcData+(y*sw)+contribution[i].pixel); - r += qRed(pixel)*contribution[i].weight; - g += qGreen(pixel)*contribution[i].weight; - b += qBlue(pixel)*contribution[i].weight; - a += qAlpha(pixel)*contribution[i].weight; - } - r = r < 0 ? 0 : r > 255 ? 255 : r + 0.5; - g = g < 0 ? 0 : g > 255 ? 255 : g + 0.5; - b = b < 0 ? 0 : b > 255 ? 255 : b + 0.5; - a = a < 0 ? 0 : a > 255 ? 255 : a + 0.5; - *(destData+(y*dw)+x) = qRgba((unsigned char)r, - (unsigned char)g, - (unsigned char)b, - (unsigned char)a); - } - } - return(true); -} - -bool BlitzScaleFilter::verticalFilter(QImage *srcImg, - QImage *destImg, - float y_factor, float blur, - ContributionInfo *contribution, - Blitz::ScaleFilterType filter) -{ - int n, start, stop, i, x, y; - float center, density, scale, support; - float r, g, b, a; - QRgb *srcData = (QRgb *)srcImg->bits(); - QRgb *destData = (QRgb *)destImg->bits(); - int sw = srcImg->width(); - int dw = destImg->width(); - QRgb pixel; - - scale = blur*qMax(1.0/y_factor, 1.0); - support = scale*filterSupport[filter]; - if(support <= 0.5){ - support = float(0.5+MagickEpsilon); - scale = 1.0; - } - scale = 1.0/scale; - - for(y=0; y < destImg->height(); ++y){ - center = (float) (y+0.5)/y_factor; - start = (int)qMax((double)center-support+0.5, (double)0.0); - stop = (int)qMin((double)center+support+0.5, (double)srcImg->height()); - density=0.0; - - for(n=0; n < (stop-start); ++n){ - contribution[n].pixel = start+n; - switch(filter){ - case Blitz::UndefinedFilter: - default: - contribution[n].weight = - Box(scale*((float)(start+n)-center+0.5), - filterSupport[filter]); - break; - case Blitz::PointFilter: - contribution[n].weight = - Box(scale*((float)(start+n)-center+0.5), - filterSupport[filter]); - break; - case Blitz::BoxFilter: - contribution[n].weight = - Box(scale*((float)(start+n)-center+0.5), - filterSupport[filter]); - break; - - case Blitz::TriangleFilter: - contribution[n].weight = - Triangle(scale*((float)(start+n)-center+0.5), - filterSupport[filter]); - break; - case Blitz::HermiteFilter: - contribution[n].weight = - Hermite(scale*((float)(start+n)-center+0.5), - filterSupport[filter]); - break; - case Blitz::HanningFilter: - contribution[n].weight = - Hanning(scale*((float)(start+n)-center+0.5), - filterSupport[filter]); - break; - case Blitz::HammingFilter: - contribution[n].weight = - Hamming(scale*((float)(start+n)-center+0.5), - filterSupport[filter]); - break; - case Blitz::BlackmanFilter: - contribution[n].weight = - Blackman(scale*((float)(start+n)-center+0.5), - filterSupport[filter]); - break; - case Blitz::GaussianFilter: - contribution[n].weight = - Gaussian(scale*((float)(start+n)-center+0.5), - filterSupport[filter]); - break; - case Blitz::QuadraticFilter: - contribution[n].weight = - Quadratic(scale*((float)(start+n)-center+0.5), - filterSupport[filter]); - break; - case Blitz::CubicFilter: - contribution[n].weight = - Cubic(scale*((float)(start+n)-center+0.5), - filterSupport[filter]); - break; - case Blitz::CatromFilter: - contribution[n].weight = - Catrom(scale*((float)(start+n)-center+0.5), - filterSupport[filter]); - break; - case Blitz::MitchellFilter: - contribution[n].weight = - Mitchell(scale*((float)(start+n)-center+0.5), - filterSupport[filter]); - break; - case Blitz::LanczosFilter: - contribution[n].weight = - Lanczos(scale*((float)(start+n)-center+0.5), - filterSupport[filter]); - break; - case Blitz::BesselFilter: - contribution[n].weight = - BlackmanBessel(scale*((float)(start+n)-center+0.5), - filterSupport[filter]); - break; - case Blitz::SincFilter: - contribution[n].weight = - BlackmanSinc(scale*((float)(start+n)-center+0.5), - filterSupport[filter]); - break; - } - density += contribution[n].weight; - } - - if((density != 0.0) && (density != 1.0)){ - // Normalize - density = 1.0/density; - for(i=0; i < n; ++i) - contribution[i].weight *= density; - } - - for(x=0; x < destImg->width(); ++x){ - r = g = b = a = 0; - for(i=0; i < n; ++i){ - pixel = *(srcData+(contribution[i].pixel*sw)+x); - r += qRed(pixel)*contribution[i].weight; - g += qGreen(pixel)*contribution[i].weight; - b += qBlue(pixel)*contribution[i].weight; - a += qAlpha(pixel)*contribution[i].weight; - } - r = r < 0 ? 0 : r > 255 ? 255 : r + 0.5; - g = g < 0 ? 0 : g > 255 ? 255 : g + 0.5; - b = b < 0 ? 0 : b > 255 ? 255 : b + 0.5; - a = a < 0 ? 0 : a > 255 ? 255 : a + 0.5; - *(destData+(y*dw)+x) = qRgba((unsigned char)r, - (unsigned char)g, - (unsigned char)b, - (unsigned char)a); - } - } - return(true); -} - -QImage Blitz::smoothScaleFilter(QImage &img, int w, int h, - float blur, ScaleFilterType filter, - Qt::AspectRatioMode aspectRatio) -{ - return(smoothScaleFilter(img, QSize(w, h), blur, filter, aspectRatio)); -} - -QImage Blitz::smoothScaleFilter(QImage &img, const QSize &sz, - float blur, ScaleFilterType filter, - Qt::AspectRatioMode aspectRatio) -{ - QSize destSize(img.size()); - destSize.scale(sz, aspectRatio); - if(img.isNull() || !destSize.isValid()) - return(img); - int dw = destSize.width(); - int dh = destSize.height(); - - if(img.depth() != 32){ - img = img.convertToFormat(img.hasAlphaChannel() ? - QImage::Format_ARGB32 : - QImage::Format_RGB32); - } - else if(img.format() == QImage::Format_ARGB32_Premultiplied) - img = img.convertToFormat(QImage::Format_ARGB32); - - QImage buffer(destSize, img.hasAlphaChannel() ? - QImage::Format_ARGB32 : QImage::Format_RGB32); - - ContributionInfo *contribution; - float support, x_factor, x_support, y_factor, y_support; - int i; - - // - // Allocate filter contribution info. - // - x_factor= (float)buffer.width()/img.width(); - y_factor= (float)buffer.height()/img.height(); - i = (int)LanczosFilter; - if(filter != UndefinedFilter) - i = (int)filter; - else - if((x_factor == 1.0) && (y_factor == 1.0)) - i = (int)PointFilter; - else - i = (int)MitchellFilter; - x_support = blur*qMax(1.0/x_factor, 1.0)*filterSupport[i]; - y_support = blur*qMax(1.0/y_factor, 1.0)*filterSupport[i]; - support = qMax(x_support, y_support); - if(support < filterSupport[i]) - support = filterSupport[i]; - contribution = - new ContributionInfo[(int)(2.0*qMax((double)support, (double)0.5)+3)]; - - // - // Scale - // - if((dw*(img.height()+dh)) > (dh*(img.width()+dw))){ - QImage tmp(dw, img.height(), buffer.format()); - horizontalFilter(&img, &tmp, x_factor, blur, contribution, filter); - verticalFilter(&tmp, &buffer, y_factor, blur, contribution, filter); - } - else{ - QImage tmp(img.width(), dh, buffer.format()); - verticalFilter(&img, &tmp, y_factor, blur, contribution, filter); - horizontalFilter(&tmp, &buffer, x_factor, blur, contribution, filter); - } - - delete[] contribution; - return(buffer); -} - - diff -Nru syncwall-1.6.0/3rdparty/qkeysequencewidget/designer-plugin/qkeysequencewidgetplugin.cpp syncwall-1.7.4/3rdparty/qkeysequencewidget/designer-plugin/qkeysequencewidgetplugin.cpp --- syncwall-1.6.0/3rdparty/qkeysequencewidget/designer-plugin/qkeysequencewidgetplugin.cpp 2010-08-17 11:53:52.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qkeysequencewidget/designer-plugin/qkeysequencewidgetplugin.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -/****************************************************************************** -Copyright (c) 2010, Artem Galichkin -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*******************************************************************************/ - -#include "qkeysequencewidget.h" -#include "qkeysequencewidgetplugin.h" - -#include - -QKeySequenceWidgetPlugin::QKeySequenceWidgetPlugin(QObject *parent) : - QObject(parent) -{ -} - -QString QKeySequenceWidgetPlugin::name() const -{ - return "QKeySequenceWidget"; -} - -QString QKeySequenceWidgetPlugin::includeFile() const -{ - return "qkeysequencewidget.h"; -} - -QString QKeySequenceWidgetPlugin::group() const -{ - return "Custom Widgets"; -} - -QIcon QKeySequenceWidgetPlugin::icon() const -{ - return QIcon(); -} - -QString QKeySequenceWidgetPlugin::toolTip() const -{ - return tr("Tool Tip"); -} - -QString QKeySequenceWidgetPlugin::whatsThis() const -{ - return ""; -} - -bool QKeySequenceWidgetPlugin::isContainer() const -{ - return false; -} - -QWidget* QKeySequenceWidgetPlugin::createWidget(QWidget *parent) -{ - return new QKeySequenceWidget(parent); -} - -Q_EXPORT_PLUGIN2(QKeySequnceWidgetPlugin, QKeySequenceWidgetPlugin) - diff -Nru syncwall-1.6.0/3rdparty/qkeysequencewidget/designer-plugin/qkeysequencewidgetplugin.h syncwall-1.7.4/3rdparty/qkeysequencewidget/designer-plugin/qkeysequencewidgetplugin.h --- syncwall-1.6.0/3rdparty/qkeysequencewidget/designer-plugin/qkeysequencewidgetplugin.h 2010-08-17 08:14:24.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qkeysequencewidget/designer-plugin/qkeysequencewidgetplugin.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -/****************************************************************************** -Copyright (c) 2010, Artem Galichkin -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*******************************************************************************/ - -#ifndef QKEYSEQUENCEWIDGETPLUGIN_H -#define QKEYSEQUENCEWIDGETPLUGIN_H - -#include -#include - -class QKeySequenceWidgetPlugin : public QObject, public QDesignerCustomWidgetInterface -{ -Q_OBJECT -Q_INTERFACES(QDesignerCustomWidgetInterface) -public: - explicit QKeySequenceWidgetPlugin(QObject *parent = 0); - - QString name() const; - QString includeFile() const; - QString group() const; - QIcon icon() const; - QString toolTip() const; - QString whatsThis() const; - - bool isContainer() const; - - QWidget* createWidget(QWidget *parent); - -}; - -#endif // QKEYSEQUENCEWIDGETPLUGIN_H diff -Nru syncwall-1.6.0/3rdparty/qkeysequencewidget/designer-plugin/qkeysequencewidgetplugin.pro syncwall-1.7.4/3rdparty/qkeysequencewidget/designer-plugin/qkeysequencewidgetplugin.pro --- syncwall-1.6.0/3rdparty/qkeysequencewidget/designer-plugin/qkeysequencewidgetplugin.pro 2010-08-20 13:58:38.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qkeysequencewidget/designer-plugin/qkeysequencewidgetplugin.pro 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -TARGET = QKeySequnceWidgetPlugin -TEMPLATE = lib -CONFIG += designer \ - plugin \ - debug_and_release -include(../qkeysequencewidget/qkeysequencewidget.pri) - -# install -target.path = $$[QT_INSTALL_PLUGINS]/designer -INSTALLS += target -HEADERS += qkeysequencewidgetplugin.h -SOURCES += qkeysequencewidgetplugin.cpp diff -Nru syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/annotated.html syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/annotated.html --- syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/annotated.html 2010-08-24 02:25:22.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/annotated.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ - - - - -QKeySequenceWidget: Class List - - - - - - -
-
-

Class List

-
-
-Here are the classes, structs, unions and interfaces with brief descriptions: - -
QKeySequenceWidgetThe QKeySequenceWidget is a widget to input a QKeySequence
-
- - - Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/bc_s.png and /tmp/OqecVKC_d5/syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/bc_s.png differ diff -Nru syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/class_q_key_sequence_widget-members.html syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/class_q_key_sequence_widget-members.html --- syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/class_q_key_sequence_widget-members.html 2010-08-24 02:25:22.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/class_q_key_sequence_widget-members.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ - - - - -QKeySequenceWidget: Member List - - - - - - -
-
-

QKeySequenceWidget Member List

-
-
-This is the complete list of members for QKeySequenceWidget, including all inherited members. - - - - - - - - - - - - - - - - - - - - - - - -
ClearButton enum nameQKeySequenceWidget
clearButtonIcon() const QKeySequenceWidget
ClearButtonShow (defined in QKeySequenceWidget)QKeySequenceWidget
clearButtonShow() const QKeySequenceWidget
clearKeySequence()QKeySequenceWidget [slot]
keyNotSupported() (defined in QKeySequenceWidget)QKeySequenceWidget [signal]
keySequence() const QKeySequenceWidget
keySequenceChanged(const QKeySequence &seq) (defined in QKeySequenceWidget)QKeySequenceWidget [signal]
noneText() const QKeySequenceWidget
NoShow enum valueQKeySequenceWidget
QKeySequenceWidget(QWidget *parent=0)QKeySequenceWidget [explicit]
QKeySequenceWidget(QKeySequence seq, QWidget *parent=0)QKeySequenceWidget [explicit]
QKeySequenceWidget(QString noneString, QWidget *parent=0)QKeySequenceWidget [explicit]
QKeySequenceWidget(QKeySequence seq, QString noneString, QWidget *parent=0)QKeySequenceWidget [explicit]
setClearButtonIcon(const QIcon &icon)QKeySequenceWidget [slot]
setClearButtonShow(QKeySequenceWidget::ClearButtonShow show)QKeySequenceWidget [slot]
setKeySequence(const QKeySequence &key)QKeySequenceWidget [slot]
setNoneText(const QString text)QKeySequenceWidget [slot]
setToolTip(const QString &tip) (defined in QKeySequenceWidget)QKeySequenceWidget
ShowLeft enum valueQKeySequenceWidget
ShowRight enum valueQKeySequenceWidget
sizeHint() const (defined in QKeySequenceWidget)QKeySequenceWidget
~QKeySequenceWidget()QKeySequenceWidget [virtual]
- - - diff -Nru syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/class_q_key_sequence_widget.html syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/class_q_key_sequence_widget.html --- syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/class_q_key_sequence_widget.html 2010-08-24 02:25:22.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/class_q_key_sequence_widget.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,468 +0,0 @@ - - - - -QKeySequenceWidget: QKeySequenceWidget Class Reference - - - - - - -
- -
-

QKeySequenceWidget Class Reference

-
-
- -

The QKeySequenceWidget is a widget to input a QKeySequence. -More...

- -

#include <qkeysequencewidget/src/qkeysequencewidget.h>

- -

List of all members.

- - - - - - - - - - - - - - - - - - - - - - - - - - -

-Public Types

enum  ClearButton {
-  NoShow = 0x00, -
-  ShowLeft = 0x01, -
-  ShowRight = 0x02 -
- }

-Public Slots

void setKeySequence (const QKeySequence &key)
void clearKeySequence ()
void setNoneText (const QString text)
void setClearButtonIcon (const QIcon &icon)
void setClearButtonShow (QKeySequenceWidget::ClearButtonShow show)

-Signals

-void keySequenceChanged (const QKeySequence &seq)
-void keyNotSupported ()

-Public Member Functions

 QKeySequenceWidget (QWidget *parent=0)
 QKeySequenceWidget (QKeySequence seq, QWidget *parent=0)
 QKeySequenceWidget (QString noneString, QWidget *parent=0)
 QKeySequenceWidget (QKeySequence seq, QString noneString, QWidget *parent=0)
virtual ~QKeySequenceWidget ()
-QSize sizeHint () const
-void setToolTip (const QString &tip)
QKeySequence keySequence () const
QString noneText () const
QIcon clearButtonIcon () const
QKeySequenceWidget::ClearButtonShow clearButtonShow () const

-Public Attributes

ClearButtonShow
-

Detailed Description

-

The QKeySequenceWidget is a widget to input a QKeySequence.

-

This widget lets the user choose a QKeySequence, which is usually used as a shortcut key. The recording is initiated by calling captureKeySequence() or the user clicking into the widget.

-
    // create new QKeySequenceWidget with empty sequence
-    QKeySequenceWidget *keyWidget = new QKeySequenceWidget;
-    
-    // Set sequence as "Ctrl+Alt+Space"
-    keyWidget->setJeySequence(QKeySequence("Ctrl+Alt+Space"));
-    
-    // set clear button position is left
-    setClearButtonShow(QKeySequenceWidget::ShowLeft);
-    
-    // set cutom clear button icon
-    setClearButtonIcon(QIcon("/path/to/icon.png"));
-    
-    // connecting keySequenceChanged signal to slot
-    connect(keyWidget, SIGNAL(keySequenceChanged(QKeySequence)), this, SLOT(slotKeySequenceChanged(QKeySequence)));
-

Member Enumeration Documentation

- -
-
- - - - -
enum ClearButton
-
-
- -

Modes of sohow ClearButton.

-
Enumerator:
- - - -
NoShow  -

Hide ClearButton

-
ShowLeft  -

ClearButton isow is left

-
ShowRight  -

ClearButton isow is left

-
-
-
- -
-
-

Constructor & Destructor Documentation

- -
-
- - - - - - - - - -
QKeySequenceWidget (QWidget *  parent = 0 )  [explicit]
-
-
-

Creates a QKeySequenceWidget object wuth parent and empty keySequence

- -
-
- -
-
- - - - - - - - - - - - - - - - - - -
QKeySequenceWidget (QKeySequence  seq,
QWidget *  parent = 0 
) [explicit]
-
-
-

Creates a QKeySequenceWidget object wuth parent and keysequence keySequence

- -
-
- -
-
- - - - - - - - - - - - - - - - - - -
QKeySequenceWidget (QString  noneString,
QWidget *  parent = 0 
) [explicit]
-
-
-

Creates a QKeySequenceWidget object wuth parent and string for noneString

- -
-
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
QKeySequenceWidget (QKeySequence  seq,
QString  noneString,
QWidget *  parent = 0 
) [explicit]
-
-
-

Creates a QKeySequenceWidget object wuth parent and keysequence keySequence and string for noneString

- -
-
- -
-
- - - - - - - - -
~QKeySequenceWidget ( )  [virtual]
-
-
-

Destroy a QKeySequenceWidget object

- -
-
-

Member Function Documentation

- -
-
- - - - - - - - -
QIcon clearButtonIcon ( )  const
-
-
-

Get clear buttom icon.

-
Returns:
QIcon object
- -
-
- -
-
- - - - - - - - -
QKeySequenceWidget::ClearButtonShow clearButtonShow ( )  const
-
-
-

Return mode of clear button dosplay.

-
Parameters:
- - -
show Dysplay mode of clear button (NoShow, ShowLeft or ShorRight)
-
-
- -
-
- -
-
- - - - - - - - -
void clearKeySequence ( )  [slot]
-
-
-

Clear key sequence.

- -
-
- -
-
- - - - - - - - -
QKeySequence keySequence ( )  const
-
-
-

Get current key sequence.

-
Returns:
Current key sequenc
- -
-
- -
-
- - - - - - - - -
QString noneText ( )  const
-
-
-

Get string for display when key sequence is undefined.

-
Returns:
Text string
- -
-
- -
-
- - - - - - - - - -
void setClearButtonIcon (const QIcon &  icon )  [slot]
-
-
-

Set custom icon for clear buttom.

-
Parameters:
- - -
icon QIcon object
-
-
- -
-
- -
-
- - - - - - - - - -
void setClearButtonShow (QKeySequenceWidget::ClearButtonShow  show )  [slot]
-
-
-

Setting mode of Clear Buttorn display.

-
Parameters:
- - -
show Position of clear button ClearButtornShow
-
-
- -
-
- -
-
- - - - - - - - - -
void setKeySequence (const QKeySequence &  key )  [slot]
-
-
-

Set the key sequence.

-
Parameters:
- - -
key Key sequence
-
-
-
See also:
clearKeySequence
- -
-
- -
-
- - - - - - - - - -
void setNoneText (const QString  text )  [slot]
-
-
-

Set string for display when key sequence is undefined.

-
Parameters:
- - -
text Text string
-
-
- -
-
-
- - - diff -Nru syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/classes.html syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/classes.html --- syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/classes.html 2010-08-24 02:25:22.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/classes.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ - - - - -QKeySequenceWidget: Alphabetical List - - - - - - -
-
-

Class Index

-
-
- - -
  Q  
-
QKeySequenceWidget   
-
- - - Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/closed.png and /tmp/OqecVKC_d5/syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/closed.png differ diff -Nru syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/doxygen.css syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/doxygen.css --- syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/doxygen.css 2010-08-24 02:25:22.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/doxygen.css 1970-01-01 00:00:00.000000000 +0000 @@ -1,656 +0,0 @@ -/* The standard CSS for doxygen */ - -body, table, div, p, dl { - font-family: Lucida Grande, Verdana, Geneva, Arial, sans-serif; - font-size: 12px; -} - -/* @group Heading Levels */ - -h1 { - font-size: 150%; -} - -h2 { - font-size: 120%; -} - -h3 { - font-size: 100%; -} - -dt { - font-weight: bold; -} - -div.multicol { - -moz-column-gap: 1em; - -webkit-column-gap: 1em; - -moz-column-count: 3; - -webkit-column-count: 3; -} - -p.startli, p.startdd, p.starttd { - margin-top: 2px; -} - -p.endli { - margin-bottom: 0px; -} - -p.enddd { - margin-bottom: 4px; -} - -p.endtd { - margin-bottom: 2px; -} - -/* @end */ - -caption { - font-weight: bold; -} - -span.legend { - font-size: 70%; - text-align: center; -} - -h3.version { - font-size: 90%; - text-align: center; -} - -div.qindex, div.navtab{ - background-color: #EBEFF6; - border: 1px solid #A3B4D7; - text-align: center; - margin: 2px; - padding: 2px; -} - -div.qindex, div.navpath { - width: 100%; - line-height: 140%; -} - -div.navtab { - margin-right: 15px; -} - -/* @group Link Styling */ - -a { - color: #3D578C; - font-weight: normal; - text-decoration: none; -} - -.contents a:visited { - color: #4665A2; -} - -a:hover { - text-decoration: underline; -} - -a.qindex { - font-weight: bold; -} - -a.qindexHL { - font-weight: bold; - background-color: #9CAFD4; - color: #ffffff; - border: 1px double #869DCA; -} - -.contents a.qindexHL:visited { - color: #ffffff; -} - -a.el { - font-weight: bold; -} - -a.elRef { -} - -a.code { - color: #4665A2; -} - -a.codeRef { - color: #4665A2; -} - -/* @end */ - -dl.el { - margin-left: -1cm; -} - -.fragment { - font-family: monospace, fixed; - font-size: 105%; -} - -pre.fragment { - border: 1px solid #C4CFE5; - background-color: #FBFCFD; - padding: 4px 6px; - margin: 4px 8px 4px 2px; - overflow: auto; - word-wrap: break-word; - font-size: 9pt; - line-height: 125%; -} - -div.ah { - background-color: black; - font-weight: bold; - color: #ffffff; - margin-bottom: 3px; - margin-top: 3px; - padding: 0.2em; - border: solid thin #333; - border-radius: 0.5em; - -webkit-border-radius: .5em; - -moz-border-radius: .5em; - -webkit-box-shadow: 2px 2px 3px #999; - -moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px; - background-image: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#000),color-stop(0.3, #444)); - background-image: -moz-linear-gradient(center top, #eee 0%, #444 40%, #000); -} - -div.groupHeader { - margin-left: 16px; - margin-top: 12px; - margin-bottom: 6px; - font-weight: bold; -} - -div.groupText { - margin-left: 16px; - font-style: italic; -} - -body { - background: white; - color: black; - margin: 0; -} - -div.contents { - margin-top: 10px; - margin-left: 10px; - margin-right: 10px; -} - -td.indexkey { - background-color: #EBEFF6; - font-weight: bold; - border: 1px solid #C4CFE5; - margin: 2px 0px 2px 0; - padding: 2px 10px; -} - -td.indexvalue { - background-color: #EBEFF6; - border: 1px solid #C4CFE5; - padding: 2px 10px; - margin: 2px 0px; -} - -tr.memlist { - background-color: #EEF1F7; -} - -p.formulaDsp { - text-align: center; -} - -img.formulaDsp { - -} - -img.formulaInl { - vertical-align: middle; -} - -div.center { - text-align: center; - margin-top: 0px; - margin-bottom: 0px; - padding: 0px; -} - -div.center img { - border: 0px; -} - -address.footer { - text-align: right; - padding-right: 12px; -} - -img.footer { - border: 0px; - vertical-align: middle; -} - -/* @group Code Colorization */ - -span.keyword { - color: #008000 -} - -span.keywordtype { - color: #604020 -} - -span.keywordflow { - color: #e08000 -} - -span.comment { - color: #800000 -} - -span.preprocessor { - color: #806020 -} - -span.stringliteral { - color: #002080 -} - -span.charliteral { - color: #008080 -} - -span.vhdldigit { - color: #ff00ff -} - -span.vhdlchar { - color: #000000 -} - -span.vhdlkeyword { - color: #700070 -} - -span.vhdllogic { - color: #ff0000 -} - -/* @end */ - -/* -.search { - color: #003399; - font-weight: bold; -} - -form.search { - margin-bottom: 0px; - margin-top: 0px; -} - -input.search { - font-size: 75%; - color: #000080; - font-weight: normal; - background-color: #e8eef2; -} -*/ - -td.tiny { - font-size: 75%; -} - -.dirtab { - padding: 4px; - border-collapse: collapse; - border: 1px solid #A3B4D7; -} - -th.dirtab { - background: #EBEFF6; - font-weight: bold; -} - -hr { - height: 0px; - border: none; - border-top: 1px solid #4A6AAA; -} - -hr.footer { - height: 1px; -} - -/* @group Member Descriptions */ - -table.memberdecls { - border-spacing: 0px; - padding: 0px; -} - -.mdescLeft, .mdescRight, -.memItemLeft, .memItemRight, -.memTemplItemLeft, .memTemplItemRight, .memTemplParams { - background-color: #F9FAFC; - border: none; - margin: 4px; - padding: 1px 0 0 8px; -} - -.mdescLeft, .mdescRight { - padding: 0px 8px 4px 8px; - color: #555; -} - -.memItemLeft, .memItemRight, .memTemplParams { - border-top: 1px solid #C4CFE5; -} - -.memItemLeft, .memTemplItemLeft { - white-space: nowrap; -} - -.memTemplParams { - color: #4665A2; - white-space: nowrap; -} - -/* @end */ - -/* @group Member Details */ - -/* Styles for detailed member documentation */ - -.memtemplate { - font-size: 80%; - color: #4665A2; - font-weight: normal; - margin-left: 3px; -} - -.memnav { - background-color: #EBEFF6; - border: 1px solid #A3B4D7; - text-align: center; - margin: 2px; - margin-right: 15px; - padding: 2px; -} - -.memitem { - padding: 0; - margin-bottom: 10px; -} - -.memname { - white-space: nowrap; - font-weight: bold; - margin-left: 6px; -} - -.memproto { - border-top: 1px solid #A8B8D9; - border-left: 1px solid #A8B8D9; - border-right: 1px solid #A8B8D9; - padding: 6px 0px 6px 0px; - color: #253555; - font-weight: bold; - text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); - /* firefox specific markup */ - -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; - -moz-border-radius-topright: 8px; - -moz-border-radius-topleft: 8px; - /* webkit specific markup */ - -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); - -webkit-border-top-right-radius: 8px; - -webkit-border-top-left-radius: 8px; - background-image:url('nav_f.png'); - background-repeat:repeat-x; - background-color: #E2E8F2; - -} - -.memdoc { - border-bottom: 1px solid #A8B8D9; - border-left: 1px solid #A8B8D9; - border-right: 1px solid #A8B8D9; - padding: 2px 5px; - background-color: #FBFCFD; - border-top-width: 0; - /* firefox specific markup */ - -moz-border-radius-bottomleft: 8px; - -moz-border-radius-bottomright: 8px; - -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; - background-image: -moz-linear-gradient(center top, #FFFFFF 0%, #FFFFFF 60%, #F7F8FB 95%, #EEF1F7); - /* webkit specific markup */ - -webkit-border-bottom-left-radius: 8px; - -webkit-border-bottom-right-radius: 8px; - -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); - background-image: -webkit-gradient(linear,center top,center bottom,from(#FFFFFF), color-stop(0.6,#FFFFFF), color-stop(0.60,#FFFFFF), color-stop(0.95,#F7F8FB), to(#EEF1F7)); -} - -.paramkey { - text-align: right; -} - -.paramtype { - white-space: nowrap; -} - -.paramname { - color: #602020; - white-space: nowrap; -} -.paramname em { - font-style: normal; -} - -/* @end */ - -/* @group Directory (tree) */ - -/* for the tree view */ - -.ftvtree { - font-family: sans-serif; - margin: 0px; -} - -/* these are for tree view when used as main index */ - -.directory { - font-size: 9pt; - font-weight: bold; - margin: 5px; -} - -.directory h3 { - margin: 0px; - margin-top: 1em; - font-size: 11pt; -} - -/* -The following two styles can be used to replace the root node title -with an image of your choice. Simply uncomment the next two styles, -specify the name of your image and be sure to set 'height' to the -proper pixel height of your image. -*/ - -/* -.directory h3.swap { - height: 61px; - background-repeat: no-repeat; - background-image: url("yourimage.gif"); -} -.directory h3.swap span { - display: none; -} -*/ - -.directory > h3 { - margin-top: 0; -} - -.directory p { - margin: 0px; - white-space: nowrap; -} - -.directory div { - display: none; - margin: 0px; -} - -.directory img { - vertical-align: -30%; -} - -/* these are for tree view when not used as main index */ - -.directory-alt { - font-size: 100%; - font-weight: bold; -} - -.directory-alt h3 { - margin: 0px; - margin-top: 1em; - font-size: 11pt; -} - -.directory-alt > h3 { - margin-top: 0; -} - -.directory-alt p { - margin: 0px; - white-space: nowrap; -} - -.directory-alt div { - display: none; - margin: 0px; -} - -.directory-alt img { - vertical-align: -30%; -} - -/* @end */ - -div.dynheader { - margin-top: 8px; -} - -address { - font-style: normal; - color: #2A3D61; -} - -table.doxtable { - border-collapse:collapse; -} - -table.doxtable td, table.doxtable th { - border: 1px solid #2D4068; - padding: 3px 7px 2px; -} - -table.doxtable th { - background-color: #374F7F; - color: #FFFFFF; - font-size: 110%; - padding-bottom: 4px; - padding-top: 5px; - text-align:left; -} - -.tabsearch { - top: 0px; - left: 10px; - height: 36px; - background-image: url('tab_b.png'); - z-index: 101; - overflow: hidden; - font-size: 13px; -} - -.navpath ul -{ - font-size: 11px; - background-image:url('tab_b.png'); - background-repeat:repeat-x; - height:30px; - line-height:30px; - color:#8AA0CC; - border:solid 1px #C2CDE4; - overflow:hidden; - margin:0px; - padding:0px; -} - -.navpath li -{ - list-style-type:none; - float:left; - padding-left:10px; - padding-right: 15px; - background-image:url('bc_s.png'); - background-repeat:no-repeat; - background-position:right; - color:#364D7C; -} - -.navpath a -{ - height:32px; - display:block; - text-decoration: none; - outline: none; -} - -.navpath a:hover -{ - color:#6884BD; -} - -div.summary -{ - float: right; - font-size: 8pt; - padding-right: 5px; - width: 50%; - text-align: right; -} - -div.summary a -{ - white-space: nowrap; -} - -div.header -{ - background-image:url('nav_h.png'); - background-repeat:repeat-x; - background-color: #F9FAFC; - margin: 0px; - border-bottom: 1px solid #C4CFE5; -} - -div.headertitle -{ - padding: 5px 5px 5px 10px; -} - Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/doxygen.png and /tmp/OqecVKC_d5/syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/doxygen.png differ diff -Nru syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/functions.html syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/functions.html --- syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/functions.html 2010-08-24 02:25:22.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/functions.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,87 +0,0 @@ - - - - -QKeySequenceWidget: Class Members - - - - - - -
-Here is a list of all documented class members with links to the class documentation for each member: -
- - - diff -Nru syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/functions_enum.html syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/functions_enum.html --- syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/functions_enum.html 2010-08-24 02:25:22.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/functions_enum.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ - - - - -QKeySequenceWidget: Class Members - Enumerations - - - - - - -
-
- - - diff -Nru syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/functions_eval.html syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/functions_eval.html --- syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/functions_eval.html 2010-08-24 02:25:22.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/functions_eval.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ - - - - -QKeySequenceWidget: Class Members - Enumerator - - - - - - -
-
- - - diff -Nru syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/functions_func.html syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/functions_func.html --- syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/functions_func.html 2010-08-24 02:25:22.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/functions_func.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ - - - - -QKeySequenceWidget: Class Members - Functions - - - - - - -
-
- - - diff -Nru syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/index.hhc syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/index.hhc --- syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/index.hhc 2010-08-24 02:25:22.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/index.hhc 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ - - - - - -
    -
  • -
  • -
      -
    -
  • -
      -
    -
  • -
      -
    • -
    -
  • -
- - diff -Nru syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/index.hhk syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/index.hhk --- syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/index.hhk 2010-08-24 02:25:22.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/index.hhk 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ - - - - - -
    -
  • -
  • -
  • -
  • -
  • -
  • -
  • -
  • -
  • -
  • -
  • -
      -
    • -
    • -
    • -
    • -
    • -
    • -
    • -
    • -
    • -
    • -
    • -
    • -
    • -
    • -
    • -
    • -
    • -
    • -
    • -
    -
  • -
  • -
  • -
  • -
  • -
  • -
  • -
  • -
  • -
  • -
- - diff -Nru syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/index.hhp syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/index.hhp --- syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/index.hhp 2010-08-24 02:25:22.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/index.hhp 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -[OPTIONS] -Compatibility=1.1 -Full-text search=Yes -Contents file=index.hhc -Default Window=main -Default topic=index.html -Index file=index.hhk -Language=0x409 English (United States) -Title=QKeySequenceWidget - -[WINDOWS] -main="QKeySequenceWidget","index.hhc","index.hhk","index.html","index.html",,,,,0x23520,,0x10387e,,,,,,,,0 - -[FILES] -index.html -pages.html -license.html -using.html -annotated.html -classes.html -functions.html -functions_func.html -functions_enum.html -functions_eval.html -class_q_key_sequence_widget.html -class_q_key_sequence_widget-members.html -tabs.css -tab_a.png -tab_b.png -tab_h.png -tab_s.png -nav_h.png -nav_f.png diff -Nru syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/index.html syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/index.html --- syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/index.html 2010-08-24 02:25:22.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/index.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ - - - - -QKeySequenceWidget: QKeySequenceWidget - - - - - - - -
-

1.0

-Overview

-

The QKeySequenceWidget is a widget to input a QKeySequence.

-

This widget lets the user choose a QKeySequence, which i s usually used as a shortcut key. The recording is initiated by calling captureKeySequence() or the user clicking into the widget.

-

The QKeySequenceWidget is based on code KKeySequenceWidget from KDE project. But it not needs kde libraries for building and working.

-

-Platforms

-

QKeySequenceWidget might be usable in all environments where you find Qt.
- QKeySequenceWidget requires Qt 4.5.x or newer.

-

-How to use the QKeySequenceWidget

-

Read the page Using the QKeySequenceWidget to obtain how to integrate SingleApplication with your project.

-

-License

-

QKeySequenceWidget is distributed under the terms of the BSD License.

-

-Author contacts

-

Author: Artem Galichkin

- -
- - - diff -Nru syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/license.html syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/license.html --- syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/license.html 2010-08-24 02:25:22.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/license.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ - - - - -QKeySequenceWidget: License - - - - - - -
-
-

License

-
-
-

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

-
    -
  • * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • -
  • * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • -
  • * Neither the name of the <organization> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
  • -
-

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT holder>=""> BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-
- - - Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/nav_f.png and /tmp/OqecVKC_d5/syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/nav_f.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/nav_h.png and /tmp/OqecVKC_d5/syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/nav_h.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/open.png and /tmp/OqecVKC_d5/syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/open.png differ diff -Nru syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/pages.html syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/pages.html --- syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/pages.html 2010-08-24 02:25:22.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/pages.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ - - - - -QKeySequenceWidget: Page Index - - - - - - -
-
-

Related Pages

-
-
-Here is a list of all related documentation pages: -
- - - Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/tab_a.png and /tmp/OqecVKC_d5/syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/tab_a.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/tab_b.png and /tmp/OqecVKC_d5/syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/tab_b.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/tab_h.png and /tmp/OqecVKC_d5/syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/tab_h.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/tab_s.png and /tmp/OqecVKC_d5/syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/tab_s.png differ diff -Nru syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/tabs.css syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/tabs.css --- syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/tabs.css 2010-08-24 02:25:22.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/tabs.css 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -.tabs, .tabs2, .tabs3 { - background-image: url('tab_b.png'); - width: 100%; - z-index: 101; - font-size: 13px; -} - -.tabs2 { - font-size: 10px; -} -.tabs3 { - font-size: 9px; -} - -.tablist { - margin: 0; - padding: 0; - display: table; -} - -.tablist li { - float: left; - display: table-cell; - background-image: url('tab_b.png'); - line-height: 36px; - list-style: none; -} - -.tablist a { - display: block; - padding: 0 20px; - font-weight: bold; - background-image:url('tab_s.png'); - background-repeat:no-repeat; - background-position:right; - color: #283A5D; - text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); - text-decoration: none; - outline: none; -} - -.tabs3 .tablist a { - padding: 0 10px; -} - -.tablist a:hover { - background-image: url('tab_h.png'); - background-repeat:repeat-x; - color: #fff; - text-shadow: 0px 1px 1px rgba(0, 0, 0, 1.0); - text-decoration: none; -} - -.tablist li.current a { - background-image: url('tab_a.png'); - background-repeat:repeat-x; - color: #fff; - text-shadow: 0px 1px 1px rgba(0, 0, 0, 1.0); -} diff -Nru syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/using.html syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/using.html --- syncwall-1.6.0/3rdparty/qkeysequencewidget/doc/html/using.html 2010-08-24 02:25:22.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qkeysequencewidget/doc/html/using.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ - - - - -QKeySequenceWidget: Using the QKeySequenceWidget - - - - - - -
-
-

Using the QKeySequenceWidget

-
-
-

How to use the QKeySequenceWidget

-

-In qmake-based projects

-

For using QKeySequenceWidget in your qmake-based project you must copy "qkeysequencewidget" directory to your source tree. And include qkeysequencewidget.pri into your *.pro file.

-

For example see projects in "demos" directoy .

-

-In qmake-based projects

-

For using QKeySequenceWidget in your CMake-based project you must coy "qkeysequencewidget" directory to your source tree. And include into main CMakeLists.txt this strings:

-
    -
  • add_subdirectory("path/to/qkeysequencewidget/")
  • -
  • include_directories("path/to/qkeysequencewidget/src")
  • -
-

Then add "qkeysequencewidget" into target_link_libraries section for your project.

-

For example, see CmakeLists.txt in root directoy.

-

-Sample code

-

This sample is shows a simple use of the widget in run-time.

-
    // create new QKeySequenceWidget with empty sequence
-    QKeySequenceWidget *keyWidget = new QKeySequenceWidget;
-    
-    // Set sequence as "Ctrl+Alt+Space"
-    keyWidget->setJeySequence(QKeySequence("Ctrl+Alt+Space"));
-    
-    // set clear button position is left
-    setClearButtonShow(QKeySequenceWidget::ShowLeft);
-    
-    // set cutom clear button icon
-    setClearButtonIcon(QIcon("/path/to/icon.png"));
-    
-    // connecting keySequenceChanged signal to slot
-    connect(keyWidget, SIGNAL(keySequenceChanged(QKeySequence)), this, SLOT(slotKeySequenceChanged(QKeySequence)));
-

-Plugin for QtDesigner

-

For using QKeySequenceWidget in QtDesigner you needs build designer-plugin. This located in "designer-plugin" directory.

-
    -
  • qmake
  • -
  • make
  • -
-

Installing QKeySeqenceWidgetPlughin^

-

In Linux:

-

make install (as root)

-

In Windows:

-

Copy QKeySequnceWidgetPlugin.dll to ${QT_DIR}/plugins/designer

-

It builded only qmake, CMake not supported.

-
- - - diff -Nru syncwall-1.6.0/3rdparty/qkeysequencewidget/qkeysequencewidget.cpp syncwall-1.7.4/3rdparty/qkeysequencewidget/qkeysequencewidget.cpp --- syncwall-1.6.0/3rdparty/qkeysequencewidget/qkeysequencewidget.cpp 2011-12-17 14:14:48.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qkeysequencewidget/qkeysequencewidget.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,575 +0,0 @@ -/****************************************************************************** -Copyright (c) 2010, Artem Galichkin -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*******************************************************************************/ - -#include -#include -#include -#include - -#include "qkeysequencewidget_p.h" -#include "qkeysequencewidget.h" - -/*! - Creates a QKeySequenceWidget object wuth \a parent and empty \a keySequence -*/ -QKeySequenceWidget::QKeySequenceWidget(QWidget *parent) : - QWidget(parent), d_ptr(new QKeySequenceWidgetPrivate()) -{ - Q_D(QKeySequenceWidget); - d->q_ptr = this; - d->init(QKeySequence(), QString()); - - _connectingSlots(); -} - -/*! - Creates a QKeySequenceWidget object wuth \a parent and keysequence \a keySequence - and string for \a noneString -*/ -QKeySequenceWidget::QKeySequenceWidget(QKeySequence seq, QString noneString, QWidget *parent) : - QWidget(parent), d_ptr(new QKeySequenceWidgetPrivate()) -{ - Q_D(QKeySequenceWidget); - d->q_ptr = this; -// qDebug() << "q_prt " << this; - d->init(seq, noneString); - _connectingSlots(); -} - -/*! - Creates a QKeySequenceWidget object wuth \a parent and keysequence \a keySequence -*/ -QKeySequenceWidget::QKeySequenceWidget(QKeySequence seq, QWidget *parent) : - QWidget(parent), d_ptr(new QKeySequenceWidgetPrivate()) -{ -// qDebug() << "widget constructor"; - Q_D(QKeySequenceWidget); - d->q_ptr = this; -// qDebug() << "q_prt " << this; - d->init(seq, QString()); - _connectingSlots(); - -} - -/*! - Creates a QKeySequenceWidget object wuth \a parent and string for \a noneString -*/ -QKeySequenceWidget::QKeySequenceWidget(QString noneString, QWidget *parent) : - QWidget(parent), d_ptr(new QKeySequenceWidgetPrivate()) -{ -// qDebug() << "widget constructor"; - Q_D(QKeySequenceWidget); - d->q_ptr = this; -// qDebug() << "q_prt " << this; - d->init(QKeySequence(), noneString); - - _connectingSlots(); -} - -/*! - Destroy a QKeySequenceWidget object -*/ -QKeySequenceWidget::~QKeySequenceWidget() -{ - delete d_ptr; -} - -QSize QKeySequenceWidget::sizeHint() const -{ - return d_ptr->shortcutButton->sizeHint(); -} - -/*! - Setting tooltip text to sequence button - \param tip Text string -*/ -void QKeySequenceWidget::setToolTip(const QString &tip) -{ - d_ptr->setToolTip(tip); -} - -/*! - Setting mode of Clear Buttorn display. - \param show Position of clear button \a ClearButtornShow - \sa clearButtonShow -*/ -void QKeySequenceWidget::setClearButtonShow(QKeySequenceWidget::ClearButtonShow show) -{ - d_ptr->showClearButton = show; - d_ptr->updateView(); -} - -/*! - Return mode of clear button dosplay. - \param show Display mode of clear button (NoShow, ShowLeft or ShorRight) - \sa setClearButtonShow -*/ -QKeySequenceWidget::ClearButtonShow QKeySequenceWidget::clearButtonShow() const -{ - return static_cast(d_ptr->showClearButton); -} - - -/*! - Set the key sequence. - \param key Key sequence - \sa clearKeySequence - */ -void QKeySequenceWidget::setKeySequence(const QKeySequence& key) -{ - if (d_ptr->isRecording == false) - { - d_ptr->oldSequence = d_ptr->currentSequence; - } - - d_ptr->doneRecording(); - - d_ptr->currentSequence = key; - d_ptr->doneRecording(); -} - -/*! - Get current key sequence. - \return Current key sequence - \sa setKeySequence - \sa clearKeySequence - */ -QKeySequence QKeySequenceWidget::keySequence() const -{ - return d_ptr->currentSequence; -} - -/*! - Clear key sequence. - \sa setKeySequence - */ -void QKeySequenceWidget::clearKeySequence() -{ - setKeySequence(QKeySequence()); -} - -// slot for capture key sequence starting (private) -void QKeySequenceWidget::captureKeySequence() -{ - d_ptr->startRecording(); -} - -/*! - Set string for display when key sequence is undefined. - \param text Text string - \sa noneText - */ -void QKeySequenceWidget::setNoneText(const QString text) -{ - d_ptr->noneSequenceText = text; - d_ptr->updateDisplayShortcut(); -} - -/*! - Get string for display when key sequence is undefined. - \return Text string - \sa setNoneText - */ -QString QKeySequenceWidget::noneText() const -{ - return d_ptr->noneSequenceText; -} - -/*! - Set custom icon for clear buttom. - \param icon QIcon object - \sa clearButtonIcon - */ -void QKeySequenceWidget::setClearButtonIcon(const QIcon &icon) -{ - d_ptr->clearButton->setIcon(icon); -} - -/*! - Get clear buttom icon. - \return QIcon object - \sa setClearButtonIcon - */ -QIcon QKeySequenceWidget::clearButtonIcon() const -{ - return d_ptr->clearButton->icon(); -} - -// connection internal signals & slots -void QKeySequenceWidget::_connectingSlots() -{ - // connect signals to slots - connect(d_ptr->clearButton, SIGNAL(clicked()), this, -SLOT(clearKeySequence())); - connect(&d_ptr->modifierlessTimeout, SIGNAL(timeout()), this, SLOT(doneRecording())); - connect(d_func()->shortcutButton, SIGNAL(clicked()), this, SLOT(captureKeySequence())); - -} - -// Private class implementation - -QKeySequenceWidgetPrivate::QKeySequenceWidgetPrivate() - : layout(NULL), clearButton(NULL), shortcutButton(NULL) -{ - Q_Q(QKeySequenceWidget); - Q_UNUSED(q); -} - -QKeySequenceWidgetPrivate::~QKeySequenceWidgetPrivate() -{ - -} - -void QKeySequenceWidgetPrivate::init(const QKeySequence keySeq, const QString noneStr) -{ - Q_Q(QKeySequenceWidget); - Q_UNUSED(q); - layout = new QHBoxLayout(q_func()); - layout->setMargin(0); - layout->setSpacing(1); - - clearButton = new QToolButton(q_func()); - clearButton->setText("x"); - - layout->addWidget(clearButton); - - shortcutButton = new QShortcutButton(this, q_func()); - - if (noneStr.isNull() == true) - { - noneSequenceText = "..."; - } - else - { - noneSequenceText = noneStr; - } - - q_ptr->clearKeySequence(); - currentSequence = keySeq; - - shortcutButton->setFocusPolicy(Qt::StrongFocus); - - layout->addWidget(shortcutButton); - - showClearButton = QKeySequenceWidget::ShowRight; - - clearButton->setIcon(QIcon(":/img/delete_32.png")); - - // unfocused clear button afyer created (small hack) - clearButton->setFocusPolicy(Qt::NoFocus); - - // update ui - updateDisplayShortcut(); - updateView(); -} - -// set tooltip only for seqyence button -void QKeySequenceWidgetPrivate::setToolTip(const QString &tip) -{ - shortcutButton->setToolTip(tip); - clearButton->setToolTip(""); -} - -// update the location of widgets -void QKeySequenceWidgetPrivate::updateView() -{ -// qDebug() << "update view "; - switch(showClearButton) - { - case QKeySequenceWidget::ShowLeft: - clearButton->setVisible(true); - layout->setDirection(QBoxLayout::LeftToRight); - break; - case QKeySequenceWidget::ShowRight: - clearButton->setVisible(true); - layout->setDirection(QBoxLayout::RightToLeft); - break; - case QKeySequenceWidget::NoShow: - clearButton->setVisible(false); - break; - default: - layout->setDirection(QBoxLayout::LeftToRight); - } -} - -void QKeySequenceWidgetPrivate::startRecording() -{ - numKey = 0; - modifierKeys = 0; - oldSequence = currentSequence; - currentSequence = QKeySequence(); - isRecording = true; - shortcutButton->setDown(true); - - shortcutButton->grabKeyboard(); - - if (!QWidget::keyboardGrabber()) - { - qWarning() << "Failed to grab the keyboard! Most likely qt's nograb option is active"; - } - - // update Shortcut display - updateDisplayShortcut(); -} - -void QKeySequenceWidgetPrivate::doneRecording() -{ - modifierlessTimeout.stop(); - - isRecording = false; - shortcutButton->releaseKeyboard(); - shortcutButton->setDown(false); - - // if sequence is not changed - if (currentSequence == oldSequence) - { - // update Shortcut display - updateDisplayShortcut(); - - return; - } - - // key sequnce is changed - emit q_ptr->keySequenceChanged(currentSequence); - - // update Shortcut display - updateDisplayShortcut(); -} - -inline void QKeySequenceWidgetPrivate::cancelRecording() -{ - currentSequence = oldSequence; - doneRecording(); -} - -inline void QKeySequenceWidgetPrivate::controlModifierlessTimout() -{ - if (numKey != 0 && !modifierKeys) - { - // No modifier key pressed currently. Start the timout - modifierlessTimeout.start(600); - } - else - { - // A modifier is pressed. Stop the timeout - modifierlessTimeout.stop(); - } -} - - -inline void QKeySequenceWidgetPrivate::keyNotSupported() -{ - Q_EMIT q_ptr->keyNotSupported(); -} - -void QKeySequenceWidgetPrivate::updateDisplayShortcut() -{ - // empty string if no non-modifier was pressed - QString str = currentSequence.toString(QKeySequence::NativeText); - str.replace('&', QLatin1String("&&")); // TODO -- check it - - if (isRecording == true) - { - if (modifierKeys) - { - if (str.isEmpty() == false) - str.append(","); - - if ((modifierKeys & Qt::META) ) - str += "Meta + "; - - if ((modifierKeys & Qt::CTRL) ) - str += "Ctrl + "; - - if ((modifierKeys & Qt::ALT) ) - str += "Alt + "; - - if ((modifierKeys & Qt::SHIFT) ) - str += "Shift + "; - } - - // make it clear that input is still going on - str.append("..."); - } - - // if is noting - if (str.isEmpty() == true) - { - str = noneSequenceText; - } - - shortcutButton->setText(str); -} - - -// QKeySequenceButton implementation -QSize QShortcutButton::sizeHint() const -{ - return QPushButton::sizeHint(); -} - -bool QShortcutButton::event(QEvent *e) -{ - if (d->isRecording == true && e->type() == QEvent::KeyPress) - { - keyPressEvent(static_cast(e)); - return true; - } - - if (d->isRecording && e->type() == QEvent::ShortcutOverride) - { - e->accept(); - return true; - } - - if (d->isRecording == true && e->type() == QEvent::FocusOut) - { - d->cancelRecording(); - return true; - } - - return QPushButton::event(e); -} - -void QShortcutButton::keyPressEvent(QKeyEvent *keyEvent) -{ -// qDebug() << "key pressed"; - int keyQt = keyEvent->key(); - -// Qt sometimes returns garbage keycodes, I observed -1, -// if it doesn't know a key. -// We cannot do anything useful with those (several keys have -1, -// indistinguishable) -// and QKeySequence.toString() will also yield a garbage string. - if (keyQt == -1) - { - // keu moy supported in Qt - d->cancelRecording(); - d->keyNotSupported(); - - } - - //get modifiers key - uint newModifiers = keyEvent->modifiers() & (Qt::SHIFT | Qt::CTRL | Qt::ALT -| Qt::META); - - // block autostart capturing on key_return or key space press - if (d->isRecording == false && (keyQt == Qt::Key_Return || keyQt == Qt::Key_Space)) - { - return; - } - - // We get events even if recording isn't active. - if (d->isRecording == false) - { - return QPushButton::keyPressEvent(keyEvent); - } - - keyEvent->accept(); - d->modifierKeys = newModifiers; - - // switching key type - switch(keyQt) - { - case Qt::Key_AltGr: //or else we get unicode salad - return; - case Qt::Key_Shift: - case Qt::Key_Control: - case Qt::Key_Alt: - case Qt::Key_Meta: - case Qt::Key_Menu: //unused (yes, but why?) - // TODO - check it key - d->controlModifierlessTimout(); - d->updateDisplayShortcut(); - break; - default: - { - - } - - // We now have a valid key press. - if (keyQt) - { - if ((keyQt == Qt::Key_Backtab) && (d->modifierKeys & Qt::SHIFT)) - { - keyQt = Qt::Key_Tab | d->modifierKeys; - } - else //if (d->isShiftAsModifierAllowed(keyQt)) - { - keyQt |= d->modifierKeys; - } - - if (d->numKey == 0) - { - d->currentSequence = QKeySequence(keyQt); - } - - d->numKey++; // increment nuber of pressed keys - - if (d->numKey >= 4) - { - d->doneRecording(); - return; - } - - d->controlModifierlessTimout(); - d->updateDisplayShortcut(); - } - } -} - -void QShortcutButton::keyReleaseEvent(QKeyEvent *keyEvent) -{ -// qDebug() << "key released"; - if (keyEvent->key() == -1) - { - // ignore garbage, see keyPressEvent() - return; - } - - // if not recording mode - if (d->isRecording == false) - { - return QPushButton::keyReleaseEvent(keyEvent); - } - - keyEvent->accept(); - - uint newModifiers = keyEvent->modifiers() & (Qt::SHIFT | Qt::CTRL | Qt::ALT | Qt::META); - - // if a modifier that belongs to the shortcut was released... - if ((newModifiers & d->modifierKeys) < d->modifierKeys) - { - d->modifierKeys = newModifiers; - d->controlModifierlessTimout(); - d->updateDisplayShortcut(); - } -} - - - diff -Nru syncwall-1.6.0/3rdparty/qkeysequencewidget/qkeysequencewidget.h syncwall-1.7.4/3rdparty/qkeysequencewidget/qkeysequencewidget.h --- syncwall-1.6.0/3rdparty/qkeysequencewidget/qkeysequencewidget.h 2010-08-24 01:23:44.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qkeysequencewidget/qkeysequencewidget.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,121 +0,0 @@ -/****************************************************************************** -Copyright (c) 2010, Artem Galichkin -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*******************************************************************************/ - -#ifndef QKEYSEQUENCEWIDGET_H -#define QKEYSEQUENCEWIDGET_H - -#include "qkeysequencewidget_p.h" - -#include -#include - -class QKeySequenceWidgetPrivate; - -/*! - \class QKeySequenceWidget - - \brief The QKeySequenceWidget is a widget to input a QKeySequence. - - This widget lets the user choose a QKeySequence, which is usually used as a - shortcut key. The recording is initiated by calling captureKeySequence() or - the user clicking into the widget. - - \code - // create new QKeySequenceWidget with empty sequence - QKeySequenceWidget *keyWidget = new QKeySequenceWidget; - - // Set sequence as "Ctrl+Alt+Space" - keyWidget->setJeySequence(QKeySequence("Ctrl+Alt+Space")); - - // set clear button position is left - setClearButtonShow(QKeySequenceWidget::ShowLeft); - - // set cutom clear button icon - setClearButtonIcon(QIcon("/path/to/icon.png")); - - // connecting keySequenceChanged signal to slot - connect(keyWidget, SIGNAL(keySequenceChanged(QKeySequence)), this, SLOT(slotKeySequenceChanged(QKeySequence))); - \endcode -*/ -class QKeySequenceWidget : public QWidget -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QKeySequenceWidget); - Q_PRIVATE_SLOT(d_func(), void doneRecording()) - - Q_PROPERTY(QKeySequence keySequence READ keySequence WRITE setKeySequence) - Q_PROPERTY(QKeySequenceWidget::ClearButtonShow clearButton READ clearButtonShow WRITE setClearButtonShow) - Q_PROPERTY(QString noneText READ noneText WRITE setNoneText) - Q_PROPERTY(QIcon clearButtonIcon READ clearButtonIcon WRITE setClearButtonIcon) - -private: - QKeySequenceWidgetPrivate * const d_ptr; - void _connectingSlots(); - -private Q_SLOTS: - void captureKeySequence(); - -public: - explicit QKeySequenceWidget(QWidget *parent = 0); - explicit QKeySequenceWidget(QKeySequence seq, QWidget *parent = 0); - explicit QKeySequenceWidget(QString noneString, QWidget *parent = 0); - explicit QKeySequenceWidget(QKeySequence seq, QString noneString, QWidget *parent = 0); - virtual ~QKeySequenceWidget(); - QSize sizeHint() const; - void setToolTip(const QString &tip); - QKeySequence keySequence() const; - QString noneText() const; - QIcon clearButtonIcon() const; - - /*! - \brief Modes of sohow ClearButton - */ - enum ClearButton { - NoShow = 0x00, /**< Hide ClearButton */ - ShowLeft = 0x01, /**< ClearButton isow is left */ - ShowRight = 0x02 /**< ClearButton isow is left */ - }; - - Q_DECLARE_FLAGS(ClearButtonShow, ClearButton); - Q_FLAGS(ClearButtonShow) - - QKeySequenceWidget::ClearButtonShow clearButtonShow() const; - -Q_SIGNALS: - void keySequenceChanged(const QKeySequence &seq); - void keyNotSupported(); - -public Q_SLOTS: - void setKeySequence(const QKeySequence &key); - void clearKeySequence(); - void setNoneText(const QString text); - void setClearButtonIcon(const QIcon& icon); - void setClearButtonShow(QKeySequenceWidget::ClearButtonShow show); -}; - -#endif // QKEYSEQUENCEWIDGET_H diff -Nru syncwall-1.6.0/3rdparty/qkeysequencewidget/qkeysequencewidget_p.h syncwall-1.7.4/3rdparty/qkeysequencewidget/qkeysequencewidget_p.h --- syncwall-1.6.0/3rdparty/qkeysequencewidget/qkeysequencewidget_p.h 2011-12-15 05:44:44.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qkeysequencewidget/qkeysequencewidget_p.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,123 +0,0 @@ -/****************************************************************************** -Copyright (c) 2010, Artem Galichkin -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*******************************************************************************/ - -#ifndef QKEYSEQUENCEWIDGET_P_H -#define QKEYSEQUENCEWIDGET_P_H - -#include -#include -#include -#include -#include -#include -#include - -#include "qkeysequencewidget.h" - -class QShortcutButton; -class QKeySequenceWidget; - -class QKeySequenceWidgetPrivate // : public QObject -{ - //Q_OBJECT - Q_DECLARE_PUBLIC(QKeySequenceWidget); - -public: - QKeySequenceWidget * q_ptr; - - QKeySequenceWidgetPrivate(); - virtual ~QKeySequenceWidgetPrivate(); - - void init(const QKeySequence keySeq, const QString noneStr); - void updateView(); - - void startRecording(); - void doneRecording(); - inline void cancelRecording(); - inline void controlModifierlessTimout(); - inline void keyNotSupported(); - - void updateDisplayShortcut(); - - // members - QKeySequence currentSequence; - QKeySequence oldSequence; - QString noneSequenceText; - - QTimer modifierlessTimeout; - - quint32 numKey; - quint32 modifierKeys; - - void setToolTip(const QString& tip); - - QHBoxLayout *layout; - QToolButton *clearButton; - QShortcutButton *shortcutButton; - - int showClearButton; - - bool isRecording; - -}; - -class QShortcutButton : public QPushButton -{ - Q_OBJECT - -public: - explicit QShortcutButton(QKeySequenceWidgetPrivate *p, QWidget *parent = 0) - : QPushButton(parent) - , d(p) - { -// qDebug() << "qShortcut button Create"; - // qDebug() << "parent----" << parent; - - // qDebug() << "visible " << isVisible(); - setMinimumWidth(QPushButton::minimumWidth()); - QPushButton::setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); - } - - virtual ~QShortcutButton() - { - // qDebug() << "qShortcut button delete"; - } - - virtual QSize sizeHint() const; - -protected: - // Reimplemented for internal reasons. - virtual bool event(QEvent *e); - virtual void keyPressEvent(QKeyEvent *keyEvent); - virtual void keyReleaseEvent(QKeyEvent *keyEvent); - -private: - QKeySequenceWidgetPrivate * const d; -}; - -#endif // QKEYSEQUENCEWIDGET_P_H diff -Nru syncwall-1.6.0/3rdparty/qt-extended/qexifimageheader.cpp syncwall-1.7.4/3rdparty/qt-extended/qexifimageheader.cpp --- syncwall-1.6.0/3rdparty/qt-extended/qexifimageheader.cpp 2012-05-15 11:58:34.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qt-extended/qexifimageheader.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,1970 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt scene graph research project. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This file was copied from Qt Extended 4.5 - -#include "qexifimageheader.h" - -#include -#include -#include -#include -#include -#include -#include - -/*! - \typedef QExifSRational - - A synonym for \c QPair representing a signed rational number as stored in EXIF - headers. The first integer in the pair is the numerator and the second the denominator. -*/ - -/*! - \typedef QExifURational - - A synonym for \c QPair representing an unsigned rational number as stored in - EXIF headers. The first integer in the pair is the numerator and the second the denominator. -*/ - -struct ExifIfdHeader -{ - quint16 tag; - quint16 type; - quint32 count; - union - { - quint32 offset; - quint8 offsetBytes[ 4 ]; - char offsetAscii[ 4 ]; - quint16 offsetShorts[ 2 ]; - }; -}; - -QDataStream &operator >>( QDataStream &stream, ExifIfdHeader &header ) -{ - stream >> header.tag; - stream >> header.type; - stream >> header.count; - - if( header.type == QExifValue::Byte && header.count <= 4 ) - { - stream.readRawData( header.offsetAscii, 4 ); - } - else if( header.type == QExifValue::Ascii && header.count <= 4 ) - { - stream.readRawData( header.offsetAscii, 4 ); - } - else if( header.type == QExifValue::Short && header.count <= 2 ) - { - stream >> header.offsetShorts[ 0 ]; - stream >> header.offsetShorts[ 1 ]; - } - else - { - stream >> header.offset; - } - - return stream; -} - - -class QExifValuePrivate : public QSharedData -{ -public: - QExifValuePrivate( quint16 t, int c ) - : type( t ), count( c ) - {} - virtual ~QExifValuePrivate(){} - - quint16 type; - int count; -}; - -class QExifByteValuePrivate : public QExifValuePrivate -{ -public: - QExifByteValuePrivate() - : QExifValuePrivate(QExifValue::Byte, 0) - { ref.ref(); } - QExifByteValuePrivate( const QVector< quint8 > &v ) - : QExifValuePrivate( QExifValue::Byte, v.size() ), value( v ) - {} - - QVector< quint8 > value; -}; - -class QExifUndefinedValuePrivate : public QExifValuePrivate -{ -public: - QExifUndefinedValuePrivate( const QByteArray &v ) - : QExifValuePrivate( QExifValue::Undefined, v.size() ), value( v ) - {} - - QByteArray value; -}; - -class QExifAsciiValuePrivate : public QExifValuePrivate -{ -public: - QExifAsciiValuePrivate( const QString &v ) - : QExifValuePrivate( QExifValue::Ascii, v.size() + 1 ), value( v ) - {} - - QString value; -}; - -class QExifShortValuePrivate : public QExifValuePrivate -{ -public: - QExifShortValuePrivate( const QVector< quint16 > &v ) - : QExifValuePrivate( QExifValue::Short, v.size() ), value( v ) - {} - - QVector< quint16 > value; -}; - -class QExifLongValuePrivate : public QExifValuePrivate -{ -public: - QExifLongValuePrivate( const QVector< quint32 > &v ) - : QExifValuePrivate( QExifValue::Long, v.size() ), value( v ) - {} - - QVector< quint32 > value; -}; - -class QExifSignedLongValuePrivate : public QExifValuePrivate -{ -public: - QExifSignedLongValuePrivate( const QVector< qint32 > &v ) - : QExifValuePrivate( QExifValue::SignedLong, v.size() ), value( v ) - {} - - QVector< qint32 > value; -}; - -class QExifRationalValuePrivate : public QExifValuePrivate -{ -public: - QExifRationalValuePrivate( const QVector< QExifURational > &v ) - : QExifValuePrivate( QExifValue::Rational, v.size() ), value( v ) - {} - - QVector< QExifURational > value; -}; - -class QExifSignedRationalValuePrivate : public QExifValuePrivate -{ -public: - QExifSignedRationalValuePrivate( const QVector< QExifSRational > &v ) - : QExifValuePrivate( QExifValue::SignedRational, v.size() ), value( v ) - {} - - QVector< QExifSRational > value; -}; - -Q_GLOBAL_STATIC(QExifByteValuePrivate,qExifValuePrivateSharedNull) - -/*! - \class QExifValue - \inpublicgroup QtBaseModule - \brief The QExifValue class represents data types found in EXIF image headers. - - Tag values in EXIF headers are stored as arrays of a limited number of data types. QExifValue - encapsulates a union of these types and provides conversions to and from appropriate Qt types. - - \section1 String encoding - - Most tags with string values in EXIF headers are ASCII encoded and have the Ascii value type, - but some tags allow other encodings. In this case the value type is Undefined and the encoding - of the text is given by the encoding function(). - - \section1 Date-time values - - Date-time values in EXIF headers are stored in ASCII encoded strings of the form - \c {yyyy:MM:dd HH:mm:ss}. Constructing a QExifValue from a QDateTime will perform this - conversion and likewise an appropriately formed QExifValue can be converted to a QDateTime - using the toDateTime() function. - - \sa QExifImageHeader - - \preliminary -*/ - -/*! - \enum QExifValue::Type - - Enumerates the possible types of EXIF values. - - \value Byte An unsigned 8 bit integer. - \value Ascii A null terminated ascii string. - \value Short An unsigned 16 bit integer. - \value Long An unsigned 32 bit integer. - \value Rational Two unsigned 32 bit integers, representing a the numerator and denominator of an unsigned rational number. - \value Undefined An array of 8 bit integers. - \value SignedLong A signed 32 bit integer. - \value SignedRational Two signed 32 bit integers representing the numerator and denominator of a signed rational number. -*/ - -/*! - \enum QExifValue::TextEncoding - - Enumerates the encodings of text strings in EXIF values of Undefined type. - - \value NoEncoding An ASCII string of Ascii type. - \value AsciiEncoding An ASCII string of Undefined type. - \value JisEncoding A JIS X208-1990 string of Undefined type. - \value UnicodeEncoding A Unicode string of Undefined type. - \value UndefinedEncoding An unspecified string encoding of Undefined type. Assumed to be the local 8-bit encoding. -*/ - -/*! - Constructs a null QExifValue. -*/ -QExifValue::QExifValue() - : d( qExifValuePrivateSharedNull() ) -{ -} - -/*! - Constructs a QExifValue with a \a value of type Byte. -*/ -QExifValue::QExifValue( quint8 value ) - : d( new QExifByteValuePrivate( QVector< quint8 >( 1, value ) ) ) -{ -} - -/*! - Constructs a QExifValue with an array of \a values of type Byte. -*/ -QExifValue::QExifValue( const QVector< quint8 > &values ) - : d( new QExifByteValuePrivate( values ) ) -{ -} - -/*! - Constructs a QExifValue with a \a value of type Ascii or Undefined. - - If the \a encoding is NoEncoding the value will be of type Ascii, otherwise it will be Undefined and the string - encoded using the given \a encoding. -*/ -QExifValue::QExifValue( const QString &value, TextEncoding encoding ) - : d( qExifValuePrivateSharedNull() ) -{ - switch( encoding ) - { - case AsciiEncoding: - d = new QExifUndefinedValuePrivate( QByteArray::fromRawData( "ASCII\0\0\0", 8 ) + value.toAscii() ); - break; - case JisEncoding: - { - QTextCodec *codec = QTextCodec::codecForName( "JIS X 0208" ); - if( codec ) - d = new QExifUndefinedValuePrivate( QByteArray::fromRawData( "JIS\0\0\0\0\0", 8 ) + codec->fromUnicode( value ) ); - } - break; - case UnicodeEncoding: - { - QTextCodec *codec = QTextCodec::codecForName( "UTF-16" ); - if( codec ) - d = new QExifUndefinedValuePrivate( QByteArray::fromRawData( "UNICODE\0", 8 ) + codec->fromUnicode( value ) ); - } - break; - case UndefinedEncoding: - d = new QExifUndefinedValuePrivate( QByteArray::fromRawData( "\0\0\0\0\0\0\0\\0", 8 ) + value.toLocal8Bit() ); - break; - default: - d = new QExifAsciiValuePrivate( value ); - } -} - -/*! - Constructs a QExifValue with a \a value of type Short. -*/ -QExifValue::QExifValue( quint16 value ) - : d( new QExifShortValuePrivate( QVector< quint16 >( 1, value ) ) ) -{ -} - -/*! - Constructs a QExifValue with an array of \a values of type Short. -*/ -QExifValue::QExifValue( const QVector< quint16 > &values ) - : d( new QExifShortValuePrivate( values ) ) -{ -} - -/*! - Constructs a QExifValue with a \a value of type Long. -*/ -QExifValue::QExifValue( quint32 value ) - : d( new QExifLongValuePrivate( QVector< quint32 >( 1, value ) ) ) -{ -} - -/*! - Constructs a QExifValue with an array of \a values of type Long. -*/ -QExifValue::QExifValue( const QVector< quint32 > &values ) - : d( new QExifLongValuePrivate( values ) ) -{ -} - -/*! - Constructs a QExifValue with a \a value of type Rational. -*/ -QExifValue::QExifValue( const QExifURational &value ) - : d( new QExifRationalValuePrivate( QVector< QExifURational >( 1, value ) ) ) -{ -} - -/*! - Constructs a QExifValue with an array of \a values of type Rational. -*/ -QExifValue::QExifValue( const QVector< QExifURational > &values ) - : d( new QExifRationalValuePrivate( values ) ) -{ -} - -/*! - Constructs a QExifValue with a \a value of type Undefined. -*/ -QExifValue::QExifValue( const QByteArray &value ) - : d( new QExifUndefinedValuePrivate( value ) ) -{ -} - -/*! - Constructs a QExifValue with a \a value of type SignedLong. -*/ -QExifValue::QExifValue( qint32 value ) - : d( new QExifSignedLongValuePrivate( QVector< qint32 >( 1, value ) ) ) -{ -} - -/*! - Constructs a QExifValue with an array of \a values of type SignedLong. -*/ -QExifValue::QExifValue( const QVector< qint32 > &values ) - : d( new QExifSignedLongValuePrivate( values ) ) -{ -} - -/*! - Constructs a QExifValue with a \a value of type SignedRational. -*/ -QExifValue::QExifValue( const QExifSRational &value ) - : d( new QExifSignedRationalValuePrivate( QVector< QExifSRational >( 1, value ) ) ) -{ -} - -/*! - Constructs a QExifValue with an array of \a values of type SignedRational. -*/ -QExifValue::QExifValue( const QVector< QExifSRational > &values ) - : d( new QExifSignedRationalValuePrivate( values ) ) -{ -} - -/*! - Constructs a QExifValue of type Ascii with an ascii string formatted from a date-time \a value. - - Date-times are stored as strings in the format \c {yyyy:MM:dd HH:mm:ss}. -*/ -QExifValue::QExifValue( const QDateTime &value ) - : d( new QExifAsciiValuePrivate( value.toString( QLatin1String( "yyyy:MM:dd HH:mm:ss" ) ) ) ) -{ -} - -/*! - Constructs a copy of the QExifValue \a other. -*/ -QExifValue::QExifValue( const QExifValue &other ) - : d( other.d ) -{ -} - -/*! - Assigns the value of \a other to a QExifValue. -*/ -QExifValue &QExifValue::operator =( const QExifValue &other ) -{ - d = other.d; - - return *this; -} - -/*! - Destroys a QExifValue. -*/ -QExifValue::~QExifValue() -{ -} - -/*! - Compares a QExifValue to \a other. Returns true if they are the same value and false otherwise. -*/ -bool QExifValue::operator ==( const QExifValue &other ) const -{ - return d == other.d; -} - -/*! - Returns true if a QExifValue has a null value and false otherwise. -*/ -bool QExifValue::isNull() const -{ - return d == qExifValuePrivateSharedNull(); -} - -/*! - Returns the type of a QExifValue. -*/ -int QExifValue::type() const -{ - return d->type; -} - -/*! - Returns the number of elements in a QExifValue. For ascii strings this is the length of the string - including the terminating null. -*/ -int QExifValue::count() const -{ - return d->count; -} - -/*! - Returns the encoding of strings stored in Undefined values. -*/ -QExifValue::TextEncoding QExifValue::encoding() const -{ - if( d->type == Undefined && d->count > 8 ) - { - QByteArray value = static_cast< const QExifUndefinedValuePrivate * >( d.constData() )->value; - - if( value.startsWith( QByteArray::fromRawData( "ASCII\0\0\0", 8 ) ) ) - return AsciiEncoding; - else if( value.startsWith( QByteArray::fromRawData( "JIS\0\0\0\0\0", 8 ) ) ) - return JisEncoding; - else if( value.startsWith( QByteArray::fromRawData( "UNICODE\0", 8 ) ) ) - return UnicodeEncoding; - else if( value.startsWith( QByteArray::fromRawData( "\0\0\0\0\0\0\0\0", 8 ) ) ) - return UndefinedEncoding; - } - return NoEncoding; -} - -/*! - Returns the value of a single element QExifValue of type Byte. -*/ -quint8 QExifValue::toByte() const -{ - return d->type == Byte && d->count == 1 - ? static_cast< const QExifByteValuePrivate * >( d.constData() )->value.at( 0 ) - : 0; -} - -/*! - Returns the value of a multiple element QExifValue of type Byte. -*/ -QVector< quint8 > QExifValue::toByteVector() const -{ - return d->type == Byte - ? static_cast< const QExifByteValuePrivate * >( d.constData() )->value - : QVector< quint8 >(); -} - -/*! - Returns the value of a QExifValue of type Ascii. -*/ -QString QExifValue::toString() const -{ - switch( d->type ) - { - case Ascii: - return static_cast< const QExifAsciiValuePrivate * >( d.constData() )->value; - case Undefined: - { - QByteArray string = static_cast< const QExifUndefinedValuePrivate * >( d.constData() )->value.mid( 8 ); - - switch( encoding() ) - { - case AsciiEncoding: - return QString::fromAscii( string.constData(), string.length() ); - case JisEncoding: - { - QTextCodec *codec = QTextCodec::codecForName( "JIS X 0208" ); - if( codec ) - return codec->toUnicode( string ); - } - break; - case UnicodeEncoding: - { - QTextCodec *codec = QTextCodec::codecForName( "UTF-16" ); - if( codec ) - return codec->toUnicode( string ); - } - case UndefinedEncoding: - return QString::fromLocal8Bit( string.constData(), string.length() ); - default: - break; - } - } - default: - return QString(); - } -} - -/*! - Returns the value of a single element QExifValue of type Byte or Short. -*/ -quint16 QExifValue::toShort() const -{ - if( d->count == 1 ) - { - switch( d->type ) - { - case Byte: - return static_cast< const QExifByteValuePrivate * >( d.constData() )->value.at( 0 ); - case Short: - return static_cast< const QExifShortValuePrivate * >( d.constData() )->value.at( 0 ); - } - } - return 0; -} - -/*! - Returns the value of a single element QExifValue of type Short. -*/ -QVector< quint16 > QExifValue::toShortVector() const -{ - return d->type == Short - ? static_cast< const QExifShortValuePrivate * >( d.constData() )->value - : QVector< quint16 >(); -} - -/*! - Returns the value of a single element QExifValue of type Byte, Short, Long, or SignedLong. -*/ -quint32 QExifValue::toLong() const -{ - if( d->count == 1 ) - { - switch( d->type ) - { - case Byte: - return static_cast< const QExifByteValuePrivate * >( d.constData() )->value.at( 0 ); - case Short: - return static_cast< const QExifShortValuePrivate * >( d.constData() )->value.at( 0 ); - case Long: - return static_cast< const QExifLongValuePrivate * >( d.constData() )->value.at( 0 ); - case SignedLong: - return static_cast< const QExifSignedLongValuePrivate * >( d.constData() )->value.at( 0 ); - } - } - return 0; -} - -/*! - Returns the value of a multiple element QExifValue of type Long. -*/ -QVector< quint32 > QExifValue::toLongVector() const -{ - return d->type == Long - ? static_cast< const QExifLongValuePrivate * >( d.constData() )->value - : QVector< quint32 >(); -} - -/*! - Returns the value of a multiple element QExifValue of type Rational. -*/ -QExifURational QExifValue::toRational() const -{ - return d->type == Rational && d->count == 1 - ? static_cast< const QExifRationalValuePrivate * >( d.constData() )->value.at( 0 ) - : QExifURational(); -} - -/*! - Returns the value of a multiple element QExifValue of type Rational. -*/ -QVector< QExifURational > QExifValue::toRationalVector() const -{ - return d->type == Rational - ? static_cast< const QExifRationalValuePrivate * >( d.constData() )->value - : QVector< QExifURational >(); -} - -/*! - Returns the value of a QExifValue of type Undefined. -*/ -QByteArray QExifValue::toByteArray() const -{ - switch( d->type ) - { - case Ascii: - return static_cast< const QExifAsciiValuePrivate * >( d.constData() )->value.toAscii(); - case Undefined: - return static_cast< const QExifUndefinedValuePrivate * >( d.constData() )->value; - default: - return QByteArray(); - } -} - -/*! - Returns the value of a single element QExifValue of type Byte, Short, Long, or SignedLong. -*/ -qint32 QExifValue::toSignedLong() const -{ - if( d->count == 1 ) - { - switch( d->type ) - { - case Byte: - return static_cast< const QExifByteValuePrivate * >( d.constData() )->value.at( 0 ); - case Short: - return static_cast< const QExifShortValuePrivate * >( d.constData() )->value.at( 0 ); - case Long: - return static_cast< const QExifLongValuePrivate * >( d.constData() )->value.at( 0 ); - case SignedLong: - return static_cast< const QExifSignedLongValuePrivate * >( d.constData() )->value.at( 0 ); - } - } - return 0; -} - -/*! - Returns the value of a multiple element QExifValue of type SignedLong. -*/ -QVector< qint32 > QExifValue::toSignedLongVector() const -{ - return d->type == SignedLong - ? static_cast< const QExifSignedLongValuePrivate * >( d.constData() )->value - : QVector< qint32 >(); -} - -/*! - Returns the value of a single element QExifValue of type SignedRational. -*/ -QExifSRational QExifValue::toSignedRational() const -{ - return d->type == SignedRational && d->count == 1 - ? static_cast< const QExifSignedRationalValuePrivate * >( d.constData() )->value.at( 0 ) - : QExifSRational(); -} - -/*! - Returns the value of a multiple element QExifValue of type SignedRational. -*/ -QVector< QExifSRational > QExifValue::toSignedRationalVector() const -{ - return d->type == SignedRational - ? static_cast< const QExifSignedRationalValuePrivate * >( d.constData() )->value - : QVector< QExifSRational >(); -} - -/*! - Returns the value of QExifValue storing a date-time. - - Date-times are stored as ascii strings in the format \c {yyyy:MM:dd HH:mm:ss}. -*/ -QDateTime QExifValue::toDateTime() const -{ - return d->type == Ascii && d->count == 20 - ? QDateTime::fromString( static_cast< const QExifAsciiValuePrivate * >( d.constData() )->value, QLatin1String( "yyyy:MM:dd HH:mm:ss" ) ) - : QDateTime(); -} - -class QExifImageHeaderPrivate -{ -public: - QSysInfo::Endian byteOrder; - mutable qint64 size; - QMap imageIfdValues; - QMap exifIfdValues; - QMap gpsIfdValues; - - QSize thumbnailSize; - QByteArray thumbnailData; - QExifValue thumbnailXResolution; - QExifValue thumbnailYResolution; - QExifValue thumbnailResolutionUnit; - QExifValue thumbnailOrientation; -}; - -/*! - \class QExifImageHeader - \inpublicgroup QtBaseModule - \brief The QExifImageHeader class provides functionality for reading and writing EXIF image headers. - - EXIF headers are a collection of properties that describe the image they're embedded in. - Each property is identified by a tag of which there are three kinds. \l {ImageTag}{Image tags} - which mostly describe the format (dimensions, resolution, orientation) but also include some - descriptive information (description, camera make and model, artist). \l {ExifExtendedTag} - {EXIF extended tags} which elaborate on some of the image tags and record the camera settings at - time of capture among other things. Finally there are \l {GpsTag}{GPS tags} which record the - location the image was captured. - - EXIF tags are typically found in JPEG images but may be found in other image formats. To read - headers from a JPEG image QExifImageHeader provides the loadFromJpeg() function, and the - complementary saveToJpeg() function for writing. To allow reading and writing arbitrary - formats QExifImageHeader provides the read() and write() functions which work with just the - EXIF header data itself. - - \preliminary -*/ - -/*! - \enum QExifImageHeader::ImageTag - Enumerates the TIFF image tag IDs defined in the EXIF specification. - - \value ImageWidth - \value ImageLength - \value BitsPerSample - \value Compression - \value PhotometricInterpretation - \value Orientation - \value SamplesPerPixel - \value PlanarConfiguration - \value YCbCrSubSampling - \value XResolution - \value YResolution - \value ResolutionUnit - \value StripOffsets - \value RowsPerStrip - \value StripByteCounts - \value TransferFunction - \value WhitePoint - \value PrimaryChromaciticies - \value YCbCrCoefficients - \value ReferenceBlackWhite - \value DateTime - \value ImageDescription - \value Make - \value Model - \value Software - \value Artist - \value Copyright -*/ - -/*! - \enum QExifImageHeader::ExifExtendedTag - Enumerates the extended EXIF tag IDs defined in the EXIF specification. - - \value ExifVersion - \value FlashPixVersion - \value ColorSpace - \value ComponentsConfiguration - \value CompressedBitsPerPixel - \value PixelXDimension - \value PixelYDimension - \value MakerNote - \value UserComment - \value RelatedSoundFile - \value DateTimeOriginal - \value DateTimeDigitized - \value SubSecTime - \value SubSecTimeOriginal - \value SubSecTimeDigitized - \value ImageUniqueId - \value ExposureTime - \value FNumber - \value ExposureProgram - \value SpectralSensitivity - \value ISOSpeedRatings - \value Oecf - \value ShutterSpeedValue - \value ApertureValue - \value BrightnessValue - \value ExposureBiasValue - \value MaxApertureValue - \value SubjectDistance - \value MeteringMode - \value LightSource - \value Flash - \value FocalLength - \value SubjectArea - \value FlashEnergy - \value SpatialFrequencyResponse - \value FocalPlaneXResolution - \value FocalPlaneYResolution - \value FocalPlaneResolutionUnit - \value SubjectLocation - \value ExposureIndex - \value SensingMethod - \value FileSource - \value SceneType - \value CfaPattern - \value CustomRendered - \value ExposureMode - \value WhiteBalance - \value DigitalZoomRatio - \value FocalLengthIn35mmFilm - \value SceneCaptureType - \value GainControl - \value Contrast - \value Saturation - \value Sharpness - \value DeviceSettingDescription - \value SubjectDistanceRange -*/ - -/*! - \enum QExifImageHeader::GpsTag - Enumerates the GPS tag IDs from the EXIF specification. - - \value GpsVersionId - \value GpsLatitudeRef - \value GpsLatitude - \value GpsLongitudeRef - \value GpsLongitude - \value GpsAltitudeRef - \value GpsAltitude - \value GpsTimeStamp - \value GpsSatellites - \value GpsStatus - \value GpsMeasureMode - \value GpsDop - \value GpsSpeedRef - \value GpsSpeed - \value GpsTrackRef - \value GpsTrack - \value GpsImageDirectionRef - \value GpsImageDirection - \value GpsMapDatum - \value GpsDestLatitudeRef - \value GpsDestLatitude - \value GpsDestLongitudeRef - \value GpsDestLongitude - \value GpsDestBearingRef - \value GpsDestBearing - \value GpsDestDistanceRef - \value GpsDestDistance - \value GpsProcessingMethod - \value GpsAreaInformation - \value GpsDateStamp - \value GpsDifferential -*/ - -/*! - Constructs a new EXIF image data editor. -*/ -QExifImageHeader::QExifImageHeader() - : d( new QExifImageHeaderPrivate ) -{ - d->byteOrder = QSysInfo::ByteOrder; - d->size = -1; -} - -/*! - Constructs a new EXIF image data editor and reads the meta-data from a JPEG image with the given \a fileName. -*/ -QExifImageHeader::QExifImageHeader(const QString &fileName) - : d(new QExifImageHeaderPrivate) -{ - d->byteOrder = QSysInfo::ByteOrder; - d->size = -1; - - loadFromJpeg(fileName); -} - -/*! - Destroys an EXIF image data editor. -*/ -QExifImageHeader::~QExifImageHeader() -{ - clear(); - - delete d; -} - -/*! - Reads meta-data from a JPEG image with the given \a fileName. - - Returns true if the data was successfully parsed and false otherwise. -*/ -bool QExifImageHeader::loadFromJpeg(const QString &fileName) -{ - QFile file(fileName); - - if(file.open(QIODevice::ReadOnly)) - return loadFromJpeg(&file); - else - return false; -} - -/*! - Reads meta-data from an I/O \a device containing a JPEG image. - - Returns true if the data was successfully parsed and false otherwise. -*/ -bool QExifImageHeader::loadFromJpeg(QIODevice *device) -{ - clear(); - - QByteArray exifData = extractExif(device); - - if (!exifData.isEmpty()) { - QBuffer buffer(&exifData); - - return buffer.open(QIODevice::ReadOnly) && read(&buffer); - } - - return false; -} - -/*! - Saves meta-data to a JPEG image with the given \a fileName. - - Returns true if the data was successfully written. -*/ -bool QExifImageHeader::saveToJpeg(const QString &fileName) const -{ - QFile file(fileName); - - if (file.open(QIODevice::ReadWrite)) - return saveToJpeg(&file); - else - return false; -} - -/*! - Save meta-data to the given I/O \a device. - - The device must be non-sequential and already contain a valid JPEG image. - - Returns true if the data was successfully written. -*/ -bool QExifImageHeader::saveToJpeg(QIODevice *device) const -{ - if( device->isSequential() ) - return false; - - QByteArray exif; - - { - QBuffer buffer( &exif ); - - if( !buffer.open( QIODevice::WriteOnly ) ) - return false; - - write( &buffer ); - - buffer.close(); - - exif = QByteArray::fromRawData( "Exif\0\0", 6 ) + exif; - } - - QDataStream stream( device ); - - stream.setByteOrder( QDataStream::BigEndian ); - - if( device->read( 2 ) != "\xFF\xD8" ) // Not a valid JPEG image. - return false; - - quint16 segmentId; - quint16 segmentLength; - - stream >> segmentId; - stream >> segmentLength; - - if( segmentId == 0xFFE0 ) - { - QByteArray jfif = device->read( segmentLength - 2 ); - - if( !jfif.startsWith( "JFIF" ) ) - return false; - - stream >> segmentId; - stream >> segmentLength; - - if( segmentId == 0xFFE1 ) - { - QByteArray oldExif = device->read( segmentLength - 2 ); - - if( !oldExif.startsWith( "Exif" ) ) - return false; - - int dSize = oldExif.size() - exif.size(); - - if( dSize > 0 ) - exif += QByteArray( dSize, '\0' ); - - QByteArray remainder = device->readAll(); - - device->seek( 0 ); - - stream << quint16( 0xFFD8 ); // SOI - stream << quint16( 0xFFE0 ); // APP0 - stream << quint16( jfif.size() + 2 ); - device->write( jfif ); - stream << quint16( 0xFFE1 ); //APP1 - stream << quint16( exif.size() + 2 ); - device->write( exif ); - device->write( remainder ); - } - else - { - QByteArray remainder = device->readAll(); - - device->seek( 0 ); - - stream << quint16( 0xFFD8 ); // SOI - stream << quint16( 0xFFE0 ); // APP0 - stream << quint16( jfif.size() + 2 ); - device->write( jfif ); - stream << quint16( 0xFFE1 ); //APP1 - stream << quint16( exif.size() + 2 ); - device->write( exif ); - stream << quint16( 0xFFE0 ); // APP0 - stream << segmentId; - stream << segmentLength; - device->write( remainder ); - } - } - else if( segmentId == 0xFFE1 ) - { - QByteArray oldExif = device->read( segmentLength - 2 ); - - if( !oldExif.startsWith( "Exif" ) ) - return false; - - int dSize = oldExif.size() - exif.size(); - - if( dSize > 0 ) - exif += QByteArray( dSize, '\0' ); - - QByteArray remainder = device->readAll(); - - device->seek( 0 ); - - stream << quint16( 0xFFD8 ); // SOI - stream << quint16( 0xFFE1 ); //APP1 - stream << quint16( exif.size() + 2 ); - device->write( exif ); - device->write( remainder ); - } - else - { - QByteArray remainder = device->readAll(); - - device->seek( 0 ); - - stream << quint16( 0xFFD8 ); // SOI - stream << quint16( 0xFFE1 ); //APP1 - stream << quint16( exif.size() + 2 ); - device->write( exif ); - stream << segmentId; - stream << segmentLength; - device->write( remainder ); - } - - return true; -} - -/*! - Returns the byte order of EXIF file. -*/ -QSysInfo::Endian QExifImageHeader::byteOrder() const -{ - return d->byteOrder; -} - - -quint32 QExifImageHeader::sizeOf(const QExifValue &value) const -{ - switch (value.type()) { - case QExifValue::Byte: - case QExifValue::Undefined: - return value.count() > 4 - ? 12 + value.count() - : 12; - case QExifValue::Ascii: - return value.count() > 4 - ? 12 + value.count() - : 12; - case QExifValue::Short: - return value.count() > 2 - ? 12 + value.count() * sizeof(quint16) - : 12; - case QExifValue::Long: - case QExifValue::SignedLong: - return value.count() > 1 - ? 12 + value.count() * sizeof(quint32) - : 12; - case QExifValue::Rational: - case QExifValue::SignedRational: - return value.count() > 0 - ? 12 + value.count() * sizeof(quint32) * 2 - : 12; - default: - return 0; - } -} - -template -quint32 QExifImageHeader::calculateSize(const QMap &values) const -{ - quint32 size = sizeof(quint16); - - foreach (const QExifValue &value, values) - size += sizeOf(value); - - return size; -} - -/*! - Returns the size of EXIF data in bytes. -*/ -qint64 QExifImageHeader::size() const -{ - if (d->size == -1) { - d->size - = 2 // Byte Order - + 2 // Marker - + 4 // Image Ifd offset - + 12 // ExifIfdPointer Ifd - + 4 // Thumbnail Ifd offset - + calculateSize(d->imageIfdValues) // Image headers and values. - + calculateSize(d->exifIfdValues); // Exif headers and values. - - if (!d->gpsIfdValues.isEmpty()) { - d->size - += 12 // GpsInfoIfdPointer Ifd - + calculateSize(d->gpsIfdValues); // Gps headers and values. - } - - if (!d->thumbnailData.isEmpty()) { - d->size - += 2 // Thumbnail Ifd count - + 12 // Compression Ifd - + 20 // XResolution Ifd - + 20 // YResolution Ifd - + 12 // ResolutionUnit Ifd - + 12 // JpegInterchangeFormat Ifd - + 12 // JpegInterchangeFormatLength Ifd - + d->thumbnailData.size(); // Thumbnail data size. - } - } - - return d->size; -} - -/*! - Clears all image meta-data. -*/ -void QExifImageHeader::clear() -{ - d->imageIfdValues.clear(); - d->exifIfdValues.clear(); - d->gpsIfdValues.clear(); - d->thumbnailData.clear(); - - d->size = -1; -} - -/*! - Returns a list of all image tags in an EXIF header. -*/ -QList QExifImageHeader::imageTags() const -{ - return d->imageIfdValues.keys(); -} - -/*! - Returns a list of all extended EXIF tags in a header. -*/ -QList QExifImageHeader::extendedTags() const -{ - return d->exifIfdValues.keys(); -} - -/*! - Returns a list of all GPS tags in an EXIF header. -*/ -QList QExifImageHeader::gpsTags() const -{ - return d->gpsIfdValues.keys(); -} - -/*! - Returns true if an EXIf header contains a value for an image \a tag and false otherwise. -*/ -bool QExifImageHeader::contains(ImageTag tag) const -{ - return d->imageIfdValues.contains(tag); -} - -/*! - Returns true if a header contains a a value for an extended EXIF \a tag and false otherwise. -*/ -bool QExifImageHeader::contains(ExifExtendedTag tag) const -{ - return d->exifIfdValues.contains(tag); -} - -/*! - Returns true if an EXIf header contains a value for a GPS \a tag and false otherwise. -*/ -bool QExifImageHeader::contains(GpsTag tag) const -{ - return d->gpsIfdValues.contains(tag); -} - -/*! - Removes the value for an image \a tag. -*/ -void QExifImageHeader::remove(ImageTag tag) -{ - d->imageIfdValues.remove(tag); - - d->size = -1; -} - -/*! - Removes the value for an extended EXIF \a tag. -*/ -void QExifImageHeader::remove(ExifExtendedTag tag) -{ - d->exifIfdValues.remove(tag); - - d->size = -1; -} - -/*! - Removes the value for a GPS \a tag. -*/ -void QExifImageHeader::remove(GpsTag tag) -{ - d->gpsIfdValues.remove(tag); - - d->size = -1; -} - -/*! - Returns the value for an image \a tag. -*/ -QExifValue QExifImageHeader::value(ImageTag tag) const -{ - return d->imageIfdValues.value(tag); -} - -/*! - Returns the value for an extended EXIF \a tag. -*/ -QExifValue QExifImageHeader::value(ExifExtendedTag tag) const -{ - return d->exifIfdValues.value(tag); -} - -/*! - Returns the value for a GPS tag. -*/ -QExifValue QExifImageHeader::value(GpsTag tag) const -{ - return d->gpsIfdValues.value(tag); -} - -/*! - Sets the \a value for an image \a tag. -*/ -void QExifImageHeader::setValue(ImageTag tag, const QExifValue &value) -{ - d->imageIfdValues[tag] = value; - - d->size = -1; -} - -/*! - Sets the \a value for an extended EXIF \a tag. -*/ -void QExifImageHeader::setValue(ExifExtendedTag tag, const QExifValue &value) -{ - d->exifIfdValues[tag] = value; - - d->size = -1; -} - -/*! - Sets the \a value for an GPS \a tag. -*/ -void QExifImageHeader::setValue(GpsTag tag, const QExifValue &value) -{ - d->gpsIfdValues[tag] = value; - - d->size = -1; -} - -/*! - Returns the image thumbnail. -*/ -QImage QExifImageHeader::thumbnail() const -{ - QImage image; - - image.loadFromData(d->thumbnailData, "JPG"); - - if (!d->thumbnailOrientation.isNull()) { - switch (d->thumbnailOrientation.toShort()) { - case 1: - return image; - case 2: - return image.transformed(QTransform().rotate(180, Qt::YAxis)); - case 3: - return image.transformed(QTransform().rotate(180, Qt::ZAxis)); - case 4: - return image.transformed(QTransform().rotate(180, Qt::XAxis)); - case 5: - return image.transformed(QTransform().rotate(180, Qt::YAxis).rotate(90, Qt::ZAxis)); - case 6: - return image.transformed(QTransform().rotate(90, Qt::ZAxis)); - case 7: - return image.transformed(QTransform().rotate(180, Qt::XAxis).rotate(90, Qt::ZAxis)); - case 8: - return image.transformed(QTransform().rotate(270, Qt::ZAxis)); - } - } - - return image; -} - -/*! - Sets the image \a thumbnail. -*/ -void QExifImageHeader::setThumbnail( const QImage &thumbnail ) -{ - if (!thumbnail.isNull()) { - QBuffer buffer; - - if (buffer.open(QIODevice::WriteOnly) && thumbnail.save(&buffer, "JPG")) { - buffer.close(); - - d->thumbnailSize = thumbnail.size(); - d->thumbnailData = buffer.data(); - d->thumbnailOrientation = QExifValue(); - } - } else { - d->thumbnailSize = QSize(); - d->thumbnailData = QByteArray(); - } - - d->size = -1; -} - -QByteArray QExifImageHeader::extractExif( QIODevice *device ) const -{ - QDataStream stream( device ); - - stream.setByteOrder( QDataStream::BigEndian ); - - if( device->read( 2 ) != "\xFF\xD8" ) - return QByteArray(); - - while( device->read( 2 ) != "\xFF\xE1" ) - { - if( device->atEnd() ) - return QByteArray(); - - quint16 length; - - stream >> length; - - device->seek( device->pos() + length - 2 ); - } - - quint16 length; - - stream >> length; - - if( device->read( 4 ) != "Exif" ) - return QByteArray(); - - device->read( 2 ); - - return device->read( length - 8 ); -} - - -QList QExifImageHeader::readIfdHeaders(QDataStream &stream) const -{ - QList headers; - - quint16 count; - - stream >> count; - - for (quint16 i = 0; i < count; i++) { - ExifIfdHeader header; - - stream >> header; - - headers.append(header); - } - - return headers; -} - -QExifValue QExifImageHeader::readIfdValue(QDataStream &stream, int startPos, const ExifIfdHeader &header) const -{ - switch (header.type) { - case QExifValue::Byte: - { - QVector value( header.count ); - - if (header.count > 4) { - stream.device()->seek(startPos + header.offset); - - for (quint32 i = 0; i < header.count; i++) - stream >> value[i]; - } else { - for( quint32 i = 0; i < header.count; i++ ) - value[ i ] = header.offsetBytes[ i ]; - - } - return QExifValue(value); - } - case QExifValue::Undefined: - if (header.count > 4) { - stream.device()->seek(startPos + header.offset); - - return QExifValue(stream.device()->read(header.count)); - } else { - return QExifValue(QByteArray::fromRawData(header.offsetAscii, header.count)); - } - case QExifValue::Ascii: - if (header.count > 4) { - stream.device()->seek(startPos + header.offset); - - QByteArray ascii = stream.device()->read(header.count); - - return QExifValue(QString::fromAscii(ascii.constData(), ascii.size() - 1)); - } else { - return QExifValue(QString::fromAscii(header.offsetAscii, header.count - 1)); - } - case QExifValue::Short: - { - QVector value(header.count); - - if (header.count > 2) { - stream.device()->seek(startPos + header.offset); - - for (quint32 i = 0; i < header.count; i++) - stream >> value[i]; - } else { - for (quint32 i = 0; i < header.count; i++) - value[i] = header.offsetShorts[i]; - - } - return QExifValue(value); - } - case QExifValue::Long: - { - QVector value(header.count); - - if (header.count > 1) { - stream.device()->seek(startPos + header.offset); - - for (quint32 i = 0; i < header.count; i++) - stream >> value[i]; - } else if(header.count == 1) { - value[0] = header.offset; - } - return QExifValue(value); - } - case QExifValue::SignedLong: - { - QVector value(header.count); - - if (header.count > 1) { - stream.device()->seek(startPos + header.offset); - - for (quint32 i = 0; i < header.count; i++) - stream >> value[i]; - } else if (header.count == 1) { - value[0] = header.offset; - } - return QExifValue(value); - } - break; - case QExifValue::Rational: - { - QVector value(header.count); - - stream.device()->seek(startPos + header.offset); - - for (quint32 i = 0; i < header.count; i++) - stream >> value[i]; - - return QExifValue(value); - } - case QExifValue::SignedRational: - { - QVector value(header.count); - - stream.device()->seek(startPos + header.offset); - - for(quint32 i = 0; i < header.count; i++) - stream >> value[i]; - - return QExifValue(value); - } - default: - qWarning() << "Invalid Ifd Type" << header.type; - - return QExifValue(); - } -} - -template QMap QExifImageHeader::readIfdValues( - QDataStream &stream, int startPos, const QList &headers) const -{ - QMap values; - - // This needs to be non-const so it works with gcc3 - QList headers_ = headers; - foreach (const ExifIfdHeader &header, headers_) - values[T(header.tag)] = readIfdValue(stream, startPos, header); - - return values; -} - -template -QMap QExifImageHeader::readIfdValues( - QDataStream &stream, int startPos, const QExifValue &pointer) const -{ - if (pointer.type() == QExifValue::Long && pointer.count() == 1) { - stream.device()->seek(startPos + pointer.toLong()); - - QList headers = readIfdHeaders(stream); - - return readIfdValues(stream, startPos, headers); - } else { - return QMap(); - } -} - - -/*! - Reads the contents of an EXIF header from an I/O \a device. - - Returns true if the header was read and false otherwise. - - \sa loadFromJpeg(), write() -*/ -bool QExifImageHeader::read(QIODevice *device) -{ - clear(); - - int startPos = device->pos(); - - QDataStream stream(device); - - QByteArray byteOrder = device->read(2); - - if (byteOrder == "II") { - d->byteOrder = QSysInfo::LittleEndian; - - stream.setByteOrder( QDataStream::LittleEndian ); - } else if (byteOrder == "MM") { - d->byteOrder = QSysInfo::BigEndian; - - stream.setByteOrder( QDataStream::BigEndian ); - } else { - return false; - } - - quint16 id; - quint32 offset; - - stream >> id; - stream >> offset; - - if (id != 0x002A) - return false; - - device->seek(startPos + offset); - - QList headers = readIfdHeaders(stream); - - stream >> offset; - - d->imageIfdValues = readIfdValues(stream, startPos, headers); - - QExifValue exifIfdPointer = d->imageIfdValues.take(ImageTag(ExifIfdPointer)); - QExifValue gpsIfdPointer = d->imageIfdValues.take(ImageTag(GpsInfoIfdPointer)); - - d->exifIfdValues = readIfdValues(stream, startPos, exifIfdPointer); - d->gpsIfdValues = readIfdValues(stream, startPos, gpsIfdPointer); - - d->exifIfdValues.remove(ExifExtendedTag(InteroperabilityIfdPointer)); - - if (offset) { - device->seek(startPos + offset); - - QMap thumbnailIfdValues = readIfdValues( - stream, startPos, readIfdHeaders( stream)); - - QExifValue jpegOffset = thumbnailIfdValues.value(JpegInterchangeFormat); - QExifValue jpegLength = thumbnailIfdValues.value(JpegInterchangeFormatLength); - - if (jpegOffset.type() == QExifValue::Long && jpegOffset.count() == 1 - && jpegLength.type() == QExifValue::Long && jpegLength.count() == 1) - { - device->seek(startPos + jpegOffset.toLong()); - - d->thumbnailData = device->read( jpegLength.toLong() ); - - d->thumbnailXResolution = thumbnailIfdValues.value(XResolution); - d->thumbnailYResolution = thumbnailIfdValues.value(YResolution); - d->thumbnailResolutionUnit = thumbnailIfdValues.value(ResolutionUnit); - d->thumbnailOrientation = thumbnailIfdValues.value(Orientation); - } - } - return true; -} - -quint32 QExifImageHeader::writeExifHeader(QDataStream &stream, quint16 tag, const QExifValue &value, quint32 offset) const -{ - stream << tag; - stream << quint16(value.type()); - stream << quint32(value.count()); - - switch (value.type()) { - case QExifValue::Byte: - if (value.count() <= 4) { - foreach (quint8 byte, value.toByteVector()) - stream << byte; - for (int j = value.count(); j < 4; j++) - stream << quint8(0); - } else { - stream << offset; - - offset += value.count(); - } - break; - case QExifValue::Undefined: - if (value.count() <= 4) { - stream.device()->write(value.toByteArray()); - - if ( value.count() < 4) - stream.writeRawData("\0\0\0\0", 4 - value.count()); - } else { - stream << offset; - - offset += value.count(); - } - break; - case QExifValue::Ascii: - if (value.count() <= 4) { - QByteArray bytes = value.toByteArray(); - - stream.writeRawData(bytes.constData(), value.count()); - if (value.count() < 4) - stream.writeRawData("\0\0\0\0", 4 - value.count()); - } else { - stream << offset; - - offset += value.count(); - } - break; - case QExifValue::Short: - if (value.count() <= 2) { - foreach (quint16 shrt, value.toShortVector()) - stream << shrt; - for (int j = value.count(); j < 2; j++) - stream << quint16(0); - } else { - stream << offset; - - offset += value.count() * sizeof(quint16); - } - break; - case QExifValue::Long: - if(value.count() == 0) { - stream << quint32(0); - } else if(value.count() == 1) { - stream << value.toLong(); - } else { - stream << offset; - - offset += value.count() * sizeof(quint32); - } - break; - case QExifValue::SignedLong: - if (value.count() == 0) { - stream << quint32( 0 ); - } else if (value.count() == 1) { - stream << value.toSignedLong(); - } else { - stream << offset; - - offset += value.count() * sizeof(qint32); - } - break; - case QExifValue::Rational: - if(value.count() == 0) { - stream << quint32(0); - } else { - stream << offset; - - offset += value.count() * sizeof(quint32) * 2; - } - break; - case QExifValue::SignedRational: - if (value.count() == 0) { - stream << quint32(0); - } else { - stream << offset; - - offset += value.count() * sizeof(qint32) * 2; - } - break; - default: - qWarning() << "Invalid Ifd Type" << value.type(); - stream << quint32(0); - } - - return offset; -} - -void QExifImageHeader::writeExifValue(QDataStream &stream, const QExifValue &value) const -{ - switch (value.type()) { - case QExifValue::Byte: - if (value.count() > 4) - foreach (quint8 byte, value.toByteVector()) - stream << byte; - break; - case QExifValue::Undefined: - if (value.count() > 4) - stream.device()->write(value.toByteArray()); - break; - case QExifValue::Ascii: - if (value.count() > 4) { - QByteArray bytes = value.toByteArray(); - - stream.writeRawData(bytes.constData(), bytes.size() + 1); - } - break; - case QExifValue::Short: - if (value.count() > 2) - foreach(quint16 shrt, value.toShortVector()) - stream << shrt; - break; - case QExifValue::Long: - if(value.count() > 1) - foreach (quint32 lng, value.toLongVector()) - stream << lng; - break; - case QExifValue::SignedLong: - if (value.count() > 1) - foreach(qint32 lng, value.toSignedLongVector()) - stream << lng; - break; - case QExifValue::Rational: - if (value.count() > 0) - foreach (QExifURational rational, value.toRationalVector()) - stream << rational; - break; - case QExifValue::SignedRational: - if (value.count() > 0) - foreach (QExifSRational rational, value.toSignedRationalVector()) - stream << rational; - break; - default: - qWarning() << "Invalid Ifd Type" << value.type(); - break; - } -} - -template quint32 QExifImageHeader::writeExifHeaders( - QDataStream &stream, const QMap &values, quint32 offset) const -{ - offset += values.count() * 12; - - for (typename QMap::const_iterator i = values.constBegin(); i != values.constEnd(); i++) - offset = writeExifHeader(stream, i.key(), i.value(), offset); - - return offset; -} - -template void QExifImageHeader::writeExifValues( - QDataStream &stream, const QMap &values) const -{ - for (typename QMap::const_iterator i = values.constBegin(); i != values.constEnd(); i++) - writeExifValue(stream, i.value()); -} - -/*! - Writes an EXIF header to an I/O \a device. - - Returns the total number of bytes written. -*/ -qint64 QExifImageHeader::write(QIODevice *device) const -{ -#ifndef QT_NO_DEBUG - qint64 startPos = device->pos(); -#endif - - QDataStream stream( device ); - - if (d->byteOrder == QSysInfo::LittleEndian) { - stream.setByteOrder( QDataStream::LittleEndian ); - - device->write("II", 2); - device->write("\x2A\x00", 2); - device->write("\x08\x00\x00\x00", 4); - } else if (d->byteOrder == QSysInfo::BigEndian) { - stream.setByteOrder(QDataStream::BigEndian); - - device->write("MM", 2); - device->write("\x00\x2A", 2); - device->write("\x00\x00\x00\x08", 4); - } - - quint16 count = d->imageIfdValues.count() + 1; - quint32 offset = 26; - - if (!d->gpsIfdValues.isEmpty()) { - count++; - offset += 12; - } - - stream << count; - - offset = writeExifHeaders(stream, d->imageIfdValues, offset); - - quint32 exifIfdOffset = offset; - - stream << quint16( ExifIfdPointer ); - stream << quint16( QExifValue::Long ); - stream << quint32( 1 ); - stream << exifIfdOffset; - offset += calculateSize(d->exifIfdValues); - - quint32 gpsIfdOffset = offset; - - if (!d->gpsIfdValues.isEmpty()) { - stream << quint16(GpsInfoIfdPointer); - stream << quint16(QExifValue::Long); - stream << quint32(1); - stream << gpsIfdOffset; - - d->imageIfdValues.insert(ImageTag(GpsInfoIfdPointer), QExifValue(offset)); - - offset += calculateSize(d->gpsIfdValues); - } - - if (!d->thumbnailData.isEmpty()) - stream << offset; // Write offset to thumbnail Ifd. - else - stream << quint32(0); - - writeExifValues( stream, d->imageIfdValues ); - - Q_ASSERT(startPos + exifIfdOffset == device->pos()); - - stream << quint16(d->exifIfdValues.count()); - - writeExifHeaders(stream, d->exifIfdValues, exifIfdOffset); - writeExifValues(stream, d->exifIfdValues); - - Q_ASSERT(startPos + gpsIfdOffset == device->pos()); - - if (!d->gpsIfdValues.isEmpty()) { - stream << quint16(d->gpsIfdValues.count()); - - writeExifHeaders(stream, d->gpsIfdValues, gpsIfdOffset); - writeExifValues(stream, d->gpsIfdValues); - } - - Q_ASSERT(startPos + offset == device->pos()); - - if (!d->thumbnailData.isEmpty()) { - offset += 86; - - stream << quint16(7); - - QExifValue xResolution = d->thumbnailXResolution.isNull() - ? QExifValue(QExifURational(72, 1)) - : d->thumbnailXResolution; - - QExifValue yResolution = d->thumbnailYResolution.isNull() - ? QExifValue(QExifURational(72, 1)) - : d->thumbnailYResolution; - - QExifValue resolutionUnit = d->thumbnailResolutionUnit.isNull() - ? QExifValue(quint16(2)) - : d->thumbnailResolutionUnit; - - QExifValue orientation = d->thumbnailOrientation.isNull() - ? QExifValue(quint16(0)) - : d->thumbnailOrientation; - - writeExifHeader(stream, Compression, QExifValue(quint16(6)), offset); - - offset = writeExifHeader(stream, XResolution, xResolution, offset); - offset = writeExifHeader(stream, YResolution, yResolution, offset); - - writeExifHeader(stream, ResolutionUnit, resolutionUnit, offset); - writeExifHeader(stream, Orientation, orientation, offset); - writeExifHeader(stream, JpegInterchangeFormat, QExifValue(offset), offset); - writeExifHeader(stream, JpegInterchangeFormatLength, - QExifValue(quint32(d->thumbnailData.size())), offset); - - writeExifValue(stream, xResolution); - writeExifValue(stream, yResolution); - - Q_ASSERT(startPos + offset == device->pos()); - - device->write(d->thumbnailData); - - offset += d->thumbnailData.size(); - } - - Q_ASSERT(startPos + offset == device->pos()); - - d->size = offset; - - return offset; -} diff -Nru syncwall-1.6.0/3rdparty/qt-extended/qexifimageheader.h syncwall-1.7.4/3rdparty/qt-extended/qexifimageheader.h --- syncwall-1.6.0/3rdparty/qt-extended/qexifimageheader.h 2012-05-15 11:58:08.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qt-extended/qexifimageheader.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,347 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt scene graph research project. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This file was copied from Qt Extended 4.5 - -#ifndef QEXIFIMAGEHEADER_H -#define QEXIFIMAGEHEADER_H - -#include -#include -#include -#include -#include - -typedef QPair< quint32, quint32 > QExifURational; -typedef QPair< qint32, qint32 > QExifSRational; - -Q_DECLARE_METATYPE(QExifURational) -Q_DECLARE_METATYPE(QExifSRational) - -class QExifValuePrivate; - -class QExifValue -{ -public: - enum Type - { - Byte = 1, - Ascii = 2, - Short = 3, - Long = 4, - Rational = 5, - Undefined = 7, - SignedLong = 9, - SignedRational = 10 - }; - - enum TextEncoding - { - NoEncoding, - AsciiEncoding, - JisEncoding, - UnicodeEncoding, - UndefinedEncoding - }; - - QExifValue(); - QExifValue( quint8 value ); - QExifValue( const QVector< quint8 > &value ); - QExifValue( const QString &value, TextEncoding encoding = NoEncoding ); - QExifValue( quint16 value ); - QExifValue( const QVector< quint16 > &value ); - QExifValue( quint32 value ); - QExifValue( const QVector< quint32 > &value ); - QExifValue( const QExifURational &value ); - QExifValue( const QVector< QExifURational > &value ); - QExifValue( const QByteArray &value ); - QExifValue( qint32 value ); - QExifValue( const QVector< qint32 > &value ); - QExifValue( const QExifSRational &value ); - QExifValue( const QVector< QExifSRational > &value ); - QExifValue( const QDateTime &value ); - QExifValue( const QExifValue &other ); - QExifValue &operator =( const QExifValue &other ); - ~QExifValue(); - - bool operator ==( const QExifValue &other ) const; - - bool isNull() const; - - int type() const; - int count() const; - - TextEncoding encoding() const; - - quint8 toByte() const; - QVector< quint8 > toByteVector() const; - QString toString() const; - quint16 toShort() const; - QVector< quint16 > toShortVector() const; - quint32 toLong() const; - QVector< quint32 > toLongVector() const; - QExifURational toRational() const; - QVector< QExifURational > toRationalVector() const; - QByteArray toByteArray() const; - qint32 toSignedLong() const; - QVector< qint32 > toSignedLongVector() const; - QExifSRational toSignedRational() const; - QVector< QExifSRational > toSignedRationalVector() const; - QDateTime toDateTime() const; - -private: - QExplicitlySharedDataPointer< QExifValuePrivate > d; -}; - -struct ExifIfdHeader; - -class QExifImageHeaderPrivate; - -class QExifImageHeader -{ - Q_DISABLE_COPY(QExifImageHeader) -public: - enum ImageTag - { - - ImageWidth = 0x0100, - ImageLength = 0x0101, - BitsPerSample = 0x0102, - Compression = 0x0103, - PhotometricInterpretation = 0x0106, - Orientation = 0x0112, - SamplesPerPixel = 0x0115, - PlanarConfiguration = 0x011C, - YCbCrSubSampling = 0x0212, - XResolution = 0x011A, - YResolution = 0x011B, - ResolutionUnit = 0x0128, - StripOffsets = 0x0111, - RowsPerStrip = 0x0116, - StripByteCounts = 0x0117, - TransferFunction = 0x012D, - WhitePoint = 0x013E, - PrimaryChromaciticies = 0x013F, - YCbCrCoefficients = 0x0211, - ReferenceBlackWhite = 0x0214, - DateTime = 0x0132, - ImageDescription = 0x010E, - Make = 0x010F, - Model = 0x0110, - Software = 0x0131, - Artist = 0x013B, - Copyright = 0x8298 - }; - - enum ExifExtendedTag - { - ExifVersion = 0x9000, - FlashPixVersion = 0xA000, - ColorSpace = 0xA001, - ComponentsConfiguration = 0x9101, - CompressedBitsPerPixel = 0x9102, - PixelXDimension = 0xA002, - PixelYDimension = 0xA003, - MakerNote = 0x927C, - UserComment = 0x9286, - RelatedSoundFile = 0xA004, - DateTimeOriginal = 0x9003, - DateTimeDigitized = 0x9004, - SubSecTime = 0x9290, - SubSecTimeOriginal = 0x9291, - SubSecTimeDigitized = 0x9292, - ImageUniqueId = 0xA420, - - ExposureTime = 0x829A, - FNumber = 0x829D, - ExposureProgram = 0x8822, - SpectralSensitivity = 0x8824, - ISOSpeedRatings = 0x8827, - Oecf = 0x8828, - ShutterSpeedValue = 0x9201, - ApertureValue = 0x9202, - BrightnessValue = 0x9203, - ExposureBiasValue = 0x9204, - MaxApertureValue = 0x9205, - SubjectDistance = 0x9206, - MeteringMode = 0x9207, - LightSource = 0x9208, - Flash = 0x9209, - FocalLength = 0x920A, - SubjectArea = 0x9214, - FlashEnergy = 0xA20B, - SpatialFrequencyResponse = 0xA20C, - FocalPlaneXResolution = 0xA20E, - FocalPlaneYResolution = 0xA20F, - FocalPlaneResolutionUnit = 0xA210, - SubjectLocation = 0xA214, - ExposureIndex = 0xA215, - SensingMethod = 0xA217, - FileSource = 0xA300, - SceneType = 0xA301, - CfaPattern = 0xA302, - CustomRendered = 0xA401, - ExposureMode = 0xA402, - WhiteBalance = 0xA403, - DigitalZoomRatio = 0xA404, - FocalLengthIn35mmFilm = 0xA405, - SceneCaptureType = 0xA406, - GainControl = 0xA407, - Contrast = 0xA408, - Saturation = 0xA409, - Sharpness = 0xA40A, - DeviceSettingDescription = 0xA40B, - SubjectDistanceRange = 0x40C - }; - - enum GpsTag - { - GpsVersionId = 0x0000, - GpsLatitudeRef = 0x0001, - GpsLatitude = 0x0002, - GpsLongitudeRef = 0x0003, - GpsLongitude = 0x0004, - GpsAltitudeRef = 0x0005, - GpsAltitude = 0x0006, - GpsTimeStamp = 0x0007, - GpsSatellites = 0x0008, - GpsStatus = 0x0009, - GpsMeasureMode = 0x000A, - GpsDop = 0x000B, - GpsSpeedRef = 0x000C, - GpsSpeed = 0x000D, - GpsTrackRef = 0x000E, - GpsTrack = 0x000F, - GpsImageDirectionRef = 0x0010, - GpsImageDirection = 0x0011, - GpsMapDatum = 0x0012, - GpsDestLatitudeRef = 0x0013, - GpsDestLatitude = 0x0014, - GpsDestLongitudeRef = 0x0015, - GpsDestLongitude = 0x0016, - GpsDestBearingRef = 0x0017, - GpsDestBearing = 0x0018, - GpsDestDistanceRef = 0x0019, - GpsDestDistance = 0x001A, - GpsProcessingMethod = 0x001B, - GpsAreaInformation = 0x001C, - GpsDateStamp = 0x001D, - GpsDifferential = 0x001E - }; - - QExifImageHeader(); - explicit QExifImageHeader(const QString &fileName); - ~QExifImageHeader(); - - bool loadFromJpeg(const QString &fileName); - bool loadFromJpeg(QIODevice *device); - bool saveToJpeg(const QString &fileName) const; - bool saveToJpeg(QIODevice *device) const; - - bool read(QIODevice *device); - qint64 write(QIODevice *device) const; - - qint64 size() const; - - QSysInfo::Endian byteOrder() const; - - void clear(); - - QList imageTags() const; - QList extendedTags() const; - QList gpsTags() const; - - bool contains(ImageTag tag) const; - bool contains(ExifExtendedTag tag) const; - bool contains(GpsTag tag) const; - - void remove(ImageTag tag); - void remove(ExifExtendedTag tag); - void remove(GpsTag tag); - - QExifValue value(ImageTag tag) const; - QExifValue value(ExifExtendedTag tag) const; - QExifValue value(GpsTag tag) const; - - void setValue(ImageTag tag, const QExifValue &value); - void setValue(ExifExtendedTag tag, const QExifValue &value); - void setValue(GpsTag tag, const QExifValue &value); - - QImage thumbnail() const; - void setThumbnail( const QImage &thumbnail ); - -private: - enum PrivateTag - { - ExifIfdPointer = 0x8769, - GpsInfoIfdPointer = 0x8825, - InteroperabilityIfdPointer = 0xA005, - JpegInterchangeFormat = 0x0201, - JpegInterchangeFormatLength = 0x0202 - }; - - QByteArray extractExif( QIODevice *device ) const; - - QList< ExifIfdHeader > readIfdHeaders( QDataStream &stream ) const; - - QExifValue readIfdValue(QDataStream &stream, int startPos, const ExifIfdHeader &header) const; - template QMap readIfdValues( - QDataStream &stream, int startPos, const QList &headers) const; - template QMap readIfdValues( - QDataStream &stream, int startPos, const QExifValue &pointer) const; - - quint32 writeExifHeader(QDataStream &stream, quint16 tag, const QExifValue &value, quint32 offset) const; - void writeExifValue(QDataStream &stream, const QExifValue &value) const; - - template quint32 writeExifHeaders( - QDataStream &stream, const QMap &values, quint32 offset) const; - template void writeExifValues( - QDataStream &target, const QMap &values) const; - - quint32 sizeOf(const QExifValue &value) const; - - template quint32 calculateSize( - const QMap &values) const; - - QExifImageHeaderPrivate *d; -}; - -#endif diff -Nru syncwall-1.6.0/3rdparty/qtwin/CMakeLists.txt syncwall-1.7.4/3rdparty/qtwin/CMakeLists.txt --- syncwall-1.6.0/3rdparty/qtwin/CMakeLists.txt 2010-07-07 16:03:36.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qtwin/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 2.6) - -set(QTWIN-SOURCES - qtwin.cpp -) - -ADD_LIBRARY(qtwin STATIC - ${QTWIN-SOURCES} -) diff -Nru syncwall-1.6.0/3rdparty/qtwin/qtwin.cpp syncwall-1.7.4/3rdparty/qtwin/qtwin.cpp --- syncwall-1.6.0/3rdparty/qtwin/qtwin.cpp 2011-12-13 02:23:56.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qtwin/qtwin.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,266 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Use, modification and distribution is allowed without limitation, -** warranty, liability or support of any kind. -** -****************************************************************************/ - -#include "qtwin.h" -#include -#include -#include -#include -#include - -#ifdef Q_WS_WIN - -#include - -// Blur behind data structures -#define DWM_BB_ENABLE 0x00000001 // fEnable has been specified -#define DWM_BB_BLURREGION 0x00000002 // hRgnBlur has been specified -#define DWM_BB_TRANSITIONONMAXIMIZED 0x00000004 // fTransitionOnMaximized has been specified -#define WM_DWMCOMPOSITIONCHANGED 0x031E // Composition changed window message - -typedef struct _DWM_BLURBEHIND -{ - DWORD dwFlags; - BOOL fEnable; - HRGN hRgnBlur; - BOOL fTransitionOnMaximized; -} DWM_BLURBEHIND, *PDWM_BLURBEHIND; - -typedef struct _MARGINS -{ - int cxLeftWidth; - int cxRightWidth; - int cyTopHeight; - int cyBottomHeight; -} MARGINS, *PMARGINS; - -typedef HRESULT (WINAPI *PtrDwmIsCompositionEnabled)(BOOL* pfEnabled); -typedef HRESULT (WINAPI *PtrDwmExtendFrameIntoClientArea)(HWND hWnd, const MARGINS* pMarInset); -typedef HRESULT (WINAPI *PtrDwmEnableBlurBehindWindow)(HWND hWnd, const DWM_BLURBEHIND* pBlurBehind); -typedef HRESULT (WINAPI *PtrDwmGetColorizationColor)(DWORD *pcrColorization, BOOL *pfOpaqueBlend); - -static PtrDwmIsCompositionEnabled pDwmIsCompositionEnabled= 0; -static PtrDwmEnableBlurBehindWindow pDwmEnableBlurBehindWindow = 0; -static PtrDwmExtendFrameIntoClientArea pDwmExtendFrameIntoClientArea = 0; -static PtrDwmGetColorizationColor pDwmGetColorizationColor = 0; - - -/* - * Internal helper class that notifies windows if the - * DWM compositing state changes and updates the widget - * flags correspondingly. - */ -class WindowNotifier : public QWidget -{ -public: - WindowNotifier() - { - winId(); - } - void addWidget(QWidget *widget) - { - widgets.append(widget); - } - void removeWidget(QWidget *widget) - { - widgets.removeAll(widget); - } - bool winEvent(MSG *message, long *result); - -private: - QWidgetList widgets; -}; - -static bool resolveLibs() -{ - if (!pDwmIsCompositionEnabled) - { - QLibrary dwmLib(QString::fromAscii("dwmapi")); - pDwmIsCompositionEnabled =(PtrDwmIsCompositionEnabled)dwmLib.resolve("DwmIsCompositionEnabled"); - pDwmExtendFrameIntoClientArea = (PtrDwmExtendFrameIntoClientArea)dwmLib.resolve("DwmExtendFrameIntoClientArea"); - pDwmEnableBlurBehindWindow = (PtrDwmEnableBlurBehindWindow)dwmLib.resolve("DwmEnableBlurBehindWindow"); - pDwmGetColorizationColor = (PtrDwmGetColorizationColor)dwmLib.resolve("DwmGetColorizationColor"); - } - - return pDwmIsCompositionEnabled != 0; -} - -#endif - -/*! - * Chekcs and returns true if Windows DWM composition - * is currently enabled on the system. - * - * To get live notification on the availability of - * this feature, you will currently have to - * reimplement winEvent() on your widget and listen - * for the WM_DWMCOMPOSITIONCHANGED event to occur. - * - */ -bool QtWin::isCompositionEnabled() -{ -#ifdef Q_WS_WIN - - if (resolveLibs()) - { - HRESULT hr = S_OK; - BOOL isEnabled = false; - hr = pDwmIsCompositionEnabled(&isEnabled); - - if (SUCCEEDED(hr)) - return isEnabled; - } - -#endif - return false; -} - -/*! - * Enables Blur behind on a Widget. - * - * \a enable tells if the blur should be enabled or not - */ -bool QtWin::enableBlurBehindWindow(QWidget *widget, bool enable, - const QRegion ®ion) -{ - Q_ASSERT(widget); - bool result = false; -#ifdef Q_WS_WIN - - if (resolveLibs()) - { - DWM_BLURBEHIND bb = {0}; - HRESULT hr = S_OK; - bb.fEnable = enable; - bb.dwFlags = DWM_BB_ENABLE; - bb.hRgnBlur = NULL; - - if (!region.isEmpty()) - { - bb.dwFlags |= DWM_BB_BLURREGION; - bb.hRgnBlur = region.handle(); - } - - widget->setAttribute(Qt::WA_TranslucentBackground, enable); - widget->setAttribute(Qt::WA_NoSystemBackground, enable); - hr = pDwmEnableBlurBehindWindow(widget->winId(), &bb); - - if (SUCCEEDED(hr)) - { - result = true; - windowNotifier()->addWidget(widget); - } - } - -#endif - return result; -} - -/*! - * ExtendFrameIntoClientArea. - * - * This controls the rendering of the frame inside the window. - * Note that passing margins of -1 (the default value) will completely - * remove the frame from the window. - * - * \note you should not call enableBlurBehindWindow before calling - * this functions - * - * \a enable tells if the blur should be enabled or not - */ -bool QtWin::extendFrameIntoClientArea(QWidget *widget, int left, int top, int right, int bottom) -{ - - Q_ASSERT(widget); - Q_UNUSED(left); - Q_UNUSED(top); - Q_UNUSED(right); - Q_UNUSED(bottom); - - bool result = false; -#ifdef Q_WS_WIN - - if (resolveLibs()) - { - QLibrary dwmLib(QString::fromAscii("dwmapi")); - HRESULT hr = S_OK; - MARGINS m = {left, top, right, bottom}; - hr = pDwmExtendFrameIntoClientArea(widget->winId(), &m); - - if (SUCCEEDED(hr)) - { - result = true; - windowNotifier()->addWidget(widget); - } - - widget->setAttribute(Qt::WA_TranslucentBackground, result); - } - -#endif - return result; -} - -/*! - * Returns the current colorizationColor for the window. - * - * \a enable tells if the blur should be enabled or not - */ -QColor QtWin::colorizatinColor() -{ - QColor resultColor = QApplication::palette().window().color(); - -#ifdef Q_WS_WIN - - if (resolveLibs()) - { - DWORD color = 0; - BOOL opaque = FALSE; - QLibrary dwmLib(QString::fromAscii("dwmapi")); - HRESULT hr = S_OK; - hr = pDwmGetColorizationColor(&color, &opaque); - - if (SUCCEEDED(hr)) - resultColor = QColor(color); - } - -#endif - return resultColor; -} - -#ifdef Q_WS_WIN -WindowNotifier *QtWin::windowNotifier() -{ - static WindowNotifier *windowNotifierInstance = 0; - - if (!windowNotifierInstance) - windowNotifierInstance = new WindowNotifier; - - return windowNotifierInstance; -} - - -/* Notify all enabled windows that the DWM state changed */ -bool WindowNotifier::winEvent(MSG *message, long *result) -{ - if (message && message->message == WM_DWMCOMPOSITIONCHANGED) - { - bool compositionEnabled = QtWin::isCompositionEnabled(); - foreach(QWidget * widget, widgets) - { - if (widget) - { - widget->setAttribute(Qt::WA_NoSystemBackground, compositionEnabled); - widget->update(); - } - } - } - - return QWidget::winEvent(message, result); -} -#endif diff -Nru syncwall-1.6.0/3rdparty/qtwin/qtwin.cpp.orig syncwall-1.7.4/3rdparty/qtwin/qtwin.cpp.orig --- syncwall-1.6.0/3rdparty/qtwin/qtwin.cpp.orig 2010-07-07 16:03:36.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qtwin/qtwin.cpp.orig 1970-01-01 00:00:00.000000000 +0000 @@ -1,229 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Use, modification and distribution is allowed without limitation, -** warranty, liability or support of any kind. -** -****************************************************************************/ - -#include "qtwin.h" -#include -#include -#include -#include -#include - -#ifdef Q_WS_WIN - -#include - -// Blur behind data structures -#define DWM_BB_ENABLE 0x00000001 // fEnable has been specified -#define DWM_BB_BLURREGION 0x00000002 // hRgnBlur has been specified -#define DWM_BB_TRANSITIONONMAXIMIZED 0x00000004 // fTransitionOnMaximized has been specified -#define WM_DWMCOMPOSITIONCHANGED 0x031E // Composition changed window message - -typedef struct _DWM_BLURBEHIND -{ - DWORD dwFlags; - BOOL fEnable; - HRGN hRgnBlur; - BOOL fTransitionOnMaximized; -} DWM_BLURBEHIND, *PDWM_BLURBEHIND; - -typedef struct _MARGINS -{ - int cxLeftWidth; - int cxRightWidth; - int cyTopHeight; - int cyBottomHeight; -} MARGINS, *PMARGINS; - -typedef HRESULT (WINAPI *PtrDwmIsCompositionEnabled)(BOOL* pfEnabled); -typedef HRESULT (WINAPI *PtrDwmExtendFrameIntoClientArea)(HWND hWnd, const MARGINS* pMarInset); -typedef HRESULT (WINAPI *PtrDwmEnableBlurBehindWindow)(HWND hWnd, const DWM_BLURBEHIND* pBlurBehind); -typedef HRESULT (WINAPI *PtrDwmGetColorizationColor)(DWORD *pcrColorization, BOOL *pfOpaqueBlend); - -static PtrDwmIsCompositionEnabled pDwmIsCompositionEnabled= 0; -static PtrDwmEnableBlurBehindWindow pDwmEnableBlurBehindWindow = 0; -static PtrDwmExtendFrameIntoClientArea pDwmExtendFrameIntoClientArea = 0; -static PtrDwmGetColorizationColor pDwmGetColorizationColor = 0; - - -/* - * Internal helper class that notifies windows if the - * DWM compositing state changes and updates the widget - * flags correspondingly. - */ -class WindowNotifier : public QWidget -{ -public: - WindowNotifier() { winId(); } - void addWidget(QWidget *widget) { widgets.append(widget); } - void removeWidget(QWidget *widget) { widgets.removeAll(widget); } - bool winEvent(MSG *message, long *result); - -private: - QWidgetList widgets; -}; - -static bool resolveLibs() -{ - if (!pDwmIsCompositionEnabled) { - QLibrary dwmLib(QString::fromAscii("dwmapi")); - pDwmIsCompositionEnabled =(PtrDwmIsCompositionEnabled)dwmLib.resolve("DwmIsCompositionEnabled"); - pDwmExtendFrameIntoClientArea = (PtrDwmExtendFrameIntoClientArea)dwmLib.resolve("DwmExtendFrameIntoClientArea"); - pDwmEnableBlurBehindWindow = (PtrDwmEnableBlurBehindWindow)dwmLib.resolve("DwmEnableBlurBehindWindow"); - pDwmGetColorizationColor = (PtrDwmGetColorizationColor)dwmLib.resolve("DwmGetColorizationColor"); - } - return pDwmIsCompositionEnabled != 0; -} - -#endif - -/*! - * Chekcs and returns true if Windows DWM composition - * is currently enabled on the system. - * - * To get live notification on the availability of - * this feature, you will currently have to - * reimplement winEvent() on your widget and listen - * for the WM_DWMCOMPOSITIONCHANGED event to occur. - * - */ -bool QtWin::isCompositionEnabled() -{ -#ifdef Q_WS_WIN - if (resolveLibs()) { - HRESULT hr = S_OK; - BOOL isEnabled = false; - hr = pDwmIsCompositionEnabled(&isEnabled); - if (SUCCEEDED(hr)) - return isEnabled; - } -#endif - return false; -} - -/*! - * Enables Blur behind on a Widget. - * - * \a enable tells if the blur should be enabled or not - */ -bool QtWin::enableBlurBehindWindow(QWidget *widget, bool enable, - const QRegion ®ion) -{ - Q_ASSERT(widget); - bool result = false; -#ifdef Q_WS_WIN - if (resolveLibs()) { - DWM_BLURBEHIND bb = {0}; - HRESULT hr = S_OK; - bb.fEnable = enable; - bb.dwFlags = DWM_BB_ENABLE; - bb.hRgnBlur = NULL; - - if (!region.isEmpty()) { - bb.dwFlags |= DWM_BB_BLURREGION; - bb.hRgnBlur = region.handle(); - } - - widget->setAttribute(Qt::WA_TranslucentBackground, enable); - widget->setAttribute(Qt::WA_NoSystemBackground, enable); - hr = pDwmEnableBlurBehindWindow(widget->winId(), &bb); - if (SUCCEEDED(hr)) { - result = true; - windowNotifier()->addWidget(widget); - } - } -#endif - return result; -} - -/*! - * ExtendFrameIntoClientArea. - * - * This controls the rendering of the frame inside the window. - * Note that passing margins of -1 (the default value) will completely - * remove the frame from the window. - * - * \note you should not call enableBlurBehindWindow before calling - * this functions - * - * \a enable tells if the blur should be enabled or not - */ -bool QtWin::extendFrameIntoClientArea(QWidget *widget, int left, int top, int right, int bottom) -{ - - Q_ASSERT(widget); - Q_UNUSED(left); - Q_UNUSED(top); - Q_UNUSED(right); - Q_UNUSED(bottom); - - bool result = false; -#ifdef Q_WS_WIN - if (resolveLibs()) { - QLibrary dwmLib(QString::fromAscii("dwmapi")); - HRESULT hr = S_OK; - MARGINS m = {left, top, right, bottom}; - hr = pDwmExtendFrameIntoClientArea(widget->winId(), &m); - if (SUCCEEDED(hr)) { - result = true; - windowNotifier()->addWidget(widget); - } - widget->setAttribute(Qt::WA_TranslucentBackground, result); - } -#endif - return result; -} - -/*! - * Returns the current colorizationColor for the window. - * - * \a enable tells if the blur should be enabled or not - */ -QColor QtWin::colorizatinColor() -{ - QColor resultColor = QApplication::palette().window().color(); - -#ifdef Q_WS_WIN - if (resolveLibs()) { - DWORD color = 0; - BOOL opaque = FALSE; - QLibrary dwmLib(QString::fromAscii("dwmapi")); - HRESULT hr = S_OK; - hr = pDwmGetColorizationColor(&color, &opaque); - if (SUCCEEDED(hr)) - resultColor = QColor(color); - } -#endif - return resultColor; -} - -#ifdef Q_WS_WIN -WindowNotifier *QtWin::windowNotifier() -{ - static WindowNotifier *windowNotifierInstance = 0; - if (!windowNotifierInstance) - windowNotifierInstance = new WindowNotifier; - return windowNotifierInstance; -} - - -/* Notify all enabled windows that the DWM state changed */ -bool WindowNotifier::winEvent(MSG *message, long *result) -{ - if (message && message->message == WM_DWMCOMPOSITIONCHANGED) { - bool compositionEnabled = QtWin::isCompositionEnabled(); - foreach(QWidget * widget, widgets) { - if (widget) { - widget->setAttribute(Qt::WA_NoSystemBackground, compositionEnabled); - } - widget->update(); - } - } - return QWidget::winEvent(message, result); -} -#endif diff -Nru syncwall-1.6.0/3rdparty/qtwin/qtwin.h syncwall-1.7.4/3rdparty/qtwin/qtwin.h --- syncwall-1.6.0/3rdparty/qtwin/qtwin.h 2010-07-07 16:03:36.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qtwin/qtwin.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Use, modification and distribution is allowed without limitation, -** warranty, liability or support of any kind. -** -****************************************************************************/ - -#ifndef QTWIN_H -#define QTWIN_H - -#include -#include -/** - * This is a helper class for using the Desktop Window Manager - * functionality on Windows 7 and Windows Vista. On other platforms - * these functions will simply not do anything. - */ - -class WindowNotifier; - -class QtWin -{ -public: - static bool enableBlurBehindWindow(QWidget *widget, bool enable = true, - const QRegion& region = QRegion()); - static bool extendFrameIntoClientArea(QWidget *widget, - int left = -1, int top = -1, - int right = -1, int bottom = -1); - static bool isCompositionEnabled(); - static QColor colorizatinColor(); - -private: - static WindowNotifier *windowNotifier(); -}; - -#endif // QTWIN_H diff -Nru syncwall-1.6.0/3rdparty/qxt/CMakeLists.txt syncwall-1.7.4/3rdparty/qxt/CMakeLists.txt --- syncwall-1.6.0/3rdparty/qxt/CMakeLists.txt 2012-01-08 14:42:24.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qxt/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -cmake_minimum_required(VERSION 2.6) - -PROJECT(qxt) - -find_package(Qt4 REQUIRED) - -INCLUDE(${QT_USE_FILE}) - -set(QXT-SOURCES - qxtglobal.cpp - qxtglobalshortcut.cpp -) - -set(QXT-MOC-HEADERS - qxtglobalshortcut.h -) - -if(WIN32) - set(QXT-SOURCES ${QXT-SOURCES} qxtglobalshortcut_win.cpp) -elseif(APPLE) - set(QXT-SOURCES ${QXT-SOURCES} qxtglobalshortcut_mac.cpp) -else(WIN32) - set(QXT-SOURCES ${QXT-SOURCES} qxtglobalshortcut_x11.cpp) -endif(WIN32) - -QT4_WRAP_CPP(QXT-SOURCES-MOC ${QXT-MOC-HEADERS}) - -# add special flags for compilation -ADD_DEFINITIONS( -DQXT_STATIC ) - -ADD_LIBRARY(qxt STATIC - ${QXT-SOURCES} - ${QXT-SOURCES-MOC} -) diff -Nru syncwall-1.6.0/3rdparty/qxt/LICENSE syncwall-1.7.4/3rdparty/qxt/LICENSE --- syncwall-1.6.0/3rdparty/qxt/LICENSE 2011-03-29 12:16:32.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qxt/LICENSE 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -Qt Extension Library -Copyright (C) 2007 Qxt Foundation - -------------------- Disclaimer ------------------------------------------------ - -Until the Qxt Foundation is legally established, copyright for the -source code falls back to the original contributor. For information about the -status of the Qxt Foundation, or about the copyright status of any part of Qxt, -contact the Qxt project maintainers at - -Once the Qxt Foundation has been legally established, all contributors must -transfer all copyright interest to the Qxt Foundation before their submissions -will be added to the project. - -------------------- License --------------------------------------------------- - -This library is free software; you can redistribute it and/or modify it -under the terms of the Common Public License, version 1.0, as published by IBM -or under the terms of the GNU Lesser General Public License, version 2.1, -as published by the Free Software Foundation - -This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY -WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR -FITNESS FOR A PARTICULAR PURPOSE. - -You should have received a copy of the CPL along with this file. -See the LICENSE file and the cpl1.0.txt file included with the source -distribution for more information. If you did not receive a copy of the -license, contact the Qxt Foundation. - -You should have received a copy of the LGPL along with this file. -See the LICENSE file and the lgpl-2.1.txt file included with the source -distribution for more information. If you did not receive a copy of the -license, contact the Qxt Foundation. - -Parts of Qxt depend on Qt 4 and/or other libraries that have their own -licenses. Qxt is independent of these licenses; however, use of these other -libraries is subject to their respective license agreements. - -------------------- Intent ---------------------------------------------------- - -The following section describes the opinions and intent of the Qxt Foundation -with regards to the licensing and use of the Qxt source code and library. In -the event that the CPL is found to be illegal or invalid, or if any application -or clause of the license is subjected to question or abuse, this section is a -general statement of the desired interpretation. - -This section has no legal standing and the statements made here are strictly -subject to the text of the CPL; that is, if this section and the CPL are in -disagreement, the text of the CPL takes precedence. In no way does this -intent grant you any additional rights or impose any additional restrictions. - -If you have questions about licensing, contact the maintainers. - -Qxt is built and supported by open-source enthusiasts. -- Please respect the open-source background of the contributors. The code is - provided for everyone's use; you may not restrict the rights of anyone to - use it. - - No individual may claim ownership of any part of the code. It belongs - to the community. - - You may modify the source code to suit your needs, but these changes - must be made free. If you distribute a modified form of Qxt, you must - also distribute the entire source code of the modified form. - - Digital Rights Management (DRM) puts unfair, unfree restrictions on - users and developers. It is the opposite of Free Software. We can't - stop you from using it, but please don't use the Qxt name for software - restricted by DRM. -- Please respect the time and effort put into the project by the developers. - - If you find Qxt useful, it would be appreciated if you would include - text in your application (for instance, in the About dialog) giving - acknowledgement to Qxt. - - If you make modifications to the source code, you must not call the - modified version "Qxt." It's okay to include "Qxt" in the name, but - anyone who receives the modified version needs to know that it's not - the same as the version distributed by the Qxt Foundation. -- We want everyone to be able to use Qxt without restrictions. - - If you distribute Qxt in compiled binary form, please ensure that - everyone who receives it can get the source code used to create it. - - You are free to use Qxt in closed-source applications as long as you - distribute Qxt in an open-source fashion. This does not require you - to make your entire application open-source. -- The Qxt Foundation is a non-profit, non-political organization. - - Please don't use the Qxt name in any political or semi-political - propaganda or publication. We don't like it. -- Qxt is distributed "as-is," with no warranty. - - If it makes your program crash, your computer blow up, or tiny demons - fly out of your nose, please don't sue us. - diff -Nru syncwall-1.6.0/3rdparty/qxt/QxtGlobalShortcut syncwall-1.7.4/3rdparty/qxt/QxtGlobalShortcut --- syncwall-1.6.0/3rdparty/qxt/QxtGlobalShortcut 2011-11-24 15:10:32.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qxt/QxtGlobalShortcut 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -#include "qxtglobalshortcut.h" - diff -Nru syncwall-1.6.0/3rdparty/qxt/qxtglobal.cpp syncwall-1.7.4/3rdparty/qxt/qxtglobal.cpp --- syncwall-1.6.0/3rdparty/qxt/qxtglobal.cpp 2011-11-24 15:10:32.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qxt/qxtglobal.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,241 +0,0 @@ -/**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtCore module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ - -#include "qxtglobal.h" - -/*! - \headerfile - \title Global Qxt Declarations - \inmodule QxtCore - - \brief The header provides basic declarations and - is included by all other Qxt headers. - */ - -/*! - \macro QXT_VERSION - \relates - - This macro expands a numeric value of the form 0xMMNNPP (MM = - major, NN = minor, PP = patch) that specifies Qxt's version - number. For example, if you compile your application against Qxt - 0.4.0, the QXT_VERSION macro will expand to 0x000400. - - You can use QXT_VERSION to use the latest Qt features where - available. For example: - \code - #if QXT_VERSION >= 0x000400 - qxtTabWidget->setTabMovementMode(QxtTabWidget::InPlaceMovement); - #endif - \endcode - - \sa QXT_VERSION_STR, qxtVersion() - */ - -/*! - \macro QXT_VERSION_STR - \relates - - This macro expands to a string that specifies Qxt's version number - (for example, "0.4.0"). This is the version against which the - application is compiled. - - \sa qxtVersion(), QXT_VERSION - */ - -/*! - \relates - - Returns the version number of Qxt at run-time as a string (for - example, "0.4.0"). This may be a different version than the - version the application was compiled against. - - \sa QXT_VERSION_STR - */ -const char* qxtVersion() -{ - return QXT_VERSION_STR; -} - -/*! -\headerfile -\title The Qxt private implementation -\inmodule QxtCore - -\brief The header provides tools for hiding -details of a class. - -Application code generally doesn't have to be concerned about hiding its -implementation details, but when writing library code it is important to -maintain a constant interface, both source and binary. Maintaining a constant -source interface is easy enough, but keeping the binary interface constant -means moving implementation details into a private class. The PIMPL, or -d-pointer, idiom is a common method of implementing this separation. QxtPimpl -offers a convenient way to connect the public and private sides of your class. - -\section1 Getting Started -Before you declare the public class, you need to make a forward declaration -of the private class. The private class must have the same name as the public -class, followed by the word Private. For example, a class named MyTest would -declare the private class with: -\code -class MyTestPrivate; -\endcode - -\section1 The Public Class -Generally, you shouldn't keep any data members in the public class without a -good reason. Functions that are part of the public interface should be declared -in the public class, and functions that need to be available to subclasses (for -calling or overriding) should be in the protected section of the public class. -To connect the private class to the public class, include the -QXT_DECLARE_PRIVATE macro in the private section of the public class. In the -example above, the private class is connected as follows: -\code -private: - QXT_DECLARE_PRIVATE(MyTest) -\endcode - -Additionally, you must include the QXT_INIT_PRIVATE macro in the public class's -constructor. Continuing with the MyTest example, your constructor might look -like this: -\code -MyTest::MyTest() { - // initialization - QXT_INIT_PRIVATE(MyTest); -} -\endcode - -\section1 The Private Class -As mentioned above, data members should usually be kept in the private class. -This allows the memory layout of the private class to change without breaking -binary compatibility for the public class. Functions that exist only as -implementation details, or functions that need access to private data members, -should be implemented here. - -To define the private class, inherit from the template QxtPrivate class, and -include the QXT_DECLARE_PUBLIC macro in its public section. The template -parameter should be the name of the public class. For example: -\code -class MyTestPrivate : public QxtPrivate { -public: - MyTestPrivate(); - QXT_DECLARE_PUBLIC(MyTest) -}; -\endcode - -\section1 Accessing Private Members -Use the qxt_d() function (actually a function-like object) from functions in -the public class to access the private class. Similarly, functions in the -private class can invoke functions in the public class by using the qxt_p() -function (this one's actually a function). - -For example, assume that MyTest has methods named getFoobar and doBaz(), -and MyTestPrivate has a member named foobar and a method named doQuux(). -The code might resemble this example: -\code -int MyTest::getFoobar() { - return qxt_d().foobar; -} - -void MyTestPrivate::doQuux() { - qxt_p().doBaz(foobar); -} -\endcode -*/ - -/*! - * \macro QXT_DECLARE_PRIVATE(PUB) - * \relates - * Declares that a public class has a related private class. - * - * This shuold be put in the private section of the public class. The parameter is the name of the public class. - */ - -/*! - * \macro QXT_DECLARE_PUBLIC(PUB) - * \relates - * Declares that a private class has a related public class. - * - * This may be put anywhere in the declaration of the private class. The parameter is the name of the public class. - */ - -/*! - * \macro QXT_INIT_PRIVATE(PUB) - * \relates - * Initializes resources owned by the private class. - * - * This should be called from the public class's constructor, - * before qxt_d() is used for the first time. The parameter is the name of the public class. - */ - -/*! - * \macro QXT_D(PUB) - * \relates - * Returns a reference in the current scope named "d" to the private class. - * - * This function is only available in a class using \a QXT_DECLARE_PRIVATE. - */ - -/*! - * \macro QXT_P(PUB) - * \relates - * Creates a reference in the current scope named "q" to the public class. - * - * This macro only works in a class using \a QXT_DECLARE_PUBLIC. - */ - -/*! - * \fn QxtPrivate& PUB::qxt_d() - * \relates - * Returns a reference to the private class. - * - * This function is only available in a class using \a QXT_DECLARE_PRIVATE. - */ - -/*! - * \fn const QxtPrivate& PUB::qxt_d() const - * \relates - * Returns a const reference to the private class. - * - * This function is only available in a class using \a QXT_DECLARE_PRIVATE. - * This overload will be automatically used in const functions. - */ - -/*! - * \fn PUB& QxtPrivate::qxt_p() - * \relates - * Returns a reference to the public class. - * - * This function is only available in a class using \a QXT_DECLARE_PUBLIC. - */ - -/*! - * \fn const PUB& QxtPrivate::qxt_p() const - * \relates - * Returns a const reference to the public class. - * - * This function is only available in a class using \a QXT_DECLARE_PUBLIC. - * This overload will be automatically used in const functions. - */ diff -Nru syncwall-1.6.0/3rdparty/qxt/qxtglobal.h syncwall-1.7.4/3rdparty/qxt/qxtglobal.h --- syncwall-1.6.0/3rdparty/qxt/qxtglobal.h 2011-11-24 15:10:32.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qxt/qxtglobal.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,207 +0,0 @@ -/**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtCore module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ - -#ifndef QXTGLOBAL_H -#define QXTGLOBAL_H - -#include - -#define QXT_VERSION 0x000602 -#define QXT_VERSION_STR "0.6.2" - -//--------------------------global macros------------------------------ - -#ifndef QXT_NO_MACROS - -#endif // QXT_NO_MACROS - -//--------------------------export macros------------------------------ - -#define QXT_DLLEXPORT DO_NOT_USE_THIS_ANYMORE - -#if !defined(QXT_STATIC) -# if defined(BUILD_QXT_CORE) -# define QXT_CORE_EXPORT Q_DECL_EXPORT -# else -# define QXT_CORE_EXPORT Q_DECL_IMPORT -# endif -#else -# define QXT_CORE_EXPORT -#endif // BUILD_QXT_CORE - -#if !defined(QXT_STATIC) -# if defined(BUILD_QXT_GUI) -# define QXT_GUI_EXPORT Q_DECL_EXPORT -# else -# define QXT_GUI_EXPORT Q_DECL_IMPORT -# endif -#else -# define QXT_GUI_EXPORT -#endif // BUILD_QXT_GUI - -#if !defined(QXT_STATIC) -# if defined(BUILD_QXT_NETWORK) -# define QXT_NETWORK_EXPORT Q_DECL_EXPORT -# else -# define QXT_NETWORK_EXPORT Q_DECL_IMPORT -# endif -#else -# define QXT_NETWORK_EXPORT -#endif // BUILD_QXT_NETWORK - -#if !defined(QXT_STATIC) -# if defined(BUILD_QXT_SQL) -# define QXT_SQL_EXPORT Q_DECL_EXPORT -# else -# define QXT_SQL_EXPORT Q_DECL_IMPORT -# endif -#else -# define QXT_SQL_EXPORT -#endif // BUILD_QXT_SQL - -#if !defined(QXT_STATIC) -# if defined(BUILD_QXT_WEB) -# define QXT_WEB_EXPORT Q_DECL_EXPORT -# else -# define QXT_WEB_EXPORT Q_DECL_IMPORT -# endif -#else -# define QXT_WEB_EXPORT -#endif // BUILD_QXT_WEB - -#if !defined(QXT_STATIC) -# if defined(BUILD_QXT_BERKELEY) -# define QXT_BERKELEY_EXPORT Q_DECL_EXPORT -# else -# define QXT_BERKELEY_EXPORT Q_DECL_IMPORT -# endif -#else -# define QXT_BERKELEY_EXPORT -#endif // BUILD_QXT_BERKELEY - -#if !defined(QXT_STATIC) -# if defined(BUILD_QXT_ZEROCONF) -# define QXT_ZEROCONF_EXPORT Q_DECL_EXPORT -# else -# define QXT_ZEROCONF_EXPORT Q_DECL_IMPORT -# endif -#else -# define QXT_ZEROCONF_EXPORT -#endif // QXT_ZEROCONF_EXPORT - -#if defined BUILD_QXT_CORE || defined BUILD_QXT_GUI || defined BUILD_QXT_SQL || defined BUILD_QXT_NETWORK || defined BUILD_QXT_WEB || defined BUILD_QXT_BERKELEY || defined BUILD_QXT_ZEROCONF -# define BUILD_QXT -#endif - -QXT_CORE_EXPORT const char* qxtVersion(); - -#ifndef QT_BEGIN_NAMESPACE -#define QT_BEGIN_NAMESPACE -#endif - -#ifndef QT_END_NAMESPACE -#define QT_END_NAMESPACE -#endif - -#ifndef QT_FORWARD_DECLARE_CLASS -#define QT_FORWARD_DECLARE_CLASS(Class) class Class; -#endif - -/**************************************************************************** -** This file is derived from code bearing the following notice: -** The sole author of this file, Adam Higerd, has explicitly disclaimed all -** copyright interest and protection for the content within. This file has -** been placed in the public domain according to United States copyright -** statute and case law. In jurisdictions where this public domain dedication -** is not legally recognized, anyone who receives a copy of this file is -** permitted to use, modify, duplicate, and redistribute this file, in whole -** or in part, with no restrictions or conditions. In these jurisdictions, -** this file shall be copyright (C) 2006-2008 by Adam Higerd. -****************************************************************************/ - -#define QXT_DECLARE_PRIVATE(PUB) friend class PUB##Private; QxtPrivateInterface qxt_d; -#define QXT_DECLARE_PUBLIC(PUB) friend class PUB; -#define QXT_INIT_PRIVATE(PUB) qxt_d.setPublic(this); -#define QXT_D(PUB) PUB##Private& d = qxt_d() -#define QXT_P(PUB) PUB& p = qxt_p() - -template -class QxtPrivate -{ -public: - virtual ~QxtPrivate() - {} - inline void QXT_setPublic(PUB* pub) - { - qxt_p_ptr = pub; - } - -protected: - inline PUB& qxt_p() - { - return *qxt_p_ptr; - } - inline const PUB& qxt_p() const - { - return *qxt_p_ptr; - } - -private: - PUB* qxt_p_ptr; -}; - -template -class QxtPrivateInterface -{ - friend class QxtPrivate; -public: - QxtPrivateInterface() - { - pvt = new PVT; - } - ~QxtPrivateInterface() - { - delete pvt; - } - - inline void setPublic(PUB* pub) - { - pvt->QXT_setPublic(pub); - } - inline PVT& operator()() - { - return *static_cast(pvt); - } - inline const PVT& operator()() const - { - return *static_cast(pvt); - } -private: - QxtPrivateInterface(const QxtPrivateInterface&) { } - QxtPrivateInterface& operator=(const QxtPrivateInterface&) { } - QxtPrivate* pvt; -}; - -#endif // QXT_GLOBAL diff -Nru syncwall-1.6.0/3rdparty/qxt/qxtglobalshortcut.cpp syncwall-1.7.4/3rdparty/qxt/qxtglobalshortcut.cpp --- syncwall-1.6.0/3rdparty/qxt/qxtglobalshortcut.cpp 2011-11-24 15:10:32.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qxt/qxtglobalshortcut.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,201 +0,0 @@ -/**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtGui module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ -#include "qxtglobalshortcut.h" -#include "qxtglobalshortcut_p.h" -#include -#include - -bool QxtGlobalShortcutPrivate::error = false; -#ifndef Q_WS_MAC -int QxtGlobalShortcutPrivate::ref = 0; -QAbstractEventDispatcher::EventFilter QxtGlobalShortcutPrivate::prevEventFilter = 0; -#endif // Q_WS_MAC -QHash, QxtGlobalShortcut*> QxtGlobalShortcutPrivate::shortcuts; - -QxtGlobalShortcutPrivate::QxtGlobalShortcutPrivate() : enabled(true), key(Qt::Key(0)), mods(Qt::NoModifier) -{ -#ifndef Q_WS_MAC - if (!ref++) - prevEventFilter = QAbstractEventDispatcher::instance()->setEventFilter(eventFilter); -#endif // Q_WS_MAC -} - -QxtGlobalShortcutPrivate::~QxtGlobalShortcutPrivate() -{ -#ifndef Q_WS_MAC - if (!--ref) - QAbstractEventDispatcher::instance()->setEventFilter(prevEventFilter); -#endif // Q_WS_MAC -} - -bool QxtGlobalShortcutPrivate::setShortcut(const QKeySequence& shortcut) -{ - Qt::KeyboardModifiers allMods = Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier; - key = shortcut.isEmpty() ? Qt::Key(0) : Qt::Key((shortcut[0] ^ allMods) & shortcut[0]); - mods = shortcut.isEmpty() ? Qt::KeyboardModifiers(0) : Qt::KeyboardModifiers(shortcut[0] & allMods); - const quint32 nativeKey = nativeKeycode(key); - const quint32 nativeMods = nativeModifiers(mods); - const bool res = registerShortcut(nativeKey, nativeMods); - if (res) - shortcuts.insert(qMakePair(nativeKey, nativeMods), &qxt_p()); - else - qWarning() << "QxtGlobalShortcut failed to register:" << QKeySequence(key + mods).toString(); - return res; -} - -bool QxtGlobalShortcutPrivate::unsetShortcut() -{ - bool res = false; - const quint32 nativeKey = nativeKeycode(key); - const quint32 nativeMods = nativeModifiers(mods); - if (shortcuts.value(qMakePair(nativeKey, nativeMods)) == &qxt_p()) - res = unregisterShortcut(nativeKey, nativeMods); - if (res) - shortcuts.remove(qMakePair(nativeKey, nativeMods)); - else - qWarning() << "QxtGlobalShortcut failed to unregister:" << QKeySequence(key + mods).toString(); - key = Qt::Key(0); - mods = Qt::KeyboardModifiers(0); - return res; -} - -void QxtGlobalShortcutPrivate::activateShortcut(quint32 nativeKey, quint32 nativeMods) -{ - QxtGlobalShortcut* shortcut = shortcuts.value(qMakePair(nativeKey, nativeMods)); - if (shortcut && shortcut->isEnabled()) - emit shortcut->activated(); -} - -/*! - \class QxtGlobalShortcut - \inmodule QxtGui - \brief The QxtGlobalShortcut class provides a global shortcut aka "hotkey". - - A global shortcut triggers even if the application is not active. This - makes it easy to implement applications that react to certain shortcuts - still if some other application is active or if the application is for - example minimized to the system tray. - - Example usage: - \code - QxtGlobalShortcut* shortcut = new QxtGlobalShortcut(window); - connect(shortcut, SIGNAL(activated()), window, SLOT(toggleVisibility())); - shortcut->setShortcut(QKeySequence("Ctrl+Shift+F12")); - \endcode - - \bold {Note:} Since Qxt 0.6 QxtGlobalShortcut no more requires QxtApplication. - */ - -/*! - \fn QxtGlobalShortcut::activated() - - This signal is emitted when the user types the shortcut's key sequence. - - \sa shortcut - */ - -/*! - Constructs a new QxtGlobalShortcut with \a parent. - */ -QxtGlobalShortcut::QxtGlobalShortcut(QObject* parent) - : QObject(parent) -{ - QXT_INIT_PRIVATE(QxtGlobalShortcut); -} - -/*! - Constructs a new QxtGlobalShortcut with \a shortcut and \a parent. - */ -QxtGlobalShortcut::QxtGlobalShortcut(const QKeySequence& shortcut, QObject* parent) - : QObject(parent) -{ - QXT_INIT_PRIVATE(QxtGlobalShortcut); - setShortcut(shortcut); -} - -/*! - Destructs the QxtGlobalShortcut. - */ -QxtGlobalShortcut::~QxtGlobalShortcut() -{ - if (qxt_d().key != 0) - qxt_d().unsetShortcut(); -} - -/*! - \property QxtGlobalShortcut::shortcut - \brief the shortcut key sequence - - \bold {Note:} Notice that corresponding key press and release events are not - delivered for registered global shortcuts even if they are disabled. - Also, comma separated key sequences are not supported. - Only the first part is used: - - \code - qxtShortcut->setShortcut(QKeySequence("Ctrl+Alt+A,Ctrl+Alt+B")); - Q_ASSERT(qxtShortcut->shortcut() == QKeySequence("Ctrl+Alt+A")); - \endcode - */ -QKeySequence QxtGlobalShortcut::shortcut() const -{ - return QKeySequence(qxt_d().key | qxt_d().mods); -} - -bool QxtGlobalShortcut::setShortcut(const QKeySequence& shortcut) -{ - if (qxt_d().key != 0) - qxt_d().unsetShortcut(); - return qxt_d().setShortcut(shortcut); -} - -/*! - \property QxtGlobalShortcut::enabled - \brief whether the shortcut is enabled - - A disabled shortcut does not get activated. - - The default value is \c true. - - \sa setDisabled() - */ -bool QxtGlobalShortcut::isEnabled() const -{ - return qxt_d().enabled; -} - -void QxtGlobalShortcut::setEnabled(bool enabled) -{ - qxt_d().enabled = enabled; -} - -/*! - Sets the shortcut \a disabled. - - \sa enabled - */ -void QxtGlobalShortcut::setDisabled(bool disabled) -{ - qxt_d().enabled = !disabled; -} diff -Nru syncwall-1.6.0/3rdparty/qxt/qxtglobalshortcut.h syncwall-1.7.4/3rdparty/qxt/qxtglobalshortcut.h --- syncwall-1.6.0/3rdparty/qxt/qxtglobalshortcut.h 2011-11-24 15:10:32.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qxt/qxtglobalshortcut.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -/**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtGui module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ -#ifndef QXTGLOBALSHORTCUT_H -#define QXTGLOBALSHORTCUT_H - -#include "qxtglobal.h" -#include -#include -class QxtGlobalShortcutPrivate; - -class QXT_GUI_EXPORT QxtGlobalShortcut : public QObject -{ - Q_OBJECT - QXT_DECLARE_PRIVATE(QxtGlobalShortcut) - Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled) - Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut) - -public: - explicit QxtGlobalShortcut(QObject* parent = 0); - explicit QxtGlobalShortcut(const QKeySequence& shortcut, QObject* parent = 0); - virtual ~QxtGlobalShortcut(); - - QKeySequence shortcut() const; - bool setShortcut(const QKeySequence& shortcut); - - bool isEnabled() const; - -public Q_SLOTS: - void setEnabled(bool enabled = true); - void setDisabled(bool disabled = true); - -Q_SIGNALS: - void activated(); -}; - -#endif // QXTGLOBALSHORTCUT_H diff -Nru syncwall-1.6.0/3rdparty/qxt/qxtglobalshortcut_mac.cpp syncwall-1.7.4/3rdparty/qxt/qxtglobalshortcut_mac.cpp --- syncwall-1.6.0/3rdparty/qxt/qxtglobalshortcut_mac.cpp 2011-11-24 15:10:32.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qxt/qxtglobalshortcut_mac.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,198 +0,0 @@ -/**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtGui module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ -#include -#include "qxtglobalshortcut_p.h" -#include -#include -#include -#include - -typedef QPair Identifier; -static QMap keyRefs; -static QHash keyIDs; -static quint32 hotKeySerial = 0; -static bool qxt_mac_handler_installed = false; - -OSStatus qxt_mac_handle_hot_key(EventHandlerCallRef nextHandler, EventRef event, void* data) -{ - Q_UNUSED(nextHandler); - Q_UNUSED(data); - if (GetEventClass(event) == kEventClassKeyboard && GetEventKind(event) == kEventHotKeyPressed) - { - EventHotKeyID keyID; - GetEventParameter(event, kEventParamDirectObject, typeEventHotKeyID, NULL, sizeof(keyID), NULL, &keyID); - Identifier id = keyIDs.key(keyID.id); - QxtGlobalShortcutPrivate::activateShortcut(id.second, id.first); - } - return noErr; -} - -quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers) -{ - quint32 native = 0; - if (modifiers & Qt::ShiftModifier) - native |= shiftKey; - if (modifiers & Qt::ControlModifier) - native |= cmdKey; - if (modifiers & Qt::AltModifier) - native |= optionKey; - if (modifiers & Qt::MetaModifier) - native |= controlKey; - if (modifiers & Qt::KeypadModifier) - native |= kEventKeyModifierNumLockMask; - return native; -} - -quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key) -{ - UTF16Char ch; - // Constants found in NSEvent.h from AppKit.framework - if (key == Qt::Key_Up) ch = 0xF700; - else if (key == Qt::Key_Down) ch = 0xF701; - else if (key == Qt::Key_Left) ch = 0xF702; - else if (key == Qt::Key_Right) ch = 0xF703; - else if (key >= Qt::Key_F1 && key <= Qt::Key_F35) - ch = key - Qt::Key_F1 + 0xF704; - else if (key == Qt::Key_Insert) ch = 0xF727; - else if (key == Qt::Key_Delete) ch = 0xF728; - else if (key == Qt::Key_Home) ch = 0xF729; - else if (key == Qt::Key_End) ch = 0xF72B; - else if (key == Qt::Key_PageUp) ch = 0xF72C; - else if (key == Qt::Key_PageDown) ch = 0xF72D; - else if (key == Qt::Key_Print) ch = 0xF72E; - else if (key == Qt::Key_ScrollLock) ch = 0xF72F; - else if (key == Qt::Key_Pause) ch = 0xF730; - else if (key == Qt::Key_SysReq) ch = 0xF731; - else if (key == Qt::Key_Stop) ch = 0xF734; - else if (key == Qt::Key_Menu) ch = 0xF735; - else if (key == Qt::Key_Select) ch = 0xF741; - else if (key == Qt::Key_Execute) ch = 0xF742; - else if (key == Qt::Key_Help) ch = 0xF746; - else if (key == Qt::Key_Mode_switch) ch = 0xF747; - else if (key == Qt::Key_Escape) ch = 27; - else if (key == Qt::Key_Return) ch = 13; - else if (key == Qt::Key_Enter) ch = 3; - else if (key == Qt::Key_Tab) ch = 9; - else ch = key; - - KeyboardLayoutRef layout; - KeyboardLayoutKind layoutKind; - KLGetCurrentKeyboardLayout(&layout); - KLGetKeyboardLayoutProperty(layout, kKLKind, const_cast(reinterpret_cast(&layoutKind))); - - if (layoutKind == kKLKCHRKind) - { // no Unicode available - if (ch > 255) return 0; - - char* data; - KLGetKeyboardLayoutProperty(layout, kKLKCHRData, const_cast(reinterpret_cast(&data))); - int ct = *reinterpret_cast(data + 258); - for (int i = 0; i < ct; i++) - { - char* keyTable = data + 260 + 128 * i; - for (int j = 0; j < 128; j++) - { - if (keyTable[j] == ch) return j; - } - } - - return 0; - } - - char* data; - KLGetKeyboardLayoutProperty(layout, kKLuchrData, const_cast(reinterpret_cast(&data))); - UCKeyboardLayout* header = reinterpret_cast(data); - UCKeyboardTypeHeader* table = header->keyboardTypeList; - - for (quint32 i=0; i < header->keyboardTypeCount; i++) - { - UCKeyStateRecordsIndex* stateRec = 0; - if (table[i].keyStateRecordsIndexOffset != 0) - { - stateRec = reinterpret_cast(data + table[i].keyStateRecordsIndexOffset); - if (stateRec->keyStateRecordsIndexFormat != kUCKeyStateRecordsIndexFormat) stateRec = 0; - } - - UCKeyToCharTableIndex* charTable = reinterpret_cast(data + table[i].keyToCharTableIndexOffset); - if (charTable->keyToCharTableIndexFormat != kUCKeyToCharTableIndexFormat) continue; - - for (quint32 j=0; j < charTable->keyToCharTableCount; j++) - { - UCKeyOutput* keyToChar = reinterpret_cast(data + charTable->keyToCharTableOffsets[j]); - for (quint32 k=0; k < charTable->keyToCharTableSize; k++) - { - if (keyToChar[k] & kUCKeyOutputTestForIndexMask) - { - long idx = keyToChar[k] & kUCKeyOutputGetIndexMask; - if (stateRec && idx < stateRec->keyStateRecordCount) - { - UCKeyStateRecord* rec = reinterpret_cast(data + stateRec->keyStateRecordOffsets[idx]); - if (rec->stateZeroCharData == ch) return k; - } - } - else if (!(keyToChar[k] & kUCKeyOutputSequenceIndexMask) && keyToChar[k] < 0xFFFE) - { - if (keyToChar[k] == ch) return k; - } - } // for k - } // for j - } // for i - - return 0; -} - -bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativeMods) -{ - if (!qxt_mac_handler_installed) - { - EventTypeSpec t; - t.eventClass = kEventClassKeyboard; - t.eventKind = kEventHotKeyPressed; - InstallApplicationEventHandler(&qxt_mac_handle_hot_key, 1, &t, NULL, NULL); - } - - EventHotKeyID keyID; - keyID.signature = 'cute'; - keyID.id = ++hotKeySerial; - - EventHotKeyRef ref = 0; - bool rv = !RegisterEventHotKey(nativeKey, nativeMods, keyID, GetApplicationEventTarget(), 0, &ref); - if (rv) - { - keyIDs.insert(Identifier(nativeMods, nativeKey), keyID.id); - keyRefs.insert(keyID.id, ref); - } - return rv; -} - -bool QxtGlobalShortcutPrivate::unregisterShortcut(quint32 nativeKey, quint32 nativeMods) -{ - Identifier id(nativeMods, nativeKey); - if (!keyIDs.contains(id)) return false; - - EventHotKeyRef ref = keyRefs.take(keyIDs[id]); - keyIDs.remove(id); - return !UnregisterEventHotKey(ref); -} diff -Nru syncwall-1.6.0/3rdparty/qxt/qxtglobalshortcut_p.h syncwall-1.7.4/3rdparty/qxt/qxtglobalshortcut_p.h --- syncwall-1.6.0/3rdparty/qxt/qxtglobalshortcut_p.h 2011-11-24 15:10:32.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qxt/qxtglobalshortcut_p.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,66 +0,0 @@ -/**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtGui module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ -#ifndef QXTGLOBALSHORTCUT_P_H -#define QXTGLOBALSHORTCUT_P_H - -#include "qxtglobalshortcut.h" -#include -#include -#include - -class QxtGlobalShortcutPrivate : public QxtPrivate -{ -public: - QXT_DECLARE_PUBLIC(QxtGlobalShortcut) - QxtGlobalShortcutPrivate(); - ~QxtGlobalShortcutPrivate(); - - bool enabled; - Qt::Key key; - Qt::KeyboardModifiers mods; - - bool setShortcut(const QKeySequence& shortcut); - bool unsetShortcut(); - - static bool error; -#ifndef Q_WS_MAC - static int ref; - static QAbstractEventDispatcher::EventFilter prevEventFilter; - static bool eventFilter(void* message); -#endif // Q_WS_MAC - - static void activateShortcut(quint32 nativeKey, quint32 nativeMods); - -private: - static quint32 nativeKeycode(Qt::Key keycode); - static quint32 nativeModifiers(Qt::KeyboardModifiers modifiers); - - static bool registerShortcut(quint32 nativeKey, quint32 nativeMods); - static bool unregisterShortcut(quint32 nativeKey, quint32 nativeMods); - - static QHash, QxtGlobalShortcut*> shortcuts; -}; - -#endif // QXTGLOBALSHORTCUT_P_H diff -Nru syncwall-1.6.0/3rdparty/qxt/qxtglobalshortcut_win.cpp syncwall-1.7.4/3rdparty/qxt/qxtglobalshortcut_win.cpp --- syncwall-1.6.0/3rdparty/qxt/qxtglobalshortcut_win.cpp 2011-12-05 08:10:54.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qxt/qxtglobalshortcut_win.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,292 +0,0 @@ -/**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtGui module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ -#include "qxtglobalshortcut_p.h" -#include - -// Key code values not found in winuser.h -#ifndef VK_MINUS -#define VK_MINUS 0xBD -#endif // VK_MINUS -#ifndef VK_SEMICOLON -#define VK_SEMICOLON 0xBA -#endif // VK_SEMICOLON -#ifndef VK_PERIOD -#define VK_PERIOD 0xBE -#endif // VK_PERIOD -#ifndef VK_COMMA -#define VK_COMMA 0xBC -#endif // VK_COMMA -#ifndef VK_QUOTE -#define VK_QUOTE 0xDE -#endif // VK_QUOTE -#ifndef VK_BACK_QUOTE -#define VK_BACK_QUOTE 0xC0 -#endif // VK_BACK_QUOTE -#ifndef VK_SLASH -#define VK_SLASH 0xBF -#endif // VK_SLASH -#ifndef VK_BACK_SLASH -#define VK_BACK_SLASH 0xDC -#endif // VK_BACK_SLASH -#ifndef VK_EQUALS -#define VK_EQUALS 0xBB -#endif // VK_EQUALS -#ifndef VK_OPEN_BRACKET -#define VK_OPEN_BRACKET 0xDB -#endif // VK_OPEN_BRACKET -#ifndef VK_CLOSE_BRACKET -#define VK_CLOSE_BRACKET 0xDD -#endif // VK_CLOSE_BRACKET -#ifndef VK_GR_LESS -#define VK_GR_LESS 0xE2 -#endif // VK_GR_LESS - -#ifndef VK_MEDIA_NEXT_TRACK -#define VK_MEDIA_NEXT_TRACK 0xB0 -#endif // VK_MEDIA_NEXT_TRACK -#ifndef VK_MEDIA_PREV_TRACK -#define VK_MEDIA_PREV_TRACK 0xB1 -#endif // VK_MEDIA_PREV_TRACK -#ifndef VK_MEDIA_STOP -#define VK_MEDIA_STOP 0xB2 -#endif // VK_MEDIA_STOP -#ifndef VK_MEDIA_PLAY_PAUSE -#define VK_MEDIA_PLAY_PAUSE 0xB3 -#endif // VK_MEDIA_PLAY_PAUSE - -#ifndef VK_VOLUME_MUTE -#define VK_VOLUME_MUTE 0xAD -#endif // VK_VOLUME_MUTE -#ifndef VK_VOLUME_DOWN -#define VK_VOLUME_DOWN 0xAE -#endif // VK_VOLUME_DOWN -#ifndef VK_VOLUME_UP -#define VK_VOLUME_UP 0xAF -#endif // VK_VOLUME_UP - -bool QxtGlobalShortcutPrivate::eventFilter(void* message) -{ - MSG* msg = static_cast(message); - if (msg->message == WM_HOTKEY) - { - const quint32 keycode = HIWORD(msg->lParam); - const quint32 modifiers = LOWORD(msg->lParam); - activateShortcut(keycode, modifiers); - } - return false; -} - -quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers) -{ - // MOD_ALT, MOD_CONTROL, (MOD_KEYUP), MOD_SHIFT, MOD_WIN - quint32 native = 0; - if (modifiers & Qt::ShiftModifier) - native |= MOD_SHIFT; - if (modifiers & Qt::ControlModifier) - native |= MOD_CONTROL; - if (modifiers & Qt::AltModifier) - native |= MOD_ALT; - if (modifiers & Qt::MetaModifier) - native |= MOD_WIN; - // TODO: resolve these? - //if (modifiers & Qt::KeypadModifier) - //if (modifiers & Qt::GroupSwitchModifier) - return native; -} - -quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key) -{ - switch (key) - { - case Qt::Key_Escape: - return VK_ESCAPE; - case Qt::Key_Tab: - case Qt::Key_Backtab: - return VK_TAB; - case Qt::Key_Backspace: - return VK_BACK; - case Qt::Key_Return: - case Qt::Key_Enter: - return VK_RETURN; - case Qt::Key_Insert: - return VK_INSERT; - case Qt::Key_Delete: - return VK_DELETE; - case Qt::Key_Pause: - return VK_PAUSE; - case Qt::Key_Print: - return VK_PRINT; - case Qt::Key_Clear: - return VK_CLEAR; - case Qt::Key_Home: - return VK_HOME; - case Qt::Key_End: - return VK_END; - case Qt::Key_Left: - return VK_LEFT; - case Qt::Key_Up: - return VK_UP; - case Qt::Key_Right: - return VK_RIGHT; - case Qt::Key_Down: - return VK_DOWN; - case Qt::Key_PageUp: - return VK_PRIOR; - case Qt::Key_PageDown: - return VK_NEXT; - case Qt::Key_F1: - return VK_F1; - case Qt::Key_F2: - return VK_F2; - case Qt::Key_F3: - return VK_F3; - case Qt::Key_F4: - return VK_F4; - case Qt::Key_F5: - return VK_F5; - case Qt::Key_F6: - return VK_F6; - case Qt::Key_F7: - return VK_F7; - case Qt::Key_F8: - return VK_F8; - case Qt::Key_F9: - return VK_F9; - case Qt::Key_F10: - return VK_F10; - case Qt::Key_F11: - return VK_F11; - case Qt::Key_F12: - return VK_F12; - case Qt::Key_F13: - return VK_F13; - case Qt::Key_F14: - return VK_F14; - case Qt::Key_F15: - return VK_F15; - case Qt::Key_F16: - return VK_F16; - case Qt::Key_F17: - return VK_F17; - case Qt::Key_F18: - return VK_F18; - case Qt::Key_F19: - return VK_F19; - case Qt::Key_F20: - return VK_F20; - case Qt::Key_F21: - return VK_F21; - case Qt::Key_F22: - return VK_F22; - case Qt::Key_F23: - return VK_F23; - case Qt::Key_F24: - return VK_F24; - case Qt::Key_Space: - return VK_SPACE; - case Qt::Key_Asterisk: - return VK_MULTIPLY; - case Qt::Key_Plus: - return VK_ADD; - case Qt::Key_Comma: - return VK_SEPARATOR; - case Qt::Key_Minus: - return VK_SUBTRACT; - case Qt::Key_Slash: - return VK_DIVIDE; - case Qt::Key_MediaNext: - return VK_MEDIA_NEXT_TRACK; - case Qt::Key_MediaPrevious: - return VK_MEDIA_PREV_TRACK; - case Qt::Key_MediaPlay: - return VK_MEDIA_PLAY_PAUSE; - case Qt::Key_MediaStop: - return VK_MEDIA_STOP; - // couldn't find those in VK_* - //case Qt::Key_MediaLast: - //case Qt::Key_MediaRecord: - case Qt::Key_VolumeDown: - return VK_VOLUME_DOWN; - case Qt::Key_VolumeUp: - return VK_VOLUME_UP; - case Qt::Key_VolumeMute: - return VK_VOLUME_MUTE; - - // numbers - case Qt::Key_0: - case Qt::Key_1: - case Qt::Key_2: - case Qt::Key_3: - case Qt::Key_4: - case Qt::Key_5: - case Qt::Key_6: - case Qt::Key_7: - case Qt::Key_8: - case Qt::Key_9: - return key; - - // letters - case Qt::Key_A: - case Qt::Key_B: - case Qt::Key_C: - case Qt::Key_D: - case Qt::Key_E: - case Qt::Key_F: - case Qt::Key_G: - case Qt::Key_H: - case Qt::Key_I: - case Qt::Key_J: - case Qt::Key_K: - case Qt::Key_L: - case Qt::Key_M: - case Qt::Key_N: - case Qt::Key_O: - case Qt::Key_P: - case Qt::Key_Q: - case Qt::Key_R: - case Qt::Key_S: - case Qt::Key_T: - case Qt::Key_U: - case Qt::Key_V: - case Qt::Key_W: - case Qt::Key_X: - case Qt::Key_Y: - case Qt::Key_Z: - return key; - - default: - return 0; - } -} - -bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativeMods) -{ - return RegisterHotKey(0, nativeMods ^ nativeKey, nativeMods, nativeKey); -} - -bool QxtGlobalShortcutPrivate::unregisterShortcut(quint32 nativeKey, quint32 nativeMods) -{ - return UnregisterHotKey(0, nativeMods ^ nativeKey); -} diff -Nru syncwall-1.6.0/3rdparty/qxt/qxtglobalshortcut_x11.cpp syncwall-1.7.4/3rdparty/qxt/qxtglobalshortcut_x11.cpp --- syncwall-1.6.0/3rdparty/qxt/qxtglobalshortcut_x11.cpp 2011-11-24 15:10:32.000000000 +0000 +++ syncwall-1.7.4/3rdparty/qxt/qxtglobalshortcut_x11.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,118 +0,0 @@ -/**************************************************************************** - ** - ** Copyright (C) Qxt Foundation. Some rights reserved. - ** - ** This file is part of the QxtGui module of the Qxt library. - ** - ** This library is free software; you can redistribute it and/or modify it - ** under the terms of the Common Public License, version 1.0, as published - ** by IBM, and/or under the terms of the GNU Lesser General Public License, - ** version 2.1, as published by the Free Software Foundation. - ** - ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY - ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY - ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR - ** FITNESS FOR A PARTICULAR PURPOSE. - ** - ** You should have received a copy of the CPL and the LGPL along with this - ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files - ** included with the source distribution for more information. - ** If you did not receive a copy of the licenses, contact the Qxt Foundation. - ** - ** - ** - ****************************************************************************/ -#include "qxtglobalshortcut_p.h" -#include -#include - -static int (*original_x_errhandler)(Display* display, XErrorEvent* event); - -static int qxt_x_errhandler(Display* display, XErrorEvent *event) -{ - Q_UNUSED(display); - switch (event->error_code) - { - case BadAccess: - case BadValue: - case BadWindow: - if (event->request_code == 33 /* X_GrabKey */ || - event->request_code == 34 /* X_UngrabKey */) - { - QxtGlobalShortcutPrivate::error = true; - //TODO: - //char errstr[256]; - //XGetErrorText(dpy, err->error_code, errstr, 256); - } - default: - return 0; - } -} - -bool QxtGlobalShortcutPrivate::eventFilter(void* message) -{ - XEvent* event = static_cast(message); - if (event->type == KeyPress) - { - XKeyEvent* key = (XKeyEvent*) event; - activateShortcut(key->keycode, - // Mod1Mask == Alt, Mod4Mask == Meta - key->state & (ShiftMask | ControlMask | Mod1Mask | Mod4Mask)); - } - return false; -} - -quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers) -{ - // ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask, and Mod5Mask - quint32 native = 0; - if (modifiers & Qt::ShiftModifier) - native |= ShiftMask; - if (modifiers & Qt::ControlModifier) - native |= ControlMask; - if (modifiers & Qt::AltModifier) - native |= Mod1Mask; - if (modifiers & Qt::MetaModifier) - native |= Mod4Mask; - - // TODO: resolve these? - //if (modifiers & Qt::MetaModifier) - //if (modifiers & Qt::KeypadModifier) - //if (modifiers & Qt::GroupSwitchModifier) - return native; -} - -quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key) -{ - Display* display = QX11Info::display(); - return XKeysymToKeycode(display, XStringToKeysym(QKeySequence(key).toString().toLatin1().data())); -} - -bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativeMods) -{ - Display* display = QX11Info::display(); - Window window = QX11Info::appRootWindow(); - Bool owner = True; - int pointer = GrabModeAsync; - int keyboard = GrabModeAsync; - error = false; - original_x_errhandler = XSetErrorHandler(qxt_x_errhandler); - XGrabKey(display, nativeKey, nativeMods, window, owner, pointer, keyboard); - XGrabKey(display, nativeKey, nativeMods | Mod2Mask, window, owner, pointer, keyboard); // allow numlock - XSync(display, False); - XSetErrorHandler(original_x_errhandler); - return !error; -} - -bool QxtGlobalShortcutPrivate::unregisterShortcut(quint32 nativeKey, quint32 nativeMods) -{ - Display* display = QX11Info::display(); - Window window = QX11Info::appRootWindow(); - error = false; - original_x_errhandler = XSetErrorHandler(qxt_x_errhandler); - XUngrabKey(display, nativeKey, nativeMods, window); - XUngrabKey(display, nativeKey, nativeMods | Mod2Mask, window); // allow numlock - XSync(display, False); - XSetErrorHandler(original_x_errhandler); - return !error; -} diff -Nru syncwall-1.6.0/CREDITS.txt syncwall-1.7.4/CREDITS.txt --- syncwall-1.6.0/CREDITS.txt 2012-05-12 09:09:00.000000000 +0000 +++ syncwall-1.7.4/CREDITS.txt 2013-04-19 07:57:40.000000000 +0000 @@ -1,13 +1,16 @@ SyncWall: a multiplatform wallpaper management system with synchronization features between computers porting tasks: -- OS/2: thanks to Elbert Pol (elbert.pol at gmail.com) +- OS/2: thanks to Elbert Pol (elbert.pol at gmail dot com) translations: -- french: thanks to xbee (xbee at xbee.net) +- French: thanks to xbee (xbee at xbee.net) +- Lithuanian: thanks to Algimantas Margevicius (Margevicius dot Algimantas at gmail dot com) Some parts are derived, inspired, extracted or use these great projects: -* Siena icon set by http://www.webdesignerdepot.com/ +* icons from Siena icons set (http://www.webdesignerdepot.com/) +* icons from Copenhagen icons set (http://www.iconfinder.com/) +* icons from Sophistique icons set (http://www.iconfinder.com/) * Blitz: A QImage manipulation library (http://sourceforge.net/projects/qimageblitz/) * Single Application : extract from http://www.qtcentre.org/wiki/index.php?title=SingleApplication * Wally: Qt4 wallpaper/background changer (http://www.becrux.com/index.php?page=projects&name=wally) @@ -17,4 +20,5 @@ * Squash: allows resizing of images in a batch mode. By Seb Ruiz * Jani Huhtanen (2006) for his Exponential blur functions * Qxt libs: a general purpose libs with many features (http://dev.libqxt.org/libqxt/wiki/Home) +* Qt examples diff -Nru syncwall-1.6.0/Changelog.txt syncwall-1.7.4/Changelog.txt --- syncwall-1.6.0/Changelog.txt 2012-08-18 06:26:14.000000000 +0000 +++ syncwall-1.7.4/Changelog.txt 2013-07-13 06:01:12.000000000 +0000 @@ -1,3 +1,38 @@ +Version 1.7.4 +* Features +- Add Vietnamese translation. Thanks to ppanhh. +* Bugs +- incorrect loading of translation file in some cases +Version 1.7.3 +* Features +- Add Dutch translation. Thanks to izumikonata. +* Bugs +- correct a problem of Unicode name in the path on Seven. +Version 1.7.2 +- some code refactoring +- add a direct link to website for help +- update .pro file for missed translation files +Version 1.7.1 +* Features +- add Lithuanian translation. Thanks to Algimantas Margevicius (Margevicius dot Algimantas at gmail dot com) +* Bugs +- change argument on LXDE window manager +- Missing #include file on some linux platform +- Missing sqlite driver in setup.exe (Windows) +- No sqlite but sqlite3 driver on some platforms +Version 1.7.0 +* Features +- display name of current wallpaper in window header +- change layout for better handling small screen (laptop) +- addition of some global shortcuts (now also displayed in systray menu) +- addition of rating on the images. The images with high rating are more often displayed. +- addition of a simple database backend for image data to speed up display. +- addition of image alignment defined graphically by user (in order to display best part of images) +- addition of an horizontal alignment parameter +- addition of several resampling methods +- change of some icons +* Bugs +- correct invalid cmake definition file Version 1.6.0 * Features - add the ability to rotate image according to Exif metadata diff -Nru syncwall-1.6.0/INSTALL.txt syncwall-1.7.4/INSTALL.txt --- syncwall-1.6.0/INSTALL.txt 2012-01-23 11:06:52.000000000 +0000 +++ syncwall-1.7.4/INSTALL.txt 2013-05-17 15:13:38.000000000 +0000 @@ -1,12 +1,19 @@ * Linux (test on ubuntu/kubuntu/Fedora/openSuse/CentOS/debian) +Required: libqxt-dev libqimageblitz-dev #> dos2unix tounix.sh #> sh ./tounix.sh -#> qmake-qt4 -recursive +# cd build +#> qmake-qt4 -recursive SyncWall.pro or -#> qmake -recursive +#> qmake -recursive SyncWall.pro +#> make +#> sudo make install + +or with cmake +#> cd build +#> cmake . #> make -#> cd SyncWall/build #>sudo make install You can also use qtcreator from qt-sdk @@ -24,5 +31,4 @@ * MAC OSX not tested -* OS2 -see README.os2 + diff -Nru syncwall-1.6.0/LICENSE.txt syncwall-1.7.4/LICENSE.txt --- syncwall-1.6.0/LICENSE.txt 2011-08-29 13:26:10.000000000 +0000 +++ syncwall-1.7.4/LICENSE.txt 2013-05-05 23:01:10.000000000 +0000 @@ -1,12 +1,12 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - Preamble + Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public @@ -15,7 +15,7 @@ General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to +the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not @@ -56,7 +56,7 @@ The precise terms and conditions for copying, distribution and modification follow. - GNU GENERAL PUBLIC LICENSE + GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains @@ -255,7 +255,7 @@ of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. - NO WARRANTY + NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN @@ -277,4 +277,63 @@ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - END OF TERMS AND CONDITIONS + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff -Nru syncwall-1.6.0/README.txt syncwall-1.7.4/README.txt --- syncwall-1.6.0/README.txt 2012-01-23 11:13:18.000000000 +0000 +++ syncwall-1.7.4/README.txt 2013-05-05 03:42:16.000000000 +0000 @@ -2,4 +2,10 @@ to synchronize wallpaper change between several workstations with a basic (and unsecured) client/server protocol. Each workstation must share the same pool of files, there is no FTP or Internet download. -Because SyncWall is written with Qt, SyncWall runs on Windows, Linux, OS/2 (MacOSX isn't tested yet). \ No newline at end of file +Because SyncWall is written with Qt, SyncWall runs on Windows, Linux, OS/2 (MacOSX isn't tested yet). + +You want to help ? You can proposed you as translator on transifex.com (SyncWall project) or post feedbacks on SourceForge: +- http://sourceforge.net/p/syncwall/tickets for bug report or feature request +- http://sourceforge.net/p/syncwall/discussion/ for general feedbacks + +You can also help me by correcting my brief help page (I'm sure you've noticed that English is not my mother tongue! :)) Contact me xbee at xbee dot net \ No newline at end of file diff -Nru syncwall-1.6.0/SyncWall/SyncWall.pro syncwall-1.7.4/SyncWall/SyncWall.pro --- syncwall-1.6.0/SyncWall/SyncWall.pro 2012-01-05 03:29:16.000000000 +0000 +++ syncwall-1.7.4/SyncWall/SyncWall.pro 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ - -SUBDIRS += build - -TEMPLATE = subdirs - - - - - - diff -Nru syncwall-1.6.0/SyncWall/build/CMakeLists.txt syncwall-1.7.4/SyncWall/build/CMakeLists.txt --- syncwall-1.6.0/SyncWall/build/CMakeLists.txt 2012-08-18 07:32:30.000000000 +0000 +++ syncwall-1.7.4/SyncWall/build/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,224 +0,0 @@ -# -# SyncWall CMakeLists.txt -# -# To build SyncWall, you will need cmake 2.6 -# To build the application run this commands: -# -# cd build -# cmake ./ -# make -# -# If you don't kwon cmake, here are some links for you: -# http://wiki.qtcentre.org/index.php?title=Compiling_Qt4_apps_with_CMake -# http://qtnode.net/wiki/Qt_with_cmake#cmake_for_Qt_4 - -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) - -# set project's name -PROJECT(SyncWall) - -# note: change this BEFORE making a release !! -SET( MYAPP_VERSION "1.6.0" ) -set( PROGNAME syncwall ) - -IF( APPLE ) - SET( MACOSX_BUNDLE_ICON_FILE ${PROGNAME}.icns ) - SET( MACOSX_BUNDLE_SHORT_VERSION_STRING ${MYAPP_VERSION} ) - SET( MACOSX_BUNDLE_VERSION ${MYAPP_VERSION} ) - SET( MACOSX_BUNDLE_LONG_VERSION_STRING Version ${MYAPP_VERSION} ) - SET( MACOSX_BUNDLE_INFO_PLIST Version "../res/Info.plist" ) - SET( CMAKE_OSX_ARCHITECTURES ppc;i386 ) #Comment out if not universal binary -ENDIF( APPLE ) - -CMAKE_MINIMUM_REQUIRED(VERSION 2.4.4) -SET(CMAKE_COLOR_MAKEFILE ON) -SET(CMAKE_VERBOSE_MAKEFILE OFF) -SET(CMAKE_INCLUDE_CURRENT_DIR TRUE) - -# this command finds Qt4 libraries and sets all required variables -FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui QtNetwork REQUIRED) - -# add some useful macros and variables -# (QT_USE_FILE is a variable defined by FIND_PACKAGE( Qt4 ) that contains a path to CMake script) -INCLUDE(${QT_USE_FILE}) -INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR} "../src/" "../../3rdparty/qkeysequencewidget" "../../3rdparty/qxt" "../../3rdparty/qimageblitz" "../../3rdparty/qt-extended") - -FILE(GLOB include_file_list "../src/*.h" "../../3rdparty/qkeysequencewidget/*.h" ) -IF (WIN32) - FILE(GLOB cpp_file_list "../src/*.cpp" "../../3rdparty/qkeysequencewidget/*.cpp" ) -ELSEIF (APPLE) - FILE(GLOB cpp_file_list "../src/*.cpp" "../../3rdparty/qkeysequencewidget/*.cpp" ) -ELSE (WIN32) - FILE(GLOB cpp_file_list "../src/*.cpp" "../../3rdparty/qkeysequencewidget/*.cpp" ) -ENDIF (WIN32) -FILE(GLOB resource_file_list "../res/*.qrc") -FILE(GLOB ui_file_list "../ui/*.ui") -FILE(GLOB trans_file_list "../lang/*.ts") - - - -SET(MYAPP_UIS - ${ui_file_list} -) - -SET(MYAPP_HDRS - ${include_file_list} -) - -SET(MYAPP_SRCS - ${cpp_file_list} -) - -SET(MYAPP_TRANS - ${trans_file_list} -) - -SET(MYAPP_RES - ${resource_file_list} -) - -# add special flags for compilation -ADD_DEFINITIONS( -DQXT_STATIC -DMAKE_QIMAGEBLITZ_LIB ) - -# enable warnings for GCC compiler -IF(CMAKE_COMPILER_IS_GNUCXX ) - ADD_DEFINITIONS( -Wall -Wextra ) -ENDIF(CMAKE_COMPILER_IS_GNUCXX ) - -# qt4 definitinos -QT4_WRAP_UI ( MYAPP_UIS_H ${MYAPP_UIS} ) -QT4_WRAP_CPP ( MYAPP_MOC_SRCS ${MYAPP_HDRS} ) -QT4_ADD_RESOURCES ( MYAPP_RESOURCES ${MYAPP_RES} ) -QT4_AUTOMOC ( ${MYAPP_SRCS} ) -QT4_ADD_TRANSLATION ( MYAPP_QM ${MYAPP_TRANS} ) - -IF(COMMAND CMAKE_POLICY) - CMAKE_POLICY(SET CMP0003 NEW) - CMAKE_POLICY(SET CMP0005 OLD) -ENDIF(COMMAND CMAKE_POLICY) - - -# we need this to be able to include headers produced by uic in our code -# (CMAKE_BINARY_DIR holds a path to the build directory, while INCLUDE_DIRECTORIES() works just like INCLUDEPATH from qmake) -INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} ) - -# resource compilation for MinGW -IF( MINGW ) - ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${PROGNAME}ico.o - COMMAND windres.exe -I${CMAKE_CURRENT_SOURCE_DIR} -i${CMAKE_CURRENT_SOURCE_DIR}/../res/${PROGNAME}.rc -o ${CMAKE_CURRENT_BINARY_DIR}/${PROGNAME}ico.o ) - SET(MYAPP_RESOURCES ${MYAPP_RESOURCES} ${CMAKE_CURRENT_BINARY_DIR}/${PROGNAME}ico.o) -ELSE( MINGW ) - SET(MYAPP_RESOURCES ${MYAPP_RESOURCES} ../res/${PROGNAME}.rc ) -ENDIF( MINGW ) - -# Set some Win32 Specific Settings -IF(WIN32) - SET(GUI_TYPE WIN32) -ENDIF(WIN32) - -IF (MSVC) - # Turn off deprecation warnings - ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS) - ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_WARNINGS) - ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE) -ENDIF(MSVC) - -# Set some Apple MacOS Specific settings -IF (APPLE) - SET(GUI_TYPE MACOSX_BUNDLE) -ENDIF (APPLE) - -# here we instruct CMake to build "myapp" executable from all of the source files -IF( APPLE ) - ADD_EXECUTABLE( ${PROGNAME} ${GUI_TYPE} ${MYAPP_SRCS} ${MYAPP_UIS_H} ${MYAPP_RESOURCES} ${MYAPP_MOC_SRCS} ) - ADD_CUSTOM_COMMAND( TARGET ${PROGNAME} POST_BUILD - COMMAND mkdir ARGS ${CMAKE_CURRENT_BINARY_DIR}/${PROGNAME}.app/Contents/Resources - COMMAND cp ARGS ${MACOSX_BUNDLE_ICON_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${PROGNAME}.app/Contents/Resources - COMMAND cp ARGS *.qm ${CMAKE_CURRENT_BINARY_DIR}/${PROGNAME}.app/Contents/Resources ) -ELSE( APPLE ) - ADD_EXECUTABLE( ${PROGNAME} WIN32 ${MYAPP_SRCS} ${MYAPP_UIS_H} ${MYAPP_MOC_SRCS} ${MYAPP_RESOURCES} ${MYAPP_QM} ) -ENDIF( APPLE ) - -# last thing we have to do is to tell CMake what libraries our executable needs, -# luckily FIND_PACKAGE prepared QT_LIBRARIES variable for us: -IF (UNIX) - TARGET_LINK_LIBRARIES( ${PROGNAME} ${QT_LIBRARIES} qxt qimageblitz -lX11 -ldl ) -ELSE (UNIX) - TARGET_LINK_LIBRARIES( ${PROGNAME} ${QT_LIBRARIES} qxt qimageblitz ) -ENDIF (UNIX) - -IF(WIN32) - SET_TARGET_PROPERTIES(${PROGNAME} PROPERTIES - LINK_FLAGS "/VERSION:${MYAPP_VERSION}" - LINK_FLAGS_RELEASE "/ENTRY:\"mainCRTStartup\" /SUBSYSTEM:WINDOWS" - LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE" ) -ENDIF(WIN32) - -# compilation of others directories -ADD_SUBDIRECTORY("../../3rdparty/qimageblitz" "${CMAKE_CURRENT_BINARY_DIR}/qimageblitz") -ADD_SUBDIRECTORY("../../3rdparty/qxt" "${CMAKE_CURRENT_BINARY_DIR}/qxt") - -# build desktop file and manpage if needed -IF( UNIX AND NOT APPLE ) - IF( NOT DESKTOP_ENTRY ) - SET( DESKTOP_ENTRY ${PROGNAME}.desktop ) - ENDIF( NOT DESKTOP_ENTRY ) - - ADD_CUSTOM_COMMAND( OUTPUT ${DESKTOP_ENTRY} - COMMAND touch ${DESKTOP_ENTRY} - COMMAND sh ${PROGNAME}-desktop.sh ${CMAKE_INSTALL_PREFIX} ${MYAPP_VERSION} >${DESKTOP_ENTRY} - DEPENDS ${PROGNAME}-desktop.sh - COMMENT "Generating desktop entry file" - ) - ADD_CUSTOM_TARGET( DESKTOP_ENTRY_FILE ALL - DEPENDS ${DESKTOP_ENTRY} - ) - - SET( APP_ICON ../res/${PROGNAME}.png ) - - #Generate manpage - IF( NOT MANPAGE_DIRECTORY ) - set( MANPAGE_DIRECTORY /usr/share/man/man1 ) - ENDIF( NOT MANPAGE_DIRECTORY) - - ADD_CUSTOM_COMMAND( OUTPUT ${PROGNAME}.1.gz - COMMAND touch ${PROGNAME}.1 - COMMAND sh ${PROGNAME}-manpage.sh ${MYAPP_VERSION} >${PROGNAME}.1 - COMMAND gzip -f -9 ${PROGNAME}.1 - DEPENDS ${PROGNAME}-manpage.sh - COMMENT "Generating manpage" - ) - ADD_CUSTOM_TARGET( MANPAGE_FILE ALL - DEPENDS ${PROGNAME}.1.gz - ) - - SET_DIRECTORY_PROPERTIES( ADDITIONAL_MAKE_CLEAN_FILES ${PROGNAME}.1 ${PROGNAME}.1.gz ) -ENDIF (UNIX AND NOT APPLE) - -# install - -# windows -IF (WIN32) - ADD_CUSTOM_COMMAND( TARGET ${PROGNAME} POST_BUILD - # there is a nsi installer !!! - COMMAND makensis.exe /DVERSION=${MYAPP_VERSION} /DSETUP_DIR=../setup ../setup/setup.nsi - COMMENT "Generating setup via NSI installer" - ) -ENDIF (WIN32) - -# linux -if (UNIX AND NOT APPLE) - INSTALL ( TARGETS ${PROGNAME} RUNTIME DESTINATION bin ) - INSTALL ( FILES ${MYAPP_QM} DESTINATION share/locale ) - # freedesktop file - INSTALL(FILES ${PROGNAME}.desktop DESTINATION "${CMAKE_INSTALL_PREFIX}/share/applications/" ) - INSTALL(FILES ../res/${PROGNAME}.png DESTINATION "${CMAKE_INSTALL_PREFIX}/share/pixmaps/" ) - INSTALL(FILES ../../CREDITS.txt ../../README.txt ../../AUTHORS.txt ../../Changelog.txt DESTINATION share/${PROGNAME}) - -endif (UNIX AND NOT APPLE) - - - - - - diff -Nru syncwall-1.6.0/SyncWall/build/build.pro syncwall-1.7.4/SyncWall/build/build.pro --- syncwall-1.6.0/SyncWall/build/build.pro 2012-08-18 07:15:28.000000000 +0000 +++ syncwall-1.7.4/SyncWall/build/build.pro 1970-01-01 00:00:00.000000000 +0000 @@ -1,188 +0,0 @@ - -TARGET = syncwall - -CONFIG += ordered debug_and_release - -CONFIG(debug,debug|release) { - LIBS+=-L../../3rdparty/qimageblitz/debug/ -} else { - LIBS+=-L../../3rdparty/qimageblitz/release/ -} - -unix:LIBS+= -lX11 - -# directories setup -isEmpty( INSTALL_PREFIX ) : INSTALL_PREFIX = /usr/local - -isEmpty( INSTALL_BINDIR ) : INSTALL_BINDIR = $$INSTALL_PREFIX/bin -isEmpty( INSTALL_LIBDIR ) { - INSTALL_LIBDIR = $$INSTALL_PREFIX/lib - #installing to lib64 on 64-bit platforms: - contains (QMAKE_HOST.arch, x86_64) : INSTALL_LIBDIR = $$INSTALL_PREFIX/lib64 -} - -isEmpty( INSTALL_MANDIR ) : INSTALL_MANDIR = $$INSTALL_PREFIX/share/man -isEmpty( INSTALL_DATADIR ) : INSTALL_DATADIR = $$INSTALL_PREFIX/share - -isEmpty( MYAPP_INSTALL_DESKTOP ) : MYAPP_INSTALL_DESKTOP = $$INSTALL_DATADIR/applications -isEmpty( MYAPP_INSTALL_PIXMAPS ) : MYAPP_INSTALL_PIXMAPS = $$INSTALL_DATADIR/pixmaps -isEmpty( MYAPP_INSTALL_DATA ) : MYAPP_INSTALL_DATA = $$INSTALL_DATADIR/$$TARGET -isEmpty( MYAPP_INSTALL_DIR ) : MYAPP_INSTALL_DIR = $$INSTALL_LIBDIR/$$TARGET -isEmpty( MYAPP_INSTALL_BINDIR ) : MYAPP_INSTALL_BINDIR = $$INSTALL_BINDIR -isEmpty( MYAPP_INSTALL_MAN ) : MYAPP_INSTALL_MAN = $$INSTALL_MANDIR/man1 -isEmpty( MYAPP_INSTALL_TRANS ) : MYAPP_INSTALL_TRANS = $$INSTALL_DATADIR/locale - -LIBS += -L../../3rdparty/qimageblitz/ -lqimageblitz - -HEADERS += \ - ../src/AppSettings.h \ - ../src/BackgroundPainter.h \ - ../src/BackgroundPainterConfigWidget.h \ - ../src/DesktopScene.h \ - ../src/DesktopView.h \ - ../src/ImageView.h \ - ../src/ImageViewer.h \ - ../src/IMessageHandler.h \ - ../src/LogHandler.h \ - ../src/MiscFunctions.h \ - ../src/NetworkManager.h \ - ../src/NetworkManagerConfigWidget.h \ - ../src/Scheduler.h \ - ../src/SchedulerConfigWidget.h \ - ../src/ScreenItem.h \ - ../src/SingleApplication.h \ - ../src/SplashScreen.h \ - ../src/SyncWall.h \ - ../src/ImageInfos.h \ - ../src/SystemIntegration.h \ - ../src/SystemIntegrationConfigWidget.h \ - ../src/WallpaperProvider.h \ - ../src/ListImagesModel.h \ - ../src/TreeImagesView.h \ - ../src/InfosUpdater.h \ - ../src/IconViewDelegate.h \ - ../src/ThreadPool.h \ - ../../3rdparty/qkeysequencewidget/qkeysequencewidget.h \ - ../../3rdparty/qkeysequencewidget/qkeysequencewidget_p.h \ - ../../3rdparty/qxt/qxtglobal.h \ - ../../3rdparty/qxt/qxtglobalshortcut.h \ - ../../3rdparty/qt-extended/qexifimageheader.h - -SOURCES += \ - ../src/AppSettings.cpp \ - ../src/BackgroundPainter.cpp \ - ../src/BackgroundPainterConfigWidget.cpp \ - ../src/DesktopScene.cpp \ - ../src/DesktopView.cpp \ - ../src/ImageView.cpp \ - ../src/ImageViewer.cpp \ - ../src/LogHandler.cpp \ - ../src/main.cpp \ - ../src/MiscFunctions.cpp \ - ../src/NetworkManager.cpp \ - ../src/NetworkManagerConfigWidget.cpp \ - ../src/Scheduler.cpp \ - ../src/SchedulerConfigWidget.cpp \ - ../src/ScreenItem.cpp \ - ../src/SingleApplication.cpp \ - ../src/SplashScreen.cpp \ - ../src/SyncWall.cpp \ - ../src/ImageInfos.cpp \ - ../src/SystemIntegration.cpp \ - ../src/SystemIntegrationConfigWidget.cpp \ - ../src/WallpaperProvider.cpp \ - ../src/ListImagesModel.cpp \ - ../src/TreeImagesView.cpp \ - ../src/InfosUpdater.cpp \ - ../src/IconViewDelegate.cpp \ - ../src/ThreadPool.cpp \ - ../../3rdparty/qkeysequencewidget/qkeysequencewidget.cpp \ - ../../3rdparty/qxt/qxtglobal.cpp \ - ../../3rdparty/qxt/qxtglobalshortcut.cpp \ - ../../3rdparty/qt-extended/qexifimageheader.cpp - -FORMS += \ - ../ui/BackgroundPainterConfigWidget.ui \ - ../ui/ImageViewer.ui \ - ../ui/NetworkManagerConfigWidget.ui \ - ../ui/SchedulerConfigWidget.ui \ - ../ui/SyncWall.ui \ - ../ui/SystemIntegrationConfigWidget.ui - -INCLUDEPATH += \ - $${DESTDIR} \ - ../../3rdparty/qimageblitz \ - ../../3rdparty/qkeysequencewidget \ - ../../3rdparty/qxt \ - ../../3rdparty/qt-extended \ - ../src - -# OS2 specific -os2:SOURCES -= \ - ../../3rdparty/qxt/qxtglobal.cpp \ - ../../3rdparty/qxt/qxtglobalshortcut.cpp - -os2:HEADERS -= \ - ../../3rdparty/qxt/qxtglobal.h \ - ../../3rdparty/qxt/qxtglobalshortcut.h - -DEFINES += QXT_STATIC MAKE_QIMAGEBLITZ_LIB - -msvc:DEFINES += _CRT_NONSTDC_NO_DEPRECATE _CRT_SECURE_NO_WARNINGS _CRT_SECURE_NO_DEPRECATE - -RESOURCES += ../res/syncwall.qrc - -QT += core gui network - -TRANSLATIONS = ../lang/syncwall_fr.ts - -macx:ICON = ../res/syncwall.icns -macx:SOURCES += ../../3rdparty/qxt/qxtglobalshortcut_mac.cpp -macx:QMAKE_INFO_PLIST = ../res/Info.plist - -win32:RC_FILE = ../res/syncwall.rc -win32:SOURCES += ../../3rdparty/qxt/qxtglobalshortcut_win.cpp - -unix:SOURCES += ../../3rdparty/qxt/qxtglobalshortcut_x11.cpp - - -Release:DESTDIR = release -Release:OBJECTS_DIR = release -Release:MOC_DIR = release -Release:RCC_DIR = release -Release:UI_DIR = release - -Debug:DESTDIR = debug -Debug:OBJECTS_DIR = debug -Debug:MOC_DIR = debug -Debug:RCC_DIR = debug -Debug:UI_DIR = debug - -unix { - # to copy executable to /usr/local/bin directory - starter.files = ./release/syncwall - starter.path = $$MYAPP_INSTALL_BINDIR - - transl.files = ./lang/*.qm - transl.path = $$MYAPP_INSTALL_TRANS - - data.files += ../../CREDITS.txt ../../README.txt ../../AUTHORS.txt ../../Changelog.txt - data.path = $$MYAPP_INSTALL_DATA - - desktop.files += syncwall.desktop - desktop.path = $$MYAPP_INSTALL_DESKTOP - - icons.files += ../res/syncwall.png - icons.path = $$MYAPP_INSTALL_PIXMAPS - - # generate manpage - system( sh syncwall-manpage.sh > syncwall.1 ) - system( gzip -9 -f syncwall.1 ) - manual.files += syncwall.1.gz - manual.path = $$MYAPP_INSTALL_MAN - - INSTALLS += starter transl data desktop icons manual -} - - - diff -Nru syncwall-1.6.0/SyncWall/build/debian/changelog syncwall-1.7.4/SyncWall/build/debian/changelog --- syncwall-1.6.0/SyncWall/build/debian/changelog 2012-02-25 07:55:28.000000000 +0000 +++ syncwall-1.7.4/SyncWall/build/debian/changelog 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -syncwall (1.3.0-1~webupd8~oneiric) oneiric; urgency=medium - - * new upstream release - * removed showwindowtray.patch (now available upstream) - - -- Alin Andrei Sat, 25 Feb 2012 14:55:25 +0000 - -syncwall (1.2.1-1~webupd8~oneiric4) oneiric; urgency=medium - - * Initial upload - - -- Alin Andrei Mon, 13 Feb 2012 12:23:35 +0000 diff -Nru syncwall-1.6.0/SyncWall/build/debian/control syncwall-1.7.4/SyncWall/build/debian/control --- syncwall-1.6.0/SyncWall/build/debian/control 2012-02-13 05:39:00.000000000 +0000 +++ syncwall-1.7.4/SyncWall/build/debian/control 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -Source: syncwall -Section: x11 -Priority: optional -Maintainer: Alin Andrei -Build-Depends: debhelper, cdbs, libqt4-dev, libx11-dev -Standards-Version: 3.8.3 -Homepage: http://qt-apps.org/content/show.php/SyncWall?content=148311 - -Package: syncwall -Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends} -Description: Wallpaper changer - SyncWall is quite a basic wallpaper changer with a special feature, it is the ability to synchronize wallpaper change between several workstations with a basic (and unsecured) client/server protocol. SyncWall has also some multi monitor support. diff -Nru syncwall-1.6.0/SyncWall/build/debian/copyright syncwall-1.7.4/SyncWall/build/debian/copyright --- syncwall-1.6.0/SyncWall/build/debian/copyright 2012-02-13 05:22:46.000000000 +0000 +++ syncwall-1.7.4/SyncWall/build/debian/copyright 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -This package was debianized by: - - Alin Andrei on Mon, 13 Feb 2012 12:22:36 +0000 - -It was downloaded from: - - http://qt-apps.org/content/show.php/SyncWall?content=148311 - -Upstream Author(s): - - xbee - -Copyright: - - Copyright (C) 2012 xbee - -License: - - GPL 2.0+ - -The Debian packaging is: - - Copyright (C) 2011 Alin Andrei - -and is licensed under the GPL version 2.0+. diff -Nru syncwall-1.6.0/SyncWall/build/debian/install syncwall-1.7.4/SyncWall/build/debian/install --- syncwall-1.6.0/SyncWall/build/debian/install 2012-02-13 05:24:00.000000000 +0000 +++ syncwall-1.7.4/SyncWall/build/debian/install 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -debian/syncwall.desktop /usr/share/applications/ diff -Nru syncwall-1.6.0/SyncWall/build/debian/patches/pathfix.patch syncwall-1.7.4/SyncWall/build/debian/patches/pathfix.patch --- syncwall-1.6.0/SyncWall/build/debian/patches/pathfix.patch 2012-02-13 05:25:22.000000000 +0000 +++ syncwall-1.7.4/SyncWall/build/debian/patches/pathfix.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ ---- syncwall-1.2.1.orig/SyncWall/src/SyncWall.cpp -+++ syncwall-1.2.1/SyncWall/src/SyncWall.cpp -@@ -983,7 +983,7 @@ - paths << QApplication::applicationDirPath () + "/../" + file; - paths << QApplication::applicationDirPath () + "/../../" + file; - paths << QApplication::applicationDirPath () + "/../../../" + file; -- paths << "/usr/local/share/syncwall/" + file; -+ paths << "/usr/share/syncwall/" + file; - - - foreach (const QString &path, paths) - ---- syncwall-1.2.1.orig/SyncWall/build/build.pro -+++ syncwall-1.2.1/SyncWall/build/build.pro -@@ -12,7 +12,7 @@ - unix:LIBS+= -lX11 - - # directories setup --isEmpty( INSTALL_PREFIX ) : INSTALL_PREFIX = /usr/local -+isEmpty( INSTALL_PREFIX ) : INSTALL_PREFIX = /usr - - isEmpty( INSTALL_BINDIR ) : INSTALL_BINDIR = $$INSTALL_PREFIX/bin - isEmpty( INSTALL_LIBDIR ) { - diff -Nru syncwall-1.6.0/SyncWall/build/debian/patches/series syncwall-1.7.4/SyncWall/build/debian/patches/series --- syncwall-1.6.0/SyncWall/build/debian/patches/series 2012-02-25 07:53:56.000000000 +0000 +++ syncwall-1.7.4/SyncWall/build/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -pathfix.patch diff -Nru syncwall-1.6.0/SyncWall/build/debian/rules syncwall-1.7.4/SyncWall/build/debian/rules --- syncwall-1.6.0/SyncWall/build/debian/rules 2012-02-13 05:18:40.000000000 +0000 +++ syncwall-1.7.4/SyncWall/build/debian/rules 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ -#!/usr/bin/make -f - -%: - dh $@ - -override_dh_auto_configure: - qmake INSTALL_PREFIX=/usr -recursive diff -Nru syncwall-1.6.0/SyncWall/build/debian/source/format syncwall-1.7.4/SyncWall/build/debian/source/format --- syncwall-1.6.0/SyncWall/build/debian/source/format 2012-01-27 06:08:26.000000000 +0000 +++ syncwall-1.7.4/SyncWall/build/debian/source/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -3.0 (quilt) diff -Nru syncwall-1.6.0/SyncWall/build/debian/syncwall.desktop syncwall-1.7.4/SyncWall/build/debian/syncwall.desktop --- syncwall-1.6.0/SyncWall/build/debian/syncwall.desktop 2012-02-13 04:46:36.000000000 +0000 +++ syncwall-1.7.4/SyncWall/build/debian/syncwall.desktop 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -[Desktop Entry] -Version=1.0 -Encoding=UTF-8 -Name=SyncWall -Comment=Wallpaper changer -Type=Application -GenericName=Wallpaper changer -Exec=syncwall -Categories=Utility;Application; -Icon=syncwall diff -Nru syncwall-1.6.0/SyncWall/build/syncwall-desktop.sh syncwall-1.7.4/SyncWall/build/syncwall-desktop.sh --- syncwall-1.6.0/SyncWall/build/syncwall-desktop.sh 2012-01-23 13:25:38.000000000 +0000 +++ syncwall-1.7.4/SyncWall/build/syncwall-desktop.sh 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -#!/bin/sh -cat < - - - - BackgroundPainter - - No Desktop Environment Detected - Aucun environnement détecté - - - load %1 - chargement de %1 - - - BackgroundPainter: Scale %1x%2 to %3x%4 - BackgroundPainter: Echelle %1x%2 à %3x%4 - - - Saving temp file (%1) - Sauvegarde du fichier temporaire (%1) - - - Failed to save temp file (%1) - Echec de la sauvegarde du fichier temporaire (%1) - - - - BackgroundPainterConfigWidget - - - BackgroundPainterConfigWidget - BackgroundPainterConfigWidget - - - - Preview desktop - Prévisualisation bureau - - - - No data - Aucune donnée - - - Tips: You can reoder and align screens by drag&drop - Remarque: vous pouvez réordonner et aligner les écrans par glisser&poser - - - - Tips: You can reorder and align screens by drag&drop - Remarque: vous pouvez réordonner et aligner les écrans par glisser & poser - - - - Image parameters - Paramètres d'images - - - - share image between monitors - Partager l'image entre moniteurs - - - - Resizing method - Méthode de redimensionnement - - - - Image Alignment (in case of resizing) - Alignement (en cas de redimensionnement) - - - - Background - Fond - - - - export image parameters to clients (server) - Transmission des paramètres d'image aux clients (serveur) - - - - Inverse gradient color - Inverser les couleurs du gradient - - - - ignore image parameters from server (client) - Ignorer les paramètres d'image du serveur (client) - - - - Special effect - Effets spéciaux - - - export image parameters to clients (in case of server) - Transmission des paramètres d'image aux clients (dans le cas d'un serveur) - - - ignore image parameters from server (in case of client) - Ignorer les paramètres d'image du serveur (dans le cas d'un client) - - - - Multi monitor display - Affichage multi-écrans - - - - skip image too small for resizing (<50% of final image) - Ignorer les images trop petites (<50% de la taille finale) - - - Image parameters - Parametres d'image - - - Ignore aspect ratio - Ignorer le rapport d'aspect - - - Keep aspect ratio - Conserver le rapport d'aspect - - - Keep aspect ratio by expanding - Conserver le rapport d'aspect par accroissement - - - Center Image - Centrer l'image - - - Linux desktop integration - Intégration au bureau Linux - - - KDE3 desktop - KDE3 - - - GNOME desktop - Gnome - - - KDE4 desktop - KDE4 - - - Xfce Desktop - Xfce - - - Fluxbox desktop - Fluxbox - - - Blackbox desktop - Blackbox - - - WindowMaker desktop - WindowMaker - - - FVWM desktop - FVWM - - - - no resize - Aucun redimentionnement - - - - Stretch to fill (Ignore aspect ratio) - Remplissage (ignorer les proportions) - - - - Proportionally stretch to fit - Adapter en étirant proportionnellement - - - - Fill proportionally - Remplir proportionnellement - - - - No multi monitor support (wallpaper duplicated) - Pas de prise en compte du multi-écrans (fond d'écran dupliqué) - - - - Extend image (one file for all monitors) - Etendre l'image (une image pour tous les écrans) - - - - Extend image then crop (one file per monitor) - Etendre l'image (une image par écran) - - - - Top alignment - Alignement haut - - - - Center alignment - Alignement Centré - - - - Bottom alignment - Alignement bas - - - - Fixed color - Couleur fixe - - - - Smart color (extract from image) - Couleur automatique - - - - Blurred image - Image floue - - - - Vertical gradient - Gradient vertical - - - - Horizontal gradient - Gradient Horizontal - - - - Radial gradient - Gradient radial - - - - No effect - Aucun effet - - - - Grayscale - Niveau de gris - - - - Blur - Flou - - - - Gaussian blur - Flou gaussien - - - - Edge - Contours - - - - Sharpen - Netteté - - - - Gaussian sharpen - Netteté gaussienne - - - - Emboss - Gauffrage - - - - Desaturate - Désaturer - - - - Flatten - Applatir - - - - Swirl - Tourbillon - - - - Oilpaint - Peinture à l'huile - - - - Charcoal - Fusain - - - - Sepia - Sépia - - - - Invert colors - Inversion des couleurs - - - - Glow - Brillance - - - - Progressive blur - Flou progressif - - - - Random Effect - Effet aléatoire - - - - ImageView - - - x: %1 y: %2 | r: %3 g: %4 b: %5 - x: %1 y: %2 | r: %3 v: %4 b: %5 - - - - a: %1 - a: %1 - - - - ImageViewer - - - ImageViewer - ImageViewer - - - - no info - aucune information - - - - NetworkManagerConfigWidget - - - NetworkManagerConfigWidget - - - - - Synchronise with server - Synchroniser avec un serveur - - - - Server (name or IP) - Serveur (nom ou IP) - - - - UDP Port - - - - - Test Connection - - - - - No connection - Aucune connection - - - - Server %1 reached ... - Serveur %1 atteint ... - - - - Disconnection from server %1 ... - Deconnection du serveur %1 ... - - - - QObject - - - Wallpaper manager. - Gestionnaire de fond d'écran. - - - - Following options are known: - Les options suivantes sont possibles : - - - - --help : displays this help. - --help : Affichage de cette aide. - - - - --reset-config : clear the saved preference parameters. - --reset-config : Effacement des paramètres de configuration sauvegardés. - - - - --no-singleinstance : enable the use of multiple instance of program (not recommended). - --no-singleinstance : autorise l'utilisation de plusieurs instances du programme (non recommandé). - - - --help - displays this help. - --help - Affichage de cette aide. - - - --reset-config - clear the saved preference parameters. - --reset-config - Effecement des paramètres de configuration sauvegardés. - - - - message from other instance. - message d'une autre instance. - - - - %1 is already running !! - %1 est déjà en fonctionnement !! - - - - Cleaning temp storage %1 ... - Nettoyage du répertoire temporaire %1 ... - - - - Deleting %1 - Effacement de %1 - - - - translations path %1 - chemin des traductions %1 - - - - setting language to : %1 - positionner le lauguage à %1 - - - - successfully loaded data from %1 - chargement réussi des données de %1 - - - - failed to load data from %1 - échec de chargement des données de %1 - - - - BackgroundPainterConfigWidget: image %1 is reject because its size is too small (%2x%3/%4x%5)) - BackgroundPainterConfigWidget: l'image %1 est rejetée car trop petite (%2x%3/%4x%5)) - - - - BackgroundPainterConfigWidget: too many reject files => please change settings of add more hi-resolution images !! - BackgroundPainterConfigWidget:trop de fichier rejetés => changez le paramétrage of ajouter plus de fichiers en haute résolution !! - - - - BackgroundPainterConfigWidget: Message with invalid nb of parameters (%1 instead of %2) - BackgroundPainterConfigWidget: Message avec un nombre de parametres incorrects (%1 au lieu de %2) - - - - BackgroundPainterConfigWidget: Message with unknown version received (%1) - BackgroundPainterConfigWidget: Message ayant une version inconnue (%1) - - - - NetworkManager: Mode SERVER listen to %1 port - NetworkManager: Mode SERVEUR écoute sur le port %1 - - - - NetworkManager: Mode CLIENT listen to %1 port - NetworkManager: Mode CLIENT écoute sur le port %1 - - - - NetworkManager: Send Server Identification for "%1" on port %2 - NetworkManager: Envoie identification au serveur pour "%1" sur le port %2 - - - - NetworkManager: Received message on port %1 - NetworkManager: Réception message sur le port %1 - - - - NetworkManager: Received Server call datagram: "%1" - NetworkManager: Réception datagram appel serveur: "%1" - - - - NetworkManager: Adding %1 to client list - NetworkManager: Ajout %1 à la liste des clients - - - - NetworkManager: %1 is already in the client list - NetworkManager: %1 est déjà dans la liste des clients - - - - NetworkManager: Received background change: "%1" - NetworkManager: Réception changement de fond d'écran : "%1" - - - - NetworkManager: no address found for host %1 (%2) - NetworkManager: pas d'adresse trouvée pour %1 (%2) - - - - NetworkManager: Send Server Call for "%1" on port %2 - NetworkManager: Envoie appel serveur pour "%1" sur le port %2 - - - - NetworkManager: Send message to "%1" (%2) on port %3 - NetworkManager: Envoie message à "%1" (%2) sur le port %3 - - - - NetworkManager:: Sending new message to client %1 - NetworkManager:: Envoie nouveau message au client %1 - - - - NetworkManager:: Ping server %1 - NetworkManager:: Ping du serveur %1 - - - - Bytes - Octets - - - - KB - Ko - - - - MB - Mo - - - - GB - Go - - - - TB - To - - - - KDE3 desktop - KDE3 - - - - KDE4 desktop - KDE4 - - - - GNOME desktop - Gnome - - - - GNOME3 desktop - Gnome3 - - - - XFCE desktop - XFCE - - - - XFCE4 desktop - XFCE4 - - - - FLUXBOX desktop - FLUXBOX - - - - BLACKBOX desktop - BlackBox - - - - Enlightenment desktop - Enlightenment - - - - ICEWM desktop - IceWM - - - - OPENBOX desktop - OpenBox - - - - LXDE desktop - LXDE - - - - WINDOWMAKER desktop - WindowMaker - - - - FVWM desktop - FVWM - - - - WINDOWS desktop - Windows - - - - MACOSX desktop - Max OSX - - - - OS/2 desktop - OS/2 - - - - Automatic detection - Détection automatique - - - - No Desktop Environment Detected - Aucun environnement détecté - - - - Scheduler - - update interval set to 0 sec => force to 30 sec ... - interval de temps positionné à 0 sec => passage à 30 sec ... - - - - update interval is to low (%1) => force to %2 sec ... - l'intervalle de temps est trop faible (%1) => passage à %2 sec ... - - - - - Start new timer for %1 sec ... - Démarrage d'un nouveau minuteur pour %1 sec ... - - - - New Schedule fired ... - Nouvelle programmation démarrée ... - - - - SchedulerConfigWidget - - - SchedulerConfigWidget - - - - - Scheduling parameters - Paramètres de programmation - - - - - Auto change at startup - Changement automatique au démarrage - - - - Quit application after startup change (30s) - Quitter l'application après le démarrage (30sec) - - - - Change Interval - Intervale - - - - Interval between change (h:m:s) - Intervale entre les changements - - - - set time of day (h:m:s) - Ajouter un horaire - - - - Add to the timeofday list - Ajouter à la liste des horaires - - - - Delete selected timeofday - Effacer les horaires sélectionnés - - - - h:mm:ss - h:mm:ss - - - - SyncWall - - - Can't create storage location, check why ?! (%1) - Impossible de créer le répertoire de stockage, recherchez pourquoi ?! (%1) - - - - Active Desktop must be disabled !! - ActiveDesktop doit être désactivé !! - - - - detected language: %1 - langue détectée : %1 - - - - Automatic detection - détection automatique - - - - Default (no use of translation files) - défaut (pas d'utilisation de traduction) - - - - The application need to restart in order to take into account new translation -, Do you want to restart application now ? - L'application a besoin de redémarrer pour tenir compte de la nouvelle langue -Voulez-vous redémarrer l'application maintenant ? - - - - Log file - Fichier de log - - - - Can't save log file !!: %1 - Impossible de sauver le fichier de log : %1 - - - - Add Wallpaper Directory - Ajouter un répertoire de fonds d'écran - - - - - Add all found directories recursively ? - Ajouter tous les répertoires récursivement ? - - - - - Watch for modifications in these directories at application startup ? - Suivre les modifications du contenu de ces répertoires au démarrage de l'application ? - - - - add %1 folder - ajouter répertoire %1 - - - - Select one or more wallpapers - Sélectionner un ou plusieurs fonds d'écran - - - - Images (%1) - Images (%1) - - - - Systray - Zone de notification - - - - The program will keep running in the system tray. To terminate the program, choose <b>Quit</b> in the context menu of the system tray entry. - Le programme va rester actif dans la zone de notification. Pour sortir définitivement, choisir <b>Quitter</b> dans le menu contextuel de la zone de notification. - - - &Quit - &Quitter - - - Change background - Change de fond d'écran - - - - %1 images in list - %1 images dans la liste - - - - new file received : %1 - nouveau fichier reçu : %1 - - - - Can't find local file as received : %1 - Impossible de trouver un fichier local correspondant à la réception : %1 - - - - Standard state. Scheduling is activated - Etat Standard . La programmation est activée - - - - Idle state. No scheduling and no server connection - Etat en attente: Aucune programmation et pas de synchronisation serveur - - - - Server state. Al least a client is connected - Etat serveur : Au moins un client est connecté - - - - Client state. Connected to server - Etat Client : connection au serveur active - - - - Client state but disconnected from server - Etat Client mais déconnecté du serveur - - - - Client state but the protocol isn't correct. Upgrade client or server ! - Etat Client mais le protocol n'est pas correct. Mettre à jour le client ou le serveur ! - - - - The %1 file can't be found, sorry ... - Le fichier %1 n'a pas été trouvé, désolé ... - - - The CREDITS.txt file can't be found, sorry ... - Le fichier CREDITS.txt n'a pas été trouvé, désolé ... - - - - Do you want to reset all the preferences to default value ? - If yes, the application will be relaunch - Voulez-vous effacer toutes les préférences ? -Si oui, l'application va redémarrer - - - The CREDITS file can't be found, sorry ... - Le fichier de CREDITS ne peut pas être trouvé, désolé ... - - - Invalid file ? : %1 - Fichier invalide ? : %1 - - - - SyncWallClass - - - SyncWall - - - - - Preview - Prévisualisation - - - - - Quit - Quitter - - - - Add a new folder - Ajouter un nouveau répertoire - - - Preview - Prévisualisation - - - - - Add new file(s) - - - - - Refresh file list - Rafraîchir la liste de fichiers - - - - - Set wallpaper - - - - Switch file list/provider view - Basculer vue fichiers/fournisseurs - - - - State ... - Etat ... - - - - Preview desktop - Prévisualiser le bureau - - - - Delete selected wallpaper from list - Effacer la sélection de la liste - - - - View simple list - Vue en liste simple - - - - View list and infos - Vue détaillée - - - - View thumbnails - View Imagettes - - - - No Wallpaper - Aucun fond d'écran - - - - Reset preferences - Réinitialiser les préférences - - - - Splashscreen with transparent background - Ecran d'acceuil avec fond transparent - - - - Next wallpaper: - Fond d'écran suivant : - - - - Language - Langue - - - - Detected language ... - Langue détectée ... - - - - Supported formats (via Qt plugins) - Formats supportés (via greffons Qt) - - - - Available translations - Traductions disponibles - - - - Credits - Remerciements - - - - Changelog - Journal des modifications - - - - Save log to file - Sauve le journal dans un fichier - - - - Preview Image - Prévisualiser l'image - - - - Delete Image - Effacer l'image - - - - Show main interface - Afficherl'interface utilisateur - - - - Show User Interface - Afficher l'interface utilisateur - - - - Quit application - Quitter l'application - - - - Next Wallpaper - Prochain fond d'écran - - - - Previous Wallpaper - Fond d'écran précédent - - - - Preview selected wallpaper - Prévisualiser le fond d'écran sélectionné - - - - Auto Change in random order - Changement automatique aléatoire - - - - Preferences - Préférences - - - - - Startup - Démarrage - - - Startup - Démarrage - - - - Start in notification tray (minimized) - Démarrer dans la zone de notification (minimisé) - - - - Display splashscreen at startup - Afficher l'écran d'accueil au démarrage - - - - Auto start with system - Démarrage automatique avec le système - - - - Use Global Hotkey for manual change of wallpaper - Utiliser un raccourcis clavier global pour changer de fond d'écran - - - Hotkey: - Raccourcis : - - - - Scheduling - Programmation - - - - Display Parameters - Paramètres d'affichage - - - - Network - Réseau - - - - About - A propos - - - Supported formats (via Qt plugins) - Formats supportés (via greffons Qt) - - - Available translations - Traductions disponibles - - - - Release Number - Version - - - - Log - Journal - - - - Clear Log - Effacer le journal - - - - SystemIntegration - - - Desktop selected: %1 - Bureau sélectionné : %1 - - - - KDE4 is currently incompletely supported. Please select %1 as the current wallpaper with "centered" parameter (it's just a workaround) - KDE4 est supporté incomplètement pour l'instant. Prière de sélectionner le fichier produit par SyncWall (%1) en mode "centré". (C'est actuellement un contournement de cette limitation) - - - - Can't open %1 - Impossible d'ouvrir %1 - - - - SystemIntegration::applyImage: Problem during saving of temp image %1 !! - SystemIntegration::applyImage: Problème à la sauvagarde du fichier temporaire %1 !! - - - - Convert QImage to %1 - Convertion de QImage en %1 - - - - Saving temp file (%1) - Sauvegarde du fichier temporaire (%1) - - - - Failed to save temp file (%1) - Echec de la sauvegarde du fichier temporaire (%1) - - - - loop detected during environment processing => skip - Une bouvle a été détectée pendant le traitement des variables d'environnement => on saute - - - - detectCurrentDesktop => Detected: KDE3 - detectCurrentDesktop => Détecté: KDE3 - - - - detectCurrentDesktop => Detected: KDE4 - detectCurrentDesktop => Détecté: KDE4 - - - - detectCurrentDesktop => Detected: Gnome - detectCurrentDesktop => Détecté: Gnome - - - - detectCurrentDesktop => Gnome version %1 - detectCurrentDesktop =>détecté Gnome version %1 - - - - detectCurrentDesktop => Detected: Xfce - detectCurrentDesktop => Détecté: Xfce - - - - detectCurrentDesktop => Detected: Xfce4 - detectCurrentDesktop => Détecté: Xfce4 - - - - detectCurrentDesktop => Detected: Fluxbox - detectCurrentDesktop => Détecté: Fluxbox - - - - detectCurrentDesktop => Detected: FVWM - detectCurrentDesktop => Détecté: FVWM - - - - detectCurrentDesktop => Detected: Blackbox - detectCurrentDesktop => Détecté: Blackbox - - - - detectCurrentDesktop => Detected: WindowMaker - detectCurrentDesktop => Détecté: WindowMaker - - - - No Desktop Environment Detected - Aucun environnement détecté - - - - SystemIntegration: The process failed to start. Either the invoked program is missing, or you may have insufficient permissions to invoke the program. - SystemIntegration: Le processus n'a pas démarré. Ou le programme appelé est manquant ou vous n'avez pas les droits suffisants pour l'exécuter. - - - - SystemIntegration: The process crashed some time after starting successfully. - SystemIntegration: Le processus s'est stoppé quelques temps après son lancement réussi. - - - - SystemIntegration: The last waitFor...() function timed out. The state of QProcess is unchanged, and you can try calling waitFor...() again. - SystemIntegration: Le dernier waitFor...() a expiré. L'état du QProcess est inchangé et vous pouvez essayer d'appeler waitFor...() encore. - - - - SystemIntegration: An error occurred when attempting to write to the process. For example, the process may not be running, or it may have closed its input channel. - SystemIntegration: Une erreur est survenue lors de l'écriture au processus.Par exemple, le processus n'est pas en exécution ou il a fermé son canal d'entrée. - - - - SystemIntegration: An error occurred when attempting to read from the process. For example, the process may not be running. - SystemIntegration: Une erreur est survenue lor de la lecture à partir du processus. Par exemple, le processus ne doit pas être en exécution. - - - - SystemIntegration: An unknown error occurred. This is the default return value of error(). - SystemIntegration: Une erreur est survenue. C'est la valeur par défaut de la fonction error(). - - - - The command exited normally. - La commande s'est terminée normallement. - - - - The command crashed. - La commande s'est plantée. - - - - Running - Lancement - - - - Tips: KDE4 is currently incompletely supported. Please select the generated wallpaper in plasma with "centered" parameter (it's just a workaround). For multi monitor with KDE activities, you can create a splitted wallpaper (one file by monitor) by selecting the right option in the "Image parameters" panel. - Note : KDE4 est supporté incomplètement pour l'instant. Prière de sélectionner dans Plasma le fichier produit par SyncWall en mode "centré". (C'est actuellement un contournement de cette limitation). Dans le cas multi-écrans, vous pouvez créer un fond d'écran découpé (un fichier par écran) en sélectionnant l'option correspondante dans le panneau "Paramètres image". - - - KDE4 is currently incompletely supported. Please select the generated wallpaper in plasma with "centered" parameter (it's just a workaround). For multi monitor with KDE activities, you can create a splitted wallpaper (one file by monitor) by selecting the right option in the "Image parameters" panel. - KDE4 est supporté incomplètement pour l'instant. Prière de sélectionner dans Plasma le fichier produit par SyncWall en mode "centré". (C'est actuellement un contournement de cette limitation). Dans le cas multi-écrans, vous pouvez créer un fond d'écran découpé (un fichier par écran) en sélectionnant l'option correspondante dans le panneau "Paramètres image". - - - - SystemIntegrationConfigWidget - - - SystemIntegrationConfigWidget - SystemIntegrationConfigWidget - - - Linux desktop integration - Intégration au bureau Linux - - - KDE3 desktop - KDE3 - - - GNOME desktop - Gnome - - - KDE4 desktop - KDE4 - - - Fluxbox desktop - Fluxbox - - - Blackbox desktop - Blackbox - - - WindowMaker desktop - WindowMaker - - - FVWM desktop - FVWM - - - Xfce Desktop - Xfce - - - - Desktop integration - Intégration au bureau - - - - no detection ... - aucune détection ... - - - - The auto detection can failed. In this case, you have to set manually your desktop ... - L'auto détection peut échoué. Dans ce cas, vous devez sélectionner vous même votre bureau dans la liste ... - - - - detected desktop: %1 - Bureau détecté : %1 - - - - TcpClient - - Client: State changed to '%1' - Client: etat changé à '%1' - - - Client: Connection timed out - Client: Connection timed out - - - Client: File transfer complete - Client: transfert de fichier terminé - - - Client: Connection to server established - Client: Connection au serveur établie - - - Client: File '%1' does not exist - Client: le fichier '%1' n'existe pas - - - Client: File information sent to server - Client: Envoi des informations sur le fichier au server - - - Client: Error reading file '%1' - Client: Erreur lecture fichier '%1' - - - Client: Starting file transfer ... - Client: Démarrage transfert fichier ... - - - Client: Sever accepted the file - Client: le serveur accepte le fichier - - - Received unknown message type: %1 - Réception d'un message inconnu: %1 - - - Unable to connect: %1. - Impossible de se connecter: %1. - - - Client: Connection closed. Transfer aborted. - Client: Connection fermé. Transfert interrompu. - - - - TcpServer - - TcpServer: Starting server... - TcpServer: Démarrage serveur ... - - - TcpServer: TcpServer stopped - TcpServer: TcpServer arrété - - - TcpServer: Connection timed out - TcpServer: Connection timed out - - - TcpServer: State changed to '%1' - TcpServer: Etat changé à '%1' - - - TcpServer: %1 is connecting... - TcpServer: %1 se connecte ... - - - TcpServer: Connection closed. Transfer aborted. - TcpServer: Connection fermé. Transfert interrompu. - - - TcpServer: File transfer complete - TcpServer: transfert terminé - - - %1 Byte - %1 octet - - - %1 KB - %1 Ko - - - %1 MB - %1 Mo - - - %1 GB - %1 Go - - - TcpServer: Received file information: - TcpServer: Reception information fichier: - - - '%1', size: %2 - '%1', taille: %2 - - - Error writing to file. Transfert aborted. - Erreur écriture du fichier. Transfert interrompu. - - - Received unknown message type: %1 - Réception d'un message inconnu: %1 - - - TcpServer: Accept message sent - TcpServer: Acceptation message envoyé - - - TcpServer: Reverse connection to %1 established - TcpServer: Connection inverse à %1 établi - - - - TreeImagesView - - - Add some images to begin - Ajouter des images pour commencer - - - - WallpaperProvider - - Cannot find the directory - Impossible de trouver le répertoire - - - - Cannot find the directory %1 - Impossible de trouver le répertoire %1 - - - diff -Nru syncwall-1.6.0/SyncWall/recopy.bat syncwall-1.7.4/SyncWall/recopy.bat --- syncwall-1.6.0/SyncWall/recopy.bat 2011-12-19 10:35:58.000000000 +0000 +++ syncwall-1.7.4/SyncWall/recopy.bat 1970-01-01 00:00:00.000000000 +0000 @@ -1,4 +0,0 @@ -d:\pskill.exe -t SyncWall.exe -xcopy /y /f \\XBEEHIVE\SyncWall\SyncWall\debug d:\SyncWall -pause - diff -Nru syncwall-1.6.0/SyncWall/res/Info.plist syncwall-1.7.4/SyncWall/res/Info.plist --- syncwall-1.6.0/SyncWall/res/Info.plist 2011-12-18 10:29:44.000000000 +0000 +++ syncwall-1.7.4/SyncWall/res/Info.plist 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ - - - - - CFBundleIconFile - syncwall.icns - CFBundlePackageType - APPL - CFBundleGetInfoString - Created by Qt/QMake - CFBundleSignature - ???? - CFBundleExecutable - SyncWall - CFBundleIdentifier - net.xbee.syncwall - NOTE - Author: xbee - NSHumanReadableCopyright - Copyright 2011 http://thehive.xbee.net - - Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/about.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/about.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/add.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/add.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/camera.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/camera.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/change.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/change.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/check.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/check.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/default.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/default.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/delete.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/delete.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/display_big.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/display_big.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/flower.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/flower.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/folder_add.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/folder_add.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/icon_quit.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/icon_quit.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/images_add.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/images_add.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/logo_big.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/logo_big.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/mode_client_connected.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/mode_client_connected.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/mode_client_disconnected.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/mode_client_disconnected.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/mode_client_invalid.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/mode_client_invalid.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/mode_idle.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/mode_idle.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/mode_server.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/mode_server.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/mode_standard.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/mode_standard.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/monitor_paint.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/monitor_paint.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/network_big.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/network_big.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/preferences.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/preferences.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/preview.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/preview.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/provider.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/provider.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/reflection.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/reflection.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/refresh.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/refresh.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/reset.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/reset.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/scheduling_big.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/scheduling_big.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/scroll.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/scroll.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/splashscreen.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/splashscreen.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/startup_big.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/startup_big.png differ diff -Nru syncwall-1.6.0/SyncWall/res/syncwall.desktop syncwall-1.7.4/SyncWall/res/syncwall.desktop --- syncwall-1.6.0/SyncWall/res/syncwall.desktop 2011-12-18 10:51:12.000000000 +0000 +++ syncwall-1.7.4/SyncWall/res/syncwall.desktop 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -[Desktop Entry] -Version=1.0 -Name=SyncWall -Comment=Wallpaper management with synchronization features -Exec=SyncWall -Icon=SyncWall -Terminal=false -Type=Application -Categories=Utility;Application; \ No newline at end of file Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/syncwall.icns and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/syncwall.icns differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/syncwall.ico and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/syncwall.ico differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/syncwall.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/syncwall.png differ diff -Nru syncwall-1.6.0/SyncWall/res/syncwall.qrc syncwall-1.7.4/SyncWall/res/syncwall.qrc --- syncwall-1.6.0/SyncWall/res/syncwall.qrc 2012-01-21 06:23:24.000000000 +0000 +++ syncwall-1.7.4/SyncWall/res/syncwall.qrc 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ - - - camera.png - default.png - syncwall.png - unavailable.png - view-detail.png - view-list.png - view-thumbnail.png - splashscreen.png - reset.png - flower.png - mode_client_invalid.png - mode_client_connected.png - mode_client_disconnected.png - mode_idle.png - mode_server.png - mode_standard.png - startup_big.png - display_big.png - network_big.png - scheduling_big.png - preview.png - provider.png - monitor_paint.png - add.png - images_add.png - refresh.png - scroll.png - trash.png - about.png - logo_big.png - change.png - check.png - delete.png - folder_add.png - icon_quit.png - reflection.png - preferences.png - - diff -Nru syncwall-1.6.0/SyncWall/res/syncwall.rc syncwall-1.7.4/SyncWall/res/syncwall.rc --- syncwall-1.6.0/SyncWall/res/syncwall.rc 2011-12-01 14:41:46.000000000 +0000 +++ syncwall-1.7.4/SyncWall/res/syncwall.rc 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -IDI_ICON1 ICON DISCARDABLE "syncwall.ico" - Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/trash.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/trash.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/unavailable.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/unavailable.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/view-detail.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/view-detail.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/view-list.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/view-list.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/res/view-thumbnail.png and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/res/view-thumbnail.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/setup/banner.bmp and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/setup/banner.bmp differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/setup/icon.ico and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/setup/icon.ico differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/setup/icon_install.ico and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/setup/icon_install.ico differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/setup/icon_uninstall.ico and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/setup/icon_uninstall.ico differ diff -Nru syncwall-1.6.0/SyncWall/setup/setup.nsi syncwall-1.7.4/SyncWall/setup/setup.nsi --- syncwall-1.6.0/SyncWall/setup/setup.nsi 2012-01-16 15:06:24.000000000 +0000 +++ syncwall-1.7.4/SyncWall/setup/setup.nsi 1970-01-01 00:00:00.000000000 +0000 @@ -1,228 +0,0 @@ - -;NSIS Modern User Interface -;Written by Joost Verburg - -XPStyle on -!define PROGRAM_NAME "SyncWall" -!define TARGET_NAME "${PROGRAM_NAME}" -!define ORGANIZATION_NAME "TheHive" -!define SHCNE_ASSOCCHANGED 0x8000000 -!define SHCNF_IDLIST 0 - - -BrandingText "${PROGRAM_NAME} installation"; remove the nsis release on the gui - -########################################################################################### -# init functions -########################################################################################### - -Function .onInit - - # fading splashscreen !! - # the plugins dir is automatically deleted when the installer exits - InitPluginsDir - File /oname=$PLUGINSDIR\splash.bmp "splashscreen.bmp" - #optional - #File /oname=$PLUGINSDIR\splash.wav "C:\myprog\sound.wav" - - advsplash::show 2000 600 400 -1 $PLUGINSDIR\splash - - Pop $0 ; $0 has '1' if the user closed the splash screen early, - ; '0' if everything closed normally, and '-1' if some error occurred. - - Delete $PLUGINSDIR\splash.bmp - - # uninstall previous release before installing a new one - ReadRegStr $R0 HKLM \ - "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROGRAM_NAME}" \ - "UninstallString" - StrCmp $R0 "" done - - MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \ - "${PROGRAM_NAME} is already installed. $\n$\nClick `OK` to remove the \ - previous version or `Cancel` to cancel this upgrade." \ - IDOK uninst - Abort - - ;Run the uninstaller - uninst: - ClearErrors - Exec "$INSTDIR\uninstall.exe /S" - - done: - -FunctionEnd - -;-------------------------------- - -Function LaunchLink - ExecShell "" "$INSTDIR\${PROGRAM_NAME}.exe" -FunctionEnd - -;-------------------------------- -;Include Modern UI - - !include "MUI2.nsh" - -;-------------------------------- -;General - - ;Name and file - !ifndef VERSION - !define VERSION 'bxx' - !endif - - ;Name and file - Name "${PROGRAM_NAME}" - -;-------------------------------- -;Configuration - - ; output directory if not set by batch - !ifndef SETUP_DIR - !define SETUP_DIR '.\' - !endif - - ; output setup file - !ifdef OUTFILE - OutFile "${SETUP_DIR}\${OUTFILE}" - !else - OutFile "${SETUP_DIR}\${PROGRAM_NAME}-${VERSION}-setup.exe" - !endif - - ;Default installation folder - InstallDir $PROGRAMFILES\${ORGANIZATION_NAME}\${PROGRAM_NAME} - - ;Get installation folder from registry if available - InstallDirRegKey HKLM "Software\${ORGANIZATION_NAME}\${PROGRAM_NAME}" "Install_Dir" - - ;Request application privileges for Windows Vista - RequestExecutionLevel admin - -;-------------------------------- -;Interface Settings - - !define MUI_HEADERIMAGE - !define MUI_HEADERIMAGE_RIGHT - !define MUI_HEADERIMAGE_BITMAP "banner.bmp" ; optional installer pages - !define MUI_HEADERIMAGE_UNBITMAP "banner.bmp" ; uninstaller pages - !define MUI_ABORTWARNING - !define MUI_ICON "icon_install.ico" - !define MUI_UNICON "icon_uninstall.ico" - !define MUI_WELCOMEFINISHPAGE_BITMAP "welcome.bmp" ; welcome/finish banner - !define MUI_FINISHPAGE_NOAUTOCLOSE - - !define MUI_FINISHPAGE_RUN - !define MUI_FINISHPAGE_RUN_NOTCHECKED - !define MUI_FINISHPAGE_RUN_TEXT "Start ${PROGRAM_NAME} after install" - !define MUI_FINISHPAGE_RUN_FUNCTION "LaunchLink" - !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED - -;-------------------------------- -;Pages - - ;!insertmacro MUI_PAGE_LICENSE "License.txt" - ;!insertmacro MUI_PAGE_COMPONENTS - !insertmacro MUI_PAGE_WELCOME ; affiche un welcome - !insertmacro MUI_PAGE_DIRECTORY - !insertmacro MUI_PAGE_INSTFILES - !insertmacro MUI_PAGE_FINISH ; affiche une page de fin - - !insertmacro MUI_UNPAGE_CONFIRM - !insertmacro MUI_UNPAGE_INSTFILES - -;-------------------------------- -;Languages - - !insertmacro MUI_LANGUAGE "English" - -;-------------------------------- -;Installer Sections - -Section "Dummy Section" SecDummy - - SectionIn RO - - ; Program files there - SetOutPath $INSTDIR - File "..\build\Release\${PROGRAM_NAME}.exe" - File "$%QTDIR%\bin\QtCore4.dll" - File "$%QTDIR%\bin\QtGui4.dll" - File "$%QTDIR%\bin\QtNetwork4.dll" - ; Minggw case ... - File /nonfatal "$%QTDIR%\bin\mingwm10.dll" - File /nonfatal "$%QTDIR%\bin\libgcc_s_dw2-1.dll" - - ; qt image plugin - SetOutPath "$INSTDIR\plugins\imageformats" - File "$%QTDIR%\plugins\imageformats\*.dll" - - ; Lang files - SetOutPath "$INSTDIR\lang" - File /nonfatal "..\lang\*.qm" - File /nonfatal "*.qm" - - ; Other files - SetOutPath $INSTDIR - File "..\..\CREDITS.txt" - File "..\..\AUTHORS.txt" - File "..\..\LICENSE.txt" - File "..\..\Changelog.txt" - - ; resources files - SetOutPath $INSTDIR - File "icon.ico" - - ; Write the installation path into the registry - WriteRegStr HKLM SOFTWARE\${ORGANIZATION_NAME}\${PROGRAM_NAME} "Install_Dir" "$INSTDIR" - WriteRegStr HKLM SOFTWARE\${ORGANIZATION_NAME}\${PROGRAM_NAME} "Version" "${VERSION}" - - ; Write the uninstall keys for Windows - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROGRAM_NAME}" "DisplayName" "${PROGRAM_NAME}" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROGRAM_NAME}" "UninstallString" '"$INSTDIR\uninstall.exe"' - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROGRAM_NAME}" "NoModify" 1 - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROGRAM_NAME}" "NoRepair" 1 - WriteUninstaller "$INSTDIR\uninstall.exe" - -SectionEnd - -;-------------------------------- -; Optional section (can be disabled by the user) -Section "Start Menu Shortcuts" - - SetShellVarContext all ; scope is "All Users" - CreateDirectory "$SMPROGRAMS\${ORGANIZATION_NAME}\${PROGRAM_NAME}" - CreateShortCut "$SMPROGRAMS\${ORGANIZATION_NAME}\${PROGRAM_NAME}\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0 - CreateShortCut "$SMPROGRAMS\${ORGANIZATION_NAME}\${PROGRAM_NAME}\${PROGRAM_NAME}.lnk" "$INSTDIR\${PROGRAM_NAME}.exe" "" "$INSTDIR\${PROGRAM_NAME}.exe" 0 - - ;create desktop shortcut - CreateShortCut "$DESKTOP\${PROGRAM_NAME}.lnk" "$INSTDIR\${PROGRAM_NAME}.exe" "" "$INSTDIR\icon.ico" - -SectionEnd - -;-------------------------------- -;Uninstaller Section - -Section "Uninstall" - - ; Remove registry keys - DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROGRAM_NAME}" - DeleteRegKey HKLM SOFTWARE\${ORGANIZATION_NAME}\${PROGRAM_NAME} - - ; Remove files and uninstaller - Delete "$INSTDIR\*.*" - - ; Remove shortcuts, if any - SetShellVarContext all ; scope is "All Users" - Delete "$SMPROGRAMS\${ORGANIZATION_NAME}\${PROGRAM_NAME}\*.*" - - ; remove desktop link - Delete "$DESKTOP\${PROGRAM_NAME}.lnk" - - ; Remove directories used - RMDir "$SMPROGRAMS\${ORGANIZATION_NAME}\${PROGRAM_NAME}" - RMDir "$SMPROGRAMS\${ORGANIZATION_NAME}\" - RMDir /r "$INSTDIR\plugins" - RMDir /r "$INSTDIR" - -SectionEnd Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/setup/splashscreen.bmp and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/setup/splashscreen.bmp differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/SyncWall/setup/welcome.bmp and /tmp/OqecVKC_d5/syncwall-1.7.4/SyncWall/setup/welcome.bmp differ diff -Nru syncwall-1.6.0/SyncWall/src/AppSettings.cpp syncwall-1.7.4/SyncWall/src/AppSettings.cpp --- syncwall-1.6.0/SyncWall/src/AppSettings.cpp 2012-01-06 12:05:02.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/AppSettings.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -/****************************************************************************** -SyncWall: Wallpaper manager -Copyright(C) 2011-2012 xbee@xbee.net - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*******************************************************************************/ - -#include "AppSettings.h" - - -AppSettings::AppSettings( ) - : QSettings (PACKAGE_ORGANIZATION, PACKAGE_NAME) -{ - -} - diff -Nru syncwall-1.6.0/SyncWall/src/AppSettings.h syncwall-1.7.4/SyncWall/src/AppSettings.h --- syncwall-1.6.0/SyncWall/src/AppSettings.h 2012-08-18 06:29:52.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/AppSettings.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ - -/****************************************************************************** - SyncWall: Wallpaper manager - Copyright(C) 2011-2012 xbee@xbee.net - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *******************************************************************************/ - -#ifndef _APPETTINGS_H_ -#define _APPETTINGS_H_ - -#include - -#define PACKAGE_ORGANIZATION "TheHive" -#define PACKAGE_NAME "SyncWall" -#define PACKAGE_VERSION "1.6.0" - -class AppSettings : - public QSettings -{ - Q_OBJECT - -public: - - AppSettings( ); - -protected: -}; - -#endif // _APPETTINGS_H_ diff -Nru syncwall-1.6.0/SyncWall/src/BackgroundPainter.cpp syncwall-1.7.4/SyncWall/src/BackgroundPainter.cpp --- syncwall-1.6.0/SyncWall/src/BackgroundPainter.cpp 2012-05-15 13:01:24.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/BackgroundPainter.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,929 +0,0 @@ - -/****************************************************************************** - SyncWall: Wallpaper manager - Copyright(C) 2011-2012 xbee@xbee.net - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *******************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "BackgroundPainter.h" - -#include "AppSettings.h" -#include "LogHandler.h" -#include "qimageblitz.h" - -#include -#ifdef Q_OS_WIN -#define M_PI 3.14159265358979323846 // VC++ does not recognise those (standard) constants -#endif - -#ifndef MIN -#define MIN(a,b) ( (a) < (b) ? (a) : (b) ) -#endif -#ifndef MAX -#define MAX(a,b) ( (a) > (b) ? (a) : (b) ) -#endif -#ifndef ABS -#define ABS(x) ( ( (int)(x) ^ ( (int)(x) >> 31 ) ) - ( (int)(x) >> 31 ) ) -#endif - -const int previewFactor = 10; - -bool operator>(const QSize &s1, const QSize &s2) -{ - return s1.width() > s2.width() || s1.height() > s2.height(); -} - -// Exponential blur, Jani Huhtanen, 2006 -#include - -template -static inline void blurinner(unsigned char *bptr, int &zR, int &zG, int &zB, int &zA, int alpha) -{ - int R,G,B,A; - R = *bptr; - G = *(bptr + 1); - B = *(bptr + 2); - A = *(bptr + 3); - zR += ( alpha * ( (R << zprec) - zR ) ) >> aprec; - zG += ( alpha * ( (G << zprec) - zG ) ) >> aprec; - zB += ( alpha * ( (B << zprec) - zB ) ) >> aprec; - zA += ( alpha * ( (A << zprec) - zA ) ) >> aprec; - *bptr = zR >> zprec; - *(bptr + 1) = zG >> zprec; - *(bptr + 2) = zB >> zprec; - *(bptr + 3) = zA >> zprec; -} - -template -static inline void blurrow( QImage & im, int line, int alpha) -{ - int zR,zG,zB,zA; - QRgb *ptr = (QRgb *)im.scanLine(line); - zR = *( (unsigned char *)ptr ) << zprec; - zG = *( (unsigned char *)ptr + 1 ) << zprec; - zB = *( (unsigned char *)ptr + 2 ) << zprec; - zA = *( (unsigned char *)ptr + 3 ) << zprec; - - for(int index = 1; index( (unsigned char *)&ptr[index],zR,zG,zB,zA,alpha ); - - for(int index = im.width() - 2; index>=0; index--) - blurinner( (unsigned char *)&ptr[index],zR,zG,zB,zA,alpha ); -} - -template -static inline void blurcol( QImage & im, int col, int alpha) -{ - int zR,zG,zB,zA; - QRgb *ptr = (QRgb *)im.bits(); - ptr += col; - zR = *( (unsigned char *)ptr ) << zprec; - zG = *( (unsigned char *)ptr + 1 ) << zprec; - zB = *( (unsigned char *)ptr + 2 ) << zprec; - zA = *( (unsigned char *)ptr + 3 ) << zprec; - - for( int index = im.width(); index<(im.height() - 1) * im.width(); index += im.width() ) - blurinner( (unsigned char *)&ptr[index],zR,zG,zB,zA,alpha ); - - for( int index = (im.height() - 2) * im.width(); index>=0; index -= im.width() ) - blurinner( (unsigned char *)&ptr[index],zR,zG,zB,zA,alpha ); -} - -/* - * expblur(QImage &img, int radius) - * - * In-place blur of image 'img' with kernel - * of approximate radius 'radius'. - * - * Blurs with two sided exponential impulse - * response. - * - * aprec = precision of alpha parameter - * in fixed-point format 0.aprec - * - * zprec = precision of state parameters - * zR,zG,zB and zA in fp format 8.zprec - */ -template -void expblur( QImage &img, int radius ) -{ - if (radius < 1) - return; - - // Calculate the alpha such that 90% of the kernel is within the radius. Kernel extends to infinity. - int alpha = (int)( (1 << aprec) * ( 1.0f - expf( -2.3f / (radius + 1.f) ) ) ); - - for(int row = 0; row(img,row,alpha); - - for(int col = 0; col(img,col,alpha); -} - -BackgroundPainter::BackgroundPainter(QObject *parent) - : QObject(parent), - m_shareImageBetweenScreen(false), - m_multiMonitorType(MULTIMONITOR_NO_MULTIMONITOR), - m_resizingType(SCALE_KEEP_EXPANDED_ASPECT), - m_alignmentType(ALIGN_CENTER), - m_fillingType(FILL_BY_SMART_COLOR), - m_specialEffectType(EFFECT_NONE), - m_lastSpecialEffectType(EFFECT_NONE), - m_specialEffectParam(5.0f), - m_fillingColor1(Qt::red), - m_fillingColor2(Qt::blue), - m_inverseGradient(false) -{ - loadSettings(); - - // update - m_hasParameter << EFFECT_BLUR; - m_hasParameter << EFFECT_GAUSSIAN_BLUR; - m_hasParameter << EFFECT_SHARPEN; - m_hasParameter << EFFECT_GAUSSIAN_SHARPEN; - m_hasParameter << EFFECT_EMBOSS; - m_hasParameter << EFFECT_DESATURATE; - m_hasParameter << EFFECT_SWIRL; - m_hasParameter << EFFECT_OILPAINT; - m_hasParameter << EFFECT_GLOW; - m_hasParameter << EFFECT_PROGRESSIVEBLUR; -} - -BackgroundPainter::~BackgroundPainter() -{ - //saveSettings(); -} - -QColor m_fillingColor; - -void BackgroundPainter::loadSettings() -{ - AppSettings settings; - - settings.beginGroup("BackgroundPainter"); - - m_shareImageBetweenScreen = settings.value("shareImageBetweenScreen",false).toBool(); - - m_multiMonitorType = settings.value("multiMonitorType",MULTIMONITOR_NO_MULTIMONITOR).toInt(); - m_resizingType = settings.value("resizingType",SCALE_KEEP_EXPANDED_ASPECT).toInt(); - m_alignmentType = settings.value("alignmentType",ALIGN_CENTER).toInt(); - m_fillingType = settings.value("fillingType",FILL_BY_SMART_COLOR).toInt(); - m_fillingColor1 = settings.value( "fillingColor1",QColor(5,150,200) ).value(); - m_fillingColor2 = settings.value( "fillingColor2",QColor(5,250,200) ).value(); - m_specialEffectType = settings.value("specialEffectType",EFFECT_NONE).toInt(); - m_specialEffectParam = settings.value("specialEffectParam",5.0f).toFloat(); - m_inverseGradient = settings.value("inverseGradient",false).toBool(); - - settings.endGroup(); -} - -void BackgroundPainter::saveSettings() -{ - AppSettings settings; - - settings.beginGroup("BackgroundPainter"); - - settings.setValue("shareImageBetweenScreen", m_shareImageBetweenScreen); - settings.setValue("multiMonitorType", m_multiMonitorType); - settings.setValue("resizingType", m_resizingType); - settings.setValue("alignmentType", m_alignmentType); - settings.setValue("fillingType", m_fillingType); - settings.setValue("fillingColor1", m_fillingColor1); - settings.setValue("fillingColor2", m_fillingColor2); - settings.setValue("specialEffectType", m_specialEffectType); - settings.setValue("specialEffectParam", m_specialEffectParam); - settings.setValue("inverseGradient", m_inverseGradient); - - settings.endGroup(); -} - -void BackgroundPainter::setMultiMonitorSupportType(int val) -{ - m_multiMonitorType = val; -} - -void BackgroundPainter::setResizingType(int method) -{ - m_resizingType = method; -} - -void BackgroundPainter::setAlignmentType(int val) -{ - m_alignmentType = val; -} - -void BackgroundPainter::setFillingType(int val) -{ - m_fillingType = val; -} - -void BackgroundPainter::setSpecialEffectType(int val) -{ - m_specialEffectType = val; -} - -void BackgroundPainter::setSpecialEffectParameter(float val) -{ - m_specialEffectParam = val; -} - -void BackgroundPainter::setShareImageBetweenScreen(bool val) -{ - m_shareImageBetweenScreen = val; -} - -void BackgroundPainter::setInverseGradient(bool val) -{ - m_inverseGradient = val; -} - -void BackgroundPainter::setFillingColor1(const QColor &color) -{ - m_fillingColor1 = color; -} - -void BackgroundPainter::setFillingColor2(const QColor &color) -{ - m_fillingColor2 = color; -} - -QImage BackgroundPainter::processImage(const QImage &srcImage, bool previewMode) -{ - QSize resampledSrcImgSize = getSizeAccordingToConfig(srcImage.size(),previewMode); - QSize resampledTargetImgSize = getSizeAccordingToConfig(m_targetSizeWithMargins,previewMode); - - QSize goodSize = resampledSrcImgSize.expandedTo(resampledTargetImgSize); - - QImage wallp(goodSize,QImage::Format_ARGB32); - - fillImage(srcImage,wallp); - - QImage img = srcImage.scaled( resampledSrcImgSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - - //img.save("d:/tmp/srcrescaled.png","PNG"); - - postProcess(img, m_specialEffectType,previewMode); - - embedImage(img,wallp); - - return wallp; -} - -void BackgroundPainter::embedImage(const QImage&src, QImage & dest) -{ - QPainter painter(&dest); - - int offsetDestX = MAX(0,( dest.width() - src.width() ) / 2); - int offsetDestY = MAX(0,( dest.height() - src.height() ) / 2); - int offsetSrcX = ABS( MIN(0,( dest.width() - src.width() ) / 2) ); - int offsetSrcY = ABS( MIN(0,( dest.height() - src.height() ) / 2) ); - int width = MIN( dest.width(),src.width() ); - int height = MIN( dest.height(),src.height() ); - - QRect source (offsetSrcX, offsetSrcY,width, height); - QRect target (offsetDestX, offsetDestY,width,height); - painter.drawImage(target, src, source); -} - -QColor BackgroundPainter::computeSmartColor(const QImage &img) -{ - int red = 0; - int green = 0; - int blue = 0; - - for (int y = 0; y < img.height(); y++) - { - const QRgb *lineSrc = reinterpret_cast( img.scanLine(y) ); - - for (int x = 0; x < img.width(); x++) - { - red += qRed(lineSrc[x]); - green += qGreen(lineSrc[x]); - blue += qBlue(lineSrc[x]); - } - } - - //Calculate average - red /= img.height() * img.width(); - green /= img.height() * img.width(); - blue /= img.height() * img.width(); - - return QColor(red,green,blue); -} - -void BackgroundPainter::postProcess(QImage &img, int effect, bool preview) -{ - float sizeFactor = 1.0f; - - if (preview) - sizeFactor = previewFactor; - - switch (effect) - { - case EFFECT_RANDOM: - if (!preview) - m_lastSpecialEffectType = qrand()%EFFECT_RANDOM; - qDebug() << "m_lastSpecialEffectType = " << m_lastSpecialEffectType; - postProcess(img,m_lastSpecialEffectType,preview); - break; - - case EFFECT_GRAYSCALE: - Blitz::grayscale(img); - break; - - case EFFECT_BLUR: - img = Blitz::blur(img,(int) m_specialEffectParam / sizeFactor); - break; - - case EFFECT_GAUSSIAN_BLUR: - img = Blitz::gaussianBlur(img,(int) m_specialEffectParam / sizeFactor); - break; - - case EFFECT_EDGE: - img = Blitz::edge(img); - break; - - case EFFECT_SHARPEN: - img = Blitz::sharpen(img, (int) m_specialEffectParam / sizeFactor); - break; - - case EFFECT_GAUSSIAN_SHARPEN: - img = Blitz::gaussianSharpen(img, (int) m_specialEffectParam / sizeFactor); - break; - - case EFFECT_EMBOSS: - img = Blitz::emboss(img, (int) m_specialEffectParam / sizeFactor); - break; - - case EFFECT_DESATURATE: - img = Blitz::desaturate(img, m_specialEffectParam); - break; - - case EFFECT_FLATTEN: - img = Blitz::flatten(img, m_fillingColor1, m_fillingColor2); - break; - - case EFFECT_SWIRL: - img = Blitz::swirl(img, m_specialEffectParam); - break; - - case EFFECT_OILPAINT: - img = Blitz::oilPaint(img, m_specialEffectParam / sizeFactor); - break; - - case EFFECT_CHARCOAL: - img = Blitz::charcoal(img); - break; - - case EFFECT_SEPIA: - img = toSepia(img); - break; - - case EFFECT_INVERTCOLOR: - img = invertColors(img); - break; - - case EFFECT_GLOW: - img = glow(img,m_specialEffectParam); - break; - - case EFFECT_PROGRESSIVEBLUR: - img = progressiveBlur(img,m_specialEffectParam); - break; - - case EFFECT_NONE: - default: - break; - } - - //img.save("c:\\postprocessed.tif","TIF"); -} - -void BackgroundPainter::fillImage(const QImage &src, QImage &target) -{ - // fill the image with the default values if needed - if (m_resizingType == SCALE_IGNORE_ASPECT || - m_resizingType == SCALE_KEEP_EXPANDED_ASPECT) - return; - - QPainter painter(&target); - - switch (m_fillingType) - { - case FILL_BY_COLOR: - { - LogHandler::getInstance()->reportDebug("BackgroundPainter: Fill by color ..."); - painter.fillRect(target.rect(),m_fillingColor1); - break; - } - - case FILL_BY_SMART_COLOR: - { - LogHandler::getInstance()->reportDebug("BackgroundPainter: Fill by smart color ..."); - painter.fillRect( target.rect(),computeSmartColor(src) ); - break; - } - - case FILL_BY_BLUR: - { - LogHandler::getInstance()->reportDebug("BackgroundPainter: Fill by blurred image ..."); - QImage blurred(src); - blurred = Blitz::blur(blurred,30); - - //blurred.save("d:/tmp/blurred.png","PNG"); - - painter.drawImage( target.rect(), blurred.scaled( target.width(),target.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation) ); - break; - } - - case FILL_BY_VERTICAL_GRADIENT: - { - LogHandler::getInstance()->reportDebug("BackgroundPainter: Fill by vertical gradient ..."); - QLinearGradient linearGrad( 0, 0, 0, target.height() ); - - if (m_inverseGradient) - { - linearGrad.setColorAt( 0.0, m_fillingColor2); - linearGrad.setColorAt( 1.0, m_fillingColor1); - } - else - { - linearGrad.setColorAt( 0.0, m_fillingColor1); - linearGrad.setColorAt( 1.0, m_fillingColor2); - } - - painter.setBrush( linearGrad ); - painter.fillRect( 0, 0, target.width(),target.height(), QBrush(linearGrad) ); - break; - } - - case FILL_BY_HORIZONTAL_GRADIENT: - { - LogHandler::getInstance()->reportDebug("BackgroundPainter: Fill by horizontal gradient ..."); - QLinearGradient linearGrad( 0, 0, target.width(), 0 ); - - if (m_inverseGradient) - { - linearGrad.setColorAt( 0.0, m_fillingColor2); - linearGrad.setColorAt( 1.0, m_fillingColor1); - } - else - { - linearGrad.setColorAt( 0.0, m_fillingColor1); - linearGrad.setColorAt( 1.0, m_fillingColor2); - } - - painter.setBrush( linearGrad ); - painter.fillRect( 0, 0, target.width(),target.height(), QBrush(linearGrad) ); - break; - } - - case FILL_BY_RADIAL_GRADIENT: - { - LogHandler::getInstance()->reportDebug("BackgroundPainter: Fill by radial gradient ..."); - float w = target.width() / 2.0f; - float h = target.height() / 2.0f; - QRadialGradient radialGrad( w,h, sqrtf(w * w + h * h) ); - - if (m_inverseGradient) - { - radialGrad.setColorAt( 0.0, m_fillingColor2); - radialGrad.setColorAt( 1.0, m_fillingColor1); - } - else - { - radialGrad.setColorAt( 0.0, m_fillingColor1); - radialGrad.setColorAt( 1.0, m_fillingColor2); - } - - painter.setBrush( radialGrad ); - painter.fillRect( 0, 0, target.width(),target.height(), QBrush(radialGrad) ); - break; - } - - default: - { - break; - } - } -} - -QSize BackgroundPainter::getSizeAccordingToConfig(const QSize &baseSize, bool preview) -{ - QSize finalSize(baseSize); - - // nothing to do !! - if (baseSize == m_targetSizeWithMargins) - { - if (preview) - finalSize /= previewFactor; - - return finalSize; - } - - float baseAspectRatio = (float) baseSize.width() / (float) ( baseSize.height() ); - float targetAspectRatio = (float) m_targetSizeWithMargins.width() / (float) ( m_targetSizeWithMargins.height() ); - - switch (m_resizingType) - { - case SCALE_NO_RESIZE: - { - finalSize = baseSize; - break; - } - - case SCALE_IGNORE_ASPECT: - { - finalSize = m_targetSizeWithMargins; - break; - } - - case SCALE_KEEP_ASPECT: - { - if ( (baseAspectRatio >= targetAspectRatio) ) - finalSize = QSize( m_targetSizeWithMargins.width(), (int) (m_targetSizeWithMargins.width() / baseAspectRatio + 0.5) ); - else - finalSize = QSize( (int) (m_targetSizeWithMargins.height() * baseAspectRatio + 0.5), m_targetSizeWithMargins.height() ); - - break; - } - - case SCALE_KEEP_EXPANDED_ASPECT: - { - if (baseAspectRatio >= targetAspectRatio ) - finalSize = QSize( (int)(baseSize.width() / ( (float)baseSize.height() / m_targetSizeWithMargins.height() ) + 0.5),m_targetSizeWithMargins.height() ); - else - finalSize = QSize( m_targetSizeWithMargins.width(), (int)(baseSize.height() / ( (float)baseSize.width() / m_targetSizeWithMargins.width() ) + 0.5) ); - - break; - } - } - - if (preview) - finalSize /= previewFactor; - - return finalSize; -} - -QList BackgroundPainter::cropAndSplit(const QImage & background,const QList &listGamingArea) -{ - QSize finalSize(m_targetSize); - float sizeFactor = 1.0f; - QList results; - - finalSize /= sizeFactor; - - QRectF total; - foreach (const QRectF &rectf, listGamingArea) - total |= rectf; - - //QImage wallp(finalSize,QImage::Format_ARGB32); - QSize bgSize = background.size(); - int alignOffsetX = ( bgSize.width() - total.width() ) / 2 - total.x(); // center image in X; - int alignOffsetY = 0; - - // compute the offset according to the alignment requirement - switch(m_alignmentType) - { - case ALIGN_CENTER: - alignOffsetY = ( bgSize.height() - finalSize.height() ) / 2; - break; - - case ALIGN_BOTTOM: - alignOffsetY = bgSize.height() - finalSize.height(); - break; - - case ALIGN_TOP: // top align by default - default: - break; - } - - //QPainter painter(&wallp); -// int offsetX = MAX(0,(finalSize.width()-bgSize.width())/2); -// int offsetY = 0; - // Fill the image with the gaming area list - foreach (const QRectF &zone, listGamingArea) - { - //QRectF target(offsetX,offsetY,zone.width()/sizeFactor,zone.height()/sizeFactor); - QRectF source( - zone.x() / sizeFactor + alignOffsetX, - zone.y() / sizeFactor + alignOffsetY, - zone.width() / sizeFactor, - zone.height() / sizeFactor - ); - - //painter.drawImage(target,background,source); - //offsetX += zone.width()/sizeFactor; - - results << background.copy( source.toRect() ); - } - return results; -} - -QImage BackgroundPainter::cropAndMerge(const QImage & background,const QList &listGamingArea) -{ - QSize finalSize(m_targetSize); - float sizeFactor = 1.0f; - - finalSize /= sizeFactor; - - QRectF total; - foreach (const QRectF &rectf, listGamingArea) - total |= rectf; - - QImage wallp(finalSize,QImage::Format_ARGB32); - QSize bgSize = background.size(); - int alignOffsetX = ( bgSize.width() - total.width() ) / 2 - total.x(); // center image in X; - int alignOffsetY = 0; - - // compute the offset according to the alignment requirement - switch(m_alignmentType) - { - case ALIGN_CENTER: - alignOffsetY = ( bgSize.height() - finalSize.height() ) / 2; - break; - - case ALIGN_BOTTOM: - alignOffsetY = bgSize.height() - finalSize.height(); - break; - - case ALIGN_TOP: // top align by default - default: - break; - } - - QPainter painter(&wallp); - int offsetX = MAX(0,( finalSize.width() - bgSize.width() ) / 2); - int offsetY = 0; - - // Fill the image with the gaming area list - foreach (const QRectF &zone, listGamingArea) - { - QRectF target(offsetX,offsetY+zone.y(),zone.width() / sizeFactor,zone.height() / sizeFactor); - QRectF source( - zone.x() / sizeFactor + alignOffsetX, - zone.y() / sizeFactor + alignOffsetY, - zone.width() / sizeFactor, - zone.height() / sizeFactor - ); - - painter.drawImage(target,background,source); - offsetX += zone.width() / sizeFactor; - } - return wallp; -} - -QImage BackgroundPainter::crop(const QImage & background, const QSize &size, bool preview) -{ - QSize finalSize(size); - float sizeFactor = 1.0f; - - if (preview) - sizeFactor = previewFactor; - - finalSize /= sizeFactor; - - QImage wallp(finalSize,QImage::Format_ARGB32); - QSize bgSize = background.size(); - int alignOffsetX = ( bgSize.width() - finalSize.width() ) / 2; // center image in X - int alignOffsetY = 0; - - // compute the offset according to the alignment requirement - switch(m_alignmentType) - { - case ALIGN_CENTER: - alignOffsetY = ( bgSize.height() - finalSize.height() ) / 2; - break; - - case ALIGN_BOTTOM: - alignOffsetY = bgSize.height() - finalSize.height(); - break; - - case ALIGN_TOP: // top align by default - default: - break; - } - - QPainter painter(&wallp); - -// int offsetX = 0; -// int offsetY = 0; - - QRectF target( 0.0f,0.0f,finalSize.width(),finalSize.height() ); - QRectF source( - alignOffsetX, - alignOffsetY, - finalSize.width(), - finalSize.height() - ); - - painter.drawImage(target,background,source); - return wallp; -} - -bool BackgroundPainter::hasSpecialEffectParameter(int specialEffect) const -{ - if ( m_hasParameter.contains(specialEffect) ) - return true; - - return false; -} - -QImage BackgroundPainter::toSepia(const QImage &img) -{ - QImage dest(img.size(), QImage::Format_ARGB32); - const int w = img.width(); - const int h = img.height(); - - for (int y = 0; y(blurred, radius); - - // replace alpha value in blurred image - int width = blurred.width(); - int height = blurred.height(); - - for (int y = 0; y < height; y++) - { - QRgb *lineSrc = reinterpret_cast( blurredImage.scanLine(y) ); - QRgb *lineBlur = reinterpret_cast( blurred.scanLine(y) ); - QRgb *lineMask = reinterpret_cast( mask.scanLine(y) ); - - for (int x = 0; x < width; x++) - { - //QRgb valueSrc = qRgba(qRed(*lineSrc),qGreen(*lineSrc),qBlue(*lineSrc),qRed(*lineMask)); - QRgb valueDest = qRgba( qRed(*lineBlur),qGreen(*lineBlur),qBlue(*lineBlur),qRed(*lineMask) ); - - //QRgb valueMsk = qRgba(qRed(*lineMask),qGreen(*lineMask),qBlue(*lineMask),qBlue(*lineMask)); - blurred.setPixel(x,y,valueDest); - - //blurredImage.setPixel(x,y,valueSrc); - //mask.setPixel(x,y,valueMsk); - lineMask++; - lineSrc++; - lineBlur++; - } - } - -// blurred.save("c:\\blur.tif","TIF"); -// blurredImage.save("c:\\src.tif","TIF"); -// mask.save("c:\\mask.tif","TIF"); - - QPainter imagePainter(&blurredImage); - - imagePainter.save(); - imagePainter.setCompositionMode(QPainter::CompositionMode_SourceOver); - imagePainter.drawImage(0,0, blurred); - imagePainter.restore(); - imagePainter.end(); - -// blurredImage.save("c:\\blurred.tif","TIF"); - - return blurredImage; -} - -QImage BackgroundPainter::glow(const QImage &image, int radius) -{ - QImage glownImage(image.size(), QImage::Format_ARGB32_Premultiplied); - glownImage.fill(0x00); - QPainter imagePainter(&glownImage); - - imagePainter.drawImage(0,0, image); - - //ExpBlur with 0.16 fp for alpha and - //8.7 fp for state parameters zR,zG,zB and zA - QImage blurred = image; - expblur<16,7>(blurred, radius); - - imagePainter.save(); - imagePainter.setCompositionMode(QPainter::CompositionMode_Plus); - imagePainter.drawImage(0,0, blurred); - imagePainter.restore(); - imagePainter.end(); - - return glownImage; -} - -QImage BackgroundPainter::invertColors(const QImage &img) -{ - QImage inverted(img.size(), QImage::Format_ARGB32); - const int w = img.width(); - const int h = img.height(); - - for (int y = 0; y -#include -#include - -class BackgroundPainter : - public QObject -{ - Q_OBJECT - -public: - - enum MultiMonitorSupportType - { - MULTIMONITOR_NO_MULTIMONITOR = 0, - MULTIMONITOR_ONE_IMAGE_MULTIPLEMONITOR , - MULTIMONITOR_ONE_IMAGE_BY_MONITOR, - MULTIMONITOR_END - }; - - enum ResizingType - { - SCALE_NO_RESIZE = 0, - SCALE_IGNORE_ASPECT, - SCALE_KEEP_ASPECT, - SCALE_KEEP_EXPANDED_ASPECT, - SCALE_END - }; - - enum AlignmentType - { - ALIGN_TOP = 0, - ALIGN_CENTER, - ALIGN_BOTTOM, - ALIGN_END - }; - - enum FillingType - { - FILL_BY_COLOR = 0, - FILL_BY_SMART_COLOR, - FILL_BY_BLUR, - FILL_BY_VERTICAL_GRADIENT, - FILL_BY_HORIZONTAL_GRADIENT, - FILL_BY_RADIAL_GRADIENT, - FILL_END - }; - - enum SpecialEffectType - { - EFFECT_NONE = 0, - EFFECT_GRAYSCALE, - EFFECT_BLUR, - EFFECT_GAUSSIAN_BLUR, - EFFECT_EDGE, - EFFECT_SHARPEN, - EFFECT_GAUSSIAN_SHARPEN, - EFFECT_EMBOSS, - EFFECT_DESATURATE, - EFFECT_FLATTEN, - EFFECT_SWIRL, - EFFECT_OILPAINT, - EFFECT_CHARCOAL, - EFFECT_SEPIA, - EFFECT_INVERTCOLOR, - EFFECT_GLOW, - EFFECT_PROGRESSIVEBLUR, - EFFECT_RANDOM, - EFFECT_END - }; - - enum RotationModeType - { - ROTATION_UNLNOWN = 0, - ROTATION_NONE, - ROTATION_FLIP_HORIZ, - ROTATION_180, - ROTATION_FLIP_VERTICAL, - ROTATION_TRANSPOSE, - ROTATION_90, - ROTATION_TRANSVERSE, - ROTATION_270, - ROTATION_END - }; - - BackgroundPainter(QObject *parent = NULL); - virtual ~BackgroundPainter(); - - void setMultiMonitorSupportType(int); - int getMultiMonitorSupportType() const - { - return m_multiMonitorType; - } - - void setResizingType(int); - int getResizingType() const - { - return m_resizingType; - } - - void setAlignmentType(int); - int getAlignmentType() const - { - return m_alignmentType; - } - - void setFillingType(int); - int getFillingType() const - { - return m_fillingType; - } - - void setSpecialEffectType(int); - int getSpecialEffectType() const - { - return m_specialEffectType; - } - - int getLastSpecialEffectType() const - { - return m_lastSpecialEffectType; - } - - void setSpecialEffectParameter(float val); - float getSpecialEffectParameter() const { return m_specialEffectParam; } - - void setShareImageBetweenScreen(bool); - bool getShareImageBetweenScreen() const - { - return m_shareImageBetweenScreen; - } - - void setFillingColor1(const QColor &color); - const QColor &getFillingColor1() const {return m_fillingColor1; } - - void setFillingColor2(const QColor &color); - const QColor &getFillingColor2() const {return m_fillingColor2; } - - void setInverseGradient(bool); - bool getInverseGradient() const - { - return m_inverseGradient; - } - - QImage processImage(const QImage &srcImage, bool previewMode = false); - - void setTargetSizeWithMargins(const QSize &size){m_targetSizeWithMargins = size; } - QSize getTargetSizeWithMargins() const { return m_targetSizeWithMargins; } - - void setTargetSize(const QSize &size){m_targetSize = size; } - QSize getTargetSize() const { return m_targetSize; } - - QSize getSizeAccordingToConfig(const QSize &baseSize, bool preview = false); - - void fillImage(const QImage &src, QImage &target); - void postProcess(QImage &, int effect, bool preview = false); - - QImage cropAndMerge(const QImage & background,const QList &listGamingArea); - QList cropAndSplit(const QImage & background,const QList &listGamingArea); - QImage crop(const QImage & background,const QSize &size, bool previewMode = false); - void embedImage(const QImage&src, QImage & desc); - - bool hasSpecialEffectParameter(int) const; - QImage transform(const QImage &image, int mode) const; - -public slots: - - void saveSettings(); - -signals: - -private: - - void loadSettings(); - - - QColor computeSmartColor(const QImage &img); - QImage toSepia(const QImage &img); - QImage invertColors(const QImage &img); - QImage glow(const QImage &image, int radius); - QImage progressiveBlur(const QImage &image, int radius); - - - bool m_shareImageBetweenScreen; - int m_multiMonitorType; - int m_resizingType; - int m_alignmentType; - int m_fillingType; - int m_specialEffectType; - int m_lastSpecialEffectType; - float m_specialEffectParam; - - QColor m_fillingColor1; - QColor m_fillingColor2; - bool m_inverseGradient; - - QSize m_targetSize; - QSize m_targetSizeWithMargins; - - QList m_hasParameter; -}; - -#endif // _BACKGROUNDPAINTER_H_ diff -Nru syncwall-1.6.0/SyncWall/src/BackgroundPainterConfigWidget.cpp syncwall-1.7.4/SyncWall/src/BackgroundPainterConfigWidget.cpp --- syncwall-1.6.0/SyncWall/src/BackgroundPainterConfigWidget.cpp 2012-08-18 06:24:02.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/BackgroundPainterConfigWidget.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,715 +0,0 @@ - -/****************************************************************************** - SyncWall: Wallpaper manager - Copyright(C) 2011-2012 xbee@xbee.net - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *******************************************************************************/ - -#include -#include -#include -#include - -#include "qexifimageheader.h" - -#include "BackgroundPainterConfigWidget.h" - -#include "ScreenItem.h" -#include "DesktopScene.h" -#include "AppSettings.h" -#include "MiscFunctions.h" -#include "LogHandler.h" - -BackgroundPainterConfigWidget::BackgroundPainterConfigWidget(QWidget *parent) - : QWidget(parent), - m_exportParameters(true), - m_ignoreParameters(false), - m_skipTooSmallImage(false), - m_rotateFromMetadata(false) -{ - setupUi(this); - createDesktop(); - loadSettings(); - updateUI(); - updateDesktop(); -} - -BackgroundPainterConfigWidget::~BackgroundPainterConfigWidget() -{ - //saveSettings(); -} - -void BackgroundPainterConfigWidget::createDesktop() -{ - QDesktopWidget *desktop = QApplication::desktop(); - - qDeleteAll(m_screens); - m_screens.clear(); - - for (int screen = 0; screen < desktop->screenCount(); screen++) - { - QRect avail = desktop->screenGeometry(screen); - m_screens << new ScreenItem(avail.size(),screen + 1); - } -} - -void BackgroundPainterConfigWidget::updateDesktop() -{ - if ( m_screens.isEmpty() ) - return; - - foreach ( QGraphicsItem * item, m_desktopScene->items() ) - m_desktopScene->removeItem(item); - - QDesktopWidget *desktop = QApplication::desktop(); - int mainScreen = desktop->primaryScreen(); - - QList screens; - - if ( m_screens.size() > 1 && m_painter.getShareImageBetweenScreen() && m_painter.getMultiMonitorSupportType() != BackgroundPainter::MULTIMONITOR_NO_MULTIMONITOR ) - { - for (int screen = 0; screen < m_screens.size(); screen++) - { - screens << m_screens.at(screen); - screens.at(screen)->setUseMargins(true); - screens.at(screen)->setDrawText(true); - } - } - else - { - screens << m_screens.at(mainScreen); - screens.at(0)->setUseMargins(false); // single screen => no margin - screens.at(0)->setDrawText(false); // single screen => no text - } - - m_desktopScene->addScreens(screens); - graphicsViewDesktop->zoomToFit(); -} - -void BackgroundPainterConfigWidget::updateUI() -{ - // connect painter signal - //connect( &m_painter, SIGNAL( newImage(const QImage &) ), this, SIGNAL( newImage(const QImage &) ) ); - - m_desktopScene = new DesktopScene(this); - graphicsViewDesktop->setScene(m_desktopScene); - - connect( m_desktopScene, SIGNAL( reordering() ), this, SLOT( previewImage() ) ); - - // setup UI - initMultiMonitorSupportType(); - initResizingType(); - initAlignmentType(); - initFillingType(); - initSpecialEffectType(); - - // apply parameters - applyConfig(); - - // connect signals if screens configuration change - connect( QApplication::desktop(),SIGNAL( screenCountChanged(int) ),this,SLOT( updateScreenConfig(int) ) ); - connect( QApplication::desktop(),SIGNAL( resized(int) ),this,SLOT( updateScreenConfig(int) ) ); -} - -void BackgroundPainterConfigWidget::updateScreenConfig(int) -{ - QDesktopWidget *desktop = QApplication::desktop(); - - // ? new screen - if ( desktop->screenCount() > m_screens.size() ) - { - for (int screen = m_screens.size() ; screen < desktop->screenCount(); screen++) - { - QRect avail = desktop->screenGeometry(screen); - m_screens << new ScreenItem(avail.size(),screen + 1); - } - } - else if ( desktop->screenCount() < m_screens.size() ) - { - int nb = m_screens.size(); - for (int screen = desktop->screenCount(); screen < nb; screen++) - delete m_screens.takeLast(); - } - - // update geometry and screen number - for (int screen = 0; screen < m_screens.size(); screen++) - { - QRect avail = desktop->screenGeometry(screen); - m_screens[screen]->setSize( avail.size() ); - m_screens[screen]->setNumber(screen + 1); - } - - updateDesktop(); - - processImage(m_lastFile); -} - -void BackgroundPainterConfigWidget::applyConfig() -{ - comboBoxMultiMonitor->setCurrentIndex( m_painter.getMultiMonitorSupportType() ); - - // enable only if several screens detected ... - comboBoxMultiMonitor->setEnabled(QApplication::desktop()->screenCount() > 1); - - // display tips only if several screens - labelTips->setVisible(QApplication::desktop()->screenCount() > 1); - - comboBoxResizingType->setCurrentIndex( m_painter.getResizingType() ); - comboBoxAlignmentType->setCurrentIndex( m_painter.getAlignmentType() ); - comboBoxAlignmentType->setEnabled(m_painter.getResizingType() != BackgroundPainter::SCALE_IGNORE_ASPECT && - m_painter.getResizingType() != BackgroundPainter::SCALE_KEEP_ASPECT - ); - comboBoxFillingType->setCurrentIndex( m_painter.getFillingType() ); - comboBoxFillingType->setEnabled(m_painter.getResizingType() != BackgroundPainter::SCALE_IGNORE_ASPECT && - m_painter.getResizingType() != BackgroundPainter::SCALE_KEEP_EXPANDED_ASPECT - ); - - // enable only if several screens detected ... - checkBoxShareScreen->setChecked( m_painter.getShareImageBetweenScreen() ); - checkBoxShareScreen->setEnabled(QApplication::desktop()->screenCount() > 1); - - setButtonColor(m_painter.getFillingColor1(),pushButtonPreviewColor1); - setButtonColor(m_painter.getFillingColor2(),pushButtonPreviewColor2); - pushButtonPreviewColor1->setEnabled(m_painter.getFillingType() == BackgroundPainter::FILL_BY_COLOR || - m_painter.getFillingType() == BackgroundPainter::FILL_BY_VERTICAL_GRADIENT || - m_painter.getFillingType() == BackgroundPainter::FILL_BY_HORIZONTAL_GRADIENT || - m_painter.getFillingType() == BackgroundPainter::FILL_BY_RADIAL_GRADIENT - ); - pushButtonPreviewColor2->setEnabled(m_painter.getFillingType() == BackgroundPainter::FILL_BY_VERTICAL_GRADIENT || - m_painter.getFillingType() == BackgroundPainter::FILL_BY_HORIZONTAL_GRADIENT || - m_painter.getFillingType() == BackgroundPainter::FILL_BY_RADIAL_GRADIENT - ); - - checkBoxInverseGradient->setEnabled( - m_painter.getFillingType() == BackgroundPainter::FILL_BY_VERTICAL_GRADIENT || - m_painter.getFillingType() == BackgroundPainter::FILL_BY_HORIZONTAL_GRADIENT || - m_painter.getFillingType() == BackgroundPainter::FILL_BY_RADIAL_GRADIENT - ); - checkBoxInverseGradient->setChecked( m_painter.getInverseGradient() ); - - comboBoxSpecialEffect->setCurrentIndex( m_painter.getSpecialEffectType() ); - doubleSpinBoxSpecialEffectParam->setValue( m_painter.getSpecialEffectParameter() ); - doubleSpinBoxSpecialEffectParam->setEnabled( m_painter.hasSpecialEffectParameter( m_painter.getSpecialEffectType() ) ); - - checkBoxExportParameters->setChecked(m_exportParameters); - checkBoxIgnoreParameters->setChecked(m_ignoreParameters); - checkBoxSkipTooSmallImage->setChecked(m_skipTooSmallImage); - checkBoxSkipTooSmallImage->setChecked(m_rotateFromMetadata); - - checkBoxSkipTooSmallImage->setEnabled(m_painter.getResizingType() == BackgroundPainter::SCALE_IGNORE_ASPECT || - m_painter.getResizingType() == BackgroundPainter::SCALE_KEEP_EXPANDED_ASPECT - ); -} - -void BackgroundPainterConfigWidget::initResizingType() -{ - // user data are set just to help (not used) - comboBoxResizingType->addItem(tr("no resize"),BackgroundPainter::SCALE_NO_RESIZE); - comboBoxResizingType->addItem(tr("Stretch to fill (Ignore aspect ratio)"),BackgroundPainter::SCALE_IGNORE_ASPECT); - comboBoxResizingType->addItem(tr("Proportionally stretch to fit"),BackgroundPainter::SCALE_KEEP_ASPECT); - comboBoxResizingType->addItem(tr("Fill proportionally"),BackgroundPainter::SCALE_KEEP_EXPANDED_ASPECT); -} - -void BackgroundPainterConfigWidget::initMultiMonitorSupportType() -{ - // user data are set just to help (not used) - comboBoxMultiMonitor->addItem(tr("No multi monitor support (wallpaper duplicated)"),BackgroundPainter::MULTIMONITOR_NO_MULTIMONITOR); - comboBoxMultiMonitor->addItem(tr("Extend image (one file for all monitors)"),BackgroundPainter::MULTIMONITOR_ONE_IMAGE_MULTIPLEMONITOR); - comboBoxMultiMonitor->addItem(tr("Extend image then crop (one file per monitor)"),BackgroundPainter::MULTIMONITOR_ONE_IMAGE_BY_MONITOR); -} - -void BackgroundPainterConfigWidget::initAlignmentType() -{ - // user data are set just to help (not used) - comboBoxAlignmentType->addItem(tr("Top alignment"),BackgroundPainter::ALIGN_TOP); - comboBoxAlignmentType->addItem(tr("Center alignment"),BackgroundPainter::ALIGN_CENTER); - comboBoxAlignmentType->addItem(tr("Bottom alignment"),BackgroundPainter::ALIGN_BOTTOM); -} - -void BackgroundPainterConfigWidget::initFillingType() -{ - // user data are set just to help (not used) - comboBoxFillingType->addItem(tr("Fixed color"),BackgroundPainter::FILL_BY_COLOR); - comboBoxFillingType->addItem(tr("Smart color (extract from image)"),BackgroundPainter::FILL_BY_SMART_COLOR); - comboBoxFillingType->addItem(tr("Blurred image"),BackgroundPainter::FILL_BY_BLUR); - comboBoxFillingType->addItem(tr("Vertical gradient"),BackgroundPainter::FILL_BY_VERTICAL_GRADIENT); - comboBoxFillingType->addItem(tr("Horizontal gradient"),BackgroundPainter::FILL_BY_HORIZONTAL_GRADIENT); - comboBoxFillingType->addItem(tr("Radial gradient"),BackgroundPainter::FILL_BY_RADIAL_GRADIENT); -} - -void BackgroundPainterConfigWidget::initSpecialEffectType() -{ - comboBoxSpecialEffect->addItem(tr("No effect"),BackgroundPainter::EFFECT_NONE); - comboBoxSpecialEffect->addItem(tr("Grayscale"),BackgroundPainter::EFFECT_GRAYSCALE); - comboBoxSpecialEffect->addItem(tr("Blur"),BackgroundPainter::EFFECT_BLUR); - comboBoxSpecialEffect->addItem(tr("Gaussian blur"),BackgroundPainter::EFFECT_GAUSSIAN_BLUR); - comboBoxSpecialEffect->addItem(tr("Edge"),BackgroundPainter::EFFECT_EDGE); - comboBoxSpecialEffect->addItem(tr("Sharpen"),BackgroundPainter::EFFECT_SHARPEN); - comboBoxSpecialEffect->addItem(tr("Gaussian sharpen"),BackgroundPainter::EFFECT_GAUSSIAN_SHARPEN); - comboBoxSpecialEffect->addItem(tr("Emboss"),BackgroundPainter::EFFECT_EMBOSS); - comboBoxSpecialEffect->addItem(tr("Desaturate"),BackgroundPainter::EFFECT_DESATURATE); - comboBoxSpecialEffect->addItem(tr("Flatten"),BackgroundPainter::EFFECT_FLATTEN); - comboBoxSpecialEffect->addItem(tr("Swirl"),BackgroundPainter::EFFECT_SWIRL); - comboBoxSpecialEffect->addItem(tr("Oilpaint"),BackgroundPainter::EFFECT_OILPAINT); - comboBoxSpecialEffect->addItem(tr("Charcoal"),BackgroundPainter::EFFECT_CHARCOAL); - comboBoxSpecialEffect->addItem(tr("Sepia"),BackgroundPainter::EFFECT_SEPIA); - comboBoxSpecialEffect->addItem(tr("Invert colors"),BackgroundPainter::EFFECT_INVERTCOLOR); - comboBoxSpecialEffect->addItem(tr("Glow"),BackgroundPainter::EFFECT_GLOW); - comboBoxSpecialEffect->addItem(tr("Progressive blur"),BackgroundPainter::EFFECT_PROGRESSIVEBLUR); - comboBoxSpecialEffect->addItem(tr("Random Effect"),BackgroundPainter::EFFECT_RANDOM); -} - -void BackgroundPainterConfigWidget::previewImage(const QString &file) -{ - if ( !file.isEmpty() && m_previewFile != file ) - { - m_previewImage = QImage(file); - labelPreviewImage->setText( QString("%1 - %2x%3").arg( QFileInfo(file).baseName() ).arg( m_previewImage.width() ).arg( m_previewImage.height() ) ); - if (m_rotateFromMetadata) - { - QExifImageHeader qexif(file); - m_previewImage = m_painter.transform(m_previewImage,qexif.value(QExifImageHeader::Orientation).toShort()); - } - } - - m_previewFile = file; - - if ( m_previewImage.isNull() ) - { - m_previewImage = QImage(":/syncwall/flower.png"); - labelPreviewImage->setText(""); - } - - // refresh final size just in case ... - m_painter.setTargetSize( m_desktopScene->getSize() ); - m_painter.setTargetSizeWithMargins( m_desktopScene->getSizeWithMargins() ); - - QSize minDesktopSize = m_desktopScene->getSizeWithMargins(); - - //QSize totalSizeWithConfig = m_painter.getSizeAccordingToConfig(minDesktopSize); - //QSize resampledSrcImgSize = m_painter.getSizeAccordingToConfig( m_previewImage.size() ); - - QImage background = m_painter.processImage(m_previewImage,true); - - //background.save("d:/tmp/background.png","PNG"); - - QImage res = m_painter.crop(background,minDesktopSize,true); - - //res.save("d:/tmp/res.png","PNG"); - - m_desktopScene->applyImage(res); -} - -void BackgroundPainterConfigWidget::processImage(const QString &file, bool manual) -{ - m_lastFile = file; - - if (m_previewFile != m_lastFile) - { - m_previewImage = QImage(file); - if (m_rotateFromMetadata) - { - QExifImageHeader qexif(file); - m_previewImage = m_painter.transform(m_previewImage,qexif.value(QExifImageHeader::Orientation).toShort()); - } - m_previewFile = file; - } - - static int rejectNum = 0; - if (manual && m_skipTooSmallImage) - { - // check a - QSize s = m_desktopScene->getSize(); - if (m_previewImage.size().width() < s.width() / 2 || m_previewImage.size().height() < s.height() / 2) - { - LogHandler::getInstance()->reportInfo( QObject::tr("BackgroundPainterConfigWidget: image %1 is reject because its size is too small (%2x%3/%4x%5))").arg( m_lastFile).arg( m_previewImage.size().width() ).arg( m_previewImage.size().height() ).arg( s.width() ).arg( s.height() ) ); - rejectNum++; - - // watchdog - if (rejectNum < 50) - emit requestNewImage(); - else - LogHandler::getInstance()->reportError( QObject::tr("BackgroundPainterConfigWidget: too many reject files => please change settings of add more hi-resolution images !!") ); - return; - } - } - rejectNum = 0; // reset the reject counter - - QImage wallp = m_painter.processImage(m_previewImage); - QList listGamingArea = m_desktopScene->getGamingAreaList(); - - if (m_painter.getMultiMonitorSupportType() != BackgroundPainter::MULTIMONITOR_ONE_IMAGE_BY_MONITOR) - { - QImage res = m_painter.cropAndMerge(wallp,listGamingArea); - emit newImage(res); - } - else - { - QList res = m_painter.cropAndSplit(wallp,listGamingArea); - emit newImages(res); - } - - previewImage(file); // load m_previewImage - - // encode configuration and send it to client - emit newConfiguration( encodeConfiguration(file) ); -} - -void BackgroundPainterConfigWidget::on_checkBoxShareScreen_stateChanged ( int state ) -{ - m_painter.setShareImageBetweenScreen(state); - - checkBoxShareScreen->setChecked( m_painter.getShareImageBetweenScreen() ); - updateDesktop(); -} - -void BackgroundPainterConfigWidget::on_checkBoxInverseGradient_stateChanged ( int state ) -{ - if ( (bool)state == m_painter.getInverseGradient() ) - return; - - m_painter.setInverseGradient(state); - previewImage(); -} - -void BackgroundPainterConfigWidget::on_checkBoxIgnoreParameters_stateChanged ( int state ) -{ - m_ignoreParameters = state; -} - -void BackgroundPainterConfigWidget::on_checkBoxExportParameters_stateChanged ( int state ) -{ - m_exportParameters = state; -} - -void BackgroundPainterConfigWidget::on_checkBoxSkipTooSmallImage_stateChanged ( int state ) -{ - m_skipTooSmallImage = state; -} - -void BackgroundPainterConfigWidget::on_checkBoxRotateWithMetadata_stateChanged ( int state ) -{ - m_rotateFromMetadata = state; -} - -void BackgroundPainterConfigWidget::on_comboBoxResizingType_activated(int index) -{ - if ( index == m_painter.getResizingType() ) - return; - - m_painter.setResizingType(index); - comboBoxAlignmentType->setEnabled( - index != BackgroundPainter::SCALE_IGNORE_ASPECT && - index != BackgroundPainter::SCALE_KEEP_ASPECT - ); - - comboBoxFillingType->setEnabled( - index != BackgroundPainter::SCALE_IGNORE_ASPECT && - index != BackgroundPainter::SCALE_KEEP_EXPANDED_ASPECT - ); - - checkBoxSkipTooSmallImage->setEnabled(index == BackgroundPainter::SCALE_IGNORE_ASPECT || - index == BackgroundPainter::SCALE_KEEP_EXPANDED_ASPECT - ); - previewImage(); -} - -void BackgroundPainterConfigWidget::on_comboBoxMultiMonitor_activated(int index) -{ - if ( index == m_painter.getMultiMonitorSupportType() ) - return; - - m_painter.setMultiMonitorSupportType(index); - updateDesktop(); -} - -void BackgroundPainterConfigWidget::on_comboBoxAlignmentType_activated(int index) -{ - if ( index == m_painter.getAlignmentType() ) - return; - - m_painter.setAlignmentType(index); - previewImage(); -} - -void BackgroundPainterConfigWidget::on_comboBoxSpecialEffect_activated(int index) -{ - if ( index == m_painter.getSpecialEffectType() ) - return; - - m_painter.setSpecialEffectType(index); - doubleSpinBoxSpecialEffectParam->setEnabled( m_painter.hasSpecialEffectParameter(index) ); - previewImage(); -} - -void BackgroundPainterConfigWidget::on_doubleSpinBoxSpecialEffectParam_valueChanged(double val) -{ - if ( val == m_painter.getSpecialEffectParameter() ) - return; - - m_painter.setSpecialEffectParameter(val); - previewImage(); -} - -void BackgroundPainterConfigWidget::on_comboBoxFillingType_activated(int index) -{ - if ( index == m_painter.getFillingType() ) - return; - - m_painter.setFillingType(index); - pushButtonPreviewColor1->setEnabled(index == BackgroundPainter::FILL_BY_COLOR || - index == BackgroundPainter::FILL_BY_VERTICAL_GRADIENT || - index == BackgroundPainter::FILL_BY_HORIZONTAL_GRADIENT || - index == BackgroundPainter::FILL_BY_RADIAL_GRADIENT - ); - pushButtonPreviewColor2->setEnabled(index == BackgroundPainter::FILL_BY_VERTICAL_GRADIENT || - index == BackgroundPainter::FILL_BY_HORIZONTAL_GRADIENT || - index == BackgroundPainter::FILL_BY_RADIAL_GRADIENT - ); - checkBoxInverseGradient->setEnabled(index == BackgroundPainter::FILL_BY_VERTICAL_GRADIENT || - index == BackgroundPainter::FILL_BY_HORIZONTAL_GRADIENT || - index == BackgroundPainter::FILL_BY_RADIAL_GRADIENT - ); - previewImage(); -} - -void BackgroundPainterConfigWidget::on_pushButtonPreviewColor1_pressed() -{ - QColor prevColor = pushButtonPreviewColor1->palette().color(QPalette::Button); - QColor c = QColorDialog::getColor(prevColor); - - if (c == prevColor) - return; - - setButtonColor(c,pushButtonPreviewColor1); - m_painter.setFillingColor1(c); - previewImage(); -} - -void BackgroundPainterConfigWidget::on_pushButtonPreviewColor2_pressed() -{ - QColor prevColor = pushButtonPreviewColor2->palette().color(QPalette::Button); - QColor c = QColorDialog::getColor(prevColor); - - if (c == prevColor) - return; - - setButtonColor(c,pushButtonPreviewColor2); - m_painter.setFillingColor2(c); - previewImage(); -} - -void BackgroundPainterConfigWidget::setButtonColor(const QColor &c, QPushButton *b) -{ - if ( c.isValid() && b) - { - QPalette palette = b->palette(); - palette.setColor(QPalette::Button, c); - b->setPalette(palette); // to easily save the color - } -} - -void BackgroundPainterConfigWidget::loadSettings() -{ - AppSettings settings; - - settings.beginGroup("ScreensConfig"); - - // screens - int size = settings.beginReadArray("screens"); - - for (int i = 0; i < size; ++i) - { - settings.setArrayIndex(i); - int num = settings.value("num").toInt(); - int marginTop = settings.value("marginTop").toInt(); - int marginBottom = settings.value("marginBottom").toInt(); - int marginLeft = settings.value("marginLeft").toInt(); - int marginRight = settings.value("marginRight").toInt(); - QPointF pos = settings.value("pos").toPointF(); - - if ( num <= m_screens.size() && num > 0 ) - { - m_screens.at(num - 1)->setMargings(marginTop,marginBottom,marginLeft,marginRight); - - //qDebug() << "screen pos av = " << m_screens.at(num - 1)->pos(); - m_screens.at(num - 1)->setPos(pos); // to restore good placement - //qDebug() << "screen pos ap = " << m_screens.at(num - 1)->pos(); - } - } - - settings.endArray(); - - settings.endGroup(); - - settings.beginGroup("ClientServerConnection"); - m_exportParameters = settings.value("exportParameters",true).toBool(); - m_ignoreParameters = settings.value("ignoreParameters",false).toBool(); - settings.endGroup(); - - settings.beginGroup("BackgroundPainter"); - m_skipTooSmallImage = settings.value("skipTooSmallImage",false).toBool(); - m_rotateFromMetadata = settings.value("rotateFromMetadata",false).toBool(); - settings.endGroup(); -} - -void BackgroundPainterConfigWidget::saveSettings() -{ - AppSettings settings; - - settings.beginGroup("ScreensConfig"); - - // screens - settings.beginWriteArray( "screens", m_screens.count() ); - - for (int i = 0; i < m_screens.size(); ++i) - { - settings.setArrayIndex(i); - settings.setValue( "num", m_screens.at(i)->getNumber() ); - settings.setValue( "marginTop", m_screens.at(i)->getMarginTop() ); - settings.setValue( "marginBottom", m_screens.at(i)->getMarginBottom() ); - settings.setValue( "marginLeft", m_screens.at(i)->getMarginLeft() ); - settings.setValue( "marginRight", m_screens.at(i)->getMarginRight() ); - settings.setValue( "pos", m_screens.at(i)->pos() ); - qDebug() << " pos = " << m_screens.at(i)->pos(); - } - - settings.endArray(); - - settings.endGroup(); - - settings.beginGroup("ClientServerConnection"); - - settings.setValue("exportParameters",m_exportParameters); - settings.setValue("ignoreParameters",m_ignoreParameters); - - settings.endGroup(); - - settings.beginGroup("BackgroundPainter"); - settings.setValue("skipTooSmallImage",m_skipTooSmallImage); - settings.setValue("rotateFromMetadata",m_rotateFromMetadata); - - settings.endGroup(); - - m_painter.saveSettings(); -} - -void BackgroundPainterConfigWidget::decodeAndApplyMessage(const QString &mess) -{ - QStringList list = mess.split('|'); - QString version = list[0]; - if (version == "1.0") - { - bool hasParameters = (list.size() == 10) ? true : false; - bool hasJustHeader = (list.size() == 2) ? true : false; - if (!hasParameters && !hasJustHeader) - { - LogHandler::getInstance()->reportError( QObject::tr("BackgroundPainterConfigWidget: Message with invalid nb of parameters (%1 instead of %2)").arg( list.size() ).arg( 10 ) ); - return; - } - - int index = 1; - QString file = list[index++]; - bool somethingDiffer = ( file != MiscFunctions::getSignificantPart(m_lastFile) ); // check if new request is different from previous - if (hasParameters && !m_ignoreParameters) - { - // m_painter.setResizingType() - somethingDiffer |= ( m_painter.getResizingType() != list[index].toInt() ); - m_painter.setResizingType( list[index++].toInt() ); - - // m_painter.setAlignmentType() - somethingDiffer |= ( m_painter.getAlignmentType() != list[index].toInt() ); - m_painter.setAlignmentType( list[index++].toInt() ); - - // m_painter.setFillingType() - somethingDiffer |= ( m_painter.getFillingType() != list[index].toInt() ); - m_painter.setFillingType( list[index++].toInt() ); - - // m_painter.getFillingColor1 - somethingDiffer |= ( m_painter.getFillingColor1() != QColor(list[index]) ); - m_painter.setFillingColor1( QColor(list[index++]) ); - - // m_painter.getFillingColor2 - somethingDiffer |= ( m_painter.getFillingColor2() != QColor(list[index]) ); - m_painter.setFillingColor2( QColor(list[index++]) ); - - // m_painter.setInverseGradient - somethingDiffer |= ( m_painter.getInverseGradient() != (bool)list[index].toInt() ); - m_painter.setInverseGradient( (bool)list[index++].toInt() ); - - // m_painter.setSpecialEffectType() - somethingDiffer |= ( m_painter.getSpecialEffectType() != list[index].toInt() ); - m_painter.setSpecialEffectType( list[index++].toInt() ); - - // m_painter.setSpecialEffectParameter(); - somethingDiffer |= ( m_painter.getSpecialEffectParameter() != list[index].toFloat() ); - m_painter.setSpecialEffectParameter( list[index++].toFloat() ); - } - - if (somethingDiffer) - { - applyConfig(); - emit decodedImage(file); - } - } - else - { - LogHandler::getInstance()->reportError( QObject::tr("BackgroundPainterConfigWidget: Message with unknown version received (%1)").arg( version ) ); - } -} - -QString BackgroundPainterConfigWidget::encodeConfiguration(const QString &file) -{ - // version string - QString mess = "1.0"; - - // file - mess += "|" + MiscFunctions::getSignificantPart(file); - - // export image parameters to client ? - if (!m_exportParameters) - return mess; - - // m_painter.getResizingType() - mess += QString("|%1").arg( m_painter.getResizingType() ); - - // m_painter.getAlignmentType() - mess += QString("|%1").arg( m_painter.getAlignmentType() ); - - // m_painter.getFillingType() - mess += QString("|%1").arg( m_painter.getFillingType() ); - - // m_painter.getFillingColor1 - mess += QString("|%1").arg( m_painter.getFillingColor1().name() ); - - // m_painter.getFillingColor1 - mess += QString("|%1").arg( m_painter.getFillingColor2().name() ); - - // m_painter.getInverseGradient - mess += QString("|%1").arg( m_painter.getInverseGradient() ); - - // m_painter.getSpecialEffectType() - // special RANDOM_EFFECT - if (m_painter.getSpecialEffectType() != BackgroundPainter::EFFECT_RANDOM) - mess += QString("|%1").arg( m_painter.getSpecialEffectType() ); - else // send computed effect - mess += QString("|%1").arg( m_painter.getLastSpecialEffectType() ); - - // m_painter.getSpecialEffectParameter(); - mess += QString("|%1").arg( m_painter.getSpecialEffectParameter() ); - - return mess; -} diff -Nru syncwall-1.6.0/SyncWall/src/BackgroundPainterConfigWidget.h syncwall-1.7.4/SyncWall/src/BackgroundPainterConfigWidget.h --- syncwall-1.6.0/SyncWall/src/BackgroundPainterConfigWidget.h 2012-05-14 12:56:44.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/BackgroundPainterConfigWidget.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,111 +0,0 @@ - -/****************************************************************************** - SyncWall: Wallpaper manager - Copyright(C) 2011-2012 xbee@xbee.net - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *******************************************************************************/ -#ifndef _BACKGROUNDPAINTERCONFIGWIDGET_H_ -#define _BACKGROUNDPAINTERCONFIGWIDGET_H_ - -#include -#include "ui_BackgroundPainterConfigWidget.h" - -#include "BackgroundPainter.h" - -// forward declarations -class DesktopScene; -class ScreenItem; - -class BackgroundPainterConfigWidget : - public QWidget, public Ui::BackgroundPainterConfigWidget -{ - Q_OBJECT - -public: - - BackgroundPainterConfigWidget(QWidget *parent = 0); - ~BackgroundPainterConfigWidget(); - -public slots: - - void on_checkBoxShareScreen_stateChanged ( int state ); - void on_checkBoxInverseGradient_stateChanged ( int state ); - void on_checkBoxIgnoreParameters_stateChanged ( int state ); - void on_checkBoxExportParameters_stateChanged ( int state ); - void on_comboBoxResizingType_activated(int index); - void on_comboBoxAlignmentType_activated(int index); - void on_comboBoxFillingType_activated(int index); - void on_comboBoxSpecialEffect_activated(int index); - void on_pushButtonPreviewColor1_pressed(); - void on_pushButtonPreviewColor2_pressed(); - void on_doubleSpinBoxSpecialEffectParam_valueChanged(double); - void on_comboBoxMultiMonitor_activated(int); - void on_checkBoxSkipTooSmallImage_stateChanged ( int state ); - void on_checkBoxRotateWithMetadata_stateChanged ( int state ); - - void processImage(const QString &,bool manual = false); - void previewImage( const QString &file = QString() ); - - DesktopScene *getScenePreview() const { return m_desktopScene; } - - void decodeAndApplyMessage(const QString &); - - void saveSettings(); - - void updateScreenConfig(int); - -signals: - - void requestNewImage(); - - void newImage(const QImage &); - void newImages(const QList &); - - void refreshPreview(); - void newConfiguration(const QString &); - void decodedImage(const QString &); - -private: - - void loadSettings(); - - - void updateUI(); - void applyConfig(); - void createDesktop(); - void updateDesktop(); - void initResizingType(); - void initAlignmentType(); - void initMultiMonitorSupportType(); - void initFillingType(); - void initSpecialEffectType(); - void setButtonColor(const QColor &c, QPushButton *b); - QString encodeConfiguration(const QString &); - - BackgroundPainter m_painter; - DesktopScene *m_desktopScene; - QImage m_previewImage; - QString m_previewFile; - - QList m_screens; - bool m_exportParameters; - bool m_ignoreParameters; - bool m_skipTooSmallImage; - bool m_rotateFromMetadata; - QString m_lastFile; -}; - -#endif // _BACKGROUNDPAINTERCONFIGWIDGET_H_ diff -Nru syncwall-1.6.0/SyncWall/src/DesktopScene.cpp syncwall-1.7.4/SyncWall/src/DesktopScene.cpp --- syncwall-1.6.0/SyncWall/src/DesktopScene.cpp 2012-03-31 14:32:52.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/DesktopScene.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,186 +0,0 @@ -/****************************************************************************** -SyncWall: Wallpaper manager -Copyright(C) 2011-2012 xbee@xbee.net - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*******************************************************************************/ - -#include "DesktopScene.h" -#include "ScreenItem.h" - -#include -#include -#include - -const int displayedMargin = 2; - -bool lessThanCenter(const QGraphicsItem *s1, const QGraphicsItem *s2) -{ - QPointF p1 = s1->pos(); - QPointF p2 = s2->pos(); - return p1.x() < p2.x(); -} - - -DesktopScene::DesktopScene(QObject * parent) - : QGraphicsScene(parent), - m_hasMove(false) -{ - setSceneRect(0,0,200, 200); -} - -DesktopScene::~DesktopScene() -{ - -} - -void DesktopScene::addScreens(const QList &screens) -{ - int offset = 0; - foreach (ScreenItem *screen, screens) - { - qDebug() << "screen pos av = " << screen->pos(); - addItem(screen); - qDebug() << "screen pos ap = " << screen->pos(); - // decal for auto placement - if (screen->x() == 0) - screen->setX(offset); - offset+=screen->boundingRect().width(); - } - reorder(); -} - -void DesktopScene::addScreen(ScreenItem *screen) -{ - addItem(screen); - // decal for auto placement - screen->setX(screen->boundingRect().width()); - reorder(); -} - -void DesktopScene::reorder() -{ - // search for cumulated width & height - QList list = items (); - - // sort list with x value => get the correct order for screen to be displayed - qSort(list.begin(),list.end(),lessThanCenter); - - // Get the higher screen for vertical alignment - int highest = 0; - foreach( QGraphicsItem *item, list ) - { - ScreenItem *screen = qgraphicsitem_cast(item); - highest = qMax(highest,screen->getSizeWithMargins ().height()); - } - - // place all item now - int offsetX = 0; - int offsetY = 0; - - foreach( QGraphicsItem *item, list ) - { - ScreenItem *screen = qgraphicsitem_cast(item); - QSize size = screen->getSizeWithMargins (); - QPointF oldScenePos = screen->scenePos(); - QPointF oldPos = screen->pos(); - QRectF oldSceneRect = screen->sceneBoundingRect(); - - int posx = offsetX; - posx += size.width()/2; // because center on (0,0) - int posy = offsetY; - posy += size.height()/2; // because center on (0,0) - //posy += (cHeight - size.height()); // because bottom alignment - posy -= screen->getMarginBottom(); - qDebug() << "posx = " << posx << " posy = " << posy << " oldpos = " << oldPos << " oldScenePos = " << oldScenePos << " oldSceneRect = " << oldSceneRect << " offsetY = " << offsetY << " highest = " << highest; - - if (oldPos.y() > highest/2) // bottom alignment - { - posy += (highest - size.height()); - qDebug() << "bottom alignement !! posy = " << posy; - } - - screen->setPos(posx,posy); - //qDebug("screen %d new pos = %f,%f (%f,%f,%)",screen->getNumber(),size.x(),size.y()); - offsetX += screen->getSizeWithMargins().width(); // + displayedMargin; - } - - emit reordering(); -} - -void DesktopScene::applyImage(const QImage &image) -{ - foreach( QGraphicsItem *item, items () ) - { - ScreenItem *screen = qgraphicsitem_cast(item); - screen->setImage(image); - } -} - -QList DesktopScene::getGamingAreaList() const -{ - QList gamingArea; - - QList list = items (); - - // sort list with x value => get the correct order for screen to be displayed - qSort(list.begin(),list.end(),lessThanCenter); - - foreach( QGraphicsItem *item, list ) - { - ScreenItem *screen = qgraphicsitem_cast(item); - gamingArea << screen->getValidSceneBoundingRect(); - } - return gamingArea; -} - -QSize DesktopScene::getSize() const -{ - QSize size(0,0); - foreach( QGraphicsItem *item, items() ) - { - ScreenItem *screen = qgraphicsitem_cast(item); - size.rwidth() += screen->getSize().width(); - size.rheight() = qMax(size.height(), screen->getSize().height()); - } - return size; -} - -QSize DesktopScene::getSizeWithMargins() const -{ - QSize size(0,0); - foreach( QGraphicsItem *item, items() ) - { - ScreenItem *screen = qgraphicsitem_cast(item); - size.rwidth() += screen->getRealSizeWithMargins().width(); - size.rheight() = qMax(size.height(), screen->getRealSizeWithMargins().height()); - } - return size; -} - -void DesktopScene::mouseMoveEvent ( QGraphicsSceneMouseEvent * mouseEvent ) -{ - m_hasMove = true; - QGraphicsScene::mouseMoveEvent(mouseEvent); -} - -void DesktopScene::mouseReleaseEvent ( QGraphicsSceneMouseEvent * mouseEvent ) -{ - if (m_hasMove) - reorder(); - QGraphicsScene::mouseReleaseEvent(mouseEvent); - m_hasMove = false; -} - diff -Nru syncwall-1.6.0/SyncWall/src/DesktopScene.h syncwall-1.7.4/SyncWall/src/DesktopScene.h --- syncwall-1.6.0/SyncWall/src/DesktopScene.h 2012-01-06 14:48:54.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/DesktopScene.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,66 +0,0 @@ - -/****************************************************************************** - SyncWall: Wallpaper manager - Copyright(C) 2011-2012 xbee@xbee.net - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *******************************************************************************/ - -#ifndef _DESKTOPSCENE_H_ -#define _DESKTOPSCENE_H_ - -#include -#include - -class ScreenItem; - -class DesktopScene : - public QGraphicsScene -{ - Q_OBJECT - -public: - - DesktopScene(QObject * parent = 0); - ~DesktopScene(); - - void addScreens(const QList &); - void addScreen(ScreenItem *); - void reorder(); - - QSize getSizeWithMargins() const; - QSize getSize() const; - - QList getGamingAreaList() const; - - void applyImage(const QImage &); - -signals: - - void reordering(); - -protected: - - virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * mouseEvent ); - virtual void mouseMoveEvent ( QGraphicsSceneMouseEvent * mouseEvent ); - -private: - - QSize m_size; - QRectF m_rect; - bool m_hasMove; -}; - -#endif // _DESKTOPSCENE_H_ diff -Nru syncwall-1.6.0/SyncWall/src/DesktopView.cpp syncwall-1.7.4/SyncWall/src/DesktopView.cpp --- syncwall-1.6.0/SyncWall/src/DesktopView.cpp 2012-01-06 14:39:14.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/DesktopView.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -/****************************************************************************** -SyncWall: Wallpaper manager -Copyright(C) 2011-2012 xbee@xbee.net - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*******************************************************************************/ - -#include "DesktopView.h" -#include "DesktopScene.h" -#include "ScreenItem.h" - -#include -#include -#include - -//#include - - -DesktopView::DesktopView(QWidget * parent) - : QGraphicsView(parent) -{ - // a gradient background - QLinearGradient lgradient(0, 0,1000,1000); // here 1000x1000 pixel !! - lgradient.setSpread(QGradient::PadSpread); - lgradient.setColorAt(0, QColor("#4a4a4a")); - lgradient.setColorAt(1, QColor("#696969")); - setBackgroundBrush(lgradient); - - setViewportUpdateMode( QGraphicsView::SmartViewportUpdate ); - setCacheMode( QGraphicsView::CacheBackground ); - - setCacheMode(QGraphicsView::CacheBackground); - setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); - setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform); - - setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); - setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); - setFrameStyle( QFrame::NoFrame ); -} - -DesktopView::~DesktopView() -{ -} - -void DesktopView::resizeEvent(QResizeEvent* event) -{ - zoomToFit(); - QGraphicsView::resizeEvent(event); -} - -void DesktopView::zoomToFit() -{ - scene()->setSceneRect(scene()->itemsBoundingRect()); - fitInView(scene()->sceneRect(), Qt::KeepAspectRatio); - scale(1 / 1.1, 1 / 1.1); -} - -void DesktopView::zoomIn() -{ - scale(1.1, 1.1); - emit zoomChanged(); -} - -void DesktopView::zoomOut() -{ - scale(1 / 1.1, 1 / 1.1); - emit zoomChanged(); -} - diff -Nru syncwall-1.6.0/SyncWall/src/DesktopView.h syncwall-1.7.4/SyncWall/src/DesktopView.h --- syncwall-1.6.0/SyncWall/src/DesktopView.h 2012-01-06 14:33:06.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/DesktopView.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ - -/****************************************************************************** - SyncWall: Wallpaper manager - Copyright(C) 2011-2012 xbee@xbee.net - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *******************************************************************************/ - -#ifndef _DESKTOPVIEW_H_ -#define _DESKTOPVIEW_H_ - -#include -#include - -class DesktopView : - public QGraphicsView -{ - Q_OBJECT - -public: - - DesktopView(QWidget * parent = 0); - ~DesktopView(); - - void zoomOut(); - void zoomIn(); - void zoomToFit(); - -signals: - - void zoomChanged(); - -protected: - - void resizeEvent(QResizeEvent* event); - -private: -}; - -#endif // _DESKTOPVIEW_H_ diff -Nru syncwall-1.6.0/SyncWall/src/IMessageHandler.h syncwall-1.7.4/SyncWall/src/IMessageHandler.h --- syncwall-1.6.0/SyncWall/src/IMessageHandler.h 2012-01-06 14:48:14.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/IMessageHandler.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ - -/****************************************************************************** - SyncWall: Wallpaper manager - Copyright(C) 2011-2012 xbee@xbee.net - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *******************************************************************************/ - -#ifndef _IMESSAGEHANDLER_H_ -#define _IMESSAGEHANDLER_H_ - -#include - -//! The Message handler, which can be implemented by the client - -class IMessageHandler -{ -public: - enum MessageLevel - { - MSG_DEBUG = 0, /*!< Message only for debugging purpose. */ - MSG_INFO, /*!< Information message. */ - MSG_WARNING, /*!< Warning, abnormal event. */ - MSG_ERROR /*!< Error, invalid file. */ - }; - - //! Virtual destructor - virtual ~IMessageHandler() {} - - //! This method is called when a message is to be reported to the client - virtual void reportMessage( MessageLevel level, const QString & message ) = 0; - - //! Report only a debug message - virtual void reportDebug(const QString & message ) = 0; - - //! Report only a debug message - virtual void reportInfo(const QString & message ) = 0; - - //! Report only a debug message - virtual void reportWarning(const QString & message ) = 0; - - //! Report only a debug message - virtual void reportError(const QString & message ) = 0; -}; - -//! Sets the error handler to be used for error and warning reporting - -/*! - * This allows the user to set the current Message handler. If the - * parameter is NULL, API reverts back to the default error handler, - * which redirects all warnings and errors to std::cerr. - * - * \sa IMessageHandler - */ -void setMessageHandler( IMessageHandler* Hdl ); - -#endif // _IMESSAGEHANDLER_H_ diff -Nru syncwall-1.6.0/SyncWall/src/IconViewDelegate.cpp syncwall-1.7.4/SyncWall/src/IconViewDelegate.cpp --- syncwall-1.6.0/SyncWall/src/IconViewDelegate.cpp 2012-01-14 12:14:46.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/IconViewDelegate.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ - -/****************************************************************************** - SyncWall: Wallpaper manager - Copyright(C) 2011-2012 xbee@xbee.net - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *******************************************************************************/ - -#include -#include - -#include "IconViewDelegate.h" - -IconViewDelegate::IconViewDelegate(QObject * parent): QStyledItemDelegate(parent) - { - } - -IconViewDelegate::~IconViewDelegate() - { - } - -// Define item size in listview. -QSize IconViewDelegate::sizeHint(const QStyleOptionViewItem & /*option*/ , - const QModelIndex & index) const -{ - QPixmap pix = qvariant_cast(index.data(Qt::DecorationRole)); - QSize iconsize = pix.size(); - //QSize iconsize = option.decorationSize; - QFont font = QApplication::font(); - QFontMetrics fm(font); - - return(QSize(iconsize.width(),iconsize.height()+2*fm.height() +8 )); -} diff -Nru syncwall-1.6.0/SyncWall/src/IconViewDelegate.h syncwall-1.7.4/SyncWall/src/IconViewDelegate.h --- syncwall-1.6.0/SyncWall/src/IconViewDelegate.h 2012-01-14 12:13:26.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/IconViewDelegate.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ - -/****************************************************************************** - SyncWall: Wallpaper manager - Copyright(C) 2011-2012 xbee@xbee.net - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *******************************************************************************/ - -#ifndef IconViewDelegate_H_ -#define IconViewDelegate_H_ -#include - -class IconViewDelegate : public QStyledItemDelegate - { - -public: - - IconViewDelegate(QObject * parent = 0); - virtual ~IconViewDelegate(); - - QSize sizeHint(const QStyleOptionViewItem &option, - const QModelIndex &index ) const; - - }; - -#endif /* IconViewDelegate_H_ */ \ No newline at end of file diff -Nru syncwall-1.6.0/SyncWall/src/ImageInfos.cpp syncwall-1.7.4/SyncWall/src/ImageInfos.cpp --- syncwall-1.6.0/SyncWall/src/ImageInfos.cpp 2012-01-14 12:14:32.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/ImageInfos.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,95 +0,0 @@ -/****************************************************************************** -SyncWall: Wallpaper manager -Copyright(C) 2011-2012 xbee@xbee.net - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*******************************************************************************/ - -#include -#include -#include -#include - -#include "ImageInfos.h" - -const int thumbnailSize = 100; - -ImageInfos::ImageInfos(const QString &file) -{ - m_name = file; - m_filename = file; - m_changed = true; - m_thumbnail = computeSubImage(); - m_key = file; -} - - -ImageInfos::~ImageInfos() -{ -} - -bool ImageInfos::update() -{ - QFileInfo infos(m_filename); - // file don't change so exist - if (infos.lastModified() == m_lastmodification) - return false; - - m_name = infos.baseName(); - m_lastmodification = infos.lastModified(); - m_thumbnail = computeSubImage(QImage(m_filename)); - QString elidedName = QApplication::fontMetrics().elidedText( infos.completeBaseName(), Qt::ElideLeft, thumbnailSize-20); - m_label = QString("%1\n(%2)").arg(elidedName).arg(m_imageSize); - - - quint64 size = infos.size(); - - QString bytesStr; - if (!(size >> 10)) - bytesStr = QString::number(size) + ' ' + QObject::tr("Bytes"); - else if (!(size >> 20)) - bytesStr = QString::number(size / 1024.0, 'f', 3) + ' ' + QObject::tr("KB"); - else if (!(size >> 30)) - bytesStr = QString::number((size >> 10) / 1024.0, 'f', 3) + ' ' + QObject::tr("MB"); - else if (!(size >> 40)) - bytesStr = QString::number((size >> 20) / 1024.0, 'f', 3) + ' ' + QObject::tr("GB"); - else - bytesStr = QString::number((size >> 30) / 1024.0, 'f', 3) + ' ' + QObject::tr("TB"); - - m_fileSize = bytesStr; - return true; -} - -QImage ImageInfos::computeSubImage(const QImage &image) -{ - // compute thumbnail if needed - QImage img(image); - if (img.isNull()) - { - img = QImage(":/syncwall/default.png"); - } - else - { - // compute the file size if available - QString valx = QString::number(img.width()); - QString valy = QString::number(img.height()); - m_imageSize = QString("%1x%2").arg(valx).arg(valy); - } - - return img.scaled(thumbnailSize, thumbnailSize, Qt::KeepAspectRatio); - //return img.scaled(thumbnailSize, thumbnailSize, Qt::IgnoreAspectRatio); -} - - diff -Nru syncwall-1.6.0/SyncWall/src/ImageInfos.h syncwall-1.7.4/SyncWall/src/ImageInfos.h --- syncwall-1.6.0/SyncWall/src/ImageInfos.h 2012-01-14 12:14:18.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/ImageInfos.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,62 +0,0 @@ - -/****************************************************************************** - SyncWall: Wallpaper manager - Copyright(C) 2011-2012 xbee@xbee.net - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *******************************************************************************/ - -#ifndef _IMAGEINFOS_H_ -#define _IMAGEINFOS_H_ - -#include -#include -#include - -class ImageInfos -{ -public: - - ImageInfos(const QString &file); - virtual ~ImageInfos(); - - const QImage& getThumbnail() const { return m_thumbnail; } - const QString& getImageSize() const { return m_imageSize; } - const QString& getLabel() const {return m_label; } - const QString& getKey() const {return m_key; } - const QString& getFilename() const {return m_filename; } - const QString& getName() const {return m_name; } - const QString& getFileSize() const { return m_fileSize; } - - bool update(); - -private: - - QImage computeSubImage( const QImage & = QImage() ); - - QImage m_thumbnail; - bool m_changed; - bool m_computedThumbnail; - QString m_imageSize; - QString m_label; - QString m_key; - bool m_loaded; //has image or is it empty? - QString m_filename; - QString m_name; - QString m_fileSize; - QDateTime m_lastmodification; -}; - -#endif // _IMAGEINFOS_H_ diff -Nru syncwall-1.6.0/SyncWall/src/ImageView.cpp syncwall-1.7.4/SyncWall/src/ImageView.cpp --- syncwall-1.6.0/SyncWall/src/ImageView.cpp 2012-01-06 15:52:42.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/ImageView.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,673 +0,0 @@ -/****************************************************************************** -SyncWall: Wallpaper manager -Copyright(C) 2011-2012 xbee@xbee.net - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*******************************************************************************/ - -#include -#include -#include -#include - - -#include "ImageView.h" - -//----------------------------------------------------------------------------------------- -// Image View - -ImageView::ImageView(QWidget *parent, Qt::WFlags flags) : QGraphicsView(parent), -m_displayInfos(false), -m_navigatorWindow(NULL), -m_navigatorSize(0.15f), -m_navigatorMargin(10), -m_showNavigator(true) - -{ - m_viewportRect = QRect(0, 0, width(), height()); - m_worldMatrix.reset(); - - m_navigatorWindow = new ImageNavigator(this, flags); - m_navigatorWindow->setTransforms(&m_worldMatrix, &m_imgMatrix); - - initBackground(); - - setStyleSheet( "QGraphicsView { border-style: none; }" ); - setMouseTracking (true); //receive mouse event everytime - - connect(m_navigatorWindow, SIGNAL(moveViewSignal(const QPointF&)), this, SLOT(moveView(const QPointF&))); -} - -ImageView::~ImageView() -{ -} - -void ImageView::initBackground() -{ - // precreate background tile - m_tileBg = QPixmap(16, 16); - m_tileBg.fill(Qt::white); - QPainter pt(&m_tileBg); - QColor color(202, 202, 202); - pt.fillRect(0, 0, 8, 8, color); - pt.fillRect(8, 8, 8, 8, color); - pt.end(); -} - -void ImageView::setImage(const QImage &newImg) -{ - m_navigatorWindow->setImage(QImage()); // clear overview - - m_image = newImg; - m_imgRect = QRectF(0, 0, newImg.width(), newImg.height()); - - m_worldMatrix.reset(); - updateImageMatrix(); - - m_navigatorWindow->setImage(m_image); - - update(); -} - - -bool ImageView::isImageInside() -{ - return m_viewportRect.contains(m_worldMatrix.mapRect(m_imgViewRect)); -} - - -// displacement functions -------------------------------------------------------------------- - -// Move Left -void ImageView::moveLeft() -{ - float delta = 2*width()/(100.0*m_worldMatrix.m11()); - moveView(QPointF(delta,0)); -} - -// Move Right -void ImageView::moveRight() -{ - float delta = -2*width()/(100.0*m_worldMatrix.m11()); - moveView(QPointF(delta,0)); -} - -// Move Up -void ImageView::moveUp() -{ - float delta = 2*height()/(100.0*m_worldMatrix.m11()); - moveView(QPointF(0,delta)); -} - -// Move Down -void ImageView::moveDown() -{ - float delta = -2*height()/(100.0*m_worldMatrix.m11()); - moveView(QPointF(0,delta)); -} - -void ImageView::setShowOverview(bool val) -{ - m_showNavigator = val; - update(); -} - -void ImageView::zoomIn() -{ - zoom(1.1f); -} - -void ImageView::zoomOut() -{ - zoom(0.9f); -} - -void ImageView::zoom(float factor, const QPointF &c) -{ - if (m_image.isNull()) - return; - - QPointF center(c); - - //limit zoom out --- - if (m_worldMatrix.m11() == 1 && factor < 1) - return; - - if (m_worldMatrix.m11()*factor < 1) - { - resetView(); - return; - } - - //limit zoom in --- - if (m_worldMatrix.m11()*m_imgMatrix.m11() > 50 && factor > 1) - return; - - bool blackBorder = false; - - // if no center assigned: zoom in at the image center - if (center.x() == -1 || center.y() == -1) - { - center = QPointF((float)width()/2.0f, (float)height()/2.0f); - } - else - { - - // if black border - do not zoom to the mouse coordinate - if ((float)m_imgViewRect.width()*(m_worldMatrix.m11()*factor) < (float)width()) - { - center.setX((float)width()/2.0f); - blackBorder = true; - } - - if (((float)m_imgViewRect.height()*m_worldMatrix.m11()*factor) < (float)height()) - { - center.setY((float)height()/2.0f); - blackBorder = true; - } - } - - //inverse the transform - int a, b; - m_worldMatrix.inverted().map(center.x(), center.y(), &a, &b); - - m_worldMatrix.translate(a-factor*a, b-factor*b); - m_worldMatrix.scale(factor, factor); - - controlImagePosition(); - - if (blackBorder && factor < 1) - centerImage(); - - emit newZoomFactor(getZoom()); - - update(); -} - -void ImageView::resetView() -{ - m_worldMatrix.reset(); - update(); -} - -float ImageView::getZoom() -{ - return m_imgMatrix.m11()*m_worldMatrix.m11()*100.0f; -} - - -void ImageView::moveView(const QPointF &d) -{ - QPointF delta(d); - QRectF imgWorldRect = m_worldMatrix.mapRect(m_imgViewRect); - - if (imgWorldRect.width() < width()) - delta.setX(0); - - if (imgWorldRect.height() < height()) - delta.setY(0); - - m_worldMatrix.translate(delta.x(), delta.y()); - controlImagePosition(); - update(); -} - -void ImageView::controlImagePosition(float lb, float ub) -{ - QRectF imgRectWorld = m_worldMatrix.mapRect(m_imgViewRect); - - if (lb == -1) lb = m_viewportRect.width()/2; - - if (ub == -1) ub = m_viewportRect.height()/2; - - if (imgRectWorld.left() > lb && imgRectWorld.width() > width()) - m_worldMatrix.translate((lb-imgRectWorld.left())/m_worldMatrix.m11(), 0); - - if (imgRectWorld.top() > ub && imgRectWorld.height() > height()) - m_worldMatrix.translate(0, (ub-imgRectWorld.top())/m_worldMatrix.m11()); - - if (imgRectWorld.right() < lb && imgRectWorld.width() > width()) - m_worldMatrix.translate((lb-imgRectWorld.right())/m_worldMatrix.m11(), 0); - - if (imgRectWorld.bottom() < ub && imgRectWorld.height() > height()) - m_worldMatrix.translate(0, (ub-imgRectWorld.bottom())/m_worldMatrix.m11()); - -} - -void ImageView::centerImage() -{ - QRectF imgWorldRect = m_worldMatrix.mapRect(m_imgViewRect); - - // if black border - center the image - if (imgWorldRect.width() < (float)width()) - { - float dx = ((float)width()-imgWorldRect.width())*0.5f-m_imgViewRect.x()*m_worldMatrix.m11(); - dx = (dx-m_worldMatrix.dx())/m_worldMatrix.m11(); - m_worldMatrix.translate(dx, 0); - } - else if (imgWorldRect.left() > 0) - m_worldMatrix.translate(-imgWorldRect.left()/m_worldMatrix.m11(), 0); - else if (imgWorldRect.right() < width()) - m_worldMatrix.translate((width()-imgWorldRect.right())/m_worldMatrix.m11(), 0); - - if (imgWorldRect.height() < height()) - { - float dy = (height()-imgWorldRect.height())*0.5f-m_imgViewRect.y()*m_worldMatrix.m22(); - dy = (dy-m_worldMatrix.dy())/m_worldMatrix.m22(); - m_worldMatrix.translate(0, dy); - } - else if (imgWorldRect.top() > 0) - { - m_worldMatrix.translate(0, -imgWorldRect.top()/m_worldMatrix.m22()); - } - else if (imgWorldRect.bottom() < height()) - { - m_worldMatrix.translate(0, (height()-imgWorldRect.bottom())/m_worldMatrix.m22()); - } -} - -void ImageView::updateImageMatrix() -{ - if (m_image.isNull()) - return; - - QRectF oldImgRect = m_imgViewRect; - QTransform oldImgMatrix = m_imgMatrix; - - m_imgMatrix.reset(); - - // if the image is smaller or zoom is active: paint the image as is - if (!m_viewportRect.contains(m_imgRect)) - { - m_imgMatrix = getScaledImageMatrix(); - } - else - { - m_imgMatrix.translate((float)(width()-m_image.width())*0.5f, (float)(height()-m_image.height())*0.5f); - m_imgMatrix.scale(1.0f, 1.0f); - } - - m_imgViewRect = m_imgMatrix.mapRect(m_imgRect); - - // update world matrix - if (m_worldMatrix.m11() != 1) - { - - float scaleFactor = oldImgMatrix.m11()/m_imgMatrix.m11(); - double dx = oldImgRect.x()/scaleFactor-m_imgViewRect.x(); - double dy = oldImgRect.y()/scaleFactor-m_imgViewRect.y(); - - m_worldMatrix.scale(scaleFactor, scaleFactor); - m_worldMatrix.translate(dx, dy); - } -} - -QTransform ImageView::getScaledImageMatrix() -{ - - // the image resizes as we zoom - float ratioImg = m_imgRect.width()/m_imgRect.height(); - float ratioWin = (float)width()/(float)height(); - - QTransform imgMatrix; - float s; - - if (m_imgRect.width() == 0 || m_imgRect.height() == 0) - s = 1.0f; - else - s = (ratioImg > ratioWin) ? (float)width()/m_imgRect.width() : (float)height()/m_imgRect.height(); - - imgMatrix.scale(s, s); - - QRectF imgViewRect = imgMatrix.mapRect(m_imgRect); - imgMatrix.translate((width()-imgViewRect.width())*0.5f/s, (height()-imgViewRect.height())*0.5f/s); - - return imgMatrix; -} - -void ImageView::paintEvent(QPaintEvent* event) -{ - QPainter painter(viewport()); - - // draw background - painter.drawTiledPixmap(rect(), m_tileBg); - - if (!m_image.isNull()) - { - painter.setWorldTransform(m_worldMatrix); - - if (m_imgMatrix.m11()*m_worldMatrix.m11() <= (float)2.0f) - painter.setRenderHint(QPainter::SmoothPixmapTransform); - - draw(&painter); - - //Now disable matrixWorld for overlay display - painter.setWorldMatrixEnabled (false); - } - - //in mode zoom/panning - if (m_worldMatrix.m11() > 1 && !isImageInside() && m_showNavigator) - { - if (m_navigatorWindow->isVisible()) - { - // top right placement - m_navigatorWindow->move(width() - m_navigatorMargin - m_navigatorWindow->width() , m_navigatorMargin); - } - else - { - m_navigatorWindow->show(); - m_navigatorWindow->update(); - } - } - else - { - m_navigatorWindow->hide(); - } - - QGraphicsView::paintEvent(event); -} - -// drawing functions -------------------------------------------------------------------- - -void ImageView::draw(QPainter *painter) -{ - painter->setRenderHint(QPainter::SmoothPixmapTransform); //-> uncomment for smooth aliasing - painter->drawImage(m_imgViewRect, m_image, m_imgRect); -} - -// event -------------------------------------------------------------------- - -void ImageView::resizeEvent(QResizeEvent *event) -{ - m_viewportRect = QRect(0, 0, width(), height()); - - updateImageMatrix(); - centerImage(); - - emit newZoomFactor(getZoom()); - - m_navigatorWindow->resize(size()*m_navigatorSize); - m_navigatorWindow->setViewPortRect(geometry()); - - QGraphicsView::resizeEvent(event); -} - -// key events -------------------------------------------------------------------- - -void ImageView::keyPressEvent(QKeyEvent* event) -{ - if (event->key() == Qt::Key_Up) - { - moveUp(); - } - else if (event->key() == Qt::Key_Down) - { - moveDown(); - } - else if (event->key() == Qt::Key_Left) - { - moveLeft(); - } - else if (event->key() == Qt::Key_Right) - { - moveRight(); - } - else if (event->key() == Qt::Key_Plus) - { - zoomIn(); - } - else if (event->key() == Qt::Key_Minus) - { - zoomOut(); - } - QGraphicsView::keyPressEvent(event); -} - -// mouse events -------------------------------------------------------------------- - -void ImageView::mousePressEvent(QMouseEvent *event) -{ - m_enterPos = event->pos(); - setCursor(Qt::ClosedHandCursor); - - if (m_worldMatrix.m11() > 1 && !isImageInside() && event->buttons() == Qt::LeftButton) - m_lastPos = event->pos(); - - QWidget::mousePressEvent(event); -} - -void ImageView::mouseReleaseEvent(QMouseEvent *event) -{ - setCursor(Qt::ArrowCursor); - QWidget::mouseReleaseEvent(event); -} - -void ImageView::mouseMoveEvent(QMouseEvent *event) -{ - if (m_displayInfos) - getPixelInfo(event->pos()); - - if (m_worldMatrix.m11() > 1 && event->buttons() == Qt::LeftButton) - { - QPointF cPos = event->pos(); - QPointF dxy = (cPos - m_lastPos); - m_lastPos = cPos; - moveView(dxy/m_worldMatrix.m11()); - } - - QWidget::mouseMoveEvent(event); -} - -void ImageView::wheelEvent(QWheelEvent *event) -{ - float factor = event->delta(); - - factor /= -1200.0f; - factor += 1.0f; - - zoom( factor, event->pos()); -} - -void ImageView::getPixelInfo(const QPoint& pos) -{ - if (m_image.isNull()) - return; - - QPointF imgPos = m_worldMatrix.inverted().map(QPointF(pos)); - imgPos = m_imgMatrix.inverted().map(imgPos); - - QPoint xy = imgPos.toPoint(); - - if (xy.x() < 0 || xy.y() < 0 || xy.x() >= m_image.width() || xy.y() >= m_image.height()) - return; - - QColor col = m_image.pixel(xy); - - QString msg = QString(tr("x: %1 y: %2 | r: %3 g: %4 b: %5")).arg(QString::number(xy.x())).arg(QString::number(xy.y())).arg(QString::number(col.red())).arg(QString::number(col.green())).arg(QString::number(col.blue())); - - if (m_image.hasAlphaChannel()) - msg = msg + QString(tr(" a: %1")).arg(QString::number(col.alpha())); - - emit infos(msg); -} - -// file handling -------------------------------------------------------------------- - -void ImageView::load(const QString & file) -{ - m_image.load(file); - setImage(m_image); -} - -QImage& ImageView::getImage() -{ - return m_image; -} - -// ImageOverview -------------------------------------------------------------------- - -ImageNavigator::ImageNavigator(QWidget* parent, Qt::WindowFlags flags) : QWidget(parent, flags), -m_worldMatrix(NULL), -m_imgMatrix(NULL), -m_backgroundColor(QColor(0, 0, 0, 150)) -{ -} - -void ImageNavigator::paintEvent(QPaintEvent * /*event */) -{ - - if (m_img.isNull() || !m_imgMatrix || !m_worldMatrix) - return; - - QPainter painter(this); - - QRectF imgRect = QRectF(QPoint(), m_img.size()); - QRectF overviewRect = QRectF(QPoint(), QSize(geometry().width()-1, geometry().height()-1)); // get the overview rect - - QTransform overviewImgMatrix = getScaledImageMatrix(); // matrix that always resizes the image to the current viewport - QRectF overviewImgRect = overviewImgMatrix.mapRect(imgRect); - overviewImgRect.setTop(overviewImgRect.top()+1); - overviewImgRect.setLeft(overviewImgRect.left()+1); - overviewImgRect.setWidth(overviewImgRect.width()-1); // we have a border... correct that... - overviewImgRect.setHeight(overviewImgRect.height()-1); - - // now render the current view - QRectF viewRect = m_viewPortRect; - viewRect = m_worldMatrix->inverted().mapRect(viewRect); - viewRect = m_imgMatrix->inverted().mapRect(viewRect); - viewRect = overviewImgMatrix.mapRect(viewRect); - - //draw the image's location - painter.setBrush(m_backgroundColor); - painter.setPen(QColor(200, 200, 200)); - painter.drawRect(overviewRect); - painter.setOpacity(0.8f); - painter.drawImage(overviewImgRect, m_imgT, QRect(0, 0, m_imgT.width(), m_imgT.height())); - - painter.setPen(QColor(100, 0, 0)); - painter.setBrush(QColor(100, 0, 0, 50)); - painter.drawRect(viewRect); -} - -void ImageNavigator::mousePressEvent(QMouseEvent *event) -{ - m_enterPos = event->pos(); - m_lastPos = event->pos(); -} - -void ImageNavigator::mouseReleaseEvent(QMouseEvent *event) -{ - QPointF dxy = m_enterPos-QPointF(event->pos()); - - if (dxy.manhattanLength() < 4) - { - // move to the current position - // now render the current view - QRectF viewRect = m_viewPortRect; - viewRect = m_worldMatrix->inverted().mapRect(viewRect); - viewRect = m_imgMatrix->inverted().mapRect(viewRect); - viewRect = getScaledImageMatrix().mapRect(viewRect); - QPointF currentViewPoint = viewRect.center(); - - float panningSpeed = -(m_worldMatrix->m11()/(getScaledImageMatrix().m11()/m_imgMatrix->m11())); - - QPointF cPos = event->pos(); - QPointF dxy = (cPos - currentViewPoint)/m_worldMatrix->m11()*panningSpeed; - emit moveViewSignal(dxy); - } - -} - -void ImageNavigator::mouseMoveEvent(QMouseEvent *event) -{ - if (event->buttons() != Qt::LeftButton) - return; - - float panningSpeed = -(m_worldMatrix->m11()/(getScaledImageMatrix().m11()/m_imgMatrix->m11())); - - QPointF cPos = event->pos(); - QPointF dxy = (cPos - m_lastPos)/m_worldMatrix->m11()*panningSpeed; - m_lastPos = cPos; - emit moveViewSignal(dxy); -} - -void ImageNavigator::resizeEvent(QResizeEvent* event) -{ - if (event->size() == size()) - return; - - resizeImg(); - - QWidget::resizeEvent(event); -} - -void ImageNavigator::resize(int w, int h) -{ - resize(QSize(w, h)); -} - -void ImageNavigator::resize(const QSize& size) -{ - QWidget::resize(size); - - // update image - resizeImg(); -} - -void ImageNavigator::resizeImg() -{ - if (m_img.isNull()) - return; - - QRectF imgRect = QRectF(QPoint(), m_img.size()); - - QTransform overviewImgMatrix = getScaledImageMatrix(); // matrix that always resizes the image to the current viewport - QRectF overviewImgRect = overviewImgMatrix.mapRect(imgRect); - overviewImgRect.setTop(overviewImgRect.top()+1); - overviewImgRect.setLeft(overviewImgRect.left()+1); - overviewImgRect.setWidth(overviewImgRect.width()-1); // we have a border... correct that... - overviewImgRect.setHeight(overviewImgRect.height()-1); - - // fast downscaling - m_imgT = m_img.scaled(overviewImgRect.size().width(), overviewImgRect.size().height(), Qt::KeepAspectRatio, Qt::SmoothTransformation); -} - -QTransform ImageNavigator::getScaledImageMatrix() -{ - if (m_img.isNull()) - return QTransform(); - - // the image resizes as we zoom - QRectF imgRect = QRectF(QPoint(), m_img.size()); - float ratioImg = imgRect.width()/imgRect.height(); - float ratioWin = (float)width()/(float)height(); - - QTransform imgMatrix; - float s; - - if (imgRect.width() == 0 || imgRect.height() == 0) - s = 1.0f; - else - s = (ratioImg > ratioWin) ? (float)width()/imgRect.width() : (float)height()/imgRect.height(); - - imgMatrix.scale(s, s); - - QRectF imgViewRect = imgMatrix.mapRect(imgRect); - imgMatrix.translate((width()-imgViewRect.width())*0.5f/s, (height()-imgViewRect.height())*0.5f/s); - - return imgMatrix; -} - - diff -Nru syncwall-1.6.0/SyncWall/src/ImageView.h syncwall-1.7.4/SyncWall/src/ImageView.h --- syncwall-1.6.0/SyncWall/src/ImageView.h 2012-01-06 14:48:34.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/ImageView.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,180 +0,0 @@ - -/****************************************************************************** - SyncWall: Wallpaper manager - Copyright(C) 2011-2012 xbee@xbee.net - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *******************************************************************************/ - -#ifndef _IMAGEVIEW_H_ -#define _IMAGEVIEW_H_ - -#include -#include -#include -#include -#include - -class ImageNavigator; - -class ImageView : - public QGraphicsView -{ - Q_OBJECT - -public: - - ImageView(QWidget *parent = 0, Qt::WFlags flags = 0); - virtual ~ImageView(); - - void release(); - - void zoom( float factor = 0.5, const QPointF & center = QPointF(-1,-1) ); - float getZoom(); - - QImage& getImage(); - void setDisplayInfos(bool val) - { - m_displayInfos = val; - } - -public slots: - - void moveLeft(); - void moveRight(); - void moveUp(); - void moveDown(); - void zoomIn(); - void zoomOut(); - void resetView(); - - void resizeEvent(QResizeEvent* event); - void paintEvent(QPaintEvent* event); - - void setShowOverview(bool); - void moveView(const QPointF &); - - // file actions - void load(const QString & file); - - virtual void setImage(const QImage &newImg); - -signals: - - void infos(const QString &); - void newZoomFactor(float); - -protected: - - void keyPressEvent(QKeyEvent *event); - - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - - void wheelEvent(QWheelEvent *event); - -private: - - // functions - void initBackground(); - virtual void draw(QPainter *painter); - bool isImageInside(); - void updateImageMatrix(); - QTransform getScaledImageMatrix(); - void controlImagePosition(float lb = -1, float ub = -1); - void centerImage(); - - void getPixelInfo(const QPoint& pos); - - bool m_displayInfos; - QPixmap m_tileBg; - QImage m_image; - - QTransform m_imgMatrix; - QTransform m_worldMatrix; - QRectF m_imgViewRect; - QRectF m_viewportRect; - QRectF m_imgRect; - - ImageNavigator* m_navigatorWindow; - - QPointF m_lastPos; - QPointF m_enterPos; - - // overview rendering - float m_navigatorSize; - float m_navigatorMargin; - - bool m_showNavigator; -}; - -class ImageNavigator : - public QWidget -{ - Q_OBJECT - -public: - - ImageNavigator(QWidget * parent = 0, Qt::WindowFlags f = 0); - ~ImageNavigator() {} - - void resize(int w, int h); - void resize(const QSize& size); - - void setImage(QImage img) - { - m_img = img; - resizeImg(); - } - - void setTransforms(QTransform* worldMatrix, QTransform* imgMatrix) - { - m_worldMatrix = worldMatrix; - m_imgMatrix = imgMatrix; - } - - void setViewPortRect(QRectF viewPortRect) - { - m_viewPortRect = viewPortRect; - } - -signals: - - void moveViewSignal(const QPointF &dxy); - -protected: - - void resizeImg(); - void paintEvent(QPaintEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mousePressEvent(QMouseEvent *event); - void resizeEvent(QResizeEvent* event); - QTransform getScaledImageMatrix(); - -private: - - QImage m_img; - QImage m_imgT; - QTransform* m_worldMatrix; - QTransform* m_imgMatrix; - QRectF m_viewPortRect; - QPointF m_lastPos; - QPointF m_enterPos; - QColor m_backgroundColor; -}; - -#endif // _IMAGEVIEW_H_ diff -Nru syncwall-1.6.0/SyncWall/src/ImageViewer.cpp syncwall-1.7.4/SyncWall/src/ImageViewer.cpp --- syncwall-1.6.0/SyncWall/src/ImageViewer.cpp 2012-01-06 12:05:04.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/ImageViewer.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -/****************************************************************************** -SyncWall: Wallpaper manager -Copyright(C) 2011-2012 xbee@xbee.net - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*******************************************************************************/ - -#include -#include -#include -#include - -#include "ImageViewer.h" - -//----------------------------------------------------------------------------------------- -// Image Viewer - -ImageViewer::ImageViewer( const QString &fileName, QWidget *parent ): QWidget(parent) -{ - setupUi(this); - - // update default widget size to half screen size - QRect geom = QApplication::desktop()->screenGeometry( ); - resize( geom.width()/2, geom.height()/2 ); - - // connect view data to the widget display - connect(graphicsView,SIGNAL(infos(const QString &)),this,SLOT(updateInfos(const QString &))); - connect(graphicsView,SIGNAL(newZoomFactor(float)),this,SLOT(updateZoomFactor(float))); - - // load image - graphicsView->load(fileName); - graphicsView->setDisplayInfos(true); - - m_name = QFileInfo(fileName).baseName(); - m_name += QString(" - %1x%2").arg(graphicsView->getImage().size().width()).arg(graphicsView->getImage().size().height()); -} - -void ImageViewer::closeEvent ( QCloseEvent * /*event*/ ) -{ - deleteLater(); -} - -ImageViewer::~ImageViewer() -{ -} - -void ImageViewer::updateInfos(const QString &infos) -{ - labelInfos->setText(infos); -} - -void ImageViewer::updateZoomFactor(float val) -{ - setWindowTitle(m_name + " - " + QString::number((int)val) + "%"); -} - - diff -Nru syncwall-1.6.0/SyncWall/src/ImageViewer.h syncwall-1.7.4/SyncWall/src/ImageViewer.h --- syncwall-1.6.0/SyncWall/src/ImageViewer.h 2012-01-06 14:48:26.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/ImageViewer.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ - -/****************************************************************************** - SyncWall: Wallpaper manager - Copyright(C) 2011-2012 xbee@xbee.net - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *******************************************************************************/ - -#ifndef _IMAGEVIEWER_H_ -#define _IMAGEVIEWER_H_ - -#include -#include -#include -#include -#include -#include "ImageView.h" - -#include "ui_ImageViewer.h" - -class ImageNavigator; -class ImageView; - -class ImageViewer : - public QWidget, public Ui::ImageViewer -{ - Q_OBJECT - -public: - - ImageViewer(const QString &file, QWidget *parent = 0); - ~ImageViewer(); - -public slots: - - void updateInfos(const QString &); - void updateZoomFactor(float); - -protected: - - void closeEvent ( QCloseEvent * ); - -private: - - QString m_name; -}; - -#endif // _IMAGEVIEWER_H_ diff -Nru syncwall-1.6.0/SyncWall/src/InfosUpdater.cpp syncwall-1.7.4/SyncWall/src/InfosUpdater.cpp --- syncwall-1.6.0/SyncWall/src/InfosUpdater.cpp 2012-01-06 12:05:04.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/InfosUpdater.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,87 +0,0 @@ -/****************************************************************************** -SyncWall: Wallpaper manager -Copyright(C) 2011-2012 xbee@xbee.net - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*******************************************************************************/ - -#include - -#include "InfosUpdater.h" -#include "ImageInfos.h" - -InfosUpdater::InfosUpdater( QObject *parent ): QObject(parent), - m_abort( false ), - m_isRunning(false) -{ -} - -InfosUpdater::~InfosUpdater() -{ - cancel(); -} - - void InfosUpdater::check( ImageInfos *ii ) - { - m_iiQueue.append( ii ); - run(); - } - - void InfosUpdater::check( const QList &list ) -{ - m_iiQueue.append( list ); - run(); -} - -void InfosUpdater::cancel() -{ - m_mutex.lock(); - m_abort = true; - m_iiQueue.clear(); - m_mutex.unlock(); -} - -bool InfosUpdater::isRunning() -{ - return m_isRunning; -} - -void InfosUpdater::run() -{ - m_abort = false; - m_isRunning = true; - bool ok = true; - - while(ok) - { - m_mutex.lock(); - - if (m_iiQueue.isEmpty()) - { - ok = false; - } - else - { - ImageInfos *ii = m_iiQueue.dequeue(); - bool somethingDone = ii->update(); - - if (somethingDone) - emit updated(ii); - } - m_mutex.unlock(); - } - - m_isRunning = false; -} diff -Nru syncwall-1.6.0/SyncWall/src/InfosUpdater.h syncwall-1.7.4/SyncWall/src/InfosUpdater.h --- syncwall-1.6.0/SyncWall/src/InfosUpdater.h 2012-01-06 14:34:44.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/InfosUpdater.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ - -/****************************************************************************** - SyncWall: Wallpaper manager - Copyright(C) 2011-2012 xbee@xbee.net - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *******************************************************************************/ - -#ifndef _INFOSUPDATER_H_ -#define _INFOSUPDATER_H_ - -#include -#include -#include - -class ImageInfos; - -class InfosUpdater : - public QObject -{ - Q_OBJECT - -public: - - InfosUpdater( QObject *parent = 0 ); - ~InfosUpdater(); - - void cancel(); - bool isRunning(); - -public slots: - - void check( ImageInfos * ); - void check( const QList & ); - -signals: - - void updated(ImageInfos *); - void finished(); - -private: - - void run(); - - QMutex m_mutex; - bool m_abort; - bool m_isRunning; - QQueue m_iiQueue; -}; - -#endif // _INFOSUPDATER_H_ diff -Nru syncwall-1.6.0/SyncWall/src/ListImagesModel.cpp syncwall-1.7.4/SyncWall/src/ListImagesModel.cpp --- syncwall-1.6.0/SyncWall/src/ListImagesModel.cpp 2012-01-16 09:06:52.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/ListImagesModel.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,420 +0,0 @@ -/****************************************************************************** -SyncWall: Wallpaper manager -Copyright(C) 2011-2012 xbee@xbee.net - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*******************************************************************************/ - -#include -#include -#include - -#include "ListImagesModel.h" -#include "ImageInfos.h" -#include "InfosUpdater.h" - -const int shadowBorderSize = 3; -const int whiteBorderSize = 3; -const int shadowStrength = 127; - - -bool lessThanByRow( const QModelIndex &indexA, const QModelIndex &indexB) -{ - return(indexA.row() > indexB.row()); -} - -QPixmap ListImagesModel::generateFuzzyRect(const QSize& size, const QColor& color, int radius) const -{ - QPixmap pix(size); - const QColor transparent(0, 0, 0, 0); - pix.fill(transparent); - - QPainter painter(&pix); - painter.setRenderHint(QPainter::Antialiasing, true); - - // Fill middle - painter.fillRect(pix.rect().adjusted(radius, radius, -radius, -radius), color); - - // Corners - QRadialGradient gradient; - gradient.setColorAt(0, color); - gradient.setColorAt(1, transparent); - gradient.setRadius(radius); - QPoint center; - - // Top Left - center = QPoint(radius, radius); - gradient.setCenter(center); - gradient.setFocalPoint(center); - painter.fillRect(0, 0, radius, radius, gradient); - - // Top right - center = QPoint(size.width() - radius, radius); - gradient.setCenter(center); - gradient.setFocalPoint(center); - painter.fillRect(center.x(), 0, radius, radius, gradient); - - // Bottom left - center = QPoint(radius, size.height() - radius); - gradient.setCenter(center); - gradient.setFocalPoint(center); - painter.fillRect(0, center.y(), radius, radius, gradient); - - // Bottom right - center = QPoint(size.width() - radius, size.height() - radius); - gradient.setCenter(center); - gradient.setFocalPoint(center); - painter.fillRect(center.x(), center.y(), radius, radius, gradient); - - // Borders - QLinearGradient linearGradient; - linearGradient.setColorAt(0, color); - linearGradient.setColorAt(1, transparent); - - // Top - linearGradient.setStart(0, radius); - linearGradient.setFinalStop(0, 0); - painter.fillRect(radius, 0, size.width() - 2 * radius, radius, linearGradient); - - // Bottom - linearGradient.setStart(0, size.height() - radius); - linearGradient.setFinalStop( 0, size.height() ); - painter.fillRect(radius, int( linearGradient.start().y() ), size.width() - 2 * radius, radius, linearGradient); - - // Left - linearGradient.setStart(radius, 0); - linearGradient.setFinalStop(0, 0); - painter.fillRect(0, radius, radius, size.height() - 2 * radius, linearGradient); - - // Right - linearGradient.setStart(size.width() - radius, 0); - linearGradient.setFinalStop(size.width(), 0); - painter.fillRect(int( linearGradient.start().x() ), radius, radius, size.height() - 2 * radius, linearGradient); - return pix; -} - -void ListImagesModel::drawShadow(QPainter* painter, const QRect& rect) const -{ - const QPoint shadowOffset(-shadowBorderSize, -shadowBorderSize + 1); - - int key = rect.height() * 1000 + rect.width(); - - QMap::Iterator it = m_shadowCache.find(key); - if ( it == m_shadowCache.end() ) - { - QSize size = QSize(rect.width() + 2 * shadowBorderSize, rect.height() + 2 * shadowBorderSize); - QColor color(0, 0, 0, shadowStrength); - QPixmap shadow = generateFuzzyRect(size, color, shadowBorderSize); - it = m_shadowCache.insert(key, shadow); - } - painter->drawPixmap( rect.topLeft() + shadowOffset, it.value() ); -} - -QPixmap ListImagesModel::shadoizePixmap(const QImage &pm) const -{ - QPixmap icon = QPixmap( pm.width() + 2 * shadowBorderSize + 2 * whiteBorderSize,pm.height() + 2 * shadowBorderSize + 2 * whiteBorderSize); - - QPainter painter(&icon); - icon.fill( QColor(244,244,244) ); - - QRect thumbnailRect = QRect( - shadowBorderSize + whiteBorderSize, - shadowBorderSize + whiteBorderSize - 1, - pm.width() + whiteBorderSize, - pm.height() + whiteBorderSize); - - drawShadow(&painter, thumbnailRect); - - // fill the "photo border" - painter.fillRect(shadowBorderSize,shadowBorderSize,pm.width() + 2 * whiteBorderSize,pm.height() + 2 * whiteBorderSize,Qt::white); - - // fill the center pixmap - painter.drawPixmap( shadowBorderSize + whiteBorderSize,shadowBorderSize + whiteBorderSize,QPixmap::fromImage(pm) ); - - painter.end(); - - return icon; -} - -ListImagesModel::ListImagesModel(QObject *parent) - : QAbstractItemModel( parent ), - m_updater(NULL), - m_mode(MODE_LIST) -{ - // create updater infos - m_updater = new InfosUpdater(); - - // create a separate thread - m_thread = new QThread(); - - // move the updater to this thread - m_updater->moveToThread(m_thread); - - // start the thread - m_thread->start(); - - qRegisterMetaType >("QList"); - - connect( m_updater, SIGNAL( updated( ImageInfos * ) ), this, SLOT( refresh( ImageInfos *) ) ); - connect( this, SIGNAL( updateInfos(const QList &) ), m_updater, SLOT( check( const QList & ) ) ); -} - -ListImagesModel::~ListImagesModel() -{ - m_updater->cancel(); - m_thread->quit(); -} - -QVariant ListImagesModel::data( const QModelIndex &index, int role ) const -{ - if( !index.isValid() ) - return QVariant(); - - if (m_mode == MODE_LIST) - return dataList(index, role); - else if (m_mode == MODE_DETAILS) - return dataDetails(index, role); - else - return dataIcons(index, role); - - return QVariant(); -} - -QVariant ListImagesModel::dataList( const QModelIndex &index, int role ) const -{ - if( !index.isValid() ) - return QVariant(); - - if( role == Qt::DisplayRole ) - { - return m_filesList.at( index.row() )->getFilename(); - } - - return QVariant(); -} - -QVariant ListImagesModel::dataDetails( const QModelIndex &index, int role ) const -{ - if( !index.isValid() ) - return QVariant(); - - if( role == Qt::DisplayRole ) - { - if (index.column() == COLUMN_NAME) - return m_filesList.at( index.row() )->getFilename(); - else if (index.column() == COLUMN_IMAGESIZE) - return m_filesList.at( index.row() )->getImageSize(); - else if (index.column() == COLUMN_FILESIZE) - return m_filesList.at( index.row() )->getFileSize(); - } - - return QVariant(); -} - -QVariant ListImagesModel::dataIcons( const QModelIndex &index, int role ) const -{ - if( !index.isValid() ) - return QVariant(); - - if( role == Qt::DecorationRole ) - return shadoizePixmap( m_filesList.at( index.row() )->getThumbnail() ); - //return QPixmap::fromImage(m_filesList.at( index.row() )->getThumbnail()); - - if ( role == Qt::ToolTipRole) - return m_filesList.at( index.row() )->getFilename(); - - if( role == Qt::DisplayRole ) - return m_filesList.at( index.row() )->getLabel(); - - if( role == Qt::UserRole ) - return m_filesList.at( index.row() )->getImageSize(); - - return QVariant(); -} - -Qt::ItemFlags ListImagesModel::flags( const QModelIndex &index ) const -{ - if( index.isValid() ) - return ( Qt::ItemIsEnabled | Qt::ItemIsSelectable ); - - return Qt::ItemIsDropEnabled; -} - -int ListImagesModel::rowCount( const QModelIndex &parent ) const -{ - if( parent.isValid() ) - return 0; - - return m_filesList.size(); -} - -void ListImagesModel::setDisplayMode(int mode) -{ - if (mode == m_mode) - return; - - m_mode = mode; - if (m_mode != MODE_LIST) - { - - emit updateInfos(m_filesList); - } - - reset(); -} - -QModelIndex ListImagesModel::index(int row, int column, const QModelIndex &parent) const -{ - if ( !parent.isValid() ) // root item - { - if(row >= (int)m_filesList.size() || row < 0) - return QModelIndex(); - - return createIndex(row, column, m_filesList[row]); - } - - return QModelIndex(); -} - -QModelIndex ListImagesModel::parent ( const QModelIndex & /*index*/ ) const -{ - return QModelIndex(); -} - -int ListImagesModel::columnCount ( const QModelIndex & /*parent*/ ) const -{ - switch (m_mode) - { - case MODE_DETAILS: - return 3; - - break; - case MODE_ICONS: - return 1; - - break; - case MODE_LIST: - default: - return 1; - - break; - } -} - -void ListImagesModel::refresh (ImageInfos *ii) -{ - int index = m_filesList.indexOf(ii); - if (index >= 0) - { - QModelIndex mIndex = createIndex(index, 0, m_filesList[index]); - emit dataChanged( mIndex,mIndex.sibling(0,0) ); - } -} - -void ListImagesModel::addImages( const QStringList & list ) -{ - int row = m_filesList.size(); - - // check for double - QStringList valid; - foreach (const QString &file, list) - { - if (!m_alreadyDefined.contains(file)) - { - valid << file; - m_alreadyDefined << file; - } - } - - beginInsertRows( QModelIndex(), row, row+valid.size() ); - - QList iiList; - foreach( const QString &location, valid ) - iiList << new ImageInfos(location); - - if (m_mode != MODE_LIST) - emit updateInfos(iiList); - - m_filesList.append(iiList); - endInsertRows(); -} - -void ListImagesModel::removeRows(const QModelIndexList& indexes) -{ - // we must sort the index by order - QModelIndexList sorted(indexes); - qSort(sorted.begin(),sorted.end(),lessThanByRow); - - foreach(const QModelIndex &index, sorted) - removeRows(index.row(),1); -} - -bool ListImagesModel::removeRows( int row, int count, const QModelIndex &parent ) -{ - if( parent.isValid() ) - return false; - - if( row >= m_filesList.size() || row + count <= 0 ) - return false; - - int beginRow = qMax( 0, row ); - int endRow = qMin( row + count - 1, m_filesList.size() - 1 ); - - beginRemoveRows( parent, beginRow, endRow ); - - while( beginRow <= endRow ) - { - ImageInfos *ii = m_filesList.takeAt( beginRow ); - m_alreadyDefined.remove(ii->getFilename()); // update map - delete ii; - ++beginRow; - } - - endRemoveRows(); - return true; -} - -void ListImagesModel::clear() -{ - m_updater->cancel(); - while(m_updater->isRunning()); - qDeleteAll(m_filesList); - m_filesList.clear(); - reset(); -} - -int ListImagesModel::getIndex(const QModelIndex &index) const -{ - if (index.isValid()) - return index.row(); - - return -1; -} - -QString ListImagesModel::getFilename(int row) const -{ - if (row >= 0 && row < m_filesList.size()) - return m_filesList[row]->getFilename(); - - return QString(); -} - -QString ListImagesModel::getFilename(const QModelIndex &index) const -{ - if (index.isValid()) - return m_filesList[index.row()]->getFilename(); - - return QString(); -} diff -Nru syncwall-1.6.0/SyncWall/src/ListImagesModel.h syncwall-1.7.4/SyncWall/src/ListImagesModel.h --- syncwall-1.6.0/SyncWall/src/ListImagesModel.h 2012-01-16 09:06:30.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/ListImagesModel.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,112 +0,0 @@ - -/****************************************************************************** - SyncWall: Wallpaper manager - Copyright(C) 2011-2012 xbee@xbee.net - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *******************************************************************************/ - -#ifndef _LISTIMAGESMODEL_H_ -#define _LISTIMAGESMODEL_H_ - -#include -#include -#include -#include -#include -#include - -class ImageInfos; -class InfosUpdater; -class QThread; - -class ListImagesModel : - public QAbstractItemModel -{ - Q_OBJECT - -public: - - enum - { - MODE_LIST = 0, - MODE_DETAILS, - MODE_ICONS - } typMode; - - enum - { - COLUMN_NAME = 0, - COLUMN_IMAGESIZE, - COLUMN_FILESIZE - } typColumn; - - ListImagesModel( QObject *parent = 0 ); - virtual ~ListImagesModel(); - - QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const; - QModelIndex parent ( const QModelIndex & index ) const; - int columnCount ( const QModelIndex & parent = QModelIndex() ) const; - - QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const; - Qt::ItemFlags flags( const QModelIndex &index ) const; - - - bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() ); - - void removeRows( const QModelIndexList& indexes ); - - int rowCount( const QModelIndex &parent = QModelIndex() ) const; - int getImageCount() const { return m_filesList.size(); } - - void addImages( const QStringList & list ); - - QString getFilename(const QModelIndex &index) const; - QString getFilename(int) const; - int getIndex(const QModelIndex &index) const; - - void setDisplayMode(int); - int getDisplayMode() const { return m_mode; } - - void clear(); - -signals: - - void updateInfos(const QList &); - -private slots: - - void refresh (ImageInfos *); - -private: - - QVariant dataList( const QModelIndex &index, int role = Qt::DisplayRole ) const; - QVariant dataDetails( const QModelIndex &index, int role = Qt::DisplayRole ) const; - QVariant dataIcons( const QModelIndex &index, int role = Qt::DisplayRole ) const; - - QPixmap shadoizePixmap(const QImage &pm) const; - void drawShadow(QPainter* painter, const QRect& rect) const; - QPixmap generateFuzzyRect(const QSize& size, const QColor& color, int radius) const; - - QList m_filesList; - - InfosUpdater *m_updater; - QThread *m_thread; - int m_mode; - mutable QMap m_shadowCache; - QSet m_alreadyDefined; -}; - -#endif // _LISTIMAGESMODEL_H_ diff -Nru syncwall-1.6.0/SyncWall/src/LogHandler.cpp syncwall-1.7.4/SyncWall/src/LogHandler.cpp --- syncwall-1.6.0/SyncWall/src/LogHandler.cpp 2012-01-21 06:42:38.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/LogHandler.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,144 +0,0 @@ -/****************************************************************************** -SyncWall: Wallpaper manager -Copyright(C) 2011-2012 xbee@xbee.net - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*******************************************************************************/ - -#include "LogHandler.h" -#include - -LogHandler* LogHandler::m_Instance = 0; - -LogHandler *LogHandler::getInstance() -{ - static QMutex mutex; - - if (!m_Instance) - { - mutex.lock(); - - if (!m_Instance) - m_Instance = new LogHandler; - - mutex.unlock(); - } - - return m_Instance; -} - -LogHandler::~LogHandler() -{ - static QMutex mutex; - mutex.lock(); - m_Instance = 0; - mutex.unlock(); -} - - -LogHandler::LogHandler( ) : - m_currLevel(MSG_DEBUG), - m_bufferized(true) -{ - -} - -void LogHandler::reportMessage(MessageLevel level, const QString &message ) -{ - // message Ignored - if (level < m_currLevel) - return; - - QString msgText( message ); - msgText.replace( "<", "<" ); - msgText.replace( ">", ">" ); - // add the current time - msgText = QTime::currentTime().toString("[hh:mm:ss]: ") + msgText; - QString msg; - - switch (level) - { - case MSG_DEBUG: - { - msg = QString( "DEBUG: " ) + msgText ; - break; - } - - case MSG_INFO: - { - msg = QString( "INFO: " ) + msgText ; - break; - } - - case MSG_WARNING: - { - msg = QString( "WARNING: " ) + msgText ; - break; - } - - case MSG_ERROR: - { - msg = QString( " ERROR:" ) + msgText ; - break; - } - - default: - { - msg = msgText; - break; - } - } - - qDebug("%s",msg.toStdString().c_str()); - if (m_bufferized) - m_buffer << msg; - else - emit newMessage(msg); -} - -void LogHandler::reportDebug(const QString &message ) -{ - reportMessage(IMessageHandler::MSG_DEBUG,message); -} - -void LogHandler::reportInfo(const QString &message ) -{ - reportMessage(IMessageHandler::MSG_INFO,message); -} - -void LogHandler::reportWarning(const QString &message ) -{ - reportMessage(IMessageHandler::MSG_WARNING,message); -} - -void LogHandler::reportError(const QString &message ) -{ - reportMessage(IMessageHandler::MSG_ERROR,message); -} - - -void LogHandler::setBufferization(bool val) -{ - m_bufferized = val; - if (!m_bufferized) // send all stored messages - { - foreach (const QString &mess, m_buffer) - { - emit newMessage(mess); - } - m_buffer.clear(); - } -} - diff -Nru syncwall-1.6.0/SyncWall/src/LogHandler.h syncwall-1.7.4/SyncWall/src/LogHandler.h --- syncwall-1.6.0/SyncWall/src/LogHandler.h 2012-01-21 06:42:00.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/LogHandler.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ - -/****************************************************************************** - SyncWall: Wallpaper manager - Copyright(C) 2011-2012 xbee@xbee.net - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *******************************************************************************/ - -#ifndef _LOGHANDLER_H_ -#define _LOGHANDLER_H_ - -#include "IMessageHandler.h" - -#include -#include -#include - -//! A dialog for displaying message from reader/writer - -/*! - * Displaying colored message by taking care of the message level - */ - -class LogHandler : - public QObject, public IMessageHandler -{ - Q_OBJECT - -public: - - static LogHandler *getInstance(); - ~LogHandler(); - - void setMessageLevel(MessageLevel level) - { - m_currLevel = level; - } - - void setBufferization(bool); - -public slots: - - void reportMessage(MessageLevel level, const QString &message ); - void reportDebug(const QString &message ); - void reportInfo(const QString &message ); - void reportWarning(const QString &message ); - void reportError(const QString &message ); - -signals: - - void newMessage(const QString &); - -private: - - LogHandler( ); - - LogHandler(const LogHandler &); // hide copy constructor - LogHandler& operator=(const LogHandler &); // hide assign op - // we leave just the declarations, so the compiler will warn us - // if we try to use those two functions by accident - -private: - - static LogHandler* m_Instance; - MessageLevel m_currLevel; - QStringList m_buffer; - bool m_bufferized; -}; - -#endif // _LOGHANDLER_H_ diff -Nru syncwall-1.6.0/SyncWall/src/MiscFunctions.cpp syncwall-1.7.4/SyncWall/src/MiscFunctions.cpp --- syncwall-1.6.0/SyncWall/src/MiscFunctions.cpp 2012-03-19 13:12:12.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/MiscFunctions.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,297 +0,0 @@ -/****************************************************************************** -SyncWall: Wallpaper manager -Copyright(C) 2011-2012 xbee@xbee.net - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*******************************************************************************/ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "MiscFunctions.h" -#include "LogHandler.h" -#include "AppSettings.h" - -#if !defined(WIN32) -#include // for unlink -#endif - - -QString MiscFunctions::getValidStorage() -{ -#ifdef Q_WS_X11 // on unix => write to the user home - return QDir::homePath() + "/." + PACKAGE_NAME; -#else // other case - return QDesktopServices::storageLocation(QDesktopServices::DataLocation); -#endif -} - -void MiscFunctions::cleanTempStorage(const QStringList &filter, const QString &root) -{ - LogHandler::getInstance()->reportDebug(QObject::tr("Cleaning temp storage %1 ...").arg(getValidStorage())); - QDir dir(getValidStorage()); - QFileInfoList list = dir.entryInfoList(filter); - foreach (const QFileInfo &info, list) - { - if (root.isEmpty()) - { - unlink(info.absoluteFilePath().toStdString().c_str()); - } - else // restrict unlink to file containing the "root" value - { - if (info.absoluteFilePath().contains(root)) - { - unlink(info.absoluteFilePath().toStdString().c_str()); - LogHandler::getInstance()->reportDebug(QObject::tr("Deleting %1").arg(info.absoluteFilePath())); - } - } - } -} - -QStringList MiscFunctions::getAvailablesImageFormatsList() -{ - QList supportedFormats = QImageReader::supportedImageFormats(); - QStringList result; - QListIterator supportedFormat(supportedFormats); - QByteArray format; - - while (supportedFormat.hasNext()) - { - format = supportedFormat.next().toLower(); - - if (!result.contains(format)) - result << format; - } - - return result; -} - -/* - * Extract from Wally - Qt4 wallpaper/background changer - * Copyright (C) 2009 Antonio Di Monaco - */ - -QMap MiscFunctions::getLongImageFormats() -{ - QMap formats; - - formats["bw"] = "Black & White"; - formats["eps"] = "Encapsulated Postscript"; - formats["epsf"] = "Encapsulated PostScript"; - formats["epsi"] = "Encapsulated PostScript Interchange"; - formats["exr"] = "OpenEXR"; - formats["pcx"] = "PC Paintbrush Exchange"; - formats["psd"] = "Photoshop Document"; - formats["rgb"] = "Raw red, green, and blue samples"; - formats["rgba"] = "Raw red, green, blue, and alpha samples"; - formats["sgi"] = "Irix RGB"; - formats["tga"] = "Truevision Targa"; - formats["xcf"] = "eXperimental Computing Facility (GIMP)"; - formats["dds"] = "DirectDraw Surface"; - formats["xv"] = "Khoros Visualization"; - formats["bmp"] = "Windows Bitmap"; - formats["gif"] = "Graphic Interchange Format"; - formats["jpg"] = "Joint Photographic Experts Group"; - formats["jpeg"] = "Joint Photographic Experts Group"; - formats["jp2"] = "Joint Photographic Experts Group 2000"; - formats["mng"] = "Multiple-image Network Graphics"; - formats["png"] = "Portable Network Graphics"; - formats["pbm"] = "Portable Bitmap"; - formats["pgm"] = "Portable Graymap"; - formats["ppm"] = "Portable Pixmap"; - formats["tiff"] = "Tagged Image File Format"; - formats["tif"] = "Tagged Image File Format"; - formats["xbm"] = "X11 Bitmap"; - formats["xpm"] = "X11 Pixmap"; - formats["ico"] = "Icon Image"; - formats["svg"] = "Scalable Vector Graphics"; - - return formats; -} - - - -QString MiscFunctions::getAvailablesImageFormats() -{ - QString imglist; - QList formats = QImageReader::supportedImageFormats(); - for (int i = 0; i < formats.size(); ++i) - { - imglist += "*." + formats[i] + " "; - } - - return imglist; -} - -QString MiscFunctions::getTranslationsPath() -{ - // search in application path - QStringList ldir; - ldir << QCoreApplication::applicationDirPath () + "/lang"; - ldir << QCoreApplication::applicationDirPath () + "/../lang"; - ldir << QCoreApplication::applicationDirPath () + "/../../lang"; - ldir << "/usr/local/share/locale"; - - foreach (const QString &dir, ldir) - { - QDir gdp (dir); - if (QDir(dir).exists()) - return dir; - } - - return ""; -} - -QMap MiscFunctions::getAvailableLanguages() -{ - QMap languageMap; - QDir dir( MiscFunctions::getTranslationsPath() ); - QRegExp expr("^syncwall_(\\w+)\\.qm$"); - QStringList files = dir.entryList(QDir::Files, QDir::Name); - - LogHandler::getInstance()->reportDebug(QObject::tr("translations path %1").arg(dir.path())); - - foreach ( const QString &file, files ) - { - if ( !file.contains(expr) ) - continue; - - QString lang = expr.cap(1); - QString name = QString("%1 (%2)").arg(QLocale::languageToString(QLocale(lang).language()), lang); - - languageMap[name] = lang; - } - return languageMap; -} - -void MiscFunctions::setDefaultLanguage() -{ - QString lang; - AppSettings settings; - - settings.beginGroup("Application"); - lang = settings.value("currentLanguage","auto").toString(); - settings.endGroup(); - - if (lang.isEmpty()) - lang = QLocale::system().name().left(2); - - if ( !lang.isEmpty() ) - setLanguage(lang); -} - -void MiscFunctions::setLanguage(const QString& lang) -{ - QString language(lang); - LogHandler::getInstance()->reportDebug(QObject::tr("setting language to : %1").arg(language)); - - // special cases - if (language == "auto") // auto detection - { - language = QLocale::system().name().left(2); - } - else if (language == "default") // no use of translator - { - return; - } - - // try load the qt translator for selected language - QTranslator *qt = new QTranslator(); - if ( qt->load("qt_" + language, QLibraryInfo::location(QLibraryInfo::TranslationsPath)) ) - { - QCoreApplication::installTranslator(qt); - } - else - { - delete qt; - } - - QString suff = language + ".qm"; - QDir dir(MiscFunctions::getTranslationsPath()); - - foreach ( QString s, dir.entryList(QDir::Files | QDir::Readable) ) - { - if ( !s.endsWith(suff) ) - continue; - - QTranslator *t = new QTranslator(); - - if ( t->load(dir.filePath(s)) ) - { - QCoreApplication::installTranslator(t); - LogHandler::getInstance()->reportDebug(QObject::tr("successfully loaded data from %1").arg(dir.filePath(s))); - break; - } - else - { - delete t; - LogHandler::getInstance()->reportDebug(QObject::tr("failed to load data from %1").arg(dir.filePath(s))); - } - } -} - -QPixmap MiscFunctions::getScreenShot(int screenNb) -{ - QDesktopWidget *scr = QApplication::desktop(); - return QPixmap::grabWindow(scr->screen(screenNb)->winId()); -} - -QString MiscFunctions::getSignificantPart(const QString &file) -{ - // we send only the last dir and the basename of the file - QStringList list = file.split(QRegExp("/")); - - if (list.size() >= 2) - return list[list.size()- 2 ] + "/" + list[list.size()-1]; - - return list[list.size()-1]; -} - -QString MiscFunctions::launchExternalSynchronousProcess(const QString program, const QStringList &arguments) -{ - QProcess proc; - - /* Start process */ - proc.setReadChannelMode(QProcess::MergedChannels); - proc.start(program, arguments); - proc.waitForFinished(); - - /* Retrieve the output results and get the difference value */ - QString output = (QString(proc.readAllStandardOutput())).trimmed(); - proc.kill(); - proc.waitForFinished(); - return output; -} - -void MiscFunctions::updateApplicationIdentity() -{ - QCoreApplication::setApplicationName(PACKAGE_NAME); - QCoreApplication::setApplicationVersion(PACKAGE_VERSION); - QCoreApplication::setOrganizationName(PACKAGE_ORGANIZATION); -} - - diff -Nru syncwall-1.6.0/SyncWall/src/MiscFunctions.h syncwall-1.7.4/SyncWall/src/MiscFunctions.h --- syncwall-1.6.0/SyncWall/src/MiscFunctions.h 2012-01-24 02:46:32.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/MiscFunctions.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ - -/****************************************************************************** - SyncWall: Wallpaper manager - Copyright(C) 2011-2012 xbee@xbee.net - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *******************************************************************************/ - -#ifndef _MISCFUNCTIONS_H_ -#define _MISCFUNCTIONS_H_ - -#include -#include - -class MiscFunctions -{ -public: - - // give a valid directory for temporary files - static QString getValidStorage(); - // clean temporary files according to files - static void cleanTempStorage(const QStringList &filter, const QString &root = ""); - - // images function - static QString getAvailablesImageFormats(); - static QStringList getAvailablesImageFormatsList(); - static QMap getLongImageFormats(); - - // translations functions - static QString getTranslationsPath(); - static QMap getAvailableLanguages(); - static void setDefaultLanguage(); - static void setLanguage(const QString& lang); - static QPixmap getScreenShot(int screen = -1); - static QString getSignificantPart(const QString &file); - static QString launchExternalSynchronousProcess(const QString program, const QStringList &arguments); - - static void updateApplicationIdentity(); - -}; - -#endif // _MISCFUNCTIONS_H_ diff -Nru syncwall-1.6.0/SyncWall/src/NetworkManager.cpp syncwall-1.7.4/SyncWall/src/NetworkManager.cpp --- syncwall-1.6.0/SyncWall/src/NetworkManager.cpp 2012-02-08 23:44:08.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/NetworkManager.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,267 +0,0 @@ -/****************************************************************************** -SyncWall: Wallpaper manager -Copyright(C) 2011-2012 xbee@xbee.net - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*******************************************************************************/ - -#include -#include -#include - -#include "NetworkManager.h" -#include "LogHandler.h" -#include "AppSettings.h" - -const int defaultUdpPort = 55555; -const int defaultPingTimeout = 15 * 1000; - -NetworkManager::NetworkManager(QObject *parent) - : QObject(parent), - m_udpSocket(NULL), - m_timer(NULL), - m_pingTimer(NULL), - m_waitAnswer(NULL), - m_udpPort(0), - m_mode(0), - m_desc("no description"), - m_initialized(false) -{ - loadSettings(); - // can't initialize other member because current thread isn't final thread !!! -} - -NetworkManager::~NetworkManager() -{ - //saveSettings(); - //delete m_udpSocket; - - m_timer->stop(); - m_waitAnswer->stop(); -} - -void NetworkManager::initialize() -{ - if (m_initialized) - return; - - m_timer = new QTimer(this); - m_pingTimer = new QTimer(this); - m_waitAnswer = new QTimer(this); - - m_udpSocket = new QUdpSocket(); - - connect( m_udpSocket, SIGNAL( readyRead() ),this, SLOT( processPendingDatagrams() ) ); - connect( m_waitAnswer, SIGNAL( timeout() ), this, SIGNAL( serverDown() ), Qt::QueuedConnection ); - connect( m_pingTimer, SIGNAL( timeout() ), this, SLOT( pingServer() ) ); - - m_initialized = true; -} - -void NetworkManager::start() -{ - initialize(); - - updateConfig(); - if (m_mode != MODE_SERVER) - pingServer(); -} - -void NetworkManager::loadSettings() -{ - AppSettings settings; - - settings.beginGroup("NetworkManager"); - - m_udpPort = settings.value("udpPort",defaultUdpPort).toInt(); - m_serverName = settings.value("serverName","").toString(); - m_mode = settings.value("mode",MODE_SERVER).toInt(); - - settings.endGroup(); -} - -void NetworkManager::saveSettings() -{ - AppSettings settings; - - settings.beginGroup("NetworkManager"); - - settings.setValue("udpPort", m_udpPort); - settings.setValue("serverName", m_serverName); - settings.setValue("mode", m_mode); - - settings.endGroup(); -} - -void NetworkManager::setServerName(const QString &name) -{ - m_serverName = name; -} - -void NetworkManager::updateConfig() -{ - int port; - - // listen to different port switch network mode - if (m_mode == MODE_SERVER) - { - port = m_udpPort; - m_pingTimer->stop(); - LogHandler::getInstance()->reportDebug( QObject::tr("NetworkManager: Mode SERVER listen to %1 port").arg(port) ); - } - else - { - port = m_udpPort + 1; - - // start the "ping" server timer - m_pingTimer->start(defaultPingTimeout); - LogHandler::getInstance()->reportDebug( QObject::tr("NetworkManager: Mode CLIENT listen to %1 port").arg(port) ); - } - - m_udpSocket->disconnectFromHost(); - m_udpSocket->bind(port); -} - -void NetworkManager::setPort(int p) -{ - if (p == m_udpPort) - return; - - m_udpPort = p; - - updateConfig(); -} - -void NetworkManager::setMode(int mode) -{ - if (m_mode == mode) - return; - - m_mode = mode; - - // clear client list - if (m_mode == MODE_CLIENT) - m_clients.clear(); - - updateConfig(); -} - -void NetworkManager::broadcastDatagramSendServerIdentification(const QHostAddress &addr) -{ - int port; - - if (m_mode == MODE_SERVER) - port = m_udpPort + 1; - else - port = m_udpPort; - - LogHandler::getInstance()->reportDebug( QObject::tr("NetworkManager: Send Server Identification for \"%1\" on port %2").arg( addr.toString() ).arg(port) ); - - // prepare identification and description - QByteArray datagram = QString("Syncwall Server Answer desc=#%2#").arg(m_desc).toLatin1(); - m_udpSocket->writeDatagram(datagram.data(), datagram.size(),addr, port); -} - -void NetworkManager::processPendingDatagrams() -{ - while ( m_udpSocket->hasPendingDatagrams() ) - { - QByteArray datagram; - datagram.resize( m_udpSocket->pendingDatagramSize() ); - QHostAddress sender; - quint16 senderPort; - m_udpSocket->readDatagram(datagram.data(), datagram.size(),&sender, &senderPort); - - LogHandler::getInstance()->reportDebug( QObject::tr("NetworkManager: Received message on port %1").arg(senderPort) ); - - if ( datagram.startsWith("Syncwall Server Call") ) - { - LogHandler::getInstance()->reportDebug( QObject::tr("NetworkManager: Received Server call datagram: \"%1\"").arg( datagram.data() ) ); - broadcastDatagramSendServerIdentification(sender); - - if ( !m_clients.contains(sender) ) - { - LogHandler::getInstance()->reportDebug( QObject::tr("NetworkManager: Adding %1 to client list").arg( sender.toString() ) ); - m_clients << sender; - } - else - { - LogHandler::getInstance()->reportDebug( QObject::tr("NetworkManager: %1 is already in the client list").arg( sender.toString() ) ); - } - - // send the current background - broadcastDatagramSendBackground(sender); - } - else if ( datagram.startsWith("Syncwall Server Answer") ) - { - m_waitAnswer->stop(); - emit serverAlive(); - } - else if ( datagram.startsWith("Syncwall Change Background") ) - { - QList bg = datagram.split(' '); - LogHandler::getInstance()->reportDebug( QObject::tr("NetworkManager: Received background change: \"%1\"").arg( QString(bg[3]) ) ); - emit newMessage( QString(bg[3]) ); - } - } -} - -void NetworkManager::searchServer(const QString &hostname) -{ - QHostInfo info = QHostInfo::fromName(hostname); - if ( !info.addresses().isEmpty() ) - { - broadcastDatagramSearchServers(info.addresses()[0]); - m_waitAnswer->start(2000); - } - else - LogHandler::getInstance()->reportError( QObject::tr("NetworkManager: no address found for host %1 (%2)").arg(hostname).arg( info.errorString() ) ); -} - -void NetworkManager::broadcastDatagramSearchServers(const QHostAddress &addr) -{ - LogHandler::getInstance()->reportDebug( QObject::tr("NetworkManager: Send Server Call for \"%1\" on port %2").arg( addr.toString() ).arg(m_udpPort) ); - QByteArray datagram = "Syncwall Server Call"; - m_udpSocket->writeDatagram(datagram.data(), datagram.size(), addr, m_udpPort); -} - -void NetworkManager::broadcastDatagramSendBackground(const QHostAddress &addr) -{ - LogHandler::getInstance()->reportDebug( QObject::tr("NetworkManager: Send message to \"%1\" (%2) on port %3").arg( addr.toString() ).arg(m_currentMessage).arg(m_udpPort + 1) ); - QByteArray datagram = QString("Syncwall Change Background %1").arg(m_currentMessage).toLatin1(); - m_udpSocket->writeDatagram(datagram.data(), datagram.size(), addr, m_udpPort + 1); -} - -void NetworkManager::sendNewMessage(const QString &img) -{ - m_currentMessage = img; - - for (int i = 0; i < m_clients.size(); i++) - { - LogHandler::getInstance()->reportDebug( QObject::tr("NetworkManager:: Sending new message to client %1 ").arg( m_clients[i].toString() ) ); - broadcastDatagramSendBackground(m_clients[i]); - } -} - -QAbstractSocket::SocketState NetworkManager::getState() const -{ - return m_udpSocket->state(); -} - -void NetworkManager::pingServer() -{ - LogHandler::getInstance()->reportDebug( QObject::tr("NetworkManager:: Ping server %1").arg(m_serverName) ); - searchServer(m_serverName); -} diff -Nru syncwall-1.6.0/SyncWall/src/NetworkManager.h syncwall-1.7.4/SyncWall/src/NetworkManager.h --- syncwall-1.6.0/SyncWall/src/NetworkManager.h 2012-02-08 23:41:32.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/NetworkManager.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,97 +0,0 @@ - -/****************************************************************************** - SyncWall: Wallpaper manager - Copyright(C) 2011-2012 xbee@xbee.net - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *******************************************************************************/ - -#ifndef _NETWORKMANAGER_H_ -#define _NETWORKMANAGER_H_ - -#include -#include - -class QTimer; -class QUdpSocket; - -class NetworkManager : - public QObject -{ - Q_OBJECT - -public: - - enum NetworkMode - { - MODE_SERVER = 0, - MODE_CLIENT - }; - - NetworkManager(QObject *parent = 0); - virtual ~NetworkManager(); - - int getPort() const {return m_udpPort; } - int getMode() const {return m_mode; } - const QString & getServerName() const {return m_serverName; } - QAbstractSocket::SocketState getState() const; - int getClientNb() const {return m_clients.size(); } - -signals: - - void serverAlive(); - void serverDown(); - void newMessage(const QString&); - -public slots: - - void start(); - void setServerName(const QString &name); - void setPort(int port); - void setMode(int mode); - - void searchServer(const QString &hostname); - void sendNewMessage(const QString &); - void saveSettings(); - -private slots: - - void broadcastDatagramSearchServers(const QHostAddress &addr); - void broadcastDatagramSendServerIdentification(const QHostAddress &adr); - void broadcastDatagramSendBackground(const QHostAddress &addr); - void processPendingDatagrams(); - void pingServer(); - -private: - - void updateConfig(); - void loadSettings(); - void initialize(); - - - QUdpSocket *m_udpSocket; - QTimer *m_timer; - QTimer *m_pingTimer; - int m_udpPort; - QString m_serverName; - int m_mode; - QString m_desc; - QString m_currentMessage; - QTimer *m_waitAnswer; - QList m_clients; - bool m_initialized; -}; - -#endif // _NETWORKMANAGER_H_ diff -Nru syncwall-1.6.0/SyncWall/src/NetworkManagerConfigWidget.cpp syncwall-1.7.4/SyncWall/src/NetworkManagerConfigWidget.cpp --- syncwall-1.6.0/SyncWall/src/NetworkManagerConfigWidget.cpp 2012-01-29 15:11:58.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/NetworkManagerConfigWidget.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,182 +0,0 @@ -/****************************************************************************** -SyncWall: Wallpaper manager -Copyright(C) 2011-2012 xbee@xbee.net - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*******************************************************************************/ - -#include "NetworkManagerConfigWidget.h" -#include "NetworkManager.h" -#include "ThreadPool.h" - -NetworkManagerConfigWidget::NetworkManagerConfigWidget(QWidget *parent) - : QWidget(parent) -{ - setupUi(this); - - m_manager = new NetworkManager(); - - m_manager->moveToThread(ThreadPool::getInstance()->getThread()); - - // transmit NetworkManager signals - connect(m_manager, SIGNAL(serverAlive()), this, SIGNAL(newState())); - connect(m_manager, SIGNAL(serverAlive()), this, SLOT(serverConnected())); - connect(m_manager, SIGNAL(serverDown()), this, SIGNAL(newState())); - connect(m_manager, SIGNAL(serverDown()), this, SLOT(serverDisconnected())); - connect(m_manager, SIGNAL(newMessage(const QString&)), this, SIGNAL(newMessage(const QString&))); - - connect(this, SIGNAL(sigSearchServer(const QString&)), m_manager, SLOT(searchServer(const QString&))); - connect(this, SIGNAL(sigSetPort(int)), m_manager, SLOT(setPort(int))); - connect(this, SIGNAL(sigSetServerName(const QString&)), m_manager, SLOT(setServerName(const QString&))); - connect(this, SIGNAL(sigSetMode(int)), m_manager, SLOT(setMode(int))); - connect(this, SIGNAL(sigSendNewMessage(const QString&)), m_manager, SLOT(sendNewMessage(const QString&))); - connect(this, SIGNAL(sigSaveSetting()), m_manager, SLOT(saveSettings())); - connect(this, SIGNAL(sigStart()), m_manager, SLOT(start())); - - updateUI(); -} - -NetworkManagerConfigWidget::~NetworkManagerConfigWidget() -{ - delete m_manager; -} - -void NetworkManagerConfigWidget::updateUI() -{ - groupBoxServer->setChecked(m_manager->getMode() == NetworkManager::MODE_CLIENT); - lineEditServerName->setText(m_manager->getServerName()); - lineEditServerPort->setText(QString::number(m_manager->getPort())); -} - -void NetworkManagerConfigWidget::on_pushButtonTestConnection_pressed() -{ - QString serverName = lineEditServerName->text(); - int udpPort = lineEditServerPort->text().toInt(); - - if (serverName.isEmpty() || !udpPort) - return; - - emit sigSetPort(udpPort); - //m_manager->setPort(udpPort); - - // clear the previous text - labelTestConnection->setText(""); - emit sigSearchServer(serverName); - //m_manager->searchServer(serverName); -} - -void NetworkManagerConfigWidget::on_lineEditServerName_returnPressed() -{ - // change color to valid modification - QPalette pal; - pal.setColor(QPalette::Text, Qt::black); - lineEditServerName->setPalette(pal); - - emit sigSetServerName(lineEditServerName->text()); - //m_manager->setServerName(lineEditServerName->text()); -} - -void NetworkManagerConfigWidget::on_lineEditServerPort_returnPressed() -{ - // change color to valid modification - QPalette pal; - pal.setColor(QPalette::Text, Qt::black); - lineEditServerPort->setPalette(pal); - - emit sigSetPort(lineEditServerPort->text().toInt()); - //m_manager->setPort(lineEditServerPort->text().toInt()); -} - -void NetworkManagerConfigWidget::serverConnected() -{ - labelTestConnection->setText(tr("Server %1 reached ...").arg(m_manager->getServerName())); - emit synchronizeByNetwork(true); -} - -void NetworkManagerConfigWidget::serverDisconnected() -{ - labelTestConnection->setText(tr("Disconnection from server %1 ...").arg(m_manager->getServerName())); -} - -void NetworkManagerConfigWidget::on_groupBoxServer_clicked(bool val) -{ - bool synchroServer = val; - - // update the network manager - if (synchroServer) - { - //m_manager->setMode(NetworkManager::MODE_CLIENT); - emit sigSetMode(NetworkManager::MODE_CLIENT); - on_pushButtonTestConnection_pressed(); // check connection with server - } - else - { - //m_manager->setMode(NetworkManager::MODE_SERVER); - emit sigSetMode(NetworkManager::MODE_SERVER); - } - - emit synchronizeByNetwork(synchroServer); - emit newState(); -} - - -void NetworkManagerConfigWidget::on_lineEditServerName_textEdited(const QString & /*text*/) -{ - // change color to highlight modification - QPalette pal; - pal.setColor(QPalette::Text, Qt::red); - lineEditServerName->setPalette(pal); -} - -void NetworkManagerConfigWidget::on_lineEditServerPort_textEdited(const QString & /*text*/) -{ - // change color to highlight modification - QPalette pal; - pal.setColor(QPalette::Text, Qt::red); - lineEditServerPort->setPalette(pal); -} - -void NetworkManagerConfigWidget::sendNewMessage(const QString &mess) -{ - emit sigSendNewMessage(mess); - //m_manager->sendNewMessage(mess); -} - -void NetworkManagerConfigWidget::saveSettings() -{ - //emit sigSaveSetting(); - m_manager->saveSettings(); -} - -int NetworkManagerConfigWidget::getNetworkMode() const -{ - return m_manager->getMode(); -} -int NetworkManagerConfigWidget::getClientNb() const -{ - return m_manager->getClientNb(); -} -QAbstractSocket::SocketState NetworkManagerConfigWidget::getState() const -{ - return m_manager->getState(); -} - -void NetworkManagerConfigWidget::start() -{ - //m_manager->start(); - emit sigStart(); -} - - diff -Nru syncwall-1.6.0/SyncWall/src/NetworkManagerConfigWidget.h syncwall-1.7.4/SyncWall/src/NetworkManagerConfigWidget.h --- syncwall-1.6.0/SyncWall/src/NetworkManagerConfigWidget.h 2012-01-29 14:15:10.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/NetworkManagerConfigWidget.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ - -/****************************************************************************** - SyncWall: Wallpaper manager - Copyright(C) 2011-2012 xbee@xbee.net - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *******************************************************************************/ - -#ifndef _NETWORKMANAGERCONFIGWIDGET_H_ -#define _NETWORKMANAGERCONFIGWIDGET_H_ - -#include -#include - -#include "ui_NetworkManagerConfigWidget.h" - -class NetworkManager; - -class NetworkManagerConfigWidget : - public QWidget, public Ui::NetworkManagerConfigWidget -{ - Q_OBJECT - -public: - - NetworkManagerConfigWidget(QWidget *parent = 0); - ~NetworkManagerConfigWidget(); - - int getNetworkMode() const; - int getClientNb() const; - QAbstractSocket::SocketState getState() const; - - void start(); - -signals: - - void newState(); - void newMessage(const QString&); - void synchronizeByNetwork(bool); - - - void sigSearchServer(const QString &); - void sigSetPort(int); - void sigSetServerName(const QString &); - void sigSetMode(int); - void sigSendNewMessage(const QString &); - void sigSaveSetting(); - void sigStart(); - -public slots: - - void on_pushButtonTestConnection_pressed(); - void on_lineEditServerName_returnPressed(); - void on_lineEditServerName_textEdited(const QString &); - void on_lineEditServerPort_returnPressed(); - void on_lineEditServerPort_textEdited(const QString &); - void on_groupBoxServer_clicked(bool); - - void serverDisconnected(); - void serverConnected(); - - void sendNewMessage(const QString &mess); - - void saveSettings(); - -private: - - void updateUI(); - - NetworkManager *m_manager; -}; - -#endif // _NETWORKMANAGERCONFIGWIDGET_H_ diff -Nru syncwall-1.6.0/SyncWall/src/Scheduler.cpp syncwall-1.7.4/SyncWall/src/Scheduler.cpp --- syncwall-1.6.0/SyncWall/src/Scheduler.cpp 2012-05-13 22:27:54.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/Scheduler.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,224 +0,0 @@ -/****************************************************************************** -SyncWall: Wallpaper manager -Copyright(C) 2011-2012 xbee@xbee.net - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*******************************************************************************/ - -#include - -#include "Scheduler.h" -#include "AppSettings.h" - -#include "LogHandler.h" - -const int minInterval = 30; // 30 sec - -Scheduler::Scheduler(QObject *parent) - : QObject(parent), - m_changeAtStartup(false), - m_quitAfterChange(false), - m_intervalBetweenChangeMode(false), - m_changeByInterval(true), - m_changeInterval(QTime(0,30)), // 30 min by default - m_idle(true) -{ - loadSettings(); - - m_eventTimer.setSingleShot(true); - connect(&m_eventTimer, SIGNAL(timeout()), this, SLOT(newSchedule())); -} - -Scheduler::~Scheduler() -{ - //saveSettings(); -} - -void Scheduler::start() -{ - m_idle = false; - checkInitState(); -} - -void Scheduler::checkInitState() -{ - if (m_changeAtStartup && !m_idle) - { - QTimer::singleShot(1000, this, SLOT(newSchedule())); - LogHandler::getInstance()->reportDebug("Change at Startup ..."); - - if (m_quitAfterChange) - { - LogHandler::getInstance()->reportDebug("Auto Quit application is 30 sec ..."); - QTimer::singleShot(30000, this, SIGNAL(quit())); - } - } - - setupNextInterval(); -} - -void Scheduler::setupNextInterval() -{ - if (!m_intervalBetweenChangeMode || m_idle) - return; - - m_referenceTime = QDateTime::currentDateTime(); - - if (m_changeByInterval) // stable interval between each event - { - int count = -m_changeInterval.secsTo(QTime(0,0,0)); - if (count < minInterval) - { - LogHandler::getInstance()->reportDebug(tr("update interval is to low (%1) => force to %2 sec ...").arg(count).arg(minInterval)); - count = minInterval; - } - m_eventTimer.start(count*1000); - LogHandler::getInstance()->reportDebug(tr("Start new timer for %1 sec ...").arg(count)); - } - else // variable interval (list of Time Of Day) - { - // search for next valid time - QTime currentTime = QTime::currentTime(); - foreach (const QTime &time, m_listTimeOfDay) - { - if (time > currentTime) - { - int count = currentTime.secsTo(time); - m_eventTimer.start(count*1000); - LogHandler::getInstance()->reportDebug(tr("Start new timer for %1 sec ...").arg(count)); - break; - } - } - } -} - -void Scheduler::newSchedule() -{ - if (m_idle) - return; - - LogHandler::getInstance()->reportDebug(tr("New Schedule fired ...")); - emit newEvent(); - setupNextInterval(); -} - -void Scheduler::restartScheduler() -{ - setupNextInterval(); -} - -void Scheduler::loadSettings() -{ - AppSettings settings; - - settings.beginGroup("Scheduler"); - - m_changeAtStartup = settings.value("changeAtStartup",false).toBool(); - m_quitAfterChange = settings.value("quitAfterChange",false).toBool(); - m_intervalBetweenChangeMode = settings.value("intervalBetweenChangeMode",false).toBool(); - - m_changeByInterval = settings.value("changeByInterval",true).toBool(); - - m_changeInterval = settings.value("changeInterval","").toTime(); - - int size = settings.beginReadArray("listTimeOfDay"); - for (int i = 0; i < size; ++i) - { - settings.setArrayIndex(i); - m_listTimeOfDay << settings.value("tod").toTime(); - } - settings.endArray(); - - settings.endGroup(); -} - -void Scheduler::saveSettings() -{ - AppSettings settings; - - settings.beginGroup("Scheduler"); - - settings.setValue("changeAtStartup", m_changeAtStartup); - settings.setValue("quitAfterChange", m_quitAfterChange); - settings.setValue("intervalBetweenChangeMode", m_intervalBetweenChangeMode); - - settings.setValue("changeByInterval", m_changeByInterval); - - settings.setValue("changeInterval", m_changeInterval); - - settings.beginWriteArray("listTimeOfDay", m_listTimeOfDay.count()); - for (int i = 0; i < m_listTimeOfDay.size(); ++i) - { - settings.setArrayIndex(i); - settings.setValue("tod", m_listTimeOfDay.at(i)); - } - settings.endArray(); - - settings.endGroup(); -} - -void Scheduler::setChangeByInterval(bool val) -{ - m_changeByInterval = val; - setupNextInterval(); -} - -void Scheduler::setChangeAtStartup(bool val) -{ - m_changeAtStartup = val; -} - -void Scheduler::setQuitAfterChange(bool val) -{ - m_quitAfterChange = val; -} - -void Scheduler::setIntervalBetweenChangeMode(bool val) -{ - m_intervalBetweenChangeMode = val; - setupNextInterval(); -} - -void Scheduler::setInterval(const QTime &time) -{ - m_changeInterval = time; - setupNextInterval(); -} - -bool Scheduler::addTOD(const QTime &tod) -{ - if (m_listTimeOfDay.indexOf(tod) != -1) - return false; - - m_listTimeOfDay << tod; - qSort(m_listTimeOfDay); - setupNextInterval(); - return true; -} - -bool Scheduler::deleteTOD(const QTime &tod) -{ - bool ok = m_listTimeOfDay.removeOne(tod); - if (ok) - setupNextInterval(); - return ok; -} - -void Scheduler::setIdle(bool val) -{ - m_idle = val; - if (!m_idle) - setupNextInterval(); -} diff -Nru syncwall-1.6.0/SyncWall/src/Scheduler.h syncwall-1.7.4/SyncWall/src/Scheduler.h --- syncwall-1.6.0/SyncWall/src/Scheduler.h 2012-05-13 22:27:54.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/Scheduler.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ - -/****************************************************************************** - SyncWall: Wallpaper manager - Copyright(C) 2011-2012 xbee@xbee.net - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *******************************************************************************/ - -#ifndef _SCHEDULER_H_ -#define _SCHEDULER_H_ - -#include -#include -#include -#include - -class Scheduler : - public QObject -{ - Q_OBJECT - -public: - - Scheduler(QObject *parent = NULL); - virtual ~Scheduler(); - - void start(); - - void setIdle(bool); - bool isIdle() const {return m_idle; } - - // settings Accessors - void setChangeAtStartup(bool val); - bool getChangeAtStartup() const {return m_changeAtStartup; } - - void setQuitAfterChange(bool val); - bool getQuitAfterChange() const {return m_quitAfterChange; } - - void setIntervalBetweenChangeMode(bool val); - bool getIntervalBetweenChangeMode() const {return m_intervalBetweenChangeMode; } - - void setInterval(const QTime &); - const QTime &getInterval() const {return m_changeInterval; } - - void setChangeByInterval(bool); - bool getChangeByInterval() const { return m_changeByInterval; } - - bool addTOD(const QTime &); - bool deleteTOD(const QTime &); - const QList & getTODList() const { return m_listTimeOfDay; } - - void restartScheduler(); - -public slots: - - void newSchedule(); - void checkInitState(); - void saveSettings(); - -signals: - - void newEvent(); - void quit(); - -private: - - void loadSettings(); - - - void setupNextInterval(); - - // preferences - - bool m_changeAtStartup; - bool m_quitAfterChange; - bool m_intervalBetweenChangeMode; - - bool m_changeByInterval; - - QTime m_changeInterval; - QList m_listTimeOfDay; - QTimer m_eventTimer; - QDateTime m_referenceTime; - bool m_idle; -}; - -#endif // _SCHEDULER_H_ diff -Nru syncwall-1.6.0/SyncWall/src/SchedulerConfigWidget.cpp syncwall-1.7.4/SyncWall/src/SchedulerConfigWidget.cpp --- syncwall-1.6.0/SyncWall/src/SchedulerConfigWidget.cpp 2012-01-29 11:27:54.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/SchedulerConfigWidget.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,122 +0,0 @@ -/****************************************************************************** -SyncWall: Wallpaper manager -Copyright(C) 2011-2012 xbee@xbee.net - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*******************************************************************************/ - -#include "SchedulerConfigWidget.h" - -SchedulerConfigWidget::SchedulerConfigWidget(QWidget *parent) -: QWidget(parent) -{ - setupUi(this); - - // transmit scheduler signals - connect(&m_scheduler, SIGNAL(newEvent()), this, SIGNAL(newEvent())); - connect(&m_scheduler, SIGNAL(quit()), this, SIGNAL(quit())); - - updateUI(); -} - -SchedulerConfigWidget::~SchedulerConfigWidget() -{ -} - -void SchedulerConfigWidget::updateUI() -{ - checkBoxStartup->setChecked(m_scheduler.getChangeAtStartup()); - checkBoxStartupAndQuit->setChecked(m_scheduler.getQuitAfterChange()); - groupBoxFrequency->setChecked(m_scheduler.getIntervalBetweenChangeMode()); - radioButtonInterval->setChecked(m_scheduler.getChangeByInterval()); - radioButtonTimeOfDay->setChecked(!m_scheduler.getChangeByInterval()); - timeEditInterval->setTime(m_scheduler.getInterval()); - rebuildTODList(); -} - -void SchedulerConfigWidget::on_checkBoxStartup_stateChanged ( int state ) -{ - m_scheduler.setChangeAtStartup(state); -} - -void SchedulerConfigWidget::on_checkBoxStartupAndQuit_stateChanged ( int state ) -{ - m_scheduler.setQuitAfterChange(state); -} - -void SchedulerConfigWidget::on_groupBoxFrequency_clicked(bool val) -{ - m_scheduler.setIntervalBetweenChangeMode(val); - emit newState(); -} - -void SchedulerConfigWidget::on_radioButtonInterval_toggled(bool val) -{ - m_scheduler.setChangeByInterval(val); -} - -void SchedulerConfigWidget::on_radioButtonTimeOfDay_toggled(bool /*val*/) -{ - -} - - -void SchedulerConfigWidget::on_timeEditInterval_timeChanged(const QTime & time) -{ - m_scheduler.setInterval(time); -} - -void SchedulerConfigWidget::on_pushButtonAddTOD_pressed() -{ - if (m_scheduler.addTOD(timeEditTOD->time())) - rebuildTODList(); -} - -void SchedulerConfigWidget::on_pushButtonDeleteTOD_pressed() -{ - QList items = listWidgetTOD->selectedItems (); - - if (items.isEmpty()) - return; - - foreach (QListWidgetItem *item, items) - { - m_scheduler.deleteTOD(QTime::fromString(item->text(), "hh:mm:ss")); - } - - rebuildTODList(); -} - -void SchedulerConfigWidget::rebuildTODList() -{ - listWidgetTOD->clear(); - const QList &list = m_scheduler.getTODList(); - foreach(const QTime &time, list) - { - new QListWidgetItem(time.toString(), listWidgetTOD); - } -} - -void SchedulerConfigWidget::setIdle(bool val) -{ - groupBoxProperties->setEnabled(val == false); - m_scheduler.setIdle(val); -} - - -void SchedulerConfigWidget::saveSettings() -{ - m_scheduler.saveSettings(); -} diff -Nru syncwall-1.6.0/SyncWall/src/SchedulerConfigWidget.h syncwall-1.7.4/SyncWall/src/SchedulerConfigWidget.h --- syncwall-1.6.0/SyncWall/src/SchedulerConfigWidget.h 2012-05-13 22:29:46.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/SchedulerConfigWidget.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ - -/****************************************************************************** - SyncWall: Wallpaper manager - Copyright(C) 2011-2012 xbee@xbee.net - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *******************************************************************************/ - -#ifndef _SCHEDULERCONFIGWIDGET_H_ -#define _SCHEDULERCONFIGWIDGET_H_ - -#include -#include "ui_SchedulerConfigWidget.h" - -#include "Scheduler.h" - -class SchedulerConfigWidget : - public QWidget, public Ui::SchedulerConfigWidget -{ - Q_OBJECT - -public: - - SchedulerConfigWidget(QWidget *parent = 0); - ~SchedulerConfigWidget(); - - void start() {m_scheduler.start(); } - - bool getIntervalBetweenChangeMode() const {return m_scheduler.getIntervalBetweenChangeMode(); } - - void restartScheduler() {m_scheduler.restartScheduler();} - -public slots: - - void on_checkBoxStartup_stateChanged ( int ); - void on_checkBoxStartupAndQuit_stateChanged ( int ); - void on_groupBoxFrequency_clicked(bool); - void on_radioButtonInterval_toggled(bool); - void on_radioButtonTimeOfDay_toggled(bool); - - void on_timeEditInterval_timeChanged(const QTime & time); - - void on_pushButtonAddTOD_pressed(); - void on_pushButtonDeleteTOD_pressed(); - - void setIdle(bool); - - void saveSettings(); - -signals: - - void newState(); - void newEvent(); - void quit(); - -private: - - void rebuildTODList(); - void updateUI(); - - Scheduler m_scheduler; -}; - -#endif // _SCHEDULERCONFIGWIDGET_H_ diff -Nru syncwall-1.6.0/SyncWall/src/ScreenItem.cpp syncwall-1.7.4/SyncWall/src/ScreenItem.cpp --- syncwall-1.6.0/SyncWall/src/ScreenItem.cpp 2012-04-26 14:01:26.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/ScreenItem.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,344 +0,0 @@ -/****************************************************************************** -SyncWall: Wallpaper manager -Copyright(C) 2011-2012 xbee@xbee.net - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*******************************************************************************/ - -#include "ScreenItem.h" -#include -#include - -const int decoMargin = 2; // default pen width + supplementary contour if selected (so 1 + 1) -const int penWidth = 1; -const int cornerSize = 2; -const int fontFactor = 15; - -ScreenItem::ScreenItem ( const QSize &size, int num, QGraphicsItem * parent ): QGraphicsItem(parent), - m_realSize(size), - m_size(size), - m_screenNum(num), - m_marginLeft(70), - m_marginRight(70), - m_marginTop(0), - m_marginBottom(0), - m_useMargins(true), - m_drawText(true) -{ - setFlag(QGraphicsItem::ItemIsMovable, true); - setFlag(QGraphicsItem::ItemIsSelectable, true); - setFlag(QGraphicsItem::ItemIsFocusable, true); -} - -void ScreenItem::setSize(const QSize &size) -{ - m_realSize = size; - m_size = size; -} - -void ScreenItem::setNumber(int num) -{ - m_screenNum = num; -} - -QSize ScreenItem::getRealSizeWithMargins() const -{ - QSize size(m_realSize); - if (m_useMargins) - { - size.rwidth() += (m_marginLeft + m_marginRight); - size.rheight() += (m_marginTop + m_marginBottom); - } - return size; -} - -QSize ScreenItem::getSizeWithMargins() const -{ - QSize size(m_size); - if (m_useMargins) - { - size.rwidth() += (m_marginLeft + m_marginRight); - size.rheight() += (m_marginTop + m_marginBottom); - } - return size; -} - -QRectF ScreenItem::boundingRect() const -{ - QRectF res; - if (m_useMargins) - res = QRectF( - -(m_size.width() + m_marginLeft + m_marginRight ) / 2 - decoMargin, - -(m_size.height() + m_marginTop + m_marginBottom) / 2 - decoMargin, - m_size.width() + m_marginLeft + m_marginRight + 2*decoMargin, - m_size.height() + m_marginTop + m_marginBottom + 2*decoMargin - ); - else - res = QRectF( - -(m_size.width() ) / 2 - decoMargin, - -(m_size.height()) / 2 - decoMargin, - m_size.width() + 2*decoMargin, - m_size.height() + 2*decoMargin - ); - - return res; -} - -QRectF ScreenItem::getPreviewSceneWithMarginsBoundingRect() -{ - QRectF sceneRect = sceneBoundingRect(); - QRectF res; - if (m_useMargins) - res = QRectF ( - (sceneRect.x() + (m_marginLeft + m_marginRight)/2 + decoMargin)/10.0f, - (sceneRect.y() + (m_marginTop + m_marginBottom)/2 + decoMargin)/10.0f, - m_size.width()/10.0f, - m_size.height()/10.0f - ); - else - res = QRectF ( - (sceneRect.x() / 2 + decoMargin)/10.0f, - (sceneRect.y() / 2 + decoMargin)/10.0f, - m_size.width()/10.0f, - m_size.height()/10.0f - ); - return res; -} -QRectF ScreenItem::getPreviewSceneBoundingRect() -{ - QRectF sceneRect = sceneBoundingRect(); - return QRectF ( - (sceneRect.x() + decoMargin)/10.0f, - (sceneRect.y() + decoMargin)/10.0f, - m_size.width()/10.0f, - m_size.height()/10.0f - ); -} - -QRectF ScreenItem::getValidSceneBoundingRect() -{ - QRectF sceneRect = sceneBoundingRect(); - QRectF res; - - if (m_useMargins) - res = QRectF ( - sceneRect.x() + (m_marginLeft + m_marginRight)/2 + decoMargin, - sceneRect.y() + (m_marginTop + m_marginBottom)/2 + decoMargin, - m_size.width(), - m_size.height() - ); - else - res = QRectF ( - sceneRect.x() /2 + decoMargin, - sceneRect.y() /2 + decoMargin, - m_size.width(), - m_size.height() - ); - return res; -} - -void ScreenItem::setImage(const QImage &image) -{ - m_image = image; - m_cropimage = m_image.copy(getPreviewSceneWithMarginsBoundingRect().toRect()); - update(); -} - -void ScreenItem::updateImage() -{ - m_cropimage = m_image.copy(getPreviewSceneWithMarginsBoundingRect().toRect()); - update(); -} - -void ScreenItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget * /* widget */) -{ - QFont font; - font.setPixelSize(10*fontFactor); - painter->setFont(font); - - QPen pen(Qt::black); - pen.setWidth(1); - pen.setCosmetic(true); - - //draw out box - pen.setBrush(Qt::black); - painter->setPen(pen); - - QRectF itemRect = boundingRect().translated(decoMargin-penWidth,decoMargin-penWidth); - - painter->drawRoundedRect(itemRect,cornerSize,cornerSize); - - // draw borders - if (m_useMargins) - drawMargins(painter); - - // draw image - drawDesktop(painter); - - // draw screen number - if (m_drawText) - drawTextEffect(painter, QString::number(m_screenNum),itemRect.translated(9*fontFactor,9*fontFactor), Qt::AlignLeft, QPoint(fontFactor, fontFactor) ); - - // display resolution - if (m_drawText) - { - font.setPixelSize(5*fontFactor); - painter->setFont(font); - QString res = QString("%1x%2").arg(m_realSize.width()).arg(m_realSize.height()); - drawTextEffect(painter, res,itemRect.translated(9*fontFactor,itemRect.height()-20*fontFactor), Qt::AlignLeft, QPoint(fontFactor/2, fontFactor/2) ); - } - - // draw highlight if needed - if (option->state & QStyle::State_Selected) - { - pen.setBrush(Qt::red); - painter->setPen(pen); - painter->drawRoundedRect(itemRect, cornerSize, cornerSize); - } -} - -void ScreenItem::drawTextEffect(QPainter *painter, const QString &text, const QRectF & rect, int alignment, const QPoint &offset) -{ - // Draw shadow. - painter->setPen(QPen(Qt::gray)); - painter->drawText(rect.translated(offset), alignment, text); - // Draw text. - painter->setPen(QPen(Qt::black)); - painter->drawText(rect, alignment, text); -} - -void ScreenItem::drawDesktop(QPainter *painter) -{ - if (m_image.isNull()) - { - painter->fillRect ( - -m_size.width()/2, - -m_size.height()/2, - m_size.width(), - m_size.height(), - Qt::white ); - } - else - { - QRectF target( - -m_size.width()/2, - -m_size.height()/2, - m_size.width(), - m_size.height() - ); - painter->drawImage(target,m_cropimage,m_cropimage.rect()); - - // add a reflextion effect just for fun !! - QImage reflection(":/syncwall/reflection.png"); - painter->drawImage(target, reflection, reflection.rect()); - } -} - -void ScreenItem::drawMargins(QPainter *painter) -{ - int x0 = -(m_size.width() + m_marginLeft + m_marginRight)/2 ; - int y0 = -(m_size.height() + m_marginTop + m_marginBottom)/2 ; - - if (m_marginTop) - { - painter->fillRect ( - x0 , - y0 , - m_size.width()+m_marginLeft + m_marginRight, - m_marginTop, - Qt::black ); - } - - if (m_marginBottom) - { - painter->fillRect ( - x0 , - y0 + m_marginTop + m_size.height(), - m_size.width()+m_marginLeft + m_marginRight, - m_marginBottom, - Qt::black ); - } - - if (m_marginRight) - { - painter->fillRect ( - x0 + m_marginLeft + m_size.width(), - y0, - m_marginRight, - m_size.height()+m_marginTop+m_marginBottom, - Qt::black ); - } - - if (m_marginLeft) - { - painter->fillRect ( - x0, - y0, - m_marginLeft, - m_size.height()+m_marginTop+m_marginBottom, - Qt::black ); - } -} - -void ScreenItem::setMargings(int top, int bottom, int left, int right) -{ - prepareGeometryChange(); - m_marginTop = top; - m_marginBottom = bottom; - m_marginLeft = left; - m_marginRight = right; - update(); -} - -void ScreenItem::setMargingTop(int val) -{ - prepareGeometryChange(); - m_marginTop = val; - update(); -} - - -void ScreenItem::setMargingBottom(int val) -{ - prepareGeometryChange(); - m_marginBottom = val; - update(); -} - -void ScreenItem::setMargingLeft(int val) -{ - prepareGeometryChange(); - m_marginLeft = val; - update(); -} - -void ScreenItem::setMargingRight(int val) -{ - prepareGeometryChange(); - m_marginRight = val; - update(); -} - -void ScreenItem::setUseMargins(bool val) -{ - m_useMargins = val; - update(); -} - -void ScreenItem::setDrawText(bool val) -{ - m_drawText = val; - update(); -} \ No newline at end of file diff -Nru syncwall-1.6.0/SyncWall/src/ScreenItem.h syncwall-1.7.4/SyncWall/src/ScreenItem.h --- syncwall-1.6.0/SyncWall/src/ScreenItem.h 2012-04-26 14:01:00.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/ScreenItem.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,95 +0,0 @@ - -/****************************************************************************** - SyncWall: Wallpaper manager - Copyright(C) 2011-2012 xbee@xbee.net - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *******************************************************************************/ - -#ifndef _SCREENITEM_H_ -#define _SCREENITEM_H_ - -#include -#include -#include - -class ScreenItem : - public QGraphicsItem -{ -public: - - ScreenItem ( const QSize &size, int num, QGraphicsItem * parent = 0 ); - - QRectF boundingRect() const; - - void setSize(const QSize &size); - void setNumber(int); - - QSize getRealSize() const {return m_realSize; } - QSize getRealSizeWithMargins() const; - QSize getSizeWithMargins() const; - QSize getSize() const {return m_size; } - - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,QWidget *widget); - int getNumber() const { return m_screenNum; } - - void setMargings(int top, int bottom, int left, int right); - void setMargingTop(int val); - int getMarginTop() const {return m_marginTop; } - void setMargingBottom(int val); - int getMarginBottom() const {return m_marginBottom; } - void setMargingLeft(int val); - int getMarginLeft() const {return m_marginLeft; } - void setMargingRight(int val); - int getMarginRight() const {return m_marginRight; } - - // use margins or not - void setUseMargins(bool); - bool getUseMargins(){ return m_useMargins; } - - // draw text or not - void setDrawText(bool); - bool getDrawText(){ return m_drawText; } - - QRectF getValidSceneBoundingRect(); - - void setImage(const QImage &); - void updateImage(); - -private: - - void drawMargins(QPainter *painter); - void drawDesktop(QPainter *painter); - void drawTextEffect(QPainter *painter, const QString &text, const QRectF & rect, int alignment, const QPoint &offset); - - QRectF getPreviewSceneBoundingRect(); - QRectF getPreviewSceneWithMarginsBoundingRect(); - - QSize m_realSize; - QSize m_size; - int m_screenNum; - - int m_marginLeft; - int m_marginRight; - int m_marginTop; - int m_marginBottom; - - QImage m_image; - QImage m_cropimage; - bool m_useMargins; - bool m_drawText; -}; - -#endif // _SCREENITEM_H_ diff -Nru syncwall-1.6.0/SyncWall/src/SingleApplication.cpp syncwall-1.7.4/SyncWall/src/SingleApplication.cpp --- syncwall-1.6.0/SyncWall/src/SingleApplication.cpp 2012-01-30 15:59:02.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/SingleApplication.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -/****************************************************************************** -SyncWall: Wallpaper manager -Copyright(C) 2011-2012 xbee@xbee.net - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*******************************************************************************/ - -#include - -#include "SingleApplication.h" - -SingleApplication::SingleApplication(int &argc, char *argv[], const QString &uniqueKey) : QApplication(argc, argv), -m_isRunning(false), -m_uniqueKey(uniqueKey), -m_localServer(NULL) -{ -#ifndef QT_NO_SHAREDMEMORY // for os/2 compilation - m_sharedMemory.setKey(m_uniqueKey); - if (m_sharedMemory.attach()) - m_isRunning = true; - else - { - m_isRunning = false; - // create shared memory. - if (!m_sharedMemory.create(1)) - { - qDebug("Unable to create single instance."); - return; - } - // create local server and listen to incomming messages from other instances. - m_localServer = new QLocalServer(this); - connect(m_localServer, SIGNAL(newConnection()), this, SLOT(receiveMessage())); - m_localServer->listen(m_uniqueKey); - } -#endif -} - -SingleApplication::~SingleApplication() -{ -#ifndef QT_NO_SHAREDMEMORY // for os/2 compilation - m_sharedMemory.detach(); -#endif -} - -// public slots. - -void SingleApplication::receiveMessage() -{ - QLocalSocket *localSocket = m_localServer->nextPendingConnection(); - if (!localSocket->waitForReadyRead(m_timeout)) - { - qDebug("%s",localSocket->errorString().toStdString().c_str()); - return; - } - QByteArray byteArray = localSocket->readAll(); - QString message = QString::fromUtf8(byteArray.constData()); - emit messageAvailable(message); - localSocket->disconnectFromServer(); -} - -// public functions. - -bool SingleApplication::isRunning() -{ - return m_isRunning; -} - -bool SingleApplication::sendMessage(const QString &message) -{ - if (!m_isRunning) - return false; - - QLocalSocket localSocket(this); - localSocket.connectToServer(m_uniqueKey, QIODevice::WriteOnly); - if (!localSocket.waitForConnected(m_timeout)) - { - qDebug("%s",localSocket.errorString().toStdString().c_str()); - return false; - } - - localSocket.write(message.toUtf8()); - if (!localSocket.waitForBytesWritten(m_timeout)) - { - qDebug("%s",localSocket.errorString().toStdString().c_str()); - return false; - } - localSocket.disconnectFromServer(); - return true; -} diff -Nru syncwall-1.6.0/SyncWall/src/SingleApplication.h syncwall-1.7.4/SyncWall/src/SingleApplication.h --- syncwall-1.6.0/SyncWall/src/SingleApplication.h 2012-01-29 13:13:46.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/SingleApplication.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ - -/****************************************************************************** - SyncWall: Wallpaper manager - Copyright(C) 2011-2012 xbee@xbee.net - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *******************************************************************************/ - -//------------------------------------------------------------------------------ -// extract from http://www.qtcentre.org/wiki/index.php?title=SingleApplication -//------------------------------------------------------------------------------ - -#ifndef _SINGLE_APPLICATION_H_ -#define _SINGLE_APPLICATION_H_ - -#include -#include - -#ifndef QT_NO_SHAREDMEMORY // for os/2 compilation -#include -#endif // QT_NO_SHAREDMEMORY - - -class SingleApplication : - public QApplication -{ - Q_OBJECT - -public: - - SingleApplication(int &argc, char *argv[], const QString &uniqueKey); - ~SingleApplication(); - - bool isRunning(); - bool sendMessage(const QString &message); - -public slots: - - void receiveMessage(); - -signals: - - void messageAvailable(const QString &message); - -private: - - bool m_isRunning; - QString m_uniqueKey; - - QLocalServer *m_localServer; - - static const int m_timeout = 1000; - -#ifndef QT_NO_SHAREDMEMORY // for os/2 compilation - QSharedMemory m_sharedMemory; -#endif // QT_NO_SHAREDMEMORY -}; - - - -#endif // _SINGLE_APPLICATION_H_ diff -Nru syncwall-1.6.0/SyncWall/src/SplashScreen.cpp syncwall-1.7.4/SyncWall/src/SplashScreen.cpp --- syncwall-1.6.0/SyncWall/src/SplashScreen.cpp 2012-01-29 10:50:42.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/SplashScreen.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,141 +0,0 @@ -/****************************************************************************** -SyncWall: Wallpaper manager -Copyright(C) 2011-2012 xbee@xbee.net - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*******************************************************************************/ - -#include "SplashScreen.h" - -#include -#include -#include -#include - -SplashScreen::SplashScreen(const QPixmap& pixmap, unsigned int minimalDisplayDuration, int screenId, bool transparentBackground, Qt::WindowFlags /* f */) - : QSplashScreen(), - m_timerFired(false), - m_currAlign(Qt::AlignLeft), - m_currColor(Qt::black), - m_screenId(screenId) -{ - setSplash(pixmap,transparentBackground); - init(minimalDisplayDuration); -} - -void SplashScreen::setSplash(const QPixmap& pixmap,bool transparentBackground) -{ - QPixmap extract(pixmap.width(),pixmap.height()); - if (transparentBackground) // extract background from desktop - { - QRect geom = QApplication::desktop()->screenGeometry( m_screenId ); - QPixmap desktopPixmap = QPixmap::grabWindow( QApplication::desktop()->winId(), geom.x(), geom.y(), geom.width(), geom.height() ); - - int x0 = desktopPixmap.width()/2.0 - pixmap.width()/2.0; - int y0 = desktopPixmap.height()/2.0 - pixmap.height()/2.0; - extract = desktopPixmap.copy(x0,y0,pixmap.width(),pixmap.height()); - } - else // create a dummy background - { - QPainter painter(&extract); - QLinearGradient linearGrad( 0, 0, 0, extract.height() ); - linearGrad.setColorAt( 0.0, QColor(255,190,0)); - linearGrad.setColorAt( 1.0, QColor(255,160,0)); - painter.setBrush( linearGrad ); - painter.fillRect( 0, 0, extract.width(),extract.height(), QBrush(linearGrad) ); - painter.setBrush(QBrush()); - painter.drawRect( 0, 0, extract.width()-1,extract.height() -1); - } - - QImage resultImage = QImage(pixmap.size(), QImage::Format_ARGB32_Premultiplied); - QPainter painter(&resultImage); - painter.setCompositionMode(QPainter::CompositionMode_SourceOver); - painter.drawImage(0, 0, extract.toImage()); - painter.drawImage(0, 0, pixmap.toImage()); - painter.end(); - setPixmap(QPixmap::fromImage(resultImage)); - - // must move the splashscreen by taking ito account screen Number - move( QApplication::desktop()->screenGeometry(m_screenId).center() - resultImage.rect().center() ); - repaint(); -} - -void SplashScreen::delayedFinish(QWidget *next) -{ - if (m_timerFired) - { - if (next) - { - next->show(); - QSplashScreen::finish(next); - } - else if (nextWidget) - { - nextWidget->show(); - QSplashScreen::finish(nextWidget); - } - } - else - { - nextWidget = next; - } -} - -void SplashScreen::init(unsigned int minimalDisplayDuration) -{ - nextWidget = 0; - setWindowModality(Qt::ApplicationModal); - - if (minimalDisplayDuration != 0 && !pixmap().isNull()) - { - m_timerFired = false; - QTimer::singleShot(minimalDisplayDuration, this, SLOT(close())); - } - else - { - m_timerFired = true; - } -} - -void SplashScreen::finish(void) -{ - m_timerFired = true; - emit finished(); - delayedFinish(); -} - -void SplashScreen::drawContents(QPainter *painter) -{ - painter->setPen(m_currColor); - - QPixmap pm = QSplashScreen::pixmap(); - QRect r(0, 0, pm.width(), pm.height()); - - r.setRect(r.x() + 100, r.y() - 15, r.width() - 10, r.height() - 10); - painter->setFont(QFont("arial", 8)); - painter->drawText(r, m_currAlign, m_currStatus); -} - -void SplashScreen::showMessage(const QString &message, int alignment, - const QColor &color) -{ - m_currStatus = message; - m_currAlign = alignment; - m_currColor = color; - emit messageChanged(m_currStatus); - repaint(); -} - - diff -Nru syncwall-1.6.0/SyncWall/src/SplashScreen.h syncwall-1.7.4/SyncWall/src/SplashScreen.h --- syncwall-1.6.0/SyncWall/src/SplashScreen.h 2012-01-29 10:50:42.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/SplashScreen.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,67 +0,0 @@ - -/****************************************************************************** - SyncWall: Wallpaper manager - Copyright(C) 2011-2012 xbee@xbee.net - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *******************************************************************************/ - -#ifndef _SPLASHSCREEN_H_ -#define _SPLASHSCREEN_H_ - -#include -#include -#include -#include -#include - -class SplashScreen : - public QSplashScreen -{ - Q_OBJECT - -public: - SplashScreen(const QPixmap& pixmap, unsigned int minimalDisplayDuration = 0, int screenId = -1, bool transparentBackground = true, Qt::WindowFlags f = 0); - - void delayedFinish(QWidget *next = 0); - void showMessage(const QString &message, int alignment = Qt::AlignLeft, const QColor &color = Qt::black); - -signals: - - void finished(); - -protected: - - void drawContents(QPainter *painter); - -private slots: - - void finish(void); - -private: - - void init(unsigned int minimalDisplayDuration); - void setSplash(const QPixmap& pixmap,bool transparentBackground = true); - - QWidget *nextWidget; - bool m_timerFired; - QPixmap m_pixmap; - QString m_currStatus; - int m_currAlign; - QColor m_currColor; - int m_screenId; -}; - -#endif // _SPLASHSCREEN_H_ diff -Nru syncwall-1.6.0/SyncWall/src/SyncWall.cpp syncwall-1.7.4/SyncWall/src/SyncWall.cpp --- syncwall-1.6.0/SyncWall/src/SyncWall.cpp 2012-05-13 22:27:54.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/SyncWall.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,1312 +0,0 @@ -/****************************************************************************** -SyncWall: Wallpaper manager -Copyright(C) 2011-2012 xbee@xbee.net - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*******************************************************************************/ - -#include "SyncWall.h" - -#include -#include -#include - -#include "LogHandler.h" - -#include "AppSettings.h" -#include "WallpaperProvider.h" - -#include "MiscFunctions.h" -#include "DesktopScene.h" -#include "ImageViewer.h" -#include "ListImagesModel.h" -#include "TreeImagesView.h" -#include "IconViewDelegate.h" -#include "NetworkManager.h" - -#include "ThreadPool.h" - -#include - -#ifdef Q_WS_WIN // for wallpaper set on windows platform - -#include -#include - -#endif - -#ifndef Q_WS_PM // OS/2 -#include -#endif - - -//enum ScaleType { IGNORE_ASPECT = 0, KEEP_ASPECT, KEEP_EXPANDED_ASPECT}; - -const int defaultBlinkInterval = 1000; // 1 sec -const int defaultBlinkingTime = 5000; // 5 sec -const int saveSettingsInterval = 10*60*1000; // 10 min - -SyncWall::SyncWall(QWidget *parent, Qt::WFlags flags) - : QMainWindow(parent, flags), - m_useGlobalHotKey(false), - m_globalHotkey("Ctrl+F11"), -#ifndef Q_WS_PM // OS/2 - m_shortCut(NULL), -#endif - m_firstCloseMessage(false), - m_appName(PACKAGE_NAME), - m_version(PACKAGE_VERSION), - m_trayIcon(NULL), - m_scheduler(NULL), - m_logLevel(LogHandler::MSG_DEBUG), - m_randomOrderChange(false), - m_currentImageIndex(-1), - m_blinking(true), - m_startInTray(false), - m_splashscreenAtStartup(true), - m_splashscreenTransparentBackground(true), - m_startWithSystem(false), - m_listModel(NULL), - m_resetConfig(false), - m_currentListIndex(-1) -{ - setupUi(this); - - // load the settings - loadSettings(); - - // create/connect specific class/widget and setup various parameters - updateUi(); - - // setup global key menu - setupGlobalKeys(); - - // update wallpaper file list - refreshWallpaperProviders(); -} - -SyncWall::~SyncWall() -{ - saveSettings(); - ThreadPool::getInstance()->stop(); - qDeleteAll(m_currentProviders); -} - -void SyncWall::updateUi() -{ - checkForSmallInterface(); - - initStateDefs(); - - // setup app name, release, ... - updateApplicationIdentity(); - - // setup About dialog with some informations - updateAbout(); - - // update language data - updatePrefsLanguage(); - - // create and connect the log handler - connect(LogHandler::getInstance(),SIGNAL(newMessage(const QString &)),this,SLOT(printToLog(const QString &))); - LogHandler::getInstance()->setBufferization(false); // get all stored messages if exists - - // force always tab(0) - tabWidgetMain->setCurrentIndex(0); - tabWidgetPreferences->setCurrentIndex(0); - - createActionsSystemTray(); - createTrayIcon(); - - // limit log display - textBrowserLog->document()->setMaximumBlockCount(1000); - - // init random generator to a "random" value !! :) - qsrand(QTime::currentTime().msec()); - - // temp storage check - QString tmpPath = MiscFunctions::getValidStorage(); - - if (!QDir(tmpPath).exists()) - { - if (!QDir::home().mkpath(tmpPath)) - QMessageBox::warning(this,m_appName,tr("Can't create storage location, check why ?! (%1)").arg(tmpPath)); - } - -#ifdef Q_WS_WIN - - SHELLFLAGSTATE shfs; - - SHGetSettings(&shfs,SSF_DESKTOPHTML); - - if (shfs.fDesktopHTML) - QMessageBox::warning(this,m_appName,tr("Active Desktop must be disabled !!")); - -#else - checkBoxStartWithSystem->hide(); // hide autostart checkbox only usable on Windows -#endif - - // connect network manager signals - connect(widgetNetworkParameters, SIGNAL(newState()), this, SLOT(checkState())); - connect(widgetNetworkParameters, SIGNAL(newMessage(const QString& )), widgetImageParameters, SLOT(decodeAndApplyMessage(const QString& ))); - connect(widgetNetworkParameters, SIGNAL(synchronizeByNetwork(bool)), widgetScheduler, SLOT(setIdle(bool))); - connect(this, SIGNAL(sigSaveSettings()), widgetNetworkParameters, SLOT(saveSettings())); - - - connect(widgetImageParameters, SIGNAL(requestNewImage()), this, SLOT(changeWallpaper())); - connect(widgetImageParameters, SIGNAL(decodedImage(const QString& )), this, SLOT(searchForWallpaper(const QString& ))); - connect(this, SIGNAL(sigSaveSettings()), widgetImageParameters, SLOT(saveSettings())); - - - // connect scheduler signals - connect(widgetScheduler, SIGNAL(newState()), this, SLOT(checkState())); - connect(widgetScheduler, SIGNAL(newEvent()), this, SLOT(checkForBlinking())); - connect(widgetScheduler, SIGNAL(quit()), this, SLOT(on_pushButtonQuit_pressed())); - connect(this, SIGNAL(sigSaveSettings()), widgetScheduler, SLOT(saveSettings())); - - // starting network before scheduler - widgetNetworkParameters->start(); - widgetScheduler->start(); - - // setup "blinking" timer - m_blinkTimer.setInterval(defaultBlinkInterval); - connect(&m_blinkTimer, SIGNAL(timeout()), this, SLOT(blink())); - - // connect painter to system integration - connect(widgetImageParameters, SIGNAL(newImage(const QImage &)), widgetSystem, SLOT(applyWallpaper(const QImage &))); - connect(widgetImageParameters, SIGNAL(newImages(const QList &)), widgetSystem, SLOT(applyWallpaper(const QList &))); - - // connect painter to network - connect(widgetImageParameters, SIGNAL(newConfiguration(const QString &)), widgetNetworkParameters, SLOT(sendNewMessage(const QString &))); - - connect(this, SIGNAL(sigSaveSettings()), widgetSystem, SLOT(saveSettings())); - - graphicsViewDesktop->setScene(widgetImageParameters->getScenePreview()); - - // create the exclusive button - QButtonGroup *buttonGroup = new QButtonGroup(this); - buttonGroup->setExclusive(true); - buttonGroup->addButton(pushButtonViewList); - buttonGroup->addButton(pushButtonViewDetail); - buttonGroup->addButton(pushButtonViewThumbnail); - - m_listModel = new ListImagesModel(this); - treeViewFiles->setModel(m_listModel); - listViewFiles->setItemDelegate(new IconViewDelegate); //connect the delegate to view - listViewFiles->setModel(m_listModel); - stackedWidgetFiles->setCurrentIndex(0); // switch to treeView - - connect(treeViewFiles->selectionModel(),SIGNAL (selectionChanged (const QItemSelection &, const QItemSelection & )), this, SLOT(selectionChanged(const QItemSelection &, const QItemSelection & ))); - connect(listViewFiles->selectionModel(),SIGNAL (selectionChanged (const QItemSelection &, const QItemSelection & )), this, SLOT(selectionChanged(const QItemSelection &, const QItemSelection & ))); - - // global hotkey not available for OS/2 -#ifdef Q_WS_PM // OS/2 - groupBoxHotKey->hide(); -#endif - - // create a timer for automatically save settings - QTimer * timer = new QTimer(this); - connect(timer, SIGNAL(timeout()), this, SLOT(saveSettings())); - timer->start(saveSettingsInterval); -} - -// on laptop => we have to reduce the icon decoration size -void SyncWall::checkForSmallInterface() -{ - QRect screen = QApplication::desktop()->screenGeometry(); - qDebug() << screen; - qDebug() << size(); - QSize size = minimumSizeHint () ; - if (size.height() > screen.height()/1.5f) - { - // resize decoration icon - QSize smallSize = labelDecoration->pixmap()->size(); - smallSize /= 2; - labelDecoration->setPixmap(labelDecoration->pixmap()->scaled(smallSize)); - labelDecoration_2->setPixmap(labelDecoration_2->pixmap()->scaled(smallSize)); - labelDecoration_3->setPixmap(labelDecoration_3->pixmap()->scaled(smallSize)); - widgetNetworkParameters->labelDecoration->setPixmap(widgetNetworkParameters->labelDecoration->pixmap()->scaled(smallSize)); - widgetImageParameters->labelDecoration->setPixmap(widgetImageParameters->labelDecoration->pixmap()->scaled(smallSize)); - widgetScheduler->labelDecoration->setPixmap(widgetScheduler->labelDecoration->pixmap()->scaled(smallSize)); - } -} - -void SyncWall::setupGlobalKeys() -{ -#ifndef Q_WS_PM // OS/2 - m_shortCut = new QxtGlobalShortcut(this); - connect(m_shortCut, SIGNAL(activated()), this, SLOT(changeWallpaper())); - QKeySequence key(m_globalHotkey); - m_shortCut->setShortcut(key); - widgetKeySequence->setKeySequence(key); - widgetKeySequence->setClearButtonIcon(QIcon((":/syncwall/delete.png"))); -#endif -} - -void SyncWall::updatePrefsLanguage() -{ - // set detected language - QString detectedLanguage = QLocale::system().name().left(2); - labelDetectedLanguage->setText(tr("detected language: %1").arg(detectedLanguage)); - - // fill comboBox - const QMap &mapLang = MiscFunctions::getAvailableLanguages(); - QStringList names = mapLang.keys(); - comboBoxLanguage->addItem(tr("Automatic detection"), "auto"); - if (m_currentLanguage == "auto") - comboBoxLanguage->setCurrentIndex(comboBoxLanguage->count() - 1); - comboBoxLanguage->addItem(tr("Default (no use of translation files)"),"default"); - if (m_currentLanguage == "default") - comboBoxLanguage->setCurrentIndex(comboBoxLanguage->count() - 1); - foreach (const QString &lang, names) - { - comboBoxLanguage->addItem(lang,mapLang[lang]); - if (mapLang[lang] == m_currentLanguage) - comboBoxLanguage->setCurrentIndex(comboBoxLanguage->count() - 1); - } - -} - -void SyncWall::on_comboBoxLanguage_activated(int index) -{ - QString lang = comboBoxLanguage->itemData(index).toString(); - if (lang == m_currentLanguage) - return; - - m_currentLanguage = lang; - - // check if recursive scan - int ret = QMessageBox::question(this, m_appName, - tr("The application need to restart in order to take into account new translation\n, Do you want to restart application now ?"), - QMessageBox::Yes - | QMessageBox::No); - - if (ret == QMessageBox::Yes) - restart(); -} - -void SyncWall::restart() -{ - QProcess::startDetached(qApp->arguments()[0], qApp->arguments()); - QApplication::exit(0); -} - -void SyncWall::on_pushButtonQuit_pressed() -{ - QApplication::exit(0); -} - -void SyncWall::on_pushButtonClearLog_pressed() -{ - textBrowserLog->clear(); -} - -void SyncWall::on_pushButtonSaveLog_pressed() -{ - QString logFile = QFileDialog::getSaveFileName( - this, - tr("Log file"), - m_lastDirectory, - "Log file (*.log)"); - - if (logFile.isEmpty()) - return; - - - QFile file(logFile); - if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) - { - LogHandler::getInstance()->reportError(tr("Can't save log file !!: %1").arg(logFile)); - } - - QTextStream out(&file); - out << textBrowserLog->document()->toPlainText(); - file.close(); -} - -void SyncWall::on_pushButtonAddDirectory_pressed() -{ - QString dir = QFileDialog::getExistingDirectory(this, tr("Add Wallpaper Directory"), - m_lastDirectory, - QFileDialog::ShowDirsOnly - | QFileDialog::DontResolveSymlinks); - - if (dir.isEmpty()) - return; - - // check if recursive scan - int rep = QMessageBox::question(this, m_appName, - tr("Add all found directories recursively ?"), - QMessageBox::Yes - | QMessageBox::No); - - bool recursiveSearch = (rep == QMessageBox::Yes); - - // check if watch at - rep = QMessageBox::question(this, m_appName, - tr("Watch for modifications in these directories at application startup ?"), - QMessageBox::Yes - | QMessageBox::No); - - bool watchForModification = (rep == QMessageBox::Yes); - - addDirToProviders(dir,recursiveSearch,watchForModification); -} - -void SyncWall::addDirToProviders(const QString &dir, bool recursiveSearch, bool watchForModification) -{ - if (dir.isEmpty()) - return; - - m_lastDirectory = dir; // save current directory - - QStringList listDir; - - if (recursiveSearch) - listDir = getSubDirectoryList(QDir(dir,"",QDir::Name,QDir::Dirs)); - - listDir << dir; - - int typeProvider = WallpaperProvider::MODE_FILELIST; - if (watchForModification) - typeProvider = WallpaperProvider::MODE_DIRECTORY; - - foreach (const QString &folder, listDir) - { - LogHandler::getInstance()->reportDebug(tr("add %1 folder").arg(folder)); - WallpaperProvider *wp = new WallpaperProvider(folder,typeProvider); - m_currentProviders << wp; - updateDisplayedFileList(wp); // update UI - } -} - -void SyncWall::on_pushButtonAddFiles_pressed() -{ - QString formats = MiscFunctions::getAvailablesImageFormats(); - QStringList list = QFileDialog::getOpenFileNames( - this, - tr("Select one or more wallpapers"), - m_lastDirectory, - tr("Images (%1)").arg(formats)); - - if (!list.isEmpty()) - { - m_lastDirectory = QFileInfo(list[0]).absolutePath(); // save current directory - WallpaperProvider *wp = new WallpaperProvider(list); - m_currentProviders << wp; - updateDisplayedFileList(wp); // update UI - } -} - - -void SyncWall::on_pushButtonRefresh_pressed() -{ - refreshWallpaperProviders(true); -} - -//-------------------------------------------------------------------------------------- -// LOG Functions -//-------------------------------------------------------------------------------------- - -void SyncWall::printToLog(const QString & mess) -{ - textBrowserLog->append(mess); -} - -//-------------------------------------------------------------------------------------- - -void SyncWall::on_pushButtonDeleteImage_pressed() -{ - on_actionDeleteImage_triggered(); -} -//----------------------------------------------------------------------- -// tray icon functions -//----------------------------------------------------------------------- - -void SyncWall::closeEvent(QCloseEvent *event) -{ - if (m_trayIcon && m_trayIcon->isVisible()) - { - if (!m_firstCloseMessage) - { - QMessageBox::information(this, tr("Systray"), - tr("The program will keep running in the " - "system tray. To terminate the program, " - "choose Quit in the context menu " - "of the system tray entry.")); - m_firstCloseMessage = true; - } - - hide(); - event->ignore(); - } -} - -void SyncWall::on_actionQuit_activated() -{ - on_pushButtonQuit_pressed(); -} - -void SyncWall::on_actionNextWallpaper_activated() -{ - changeWallpaper(getNextImageIndex()); -} - -void SyncWall::on_actionPreviousWallpaper_activated() -{ - changeWallpaper(getPrevImageIndex()); -} - -void SyncWall::createActionsSystemTray() -{ - // nothing to do yet -} - -void SyncWall::on_actionShowUI_triggered() -{ - show(); -} - -void SyncWall::createTrayIcon() -{ - // tray menu - m_trayIconMenu = new QMenu(this); - - m_trayIconMenu->addAction(actionShowUI); - m_trayIconMenu->addAction(actionNextWallpaper); - m_trayIconMenu->addAction(actionPreviousWallpaper); - m_trayIconMenu->insertSeparator(actionQuit); - m_trayIconMenu->addAction(actionQuit); - - m_trayIconMenu->setTitle(m_appName); - m_trayIconMenu->setIcon(QIcon(":/syncwall/logo_big.png")); - - m_trayIcon = new QSystemTrayIcon(this); - m_trayIcon->setContextMenu(m_trayIconMenu); - - connect(m_trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), - this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason))); - - m_trayIcon->setIcon(QIcon(":/syncwall/logo_big.png")); - - m_trayIcon->show(); -} - -//----------------------------------------------------------------------- -// Save/Restore parameters functions -//----------------------------------------------------------------------- - -void SyncWall::saveSettings() -{ - AppSettings settings; - - settings.beginGroup("MainWindow"); - - settings.setValue("MainWindowState",saveState(0)); - - settings.setValue("size", size()); - settings.setValue("pos", pos()); - - settings.setValue("fullScreen", isFullScreen()); - - // save the screen number for the splashsreeen ... - if (QApplication::desktop()->isVirtualDesktop()) - settings.setValue("screenNumber", QApplication::desktop()->screenNumber(pos())); - else - settings.setValue("screenNumber", QApplication::desktop()->screenNumber(this)); - - settings.setValue("screenNumber", QApplication::desktop()->screenNumber(this)); - - settings.endGroup(); - - settings.beginGroup("Application"); - - - settings.setValue("useGlobalHotKey", m_useGlobalHotKey); - settings.setValue("globalHotkey", m_globalHotkey); - - settings.setValue("randomOrderChange", m_randomOrderChange); - - settings.setValue("currentLanguage", m_currentLanguage); - - settings.setValue("resetConfig", m_resetConfig); - - // providers - settings.beginWriteArray("providers", m_currentProviders.count()); - - for (int i = 0; i < m_currentProviders.size(); ++i) - { - settings.setArrayIndex(i); - settings.setValue("mode", m_currentProviders.at(i)->getMode()); - settings.setValue("inputs", m_currentProviders.at(i)->getInputList()); - } - - settings.endArray(); - - - settings.setValue("lastDirectory", m_lastDirectory); - settings.setValue("lastFile", m_lastFile); - settings.setValue("startInTray", m_startInTray); - settings.setValue("splashscreenAtStartup", m_splashscreenAtStartup); - settings.setValue("splashscreenTransparentBackground", m_splashscreenTransparentBackground); - settings.setValue("startWithSystem", m_startWithSystem); - - - settings.endGroup(); - - // save child class settings - emit sigSaveSettings(); -} - -void SyncWall::loadSettings() -{ - AppSettings settings; - - settings.beginGroup("MainWindow"); - - restoreState(settings.value("MainWindowState").toByteArray(), 0); - - resize(settings.value("size", QSize(400, 400)).toSize()); - move(settings.value("pos", QPoint(200, 200)).toPoint()); - - bool fullScreen = settings.value("fullScreen",false).toBool(); - - if (fullScreen) - showFullScreen () ; - - settings.endGroup(); - - settings.beginGroup("Application"); - - m_useGlobalHotKey = settings.value("useGlobalHotKey",false).toBool(); - groupBoxHotKey->setChecked(m_useGlobalHotKey); - m_globalHotkey = settings.value("globalHotkey","Ctrl+F11").toString(); - - m_randomOrderChange = settings.value("randomOrderChange",false).toBool(); - checkBoxRandomOrder->setChecked(m_randomOrderChange); - - m_resetConfig = settings.value("resetConfig", false).toBool(); - - m_currentLanguage = settings.value("currentLanguage","auto").toString(); - - if (m_currentLanguage.isEmpty()) - m_currentLanguage = QLocale::system().name().left(2); - - // providers - int size = settings.beginReadArray("providers"); - - for (int i = 0; i < size; ++i) - { - settings.setArrayIndex(i); - int mode = settings.value("mode").toInt(); - - if (mode == WallpaperProvider::MODE_DIRECTORY) - m_currentProviders << new WallpaperProvider(settings.value("inputs").toStringList()[0]); - else - m_currentProviders << new WallpaperProvider(settings.value("inputs").toStringList()); - - } - - settings.endArray(); - - m_lastDirectory = settings.value("lastDirectory","/home").toString(); - m_lastFile = settings.value("lastFile","/home").toString(); - - m_startInTray = settings.value("startInTray",false).toBool(); - checkBoxStartInTray->setChecked(m_startInTray); - - m_splashscreenAtStartup = settings.value("splashscreenAtStartup",true).toBool(); - checkBoxSplashscreenAtStartup->setChecked(m_splashscreenAtStartup); - - m_splashscreenTransparentBackground = settings.value("splashscreenTransparentBackground",true).toBool(); - checkBoxSplashscreenTransparentBackground->setChecked(m_splashscreenTransparentBackground); - - m_startWithSystem = settings.value("startWithSystem",false).toBool(); - checkBoxStartWithSystem->setChecked(m_startWithSystem); - - settings.endGroup(); -} - -// preferences -void SyncWall::iconActivated(QSystemTrayIcon::ActivationReason reason) -{ - switch (reason) - { - case QSystemTrayIcon::Trigger: - break; - - case QSystemTrayIcon::DoubleClick: - showNormal (); - QWidget::setVisible(true); - break; - - case QSystemTrayIcon::MiddleClick: - //showMessage(); - break; - - default: - ; - } -} - -void SyncWall::refreshWallpaperProviders(bool force) -{ - //m_listModel->clear(); // clear widget - //m_listFiles.clear(); // clear global wallpaper list - - foreach (WallpaperProvider *wp, m_currentProviders) - { - if (force) - wp->refreshWallpaperList(); - - updateDisplayedFileList(wp); - } - - // update the fixed list of index - computeIndexList(); -} - -void SyncWall::updateDisplayedFileList(WallpaperProvider *wp) -{ - if (!wp) - return; - - m_listModel->addImages(wp->getWallpaperList()); // update global wallpaper list - - // update the "stats" - labelStats->setText(tr("%1 images in list").arg(m_listModel->rowCount())); -} - -QStringList SyncWall::getSubDirectoryList(const QDir & dir) -{ - QStringList res; - QFileInfoList qsl = dir.entryInfoList(); - foreach (const QFileInfo &entry, qsl) - { - qDebug() << entry.absoluteFilePath(); - - if ( entry.isDir() ) - { - QString dirname = entry.fileName(); - - if ((dirname==".") || (dirname == "..")) - continue; - - res << entry.absoluteFilePath(); - res.append(getSubDirectoryList(QDir( entry.absoluteFilePath(),"",QDir::Name,QDir::Dirs))); - } - } - return res; -} - -void SyncWall::on_pushButtonSetWallpaper_pressed() -{ -on_actionSetWallpaper_triggered(); -} - -void SyncWall::checkForBlinking() -{ - if (!m_blinking) // direct wallpaper change - { - changeWallpaper(); - } - else - { - m_blinkTimer.start(); - QTimer::singleShot(defaultBlinkingTime, this, SLOT(changeWallpaper())); - } -} - -void SyncWall::changeWallpaper(int index, bool manual) -{ - m_blinkTimer.stop(); - - if (m_listModel->rowCount() == 0) - return; - - if (index < 0) // mode auto compute next wallpaper - index = getNextImageIndex(); - - m_currentImageIndex = index; - - // manual => reset the sheduler manually - if (manual) - widgetScheduler->restartScheduler(); - - - // send new wallpaper to connected client if needed - widgetImageParameters->processImage(m_listModel->getFilename(m_currentImageIndex),manual); -} - -int SyncWall::getRandomIndex() -{ - if (m_listModel->rowCount() > 1) - return qrand()%(m_listModel->rowCount() - 1); - else - return 0; -} - -void SyncWall::computeIndexList() -{ - m_listIndex.clear(); - m_currentListIndex = 0; - - if (!m_listModel) - return; - - for (int i = 0; i < m_listModel->rowCount()*2; i++) - { - if (m_randomOrderChange) - m_listIndex << getRandomIndex(); - else - m_listIndex << i % m_listModel->rowCount(); - } -} - -int SyncWall::getNextImageIndex() -{ - if (!m_listIndex.size()) - return -1; - - m_currentListIndex++; - m_currentListIndex = m_currentListIndex % m_listIndex.size(); - - return m_listIndex[m_currentListIndex]; -} - -int SyncWall::getPrevImageIndex() -{ - if (!m_listIndex.size()) - return -1; - - m_currentListIndex--; - if (m_currentListIndex < 0) - m_currentListIndex = m_listIndex.size() - 1; - - return m_listIndex[m_currentListIndex]; -} - -void SyncWall::selectionChanged(const QItemSelection& selected, const QItemSelection& /*deselected*/) // update only the preview -{ - QModelIndexList indexes = selected.indexes(); - if (!indexes.isEmpty()) - widgetImageParameters->previewImage(m_listModel->getFilename(indexes[0])); -} - -void SyncWall::on_listViewFiles_doubleClicked(const QModelIndex & /*index*/) -{ - QModelIndexList selected = listViewFiles->selectionModel()->selectedRows (); - if (!selected.isEmpty()) - changeWallpaper(m_listModel->getIndex(selected[0]),true); -} - -void SyncWall::on_treeViewFiles_doubleClicked(const QModelIndex & /*index*/) -{ - QModelIndexList selected = treeViewFiles->selectionModel()->selectedRows (); - if (!selected.isEmpty()) - changeWallpaper(m_listModel->getIndex(selected[0]),true); -} - -void SyncWall::on_pushButtonPreview_pressed() -{ - on_actionPreviewImage_triggered(); -} - -void SyncWall::on_actionPreviewImage_triggered() -{ - QModelIndexList selected; - if (m_listModel->getDisplayMode() != ListImagesModel::MODE_ICONS) - selected = treeViewFiles->selectionModel()->selectedRows (); - else - selected = listViewFiles->selectionModel()->selectedRows (); - - if (!selected.isEmpty()) - { - ImageViewer *viewer = new ImageViewer(m_listModel->getFilename(selected.at(0))); - viewer->show(); - } -} - -void SyncWall::on_actionSetWallpaper_triggered() -{ - QModelIndexList selected; - if (m_listModel->getDisplayMode() != ListImagesModel::MODE_ICONS) - selected = treeViewFiles->selectionModel()->selectedRows (); - else - selected = listViewFiles->selectionModel()->selectedRows (); - - if (!selected.isEmpty()) - { - m_currentImageIndex = m_listModel->getIndex(selected[0]); - changeWallpaper(m_currentImageIndex,true); - } -} -void SyncWall::on_actionDeleteImage_triggered() -{ - bool somethingToDo = false; - - QModelIndexList selected; - if (m_listModel->getDisplayMode() != ListImagesModel::MODE_ICONS) - selected = treeViewFiles->selectionModel()->selectedRows (); - else - selected = listViewFiles->selectionModel()->selectedRows (); - - foreach(const QModelIndex &index, selected) - { - QString file = m_listModel->getFilename(index); - foreach (WallpaperProvider *wp, m_currentProviders) - { - wp->deleteInput(file); - } - somethingToDo = true; - //m_listModel->removeRows( index.row(), 1) ); - } - - m_listModel->removeRows(selected); - - // reset the list - if (somethingToDo) - { - // search for empty providers - for (int i = m_currentProviders.size()-1; i >= 0; i--) - { - if (m_currentProviders.at(i)->getWallpaperList().isEmpty()) - delete m_currentProviders.takeAt(i); - } - - refreshWallpaperProviders(); - } -} - -void SyncWall::on_checkBoxRandomOrder_stateChanged ( int state) -{ - m_randomOrderChange = state; - // update the fixed list of index - computeIndexList(); -} - - -void SyncWall::updateApplicationIdentity() -{ - setWindowTitle(m_appName + " " + m_version); -} - -void SyncWall::updateAbout() -{ - // setup credits ... - updateCredits(); - // setup changelog ... - updateChangelog(); - updateInfosImageFormats(); - updateInfosLanguages(); - labelRelease->setText(m_appName + " " + m_version); -} - -void SyncWall::updateInfosImageFormats() -{ - // update format list - - // clear the current list - listWidgetFormats->clear(); - - QStringList formats = MiscFunctions::getAvailablesImageFormatsList(); - QMap longFormats = MiscFunctions::getLongImageFormats(); - - foreach (const QString &format, formats) - { - if (longFormats.contains(format)) - new QListWidgetItem(longFormats[format] + " (*." + format + ")", listWidgetFormats); - else - new QListWidgetItem(format, listWidgetFormats); - } -} - -void SyncWall::updateInfosLanguages() -{ -// update translation list -const QMap &mapLang = MiscFunctions::getAvailableLanguages(); -QStringList names = mapLang.keys(); -listWidgetTranslations->clear(); -foreach (const QString &lang, names) -{ - QString text; - - if (mapLang[lang] == m_currentLanguage) - text = lang + " *"; - else - text = lang; - - new QListWidgetItem(text, listWidgetTranslations); -} -} - -void SyncWall::searchForWallpaper(const QString &file) -{ - LogHandler::getInstance()->reportInfo(tr("new file received : %1").arg(file)); - - for (int i = 0 ; i < m_listModel->rowCount(); i++) - { - if (m_listModel->getFilename(i).endsWith(file)) - { - m_currentImageIndex = i; - widgetImageParameters->processImage(m_listModel->getFilename(m_currentImageIndex)); - return; - } - } - - LogHandler::getInstance()->reportError(tr("Can't find local file as received : %1").arg(file)); -} - -void SyncWall::blink() -{ - static int i = 0; - - if (i++%2) - checkState(); - else - m_trayIcon->setIcon(QIcon(":/syncwall/mode_idle.png")); - -} - -void SyncWall::changeTrayIcon() -{ - m_trayIcon->setIcon(QIcon(":/syncwall/mode_standard.png")); - m_trayIcon->setIcon(QIcon(":/syncwall/mode_client_connected.png")); - m_trayIcon->setIcon(QIcon(":/syncwall/mode_client_disconnected.png")); - m_trayIcon->setIcon(QIcon(":/syncwall/mode_server.png")); -} - -int SyncWall::getState() -{ - /* - STATE_STANDARD = 0, // scheduling on, no connected client - STATE_IDLE, // scheduling off, no connected client - STATE_SERVER, // connected client - STATE_CLIENT_CONNECTED, // connected to server - STATE_CLIENT_DISCONNECTED, // can't connect to server - STATE_CLIENT_INVALID // connected to server but invalid protocol (version ?) - */ - int state = STATE_STANDARD; - - if (widgetNetworkParameters->getNetworkMode() == NetworkManager::MODE_SERVER) - { - if (widgetNetworkParameters->getClientNb() == 0) // no client - { - if (widgetScheduler->getIntervalBetweenChangeMode()) // change by interval - state = STATE_STANDARD; - else - state = STATE_IDLE; - } - else - state = STATE_SERVER; - } - else // mode client - { - if (widgetNetworkParameters->getState() != QAbstractSocket::UnconnectedState) - { - state = STATE_CLIENT_CONNECTED; - // check for invalid connection not yet defined !! - } - else - { - state = STATE_CLIENT_DISCONNECTED; - } - } - return state; -} - -void SyncWall::initStateDefs() -{ - m_mapToStateDesc[STATE_STANDARD] = tr("Standard state. Scheduling is activated"); - m_mapToStateDesc[STATE_IDLE] = tr("Idle state. No scheduling and no server connection"); - m_mapToStateDesc[STATE_SERVER] = tr("Server state. Al least a client is connected"); - m_mapToStateDesc[STATE_CLIENT_CONNECTED] = tr("Client state. Connected to server"); - m_mapToStateDesc[STATE_CLIENT_DISCONNECTED] = tr("Client state but disconnected from server"); - m_mapToStateDesc[STATE_CLIENT_INVALID] = tr("Client state but the protocol isn't correct. Upgrade client or server !"); - - m_mapToStateIcon[STATE_STANDARD] = ":/syncwall/mode_standard.png"; - m_mapToStateIcon[STATE_IDLE] = ":/syncwall/mode_idle.png"; - m_mapToStateIcon[STATE_SERVER] = ":/syncwall/mode_server.png"; - m_mapToStateIcon[STATE_CLIENT_CONNECTED] = ":/syncwall/mode_client_connected.png"; - m_mapToStateIcon[STATE_CLIENT_DISCONNECTED] = ":/syncwall/mode_client_disconnected.png"; - m_mapToStateIcon[STATE_CLIENT_INVALID] = ":/syncwall/mode_client_invalid.png"; -} - - -void SyncWall::checkState() -{ - int state = getState(); - // update UI labels - labelStateDesc->setText(m_mapToStateDesc[state]); - labelStateImg->setPixmap(QPixmap(m_mapToStateIcon[state])); - // update tray icon - m_trayIcon->setIcon(QIcon(m_mapToStateIcon[state])); - m_trayIcon->setToolTip(m_mapToStateDesc[state]); -} - -void SyncWall::updateChangelog() -{ - fillTextedit("Changelog.txt", textEditChangelog); -} - -void SyncWall::updateCredits() -{ - fillTextedit("CREDITS.txt", textEditCredits); -} - -void SyncWall::fillTextedit(const QString &file, QTextEdit *text) -{ - text->viewport ()->setAutoFillBackground(false); - QStringList paths; - QString filePath; - paths << QApplication::applicationDirPath () + "/" + file; - paths << QApplication::applicationDirPath () + "/../" + file; - paths << QApplication::applicationDirPath () + "/../../" + file; - paths << QApplication::applicationDirPath () + "/../../../" + file; - paths << "/usr/share/syncwall/" + file; - paths << "/usr/local/share/syncwall/" + file; - - - foreach (const QString &path, paths) - { - if (QFileInfo(path).exists()) - { - filePath = path; - break; - } - } - - // perhaps, not found !! - if (QFileInfo(filePath).exists()) - { - QFile file( filePath ); - if( file.open( QIODevice::ReadOnly | QIODevice::Text ) ) - { - text->setText( file.readAll() ); - file.close(); - return; - } - } - text->setText(tr("The %1 file can't be found, sorry ...").arg(file)); -} - -void SyncWall::on_groupBoxHotKey_clicked(bool val) -{ -#ifndef Q_WS_PM // OS/2 - m_useGlobalHotKey = val; - m_shortCut->setEnabled(m_useGlobalHotKey); -#endif -} - -void SyncWall::on_widgetKeySequence_keySequenceChanged(const QKeySequence &seq) -{ -#ifndef Q_WS_PM // OS/2 - m_shortCut->setShortcut(seq); - m_globalHotkey = seq.toString(); -#endif -} - - -void SyncWall::on_checkBoxStartInTray_stateChanged ( int state ) -{ - m_startInTray = state; -} - -void SyncWall::on_checkBoxSplashscreenAtStartup_stateChanged ( int state ) -{ - m_splashscreenAtStartup = state; -} - -void SyncWall::on_checkBoxSplashscreenTransparentBackground_stateChanged ( int state ) -{ - m_splashscreenTransparentBackground = state; -} - -void SyncWall::on_checkBoxStartWithSystem_stateChanged ( int state ) -{ - m_startWithSystem = state; - -#ifdef Q_WS_WIN - QSettings regSettings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat); - - if (m_startWithSystem) - regSettings.setValue(PACKAGE_NAME,QDir::toNativeSeparators(QCoreApplication::applicationFilePath ())); - else - regSettings.remove(PACKAGE_NAME); -#endif -} - -void SyncWall::on_pushButtonViewList_pressed() -{ - m_listModel->setDisplayMode(ListImagesModel::MODE_LIST); - treeViewFiles->resizeColumnToContents(0); - treeViewFiles->setAlternatingRowColors(false); - stackedWidgetFiles->setCurrentIndex(0); // switch to treeview -} - -void SyncWall::on_pushButtonViewDetail_pressed() -{ - m_listModel->setDisplayMode(ListImagesModel::MODE_DETAILS); - treeViewFiles->resizeColumnToContents(0); - treeViewFiles->setAlternatingRowColors(true); - stackedWidgetFiles->setCurrentIndex(0); // switch to treeview -} - -void SyncWall::on_pushButtonViewThumbnail_pressed() -{ - m_listModel->setDisplayMode(ListImagesModel::MODE_ICONS); - treeViewFiles->resizeColumnToContents(0); - treeViewFiles->setAlternatingRowColors(false); - stackedWidgetFiles->setCurrentIndex(1); // switch to iconview -} - -void SyncWall::dragEnterEvent(QDragEnterEvent *event) -{ - if (event->mimeData()->hasUrls()) - event->acceptProposedAction(); -} - -void SyncWall::dropEvent(QDropEvent *event) -{ - if (event->mimeData()->hasUrls()) - { - QList urls = event->mimeData()->urls(); - QStringList files; - QStringList dirs; - for (int i = 0; i < urls.size(); ++i) - { - - if (QFileInfo(urls[i].toLocalFile()).isDir()) - dirs << urls[i].toLocalFile(); - else - files << urls[i].toLocalFile(); - } - - // processing files in a single WallpaperProvider - if (!files.isEmpty()) - { - WallpaperProvider *wp = new WallpaperProvider(files); - m_currentProviders << wp; - updateDisplayedFileList(wp); // update UI - } - - // processing directoriesfiles in a single WallpaperProvider - if (!dirs.isEmpty()) - { - // check if recursive scan - int rep = QMessageBox::question(this, m_appName, - tr("Add all found directories recursively ?"), - QMessageBox::Yes - | QMessageBox::No); - - bool recursiveSearch = (rep == QMessageBox::Yes); - - // check if watch at - rep = QMessageBox::question(this, m_appName, - tr("Watch for modifications in these directories at application startup ?"), - QMessageBox::Yes - | QMessageBox::No); - - bool watchForModification = (rep == QMessageBox::Yes); - - foreach(const QString &dir, dirs) - addDirToProviders(dir,recursiveSearch,watchForModification); - } - - // we have to redefined some properties of WallpaperProvider !!!!! - //load(files); not yet implemented !!! - } -} - -void SyncWall::on_listViewFiles_customContextMenuRequested(const QPoint & pos) -{ - QModelIndex index = listViewFiles->indexAt(pos); - if (index.isValid()) - { - QMenu menu(this); - - // if multi selection => only display the same value on each element - QModelIndexList proxyList = listViewFiles->selectionModel()->selectedRows (); - - actionPreviewImage->setEnabled(false); - actionSetWallpaper->setEnabled(false); - actionDeleteImage->setEnabled(false); - - if (proxyList.size() > 0) - { - actionPreviewImage->setEnabled(true); - actionSetWallpaper->setEnabled(true); - actionDeleteImage->setEnabled(true); - } - - menu.addAction(actionPreviewImage); - menu.addAction(actionSetWallpaper); - menu.addAction(actionDeleteImage); - - menu.exec(listViewFiles->viewport()->mapToGlobal(pos)); - } -} - -void SyncWall::on_treeViewFiles_customContextMenuRequested(const QPoint & pos) -{ - QModelIndex index = treeViewFiles->indexAt(pos); - if (index.isValid()) - { - QMenu menu(this); - - // if multi selection => only display the same value on each element - QModelIndexList proxyList = treeViewFiles->selectionModel()->selectedRows (); - - actionPreviewImage->setEnabled(false); - actionSetWallpaper->setEnabled(false); - actionDeleteImage->setEnabled(false); - - if (proxyList.size() > 0) - { - actionPreviewImage->setEnabled(true); - actionSetWallpaper->setEnabled(true); - actionDeleteImage->setEnabled(true); - } - - menu.addAction(actionPreviewImage); - menu.addAction(actionSetWallpaper); - menu.addAction(actionDeleteImage); - - - menu.exec(treeViewFiles->viewport()->mapToGlobal(pos)); - } -} - -void SyncWall::on_pushButtonResetPreferences_pressed() -{ - // check if recursive scan - int ret = QMessageBox::question(this, m_appName, - tr("Do you want to reset all the preferences to default value ?\n If yes, the application will be relaunch"), - QMessageBox::Yes - | QMessageBox::No); - - if (ret == QMessageBox::Yes) - { - m_resetConfig = true; - restart(); - } -} - -void SyncWall::wakeUp(const QString &mess) -{ - LogHandler::getInstance()->reportWarning(mess); - show(); -} - diff -Nru syncwall-1.6.0/SyncWall/src/SyncWall.h syncwall-1.7.4/SyncWall/src/SyncWall.h --- syncwall-1.6.0/SyncWall/src/SyncWall.h 2012-04-24 09:23:18.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/SyncWall.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,238 +0,0 @@ - -/****************************************************************************** - SyncWall: Wallpaper manager - Copyright(C) 2011-2012 xbee@xbee.net - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *******************************************************************************/ - -#ifndef _SYNCWALL_H_ -#define _SYNCWALL_H_ - -#include -#include -#include - -#include -#include - -#include "ui_SyncWall.h" - -// forward declarations -class Scheduler; -class WallpaperProvider; -#ifndef Q_WS_PM // OS/2 -class QxtGlobalShortcut; -#endif -class ListImagesModel; - -class SyncWall : - public QMainWindow, private Ui::SyncWallClass -{ - Q_OBJECT - -public: - - enum typState - { - STATE_STANDARD = 0, // scheduling on, no connected client - STATE_IDLE, // scheduling off, no connected client - STATE_SERVER, // connected client - STATE_CLIENT_CONNECTED, // connected to server - STATE_CLIENT_DISCONNECTED, // can't connect to server - STATE_CLIENT_INVALID // connected to server but invalid protocol (version ?) - }; - - SyncWall(QWidget *parent = 0, Qt::WFlags flags = 0); - ~SyncWall(); - -public slots: - - void on_pushButtonQuit_pressed(); - - void on_pushButtonAddDirectory_pressed(); - void on_pushButtonAddFiles_pressed(); - void on_pushButtonRefresh_pressed(); - void on_pushButtonDeleteImage_pressed(); - void on_pushButtonClearLog_pressed(); - void on_pushButtonSaveLog_pressed(); - void on_pushButtonSetWallpaper_pressed(); - - void on_actionPreviewImage_triggered(); - void on_actionSetWallpaper_triggered(); - void on_actionDeleteImage_triggered(); - - void on_pushButtonPreview_pressed(); - void on_groupBoxHotKey_clicked(bool val); - - void on_checkBoxRandomOrder_stateChanged ( int ); - void on_actionShowUI_triggered(); - - // preferences - - void closeEvent(QCloseEvent *event); - - void iconActivated(QSystemTrayIcon::ActivationReason reason); - - void printToLog(const QString & mess); - - void selectionChanged(const QItemSelection&, const QItemSelection&); - void changeWallpaper(int index = -1, bool manual = false); - - // slot for network - void searchForWallpaper(const QString &); - - void checkForBlinking(); - void blink(); - - void checkState(); - - void on_widgetKeySequence_keySequenceChanged(const QKeySequence &seq); - void on_checkBoxStartInTray_stateChanged ( int state ); - void on_checkBoxSplashscreenAtStartup_stateChanged ( int state ); - void on_checkBoxSplashscreenTransparentBackground_stateChanged ( int state ); - void on_checkBoxStartWithSystem_stateChanged ( int state ); - - // view list/icon/... - void on_pushButtonViewList_pressed(); - void on_pushButtonViewDetail_pressed(); - void on_pushButtonViewThumbnail_pressed(); - void on_actionQuit_activated(); - void on_actionNextWallpaper_activated(); - void on_actionPreviousWallpaper_activated(); - - void dropEvent(QDropEvent *event); - void dragEnterEvent(QDragEnterEvent *event); - - void on_listViewFiles_customContextMenuRequested(const QPoint & pos); - void on_treeViewFiles_customContextMenuRequested(const QPoint & pos); - void on_treeViewFiles_doubleClicked(const QModelIndex & index); - void on_listViewFiles_doubleClicked(const QModelIndex & index); - - // language - void on_comboBoxLanguage_activated(int); - - // prefs - void on_pushButtonResetPreferences_pressed(); - - void wakeUp(const QString &mess); - - void saveSettings(); - -signals: - - void sigSaveSettings(); - -private: - - void updateUi(); - void updateAbout(); - void updateInfosImageFormats(); - void updateInfosLanguages(); - void updatePrefsLanguage(); - - // setup - void setupGlobalKeys(); - - // settings - - void loadSettings(); - - // tray icon - void createTrayIcon(); - void createActionsSystemTray(); - - QStringList getSubDirectoryList(const QDir & dir); - void refreshWallpaperProviders(bool force = false); - void updateDisplayedFileList(WallpaperProvider *ws); - - int getRandomIndex(); - - void updateApplicationIdentity(); - QString availablesImageFormats(); - QStringList availablesImageFormatsList(); - - void changeTrayIcon(); - - int getState(); - void initStateDefs(); - - void updateCredits(); - void updateChangelog(); - void fillTextedit(const QString &file, QTextEdit *); - void restart(); - - void addDirToProviders(const QString &,bool,bool); - - void checkForSmallInterface(); - - // index - void computeIndexList(); - int getNextImageIndex(); - int getPrevImageIndex(); - - // global key variables - bool m_useGlobalHotKey; - QString m_globalHotkey; -#ifndef Q_WS_PM // OS/2 - QxtGlobalShortcut *m_shortCut; -#endif - - bool m_firstCloseMessage; - - QString m_appName; - QString m_version; - QString m_title; - - QString m_lastDirectory; - QString m_lastFile; - - //QStringList m_listFiles; - - //system tray - QSystemTrayIcon *m_trayIcon; - QMenu *m_trayIconMenu; - - Scheduler *m_scheduler; - int m_logLevel; - bool m_randomOrderChange; - - // preferences - - QList m_currentProviders; - - // display - int m_currentImageIndex; - - QString m_currentLanguage; - QTimer m_blinkTimer; - bool m_blinking; - - QMap m_mapToStateDesc; - QMap m_mapToStateIcon; - - bool m_startInTray; - bool m_splashscreenAtStartup; - bool m_splashscreenTransparentBackground; - bool m_startWithSystem; - - ListImagesModel *m_listModel; - bool m_resetConfig; - - QVector m_listIndex; - int m_currentListIndex; -}; - -#endif // _SYNCWALL_H_ diff -Nru syncwall-1.6.0/SyncWall/src/SystemIntegration.cpp syncwall-1.7.4/SyncWall/src/SystemIntegration.cpp --- syncwall-1.6.0/SyncWall/src/SystemIntegration.cpp 2012-01-29 11:39:00.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/SystemIntegration.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,773 +0,0 @@ - -/****************************************************************************** - SyncWall: Wallpaper manager - Copyright(C) 2011-2012 xbee@xbee.net - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *******************************************************************************/ - -#include -#include -#include -#include - -//#include - -#include "SystemIntegration.h" - -#include "AppSettings.h" -#include "LogHandler.h" -#include "MiscFunctions.h" - -#ifdef Q_WS_WIN // for wallpaper set on windows platform -#include -#endif - -#ifdef Q_WS_MAC -#include -#include -#include -#endif - -#ifdef Q_WS_PM -#define INCL_WINWORKPLACE -#include -#include -#endif - -#if !defined(WIN32) -#include // for unlink -#endif - - -SystemIntegration::SystemIntegration(QObject *parent) - : QObject(parent), - m_desktopType(DESKTOP_UNKNOWN) -{ - loadSettings(); - - // force desktop type for known platform -#if defined(Q_WS_WIN) - m_desktopType = DESKTOP_WINDOWS; -#elif defined(Q_WS_MAC) - m_desktopType = DESKTOP_MACOSX; -#elif defined(Q_WS_PM) - m_desktopType = DESKTOP_OS2; -#endif - - // not yet defined => try auto detect - if (m_desktopType == DESKTOP_UNKNOWN) - m_desktopType = detectCurrentDesktop(); - - LogHandler::getInstance()->reportInfo( tr("Desktop selected: %1").arg( desktopToString(m_desktopType) ) ); - - //m_processRunner.setWorkingDirectory(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); - // connect the process runner - connect( &m_processRunner,SIGNAL( readyReadStandardOutput () ),this,SLOT( readStandardOutput() ) ); - connect( &m_processRunner,SIGNAL( readyReadStandardError () ),this,SLOT( readStandardError() ) ); - connect( &m_processRunner,SIGNAL( finished ( int, QProcess::ExitStatus) ),this,SLOT( finishedProcess( int, QProcess::ExitStatus) ) ); - connect( &m_processRunner,SIGNAL( error (QProcess::ProcessError) ),this,SLOT( errorProcess(QProcess::ProcessError) ) ); - - // for debugging purpose displat the environment variables - QProcessEnvironment currentEnv = QProcessEnvironment::systemEnvironment (); - LogHandler::getInstance()->reportDebug("===================== begin system env ========================="); - foreach( const QString &env, currentEnv.toStringList() ) - LogHandler::getInstance()->reportDebug(env); - LogHandler::getInstance()->reportDebug("===================== end system env ========================="); - - updateDesktopTips(); - - // clean temps storage - QStringList fileFormats = MiscFunctions::getAvailablesImageFormats().split(" "); - MiscFunctions::cleanTempStorage(fileFormats,"dynamic_wallpaper"); -} - -SystemIntegration::~SystemIntegration() -{ - //saveSettings(); -} - -void SystemIntegration::applyImage(const QList &imgs) -{ - QString bgImg; - QString command; - QStringList args; - JobDef job; - - if (imgs.isEmpty()) - return; - - try - { - switch (m_desktopType) - { - case DESKTOP_WINDOWS: - { - bgImg = convertImage(imgs[0],"BMP"); -#ifdef Q_WS_WIN - QSettings appSettings( "HKEY_CURRENT_USER\\Control Panel\\Desktop", QSettings::NativeFormat); - appSettings.setValue( "Wallpaper", QDir::toNativeSeparators(bgImg) ); - appSettings.setValue("WallpaperStyle","0"); - appSettings.setValue("TileWallpaper","1"); - QByteArray ba = bgImg.toLatin1(); - SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, reinterpret_cast( ba.data() ), SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE); -#endif - break; - } - - case DESKTOP_KDE3: - { - bgImg = convertImage(imgs[0],"PNG"); - - //1 = none - //2 = tiled - //3 = center tiled - //4 = centered - //5 = scaled - //6 = stretched - QString wmode = "1"; - job.args << "kdesktop" << "KBackgroundIface" << "setWallpaper" << bgImg << wmode; - job.command = "dcop"; - m_cmdQueue.enqueue(job); - - break; - } - - case DESKTOP_KDE4: - { - int screen = 0; - foreach(const QImage&img, imgs) - bgImg = convertImage(img,"PNG",screen++); - - //1 = none - //2 = tiled - //3 = center tiled - //4 = centered - //5 = scaled - //6 = stretched - QString wmode = "1"; - job.args << "kdesktop" << "KBackgroundIface" << "setWallpaper" << "1" << bgImg << wmode; - job.command = "dbus"; - - //m_cmdQueue.enqueue(job); - LogHandler::getInstance()->reportWarning( tr("KDE4 is currently incompletely supported. Please select %1 as the current wallpaper with \"centered\" parameter (it's just a workaround)").arg(bgImg) ); - - break; - } - - case DESKTOP_GNOME: - { - bgImg = convertImage(imgs[0],"PNG"); - job.args << "--type" << "bool" << "--set" << "/desktop/gnome/background/draw_background" << "true"; - job.command = "gconftool-2"; - m_cmdQueue.enqueue(job); - job.args.clear(); - - job.args << "--type" << "string" << "--set" << "/desktop/gnome/background/picture_options" << "centered"; - job.command = "gconftool-2"; - m_cmdQueue.enqueue(job); - job.args.clear(); - - job.args << "--type" << "string" << "--set" << "/desktop/gnome/background/picture_filename" << bgImg; - job.command = "gconftool-2"; - m_cmdQueue.enqueue(job); - - break; - } - - case DESKTOP_GNOME3: - { - bgImg = convertImage(imgs[0],"PNG"); - - job.args << "set" << "org.gnome.desktop.background" << "draw-background" << "true"; - job.command = "gsettings"; - m_cmdQueue.enqueue(job); - job.args.clear(); - - job.args << "set" << "org.gnome.desktop.background" << "picture-options" << "spanned"; - job.command = "gsettings"; - m_cmdQueue.enqueue(job); - job.args.clear(); - - job.args << "set" << "org.gnome.desktop.background" << "picture-uri" << "\"file://" + bgImg + "\""; - job.command = "gsettings"; - m_cmdQueue.enqueue(job); - - break; - } - - case DESKTOP_XFCE: - { - bgImg = convertImage(imgs[0],"PNG"); - QFile xfceFile(QDir::homePath() + "/.config/xfce4/desktop/backdrops.list"); - - if ( !xfceFile.open(QIODevice::WriteOnly | QIODevice::Text) ) - { - LogHandler::getInstance()->reportError( tr("Can't open %1 ").arg( xfceFile.fileName() ) ); - return; - } - - xfceFile.open(QIODevice::WriteOnly); - QTextStream out; - out.setDevice(&xfceFile); - - out << "# xfce backdrop list" << endl; - out << bgImg << endl; - xfceFile.close(); - - job.args << "--reload"; - job.command = "xfdesktop"; - m_cmdQueue.enqueue(job); - - break; - } - - case DESKTOP_OPENBOX: - case DESKTOP_LXDE: - { - bgImg = convertImage(imgs[0],"PNG"); - - // --desktop-pref Open desktop preference dialog - // --set-wallpaper= Set desktop wallpaper - // --wallpaper-mode= Set mode of desktop wallpaper. - // =(color|stretch|fit|center|tile) - - job.args << "--wallpaper-mode=center"; - job.command = "pcmanfm"; - m_cmdQueue.enqueue(job); - job.args.clear(); - - job.args << "--set-wallpaper=" + bgImg; - job.command = "pcmanfm"; - m_cmdQueue.enqueue(job); - - break; - } - - case DESKTOP_XFCE4: - { - bgImg = convertImage(imgs[0],"PNG"); - - job.args << "set" << "-c" << "xfce4-desktop" << "-p" << "/backdrop/screen0/monitor0/image-path" << "-s" << bgImg; - job.command = "xfconf-query"; - m_cmdQueue.enqueue(job); - job.args.clear(); - - job.args << "set" << "-c" << "xfce4-desktop" << "-p" << "/backdrop/screen0/monitor0/image-style" << "-s" << "centered"; - job.command = "xfconf-query"; - m_cmdQueue.enqueue(job); - - break; - } - - case DESKTOP_FLUXBOX: - { - bgImg = convertImage(imgs[0],"PNG"); - - //-f = stretched - //-c = centered - //-t = tiled - job.args << "-c" << bgImg; - job.command = "fbsetbg"; - m_cmdQueue.enqueue(job); - - break; - } - - case DESKTOP_BLACKBOX: - { - bgImg = convertImage(imgs[0],"PNG"); - - //-full = stretched - //-center = centered - //-tile = tiled - job.args << "-center" << bgImg; - job.command = "bsetbg"; - m_cmdQueue.enqueue(job); - - break; - } - - case DESKTOP_ENLIGHTENMENT: - { - bgImg = convertImage(imgs[0],"PNG"); - - // -c center - job.args << "-c" << bgImg; - job.command = "Esetroot"; - m_cmdQueue.enqueue(job); - - break; - } - - case DESKTOP_ICEWM: - { - bgImg = convertImage(imgs[0],"PNG"); - - // use display from ImageMagick - job.args << "-backdrop" << "-window" << "root" << bgImg; - job.command = "display"; - m_cmdQueue.enqueue(job); - - break; - } - - case DESKTOP_WINDOWMAKER: - { - bgImg = convertImage(imgs[0],"PNG"); - - //-t = tiled - //-e = centered - //-s = scaled - job.args << "-e" << bgImg; - job.command = "wmsetbg"; - m_cmdQueue.enqueue(job); - break; - } - - case DESKTOP_FVWM: - { - bgImg = convertImage(imgs[0],"PNG"); - job.args << bgImg; - job.command = "fvwm-root"; - m_cmdQueue.enqueue(job); - break; - } - - case DESKTOP_MACOSX: - { - // extract from wally, a Qt4 wallpaper/background changer Copyright (C) 2009 Antonio Di Monaco - // I've no mac so I can't test - bgImg = convertImage(imgs[0],"PNG"); - - QFile scriptFile(MiscFunctions::getValidStorage() + "/syncwall.scpt"); - QTextStream scriptText(&scriptFile); - - scriptFile.open(QIODevice::WriteOnly); -#ifdef Q_WS_MAC - - if (QSysInfo::MacintoshVersion == QSysInfo::MV_10_6) - { - scriptText << "tell application \"System Events\"" << endl; - scriptText << "set picture of every desktop to POSIX file \"" << bgImg << "\"" << endl; - scriptText << "end tell" << endl; - } - else - { - scriptText << "tell application \"Finder\"" << endl; - scriptText << "set desktop picture to POSIX file \"" << bgImg << "\"" << endl; - scriptText << "end tell" << endl; - } - -#endif - scriptFile.close(); - - job.args << QDir::toNativeSeparators(MiscFunctions::getValidStorage() + "/syncwall.scpt"); - job.command = "osascript"; - m_cmdQueue.enqueue(job); - - break; - } - - case DESKTOP_OS2: - { - bgImg = convertImage(imgs[0],"BMP",0,true); -#ifdef Q_WS_PM - HOBJECT hobj; - const char *objName = ""; - - if ( hobj = WinQueryObject( reinterpret_cast< const unsigned char * > (objName) ) ) - { - WinSetObjectData( hobj,reinterpret_cast< const unsigned char * > ( ( QString("BACKGROUND=%1,S,1,I;").arg( QDir::toNativeSeparators(bgImg) ) ).toStdString().c_str() ) ); - } - else - { - LogHandler::getInstance()->reportDebug( QString ("Can't find object with name (%1)").arg(objName) ); - } - -// The first parameter after = is the file name, obviously. -// Replace the 2nd parameter (N) with S or T to Scale or Tile. -// The third parameter is the scale factor if needed. -// The fourth parameter is I for image or C for colour. -// The fifth parameter (only used for C and not shown here) is an RGB string e.g. 128 128 128 -// -// if (hobj = WinQueryObject("")) -// WinSetObjectData(hobj, "BACKGROUND=c:\\path\\image.bmp,N,1,I;"); - -#endif - break; - } - - default: - {} - } - - startNextJob(); - } - catch (...) - { - LogHandler::getInstance()->reportError( tr("SystemIntegration::applyImage: Problem during saving of temp image %1 !!").arg(bgImg) ); - } -} - -QString SystemIntegration::convertImage(const QImage &img, const QString &format, int screenNum, bool roundrobin) -{ - static int count = 0; - LogHandler::getInstance()->reportDebug( tr("Convert QImage to %1").arg(format) ); - - QString bgpath = QDir::toNativeSeparators( MiscFunctions::getValidStorage() + "/dynamic_wallpaper" + QString::number(screenNum) + "." + format.toLower() ); - - if (roundrobin) // workaround for some wm (the file name must change each time) - { - if (!m_lastCreatedFile.isEmpty()) - unlink(m_lastCreatedFile.toStdString().c_str()); - - // add a "random" value to the filename - m_lastCreatedFile = bgpath.replace( QString(".%1").arg( format.toLower() ),QString("-%1.%2").arg(qrand()).arg( format.toLower() ) ); - } - - LogHandler::getInstance()->reportDebug( tr("Saving temp file (%1)").arg(bgpath) ); - - if ( !img.save(bgpath) ) - LogHandler::getInstance()->reportInfo( tr("Failed to save temp file (%1)").arg(bgpath) ); - - count++; - return bgpath; -} - -void SystemIntegration::loadSettings() -{ - AppSettings settings; - - settings.beginGroup("SystemIntegration"); - - m_desktopType = settings.value("desktopType",DESKTOP_UNKNOWN).toInt(); - - settings.endGroup(); -} - -void SystemIntegration::saveSettings() -{ - AppSettings settings; - - settings.beginGroup("SystemIntegration"); - - settings.setValue("desktopType", m_desktopType); - - settings.endGroup(); -} - -QString SystemIntegration::desktopToString(int val) -{ - QString desktop; - - switch (val) - { - case DESKTOP_KDE3: - desktop = QObject::tr("KDE3 desktop"); - break; - - case DESKTOP_KDE4: - desktop = QObject::tr("KDE4 desktop"); - break; - - case DESKTOP_GNOME: - desktop = QObject::tr("GNOME desktop"); - break; - - case DESKTOP_GNOME3: - desktop = QObject::tr("GNOME3 desktop"); - break; - - case DESKTOP_XFCE: - desktop = QObject::tr("XFCE desktop"); - break; - - case DESKTOP_XFCE4: - desktop = QObject::tr("XFCE4 desktop"); - break; - - case DESKTOP_FLUXBOX: - desktop = QObject::tr("FLUXBOX desktop"); - break; - - case DESKTOP_BLACKBOX: - desktop = QObject::tr("BLACKBOX desktop"); - break; - - case DESKTOP_ENLIGHTENMENT: - desktop = QObject::tr("Enlightenment desktop"); - break; - - case DESKTOP_ICEWM: - desktop = QObject::tr("ICEWM desktop"); - break; - - case DESKTOP_OPENBOX: - desktop = QObject::tr("OPENBOX desktop"); - break; - - case DESKTOP_LXDE: - desktop = QObject::tr("LXDE desktop"); - break; - - case DESKTOP_WINDOWMAKER: - desktop = QObject::tr("WINDOWMAKER desktop"); - break; - - case DESKTOP_FVWM: - desktop = QObject::tr("FVWM desktop"); - break; - - case DESKTOP_WINDOWS: - desktop = QObject::tr("WINDOWS desktop"); - break; - - case DESKTOP_MACOSX: - desktop = QObject::tr("MACOSX desktop"); - break; - - case DESKTOP_OS2: - desktop = QObject::tr("OS/2 desktop"); - break; - - case DESKTOP_UNKNOWN: - desktop = QObject::tr("Automatic detection"); - break; - - default: - desktop = QObject::tr("No Desktop Environment Detected"); - break; - } - - return desktop; -} - -//---------------------------------------------------------------- -// detectCurrentDesktop is adapted from -// AutoWallpaper 2.1 (Linux) - version 2.1.2.x RC 1 -// Tyler Jones - May 2009 -//---------------------------------------------------------------- - -int SystemIntegration::detectCurrentDesktop() -{ - bool ok; - desktopType temp = DESKTOP_UNKNOWN; - - // force desktop type for known platform -#if defined(Q_WS_WIN) - temp = DESKTOP_WINDOWS; -#elif defined(Q_WS_MAC) - temp = DESKTOP_MACOSX; -#elif defined(Q_WS_PM) - temp = DESKTOP_OS2; -#endif - - QFileInfoList files = QDir("/proc").entryInfoList(QDir::AllDirs | QDir::NoDotAndDotDot); - QListIterator file(files); - int count = 0; - - while ( file.hasNext() && (temp == DESKTOP_UNKNOWN) ) - { - if ( count > files.size() ) // sometimes this loop is infinite ???? - { - LogHandler::getInstance()->reportError( tr("loop detected during environment processing => skip") ); - break; - } - - file.peekNext().fileName().toInt(&ok); - - if (ok) - { - if ( QFileInfo(file.peekNext().absoluteFilePath() + "/exe").symLinkTarget().contains("kdeinit") && - !QFileInfo(file.peekNext().absoluteFilePath() + "/exe").symLinkTarget().contains("kdeinit4") ) - { - LogHandler::getInstance()->reportDebug( tr("detectCurrentDesktop => Detected: KDE3") ); - temp = DESKTOP_KDE3; - } - else if ( QFileInfo(file.peekNext().absoluteFilePath() + "/exe").symLinkTarget().contains("kdeinit4") ) - { - LogHandler::getInstance()->reportDebug( tr("detectCurrentDesktop => Detected: KDE4") ); - temp = DESKTOP_KDE4; - } - else if ( QFileInfo(file.peekNext().absoluteFilePath() + "/exe").symLinkTarget().contains("gconfd-2") ) - { - LogHandler::getInstance()->reportDebug( tr("detectCurrentDesktop => Detected: Gnome") ); - temp = DESKTOP_GNOME; - - // check if gnome 2 or 3 - QString version = MiscFunctions::launchExternalSynchronousProcess("gnome-session", QStringList() << "--version"); - LogHandler::getInstance()->reportDebug( tr("detectCurrentDesktop => Gnome version %1").arg(version) ); - - if ( !version.isEmpty() && version.contains(" ") ) - { - QStringList list = version.split(" "); - - if ( list.size() > 1 && list[1].startsWith("3") ) - temp = DESKTOP_GNOME3; - } - } - else if ( QFileInfo(file.peekNext().absoluteFilePath() + "/exe").symLinkTarget().contains("xfdesktop") ) - { - LogHandler::getInstance()->reportDebug( tr("detectCurrentDesktop => Detected: Xfce") ); - temp = DESKTOP_XFCE; - } - else if ( QFileInfo(file.peekNext().absoluteFilePath() + "/exe").symLinkTarget().contains("xfdesktop") ) // not yet functional !!! - { - LogHandler::getInstance()->reportDebug( tr("detectCurrentDesktop => Detected: Xfce4") ); - temp = DESKTOP_XFCE4; - } - else if ( QFileInfo(file.peekNext().absoluteFilePath() + "/exe").symLinkTarget().contains("fluxbox") ) - { - LogHandler::getInstance()->reportDebug( tr("detectCurrentDesktop => Detected: Fluxbox") ); - temp = DESKTOP_FLUXBOX; - } - else if ( QFileInfo(file.peekNext().absoluteFilePath() + "/exe").symLinkTarget().contains("fvwm") ) - { - LogHandler::getInstance()->reportDebug( tr("detectCurrentDesktop => Detected: FVWM") ); - temp = DESKTOP_FVWM; - } - else if ( QFileInfo(file.peekNext().absoluteFilePath() + "/exe").symLinkTarget().contains("blackbox") ) - { - LogHandler::getInstance()->reportDebug( tr("detectCurrentDesktop => Detected: Blackbox") ); - temp = DESKTOP_BLACKBOX; - } - else if ( QFileInfo(file.peekNext().absoluteFilePath() + "/exe").symLinkTarget().contains("wmaker") ) - { - LogHandler::getInstance()->reportDebug( tr("detectCurrentDesktop => Detected: WindowMaker") ); - temp = DESKTOP_WINDOWMAKER; - } - - file.next(); - } - } - - if (temp == DESKTOP_UNKNOWN) - LogHandler::getInstance()->reportError( tr("No Desktop Environment Detected") ); - - return temp; -} - -void SystemIntegration::errorProcess( QProcess::ProcessError error) -{ - QString mess; - - switch (error) - { - case QProcess::FailedToStart: - { - mess = tr("SystemIntegration: The process failed to start. Either the invoked program is missing, or you may have insufficient permissions to invoke the program."); - break; - } - - case QProcess::Crashed: - { - mess = tr("SystemIntegration: The process crashed some time after starting successfully."); - break; - } - - case QProcess::Timedout: - { - mess = tr("SystemIntegration: The last waitFor...() function timed out. The state of QProcess is unchanged, and you can try calling waitFor...() again."); - break; - } - - case QProcess::WriteError: - { - mess = tr("SystemIntegration: An error occurred when attempting to write to the process. For example, the process may not be running, or it may have closed its input channel."); - break; - } - - case QProcess::ReadError: - { - mess = tr("SystemIntegration: An error occurred when attempting to read from the process. For example, the process may not be running."); - break; - } - - case QProcess::UnknownError: - { - mess = tr("SystemIntegration: An unknown error occurred. This is the default return value of error()."); - break; - } - } - - LogHandler::getInstance()->reportError( mess ); - startNextJob(); -} - -void SystemIntegration::readStandardError() -{ - LogHandler::getInstance()->reportError( m_processRunner.readAllStandardError() ); -} - -void SystemIntegration::readStandardOutput() -{ - QString temp = m_processRunner.readAllStandardOutput(); - LogHandler::getInstance()->reportInfo(temp); -} - -void SystemIntegration::finishedProcess( int /*exitCode*/, QProcess::ExitStatus exitStatus ) -{ - switch (exitStatus) - { - case QProcess::NormalExit: - { - LogHandler::getInstance()->reportInfo( tr("The command exited normally.") ); - break; - } - - case QProcess::CrashExit: - { - LogHandler::getInstance()->reportError( tr("The command crashed.") ); - break; - } - } - - startNextJob(); -} - -void SystemIntegration::startNextJob() -{ - // process already running - if (m_processRunner.state () != QProcess::NotRunning) - { - LogHandler::getInstance()->reportDebug("process already running, waiting ..."); - return; - } - - // no job in queue, exiting ... - if ( m_cmdQueue.isEmpty() ) - return; - - m_currJob = m_cmdQueue.dequeue(); - LogHandler::getInstance()->reportDebug( tr("Running ") + m_currJob.command + " " + m_currJob.args.join(" ") ); - m_processRunner.start(m_currJob.command, m_currJob.args); -} - -QString SystemIntegration::getDesktopTips(int index) -{ - if (m_desktopTips.contains(index)) - return m_desktopTips[index]; - else - return ""; -} - -void SystemIntegration::updateDesktopTips() -{ - for (int i = DESKTOP_UNKNOWN; i < DESKTOP_TYPE_NUMBER; i++) - m_desktopTips[i] = ""; - m_desktopTips[DESKTOP_KDE4] = tr("Tips: KDE4 is currently incompletely supported. Please select the generated wallpaper in plasma with \"centered\" parameter (it's just a workaround). For multi monitor with KDE activities, you can create a splitted wallpaper (one file by monitor) by selecting the right option in the \"Image parameters\" panel."); -} - diff -Nru syncwall-1.6.0/SyncWall/src/SystemIntegration.h syncwall-1.7.4/SyncWall/src/SystemIntegration.h --- syncwall-1.6.0/SyncWall/src/SystemIntegration.h 2012-01-29 11:20:56.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/SystemIntegration.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,120 +0,0 @@ - -/****************************************************************************** - SyncWall: Wallpaper manager - Copyright(C) 2011-2012 xbee@xbee.net - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *******************************************************************************/ - -#ifndef _SYSTEMINTEGRATION_H_ -#define _SYSTEMINTEGRATION_H_ - -#include -#include -#include -#include -#include -#include - -typedef struct -{ - QString command; - QStringList args; -} JobDef; - -class SystemIntegration : - public QObject -{ - Q_OBJECT - -public: - -// enum Desktop type - enum desktopType - { - DESKTOP_UNKNOWN = 0, - DESKTOP_KDE3, - DESKTOP_KDE4, - DESKTOP_GNOME, - DESKTOP_GNOME3, - DESKTOP_XFCE, - DESKTOP_XFCE4, - DESKTOP_FLUXBOX, - DESKTOP_ICEWM, - DESKTOP_BLACKBOX, - DESKTOP_OPENBOX, - DESKTOP_LXDE, - DESKTOP_WINDOWMAKER, - DESKTOP_ENLIGHTENMENT, - DESKTOP_FVWM, // end Unix desktop - DESKTOP_WINDOWS, // XP, VISTA, SEVEN - DESKTOP_MACOSX, // MAC OSX - DESKTOP_OS2, // OS/2 - DESKTOP_TYPE_NUMBER - }; - - SystemIntegration(QObject *parent = 0); - ~SystemIntegration(); - - QString desktopToString(int val); - int detectCurrentDesktop(); - - QString getDesktopTips(int); - - void setDesktopType(int type) - { - m_desktopType = type; - } - - int getDesktopType() const - { - return m_desktopType; - } - -public slots: - - void applyImage(const QList &); - -//! process errors from QProcess (python script) - void errorProcess( QProcess::ProcessError error); - -//! read the std output errors (output from the script running) - void readStandardError(); - -//! read the std output (output from the script running) - void readStandardOutput(); - -//! called at the end of the script - void finishedProcess( int exitCode, QProcess::ExitStatus exitStatus ); - - void saveSettings(); - -private: - - void loadSettings(); - - QString convertImage(const QImage &img, const QString &format, int screenNum = 0, bool flipflop = false); - void startNextJob(); - void updateDesktopTips(); - - int m_desktopType; - QProcess m_processRunner; - QQueue m_cmdQueue; - JobDef m_currJob; - QMap m_desktopTips; - QString m_lastCreatedFile; -}; - -#endif // _SYSTEMINTEGRATION_H_ diff -Nru syncwall-1.6.0/SyncWall/src/SystemIntegrationConfigWidget.cpp syncwall-1.7.4/SyncWall/src/SystemIntegrationConfigWidget.cpp --- syncwall-1.6.0/SyncWall/src/SystemIntegrationConfigWidget.cpp 2012-01-29 11:33:04.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/SystemIntegrationConfigWidget.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ -/****************************************************************************** -SyncWall: Wallpaper manager -Copyright(C) 2011-2012 xbee@xbee.net - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*******************************************************************************/ -#include "SystemIntegrationConfigWidget.h" - -SystemIntegrationConfigWidget::SystemIntegrationConfigWidget(QWidget *parent) - : QWidget(parent) -{ - setupUi(this); - - // hide linux settings -#ifndef Q_WS_X11 - groupBoxDesktop->hide(); -#endif - - updateUI(); -} - -SystemIntegrationConfigWidget::~SystemIntegrationConfigWidget() -{ - -} - -void SystemIntegrationConfigWidget::updateUI() -{ - for (int i = SystemIntegration::DESKTOP_UNKNOWN; i <= SystemIntegration::DESKTOP_FVWM; i++) - { - comboBoxDesktop->addItem(m_system.desktopToString(i),i); - if (m_system.getDesktopType() == i) - comboBoxDesktop->setCurrentIndex(i); - } - // update the tips if exists ... - labelTipsSystem->setText(m_system.getDesktopTips(m_system.getDesktopType())); - - // auto detect display - labelDetectedDesktop->setText(tr("detected desktop: %1").arg(m_system.desktopToString(m_system.detectCurrentDesktop()))); -} - -void SystemIntegrationConfigWidget::on_comboBoxDesktop_activated(int index) -{ - m_system.setDesktopType(comboBoxDesktop->itemData(index).toInt()); - // update the tips if exists ... - labelTipsSystem->setText(m_system.getDesktopTips(m_system.getDesktopType())); -} - -void SystemIntegrationConfigWidget::applyWallpaper(const QImage &file) -{ - m_system.applyImage(QList() << file); -} - -void SystemIntegrationConfigWidget::applyWallpaper(const QList &files) -{ - m_system.applyImage(files); -} - -void SystemIntegrationConfigWidget::saveSettings() -{ - m_system.saveSettings(); -} diff -Nru syncwall-1.6.0/SyncWall/src/SystemIntegrationConfigWidget.h syncwall-1.7.4/SyncWall/src/SystemIntegrationConfigWidget.h --- syncwall-1.6.0/SyncWall/src/SystemIntegrationConfigWidget.h 2012-01-29 11:33:06.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/SystemIntegrationConfigWidget.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ - -/****************************************************************************** - SyncWall: Wallpaper manager - Copyright(C) 2011-2012 xbee@xbee.net - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *******************************************************************************/ - -#ifndef _SYSTEMINTEGRATIONCONFIGWIDGET_H_ -#define _SYSTEMINTEGRATIONCONFIGWIDGET_H_ - -#include -#include "ui_SystemIntegrationConfigWidget.h" - -#include "SystemIntegration.h" - -class SystemIntegrationConfigWidget : - public QWidget, public Ui::SystemIntegrationConfigWidget -{ - Q_OBJECT - -public: - - SystemIntegrationConfigWidget(QWidget *parent = 0); - ~SystemIntegrationConfigWidget(); - -public slots: - - void on_comboBoxDesktop_activated(int index); - void applyWallpaper(const QImage &); - void applyWallpaper(const QList &); - - void saveSettings(); - -private: - - void updateUI(); - - SystemIntegration m_system; -}; - -#endif // _SYSTEMINTEGRATIONCONFIGWIDGET_H_ diff -Nru syncwall-1.6.0/SyncWall/src/TcpClient.cpp syncwall-1.7.4/SyncWall/src/TcpClient.cpp --- syncwall-1.6.0/SyncWall/src/TcpClient.cpp 2012-02-08 15:10:20.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/TcpClient.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,294 +0,0 @@ - -#include -#include -#include - -#include "TcpClient.h" -#include "LogHandler.h" - -static quint32 const PAYLOADSIZE = 65536; - -//status strings -static const QString INACTIVE_STRING = "inactive"; -static const QString LISTENING_STRING = "listening"; -static const QString CONNECTING_STRING = "connecting"; -static const QString NEGOTIATING_STRING = "negotiating"; -static const QString SENDING_STRING = "sending"; -static const QString RECEIVING_STRING = "receiving"; -static const QString FINISHED_STRING = "finished"; -static const QString UNKNOWN_STRING = "unknown"; - -//--------------------------------------------------------------------------------------------- -TcpClient::TcpClient(QObject *parent) : - QObject(parent), - m_file(0) -{ - m_socket = new QTcpSocket(this); - - m_timeOutCounter = 0; - m_connectionTimer = new QTimer(this); - - QObject::connect( m_socket, SIGNAL( connected() ), - this, SLOT( on_socketConnected() ) ); - - QObject::connect( m_socket, SIGNAL( bytesWritten(qint64) ), - this, SLOT( updateClientProgress(qint64) ) ); - - QObject::connect( m_socket, SIGNAL( disconnected() ), - this, SLOT( on_socketDisconnected() ) ); - - QObject::connect( m_connectionTimer, SIGNAL( timeout() ), - this, SLOT( timeout() ) ); -} - -//--------------------------------------------------------------------------------------------- -TcpClient::~TcpClient() -{ - delete m_socket; -} - -//--------------------------------------------------------------------------------------------- -QString TcpClient::getStateAsString(quint8 state) -{ - QString state_string = ""; - - switch(state) - { - case INACTIVE: - state_string = INACTIVE_STRING; - break; - - case CONNECTING: - state_string = CONNECTING_STRING; - break; - - case NEGOTIATING: - state_string = NEGOTIATING_STRING; - break; - - case SENDING: - state_string = SENDING_STRING; - break; - - case FINISHED: - state_string = FINISHED_STRING; - break; - - default: - state_string = UNKNOWN_STRING; - } - - return state_string; -} - -//--------------------------------------------------------------------------------------------- -void TcpClient::setState(quint8 new_state) -{ - m_currentState = new_state; - LogHandler::getInstance()->reportInfo( tr("Client: State changed to '%1'").arg( getStateAsString(new_state) ) ); - - switch(m_currentState) - { - case INACTIVE: - - m_bytesWritten = 0; - m_blockSize = 0; - m_connectionTimer->stop(); - m_tempBytesWritten = 0; - m_timeOutCounter = 0; - - if(m_socket) - m_socket->abort(); - - if( m_file && m_file->isOpen() ) - m_file->close(); - - break; - - case CONNECTING: - - break; - - case NEGOTIATING: - break; - - case SENDING: - break; - } - - emit stateChanged(new_state); -} - -//--------------------------------------------------------------------------------------------- -void TcpClient::timeout() -{ - quint32 speed = (m_bytesWritten - m_tempBytesWritten) >> 10; - m_tempBytesWritten = m_bytesWritten; - - if(speed > 0) - { - m_timeOutCounter = 0; - } - else - { - if(++m_timeOutCounter == m_timeOut) - { - LogHandler::getInstance()->reportInfo( tr("Client: Connection timed out") ); - setState(INACTIVE); - } - } -} - -//--------------------------------------------------------------------------------------------- -void TcpClient::updateClientProgress(qint64 num_bytes) -{ - if(m_currentState != SENDING) - return; - - m_bytesWritten += (int)num_bytes; - - if(m_bytesToWrite > 0) - { - m_fileBlock = m_file->read(PAYLOADSIZE); - m_bytesToWrite -= (int)m_socket->write( m_fileBlock.left( qMin(m_bytesToWrite, PAYLOADSIZE) ) ); - } - - if(m_bytesWritten >= m_fileSize) - { - setState(FINISHED); - LogHandler::getInstance()->reportInfo( tr("Client: File transfer complete") ); - setState(INACTIVE); - } -} - -//--------------------------------------------------------------------------------------------- -void TcpClient::on_socketConnected() -{ - LogHandler::getInstance()->reportInfo( tr("Client: Connection to server established") ); - setState(NEGOTIATING); - - sendFileInformation(); - - QObject::connect( m_socket, SIGNAL( readyRead() ), - this, SLOT( readMessage() ) ); -} - -//--------------------------------------------------------------------------------------------- -void TcpClient::sendFileInformation() -{ - QString filepath; // = filename_textbox_->text(); - QString filename = filepath; - QFile file(filepath); - - if( !file.exists() ) - { - LogHandler::getInstance()->reportError( tr("Client: File '%1' does not exist").arg(filepath) ); - setState(INACTIVE); - return; - } - - //extract filename only (without the path) - int index = filename.lastIndexOf('/'); - - if(index != -1) - filename = filename.right(filename.length() - index - 1); - - //send the file information - QByteArray block; - QDataStream out(&block, QIODevice::WriteOnly); - quint32 filesize = file.size(); - - out.setVersion(QDataStream::Qt_4_0); - out << (quint16)0; - out << (quint8)'I' << filename << filesize; - out.device()->seek(0); - out << (quint16)( block.size() - sizeof(quint16) ); - - m_socket->write(block); - - m_connectionTimer->start(1000); - - LogHandler::getInstance()->reportInfo( tr("Client: File information sent to server") ); -} - -//--------------------------------------------------------------------------------------------- -void TcpClient::sendFile() -{ - QString filepath; // = filename_textbox_->text(); - m_file = new QFile(filepath); - - if( !m_file->open(QIODevice::ReadOnly) ) - { - LogHandler::getInstance()->reportError( tr("Client: Error reading file '%1'").arg(filepath) ); - setState(INACTIVE); - return; - } - - m_timeOutCounter = 0; - m_tempBytesWritten = 0; - - //m_connectionTimer->start(1000); - - LogHandler::getInstance()->reportInfo( tr("Client: Starting file transfer ...") ); - setState(SENDING); - - m_fileSize = m_file->size(); - m_fileBlock = m_file->read(PAYLOADSIZE); - - m_bytesToWrite = m_fileSize - (int)m_socket->write(m_fileBlock); -} - -//--------------------------------------------------------------------------------------------- -void TcpClient::readMessage() -{ - QDataStream in(m_socket); - in.setVersion(QDataStream::Qt_4_0); - - if(m_blockSize == 0) - { - if( m_socket->bytesAvailable() < (int)sizeof(quint16) ) - return; - - in >> m_blockSize; - } - - if(m_socket->bytesAvailable() < m_blockSize) - return; - - quint8 message_type; - in >> message_type; - - if(m_currentState == NEGOTIATING) - { - switch(message_type) - { - case 'A': //Peer accepted the file - LogHandler::getInstance()->reportInfo( tr("Client: Sever accepted the file") ); - sendFile(); - break; - - default: - if(m_currentState != NEGOTIATING) - LogHandler::getInstance()->reportError( tr("Received unknown message type: %1").arg(message_type) ); - } - } -} - -//--------------------------------------------------------------------------------------------- -void TcpClient::on_socketError(int socket_error) -{ - LogHandler::getInstance()->reportError( tr("Unable to connect: %1.").arg( m_socket->errorString() ) ); - - setState(INACTIVE); -} - -//--------------------------------------------------------------------------------------------- -void TcpClient::on_socketDisconnected() -{ - if( (m_currentState == NEGOTIATING || m_currentState == SENDING) ) - { - LogHandler::getInstance()->reportError( tr("Client: Connection closed. Transfer aborted.") ); - } - - setState(INACTIVE); -} diff -Nru syncwall-1.6.0/SyncWall/src/TcpClient.h syncwall-1.7.4/SyncWall/src/TcpClient.h --- syncwall-1.6.0/SyncWall/src/TcpClient.h 2012-02-08 15:10:20.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/TcpClient.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ - -#ifndef _TCPCLIENT_H_ -#define _TCPCLIENT_H_ - -#include - -class QTcpSocket; -class QTimer; -class QFile; - -class TcpClient : - public QObject -{ - Q_OBJECT - -public: - - enum States - { - INACTIVE, - CONNECTING, - NEGOTIATING, - SENDING, - FINISHED - }; - - TcpClient(QObject *parent = 0); - - virtual ~TcpClient(); - - QString getStateAsString(quint8 state); - - -signals: - - void stateChanged(quint8 new_state); - - -private slots: - - void updateClientProgress(qint64 num_bytes); - void timeout(); - void readMessage(); - void on_socketConnected(); - void on_socketError(int socket_error); - void on_socketDisconnected(); - -private: - - //------------------------ - - void setState(quint8 new_state); - void sendFileInformation(); - void sendFile(); - - QTcpSocket *m_socket; - quint8 m_currentState; - quint16 m_blockSize; - quint32 m_bytesWritten; - quint32 m_bytesToWrite; - quint32 m_fileSize; - QByteArray m_fileBlock; - QFile *m_file; - - //timeout variables------- - quint32 m_tempBytesWritten; - quint16 m_timeOut; - quint16 m_timeOutCounter; - QTimer *m_connectionTimer; - -}; - -#endif // _TCPCLIENT_H_ diff -Nru syncwall-1.6.0/SyncWall/src/TcpServer.cpp syncwall-1.7.4/SyncWall/src/TcpServer.cpp --- syncwall-1.6.0/SyncWall/src/TcpServer.cpp 2012-02-08 14:33:20.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/TcpServer.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,403 +0,0 @@ - -/****************************************************************************** - SyncWall: Wallpaper manager - Copyright(C) 2011-2012 xbee@xbee.net - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *******************************************************************************/ - -#include "TcpServer.h" -#include "LogHandler.h" - -#include -#include - -static quint32 const PAYLOADSIZE = 65536; - -//status strings -static const QString INACTIVE_STRING = "inactive"; -static const QString LISTENING_STRING = "listening"; -static const QString CONNECTING_STRING = "connecting"; -static const QString NEGOTIATING_STRING = "negotiating"; -static const QString SENDING_STRING = "sending"; -static const QString RECEIVING_STRING = "receiving"; -static const QString FINISHED_STRING = "finished"; -static const QString UNKNOWN_STRING = "unknown"; - -//--------------------------------------------------------------------------------------------- -TcpServer::TcpServer(QObject *parent) - : QObject(parent) -{ - m_server = new QTcpServer(parent); - m_connectionTimer = new QTimer(this); - m_file = 0; - m_socket = 0; - m_port = 0; - m_timeOutCounter = 0; - m_timeOut = 10; //FIXXXME: Should be set by the user - - QObject::connect(m_server, SIGNAL(newConnection()), - this, SLOT(on_server__newConnection())); - - QObject::connect(m_connectionTimer, SIGNAL(timeout()), - this, SLOT(timeout())); - - m_currentState = 0; - m_reverseConnection = false; -} - -//--------------------------------------------------------------------------------------------- -TcpServer::~TcpServer() -{ - if(m_server) - delete m_server; -} - -//--------------------------------------------------------------------------------------------- -QString TcpServer::getStateAsString(quint8 state) -{ - QString state_string = ""; - - switch(state) - { - case INACTIVE: - state_string = INACTIVE_STRING; - break; - - case LISTENING: - state_string = LISTENING_STRING; - break; - - case CONNECTING: - state_string = CONNECTING_STRING; - break; - - case NEGOTIATING: - state_string = NEGOTIATING_STRING; - break; - - case RECEIVING: - state_string = RECEIVING_STRING; - break; - - case FINISHED: - state_string = FINISHED_STRING; - break; - - default: - state_string = UNKNOWN_STRING; - } - - return state_string; -} - -//--------------------------------------------------------------------------------------------- -bool TcpServer::start(quint16 port) -{ - m_port = port; - - if(m_reverseConnection) - { - LogHandler::getInstance()->reportInfo( tr("TcpServer: Initiating reverse connection") ); - - if(!m_socket) - m_socket = new QTcpSocket(this); - - QObject::connect(m_socket, SIGNAL(connected()), - this, SLOT(on_socketConnected())); - QObject::connect(m_socket, SIGNAL(readyRead()), - this, SLOT(readMessage())); - QObject::connect(m_socket, SIGNAL(disconnected()), - this, SLOT(on_socketDisconnected())); - - QString target; // = parent_->getTargetReceiveCombobox()->lineEdit()->text(); - - //if(parent_->isIP(target)) - // m_socket->connectToHost(QHostAddress(target), m_port); - //else - m_socket->connectToHost(target, m_port); - } - else - { - while(!m_server->isListening() && !m_server->listen(QHostAddress::Any, m_port)) - { - LogHandler::getInstance()->reportInfo( tr("TcpServer: Unable to start the server: %1").arg(m_server->errorString()) ); - return false; - } - - LogHandler::getInstance()->reportInfo( tr("TcpServer: Starting server...") ); - } - - m_blockSize = 0; - m_bytesReceived = 0; - m_tempBytesReceived = 0; - - setState(LISTENING); - return true; -} - -//--------------------------------------------------------------------------------------------- -void TcpServer::stop() -{ - if(m_server->isListening()) - m_server->close(); - - setState(INACTIVE); - LogHandler::getInstance()->reportInfo( tr("TcpServer: TcpServer stopped") ); -} - -//--------------------------------------------------------------------------------------------- -void TcpServer::timeout() -{ - quint32 speed = (m_bytesReceived - m_tempBytesReceived) >> 10; - m_tempBytesReceived = m_bytesReceived; - - if(speed > 0) - { - m_timeOutCounter = 0; - } - else - { - if(++m_timeOutCounter == m_timeOut) - { - LogHandler::getInstance()->reportInfo( tr("TcpServer: Connection timed out") ); - abort(); - } - } -} - -//--------------------------------------------------------------------------------------------- -void TcpServer::abort() -{ - if(m_currentState == RECEIVING && m_file->exists()) - m_file->remove(); - - stop(); -} - -//--------------------------------------------------------------------------------------------- -QString TcpServer::errorString() const -{ - return m_server->errorString(); -} - -//--------------------------------------------------------------------------------------------- -void TcpServer::setState(quint8 new_state) -{ - m_currentState = new_state; - LogHandler::getInstance()->reportInfo( tr("TcpServer: State changed to '%1'").arg(getStateAsString(new_state)) ); - - switch(m_currentState) - { - case INACTIVE: - if(m_socket) - m_socket->abort(); - - if(m_file) - { - m_file->close(); - delete m_file; - m_file = 0; - } - - m_saveFilename = ""; - m_fileSize = 0; - m_blockSize = 0; - - m_connectionTimer->stop(); - m_tempBytesReceived = 0; - m_timeOutCounter = 0; - - break; - - case RECEIVING: - - break; - - default: - break; - } - - emit stateChanged(new_state); -} - -//--------------------------------------------------------------------------------------------- -void TcpServer::on_server__newConnection() -{ - if(m_socket) - delete m_socket; - - m_socket = m_server->nextPendingConnection(); - LogHandler::getInstance()->reportInfo(tr("TcpServer: %1 is connecting...").arg(m_socket->peerAddress().toString()) ); - setState(CONNECTING); - - QObject::connect(m_socket, SIGNAL(readyRead()), - this, SLOT(readMessage())); - - QObject::connect(m_socket, SIGNAL(disconnected()), - this, SLOT(on_socketDisconnected())); -} - -//--------------------------------------------------------------------------------------------- -void TcpServer::on_socketDisconnected() -{ - if(m_currentState == RECEIVING) - { - LogHandler::getInstance()->reportInfo(tr("TcpServer: Connection closed. Transfer aborted.") ); - abort(); - } -} - -//--------------------------------------------------------------------------------------------- -void TcpServer::updateTcpServerProgress() -{ - m_bytesReceived += (int)m_socket->bytesAvailable(); - m_fileData.clear(); - m_fileData.resize(PAYLOADSIZE); - m_fileData = m_socket->readAll(); - - m_file->write(m_fileData); - - if(m_bytesReceived == m_fileSize) - { - setState(FINISHED); - m_socket->close(); - m_file->flush(); - m_file->close(); - delete m_file; - m_file = 0; - - LogHandler::getInstance()->reportInfo(tr("TcpServer: File transfer complete") ); - stop(); - } -} - -//--------------------------------------------------------------------------------------------- -void TcpServer::readMessage() -{ - QDataStream in(m_socket); - in.setVersion(QDataStream::Qt_4_0); - - if(m_blockSize == 0) - { - if(m_socket->bytesAvailable() < (int)sizeof(quint16)) - return; - - in >> m_blockSize; - } - - if(m_socket->bytesAvailable() < m_blockSize) - return; - - if(m_currentState == CONNECTING) - { - setState(NEGOTIATING); - - quint8 messageType; - QString filename; - QString filesizeString; - - in >> messageType; - - switch(messageType) - { - case 'I': //File info - { - in >> filename >> m_fileSize; - - if(m_fileSize < 1024) - filesizeString = tr("%1 Byte").arg(m_fileSize); - else if(m_fileSize < 1048576) - filesizeString = tr("%1 KB").arg(static_cast(m_fileSize) / 1024, 0, 'f', 2); - else if(m_fileSize < 1073741824) - filesizeString = tr("%1 MB").arg(static_cast(m_fileSize) / 1048576, 0, 'f', 2); - else - filesizeString = tr("%1 GB").arg(static_cast(m_fileSize) / 1073741824, 0, 'f', 2); - - LogHandler::getInstance()->reportInfo(tr("TcpServer: Received file information:") ); - LogHandler::getInstance()->reportInfo(tr(" '%1', size: %2").arg(filename).arg(filesizeString) ); - - -// m_saveFilename = QFileDialog::getSaveFileName(parent_, "Save file as...", -// last_dir_.append(filename), ""); - m_file = new QFile(m_saveFilename); - - if(!m_file->open(QIODevice::WriteOnly)) - { - LogHandler::getInstance()->reportError(tr("Error writing to file. Transfert aborted.") ); - setState(INACTIVE); - } - - sendAcceptMessage(); - - m_fileData.resize(PAYLOADSIZE); - QObject::connect(m_socket, SIGNAL(readyRead()),this, SLOT(updateTcpServerProgress())); - - m_timeOutCounter = 0; - m_connectionTimer->start(1000); - setState(RECEIVING); - - - } - break; - - default: - - LogHandler::getInstance()->reportError( tr("Received unknown message type: %1").arg(messageType) ); - break; - } - } -} - -//--------------------------------------------------------------------------------------------- -void TcpServer::sendAcceptMessage() -{ - QByteArray block; - QDataStream out(&block, QIODevice::WriteOnly); - - out.setVersion(QDataStream::Qt_4_0); - out << (quint16)0; - out << (quint8)'A'; - out.device()->seek(0); - out << (quint16)(block.size() - sizeof(quint16)); - - m_socket->write(block); - LogHandler::getInstance()->reportInfo(tr("TcpServer: Accept message sent") ); -} - -//--------------------------------------------------------------------------------------------- -void TcpServer::setTimeOut(quint16 time_out) -{ - m_timeOut = time_out; -} - -//--------------------------------------------------------------------------------------------- -void TcpServer::setReverseConnection(bool reverse_connection) -{ - m_reverseConnection = reverse_connection; -} - -//--------------------------------------------------------------------------------------------- -void TcpServer::on_socketConnected() -{ - LogHandler::getInstance()->reportInfo(tr("TcpServer: Reverse connection to %1 established").arg(m_socket->peerAddress().toString())); - setState(CONNECTING); -} - -//--------------------------------------------------------------------------------------------- -bool TcpServer::getReverseConnection() -{ - return m_reverseConnection; -} diff -Nru syncwall-1.6.0/SyncWall/src/TcpServer.h syncwall-1.7.4/SyncWall/src/TcpServer.h --- syncwall-1.6.0/SyncWall/src/TcpServer.h 2012-02-08 14:28:18.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/TcpServer.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ - -/****************************************************************************** - SyncWall: Wallpaper manager - Copyright(C) 2011-2012 xbee@xbee.net - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *******************************************************************************/ - - -#ifndef _TCPSERVER_H_ -#define _TCPSERVER_H_ - -#include -#include -#include - -class TcpServer : public QObject -{ - Q_OBJECT - -public: - - enum States - { - INACTIVE = 0, - LISTENING, - CONNECTING, - NEGOTIATING, - RECEIVING, - FINISHED - }; - - TcpServer(QObject * parent = 0); - virtual ~TcpServer(); - - static QString getStateAsString(quint8 state); - bool start(quint16 port); - void stop(); - void abort(); - QString errorString() const; - void setTimeOut(quint16 time_out); - QString getLastDir() const; - void setLastDir(const QString &last_dir); - void setReverseConnection(bool reverseConnection); - bool getReverseConnection(); - -signals: - - void stateChanged(quint8 new_state); - -private slots: - - void updateTcpServerProgress(); - void on_server__newConnection(); - void readMessage(); - void on_socketDisconnected(); - void timeout(); - void on_socketConnected(); - -private: - - void sendAcceptMessage(); - void setState(quint8 new_state); - - QTcpServer *m_server; - QTcpSocket *m_socket; - quint8 m_currentState; - quint16 m_blockSize; - quint16 m_port; - quint32 m_fileSize; - quint32 m_bytesReceived; - bool m_reverseConnection; - - //timeout variables------- - quint32 m_tempBytesReceived; - quint16 m_timeOut; - quint16 m_timeOutCounter; - QTimer *m_connectionTimer; - //------------------------ - - QString m_saveFilename; - QFile *m_file; - QByteArray m_fileData; - -}; - -#endif // _TCPSERVER_H_ diff -Nru syncwall-1.6.0/SyncWall/src/ThreadPool.cpp syncwall-1.7.4/SyncWall/src/ThreadPool.cpp --- syncwall-1.6.0/SyncWall/src/ThreadPool.cpp 2012-01-29 13:23:18.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/ThreadPool.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,87 +0,0 @@ - -/****************************************************************************** - SyncWall: Wallpaper manager - Copyright(C) 2011-2012 xbee@xbee.net - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *******************************************************************************/ - -#include "ThreadPool.h" - -bool ThreadPool::instanceFlag = false; -ThreadPool* ThreadPool::single = NULL; - -ThreadPool* ThreadPool::getInstance() -{ - if(! instanceFlag) - { - single = new ThreadPool(); - instanceFlag = true; - return single; - } - else - { - return single; - } -} - -ThreadPool::ThreadPool() -{ -// create the treads - for (int i = 0 ; i < QThread::idealThreadCount(); i++) - { - m_threadPool << new QThread; - qDebug("ThreadPool: start thread %d ",i); - m_threadPool.at(i)->start(); - } -} - -void ThreadPool::stop() -{ - // stop each running thread properly - foreach(QThread *th, m_threadPool) - { - if (th->isRunning()) - { - th->quit(); - th->wait(1000); - } - } - - foreach(QThread *th, m_reservedThreadPool) - { - if (th->isRunning()) - { - th->quit(); - th->wait(1000); - } - } -} - -QThread *ThreadPool::getThread() -{ - int index = qrand()%m_threadPool.size(); - qDebug("send thread %d to caller",index); - return m_threadPool[qrand()%m_threadPool.size()]; -} - -QThread *ThreadPool::getReservedThread() -{ - qDebug("send a reserved thread to caller"); - QThread *th = new QThread(); - m_reservedThreadPool << th; - th->start(); - return th; -} diff -Nru syncwall-1.6.0/SyncWall/src/ThreadPool.h syncwall-1.7.4/SyncWall/src/ThreadPool.h --- syncwall-1.6.0/SyncWall/src/ThreadPool.h 2012-01-29 13:23:18.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/ThreadPool.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ - -/****************************************************************************** - SyncWall: Wallpaper manager - Copyright(C) 2011-2012 xbee@xbee.net - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *******************************************************************************/ - -#ifndef _THREADPOOL_H_ -#define _THREADPOOL_H_ - -// this class provide a way to get access to the thread pool - -#include -#include -#include -#include - -class ThreadPool: public QObject -{ - - Q_OBJECT - -private: - - static bool instanceFlag; - static ThreadPool *single; - - QList m_threadPool; - QList m_reservedThreadPool; - - QMutex m_lock; - - ThreadPool(); //private constructor - -public: - - static ThreadPool* getInstance(); - ~ThreadPool() - { - instanceFlag = false; - } - - void stop(); - - QThread *getThread(); - QThread *getReservedThread(); - -public slots: - -signals: - - -}; - -#endif // _THREADPOOL_H_ diff -Nru syncwall-1.6.0/SyncWall/src/TreeImagesView.cpp syncwall-1.7.4/SyncWall/src/TreeImagesView.cpp --- syncwall-1.6.0/SyncWall/src/TreeImagesView.cpp 2012-01-06 12:05:02.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/TreeImagesView.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -/****************************************************************************** -SyncWall: Wallpaper manager -Copyright(C) 2011-2012 xbee@xbee.net@xbee.net - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*******************************************************************************/ - -#include "TreeImagesView.h" - -#include -#include -#include -#include - - -TreeImagesView::TreeImagesView( QWidget *parent ) - : QTreeView( parent ) -{ -} - -void TreeImagesView::paintEvent( QPaintEvent *event ) -{ - if( model() && model()->rowCount() > 0 ) - { - QTreeView::paintEvent( event ); - return; - } - - QPainter painter( viewport() ); - - QPalette palette; - - QPen pen( palette.color( QPalette::Highlight ) ); - - QFont font = painter.font(); - font.setBold( true ); - font.setPointSize( font.pointSize() + 10 ); - - const QString text = tr( "Add some images to begin" ); - - const QFontMetrics fm( font ); - if( fm.width( text ) > viewport()->rect().width() ) - return; - - painter.setPen( pen ); - painter.setFont( font ); - - painter.drawText( rect(), Qt::AlignCenter, text ); -} diff -Nru syncwall-1.6.0/SyncWall/src/TreeImagesView.h syncwall-1.7.4/SyncWall/src/TreeImagesView.h --- syncwall-1.6.0/SyncWall/src/TreeImagesView.h 2012-01-06 14:46:40.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/TreeImagesView.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ - -/****************************************************************************** - SyncWall: Wallpaper manager - Copyright(C) 2011-2012 xbee@xbee.net - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *******************************************************************************/ - -#ifndef _TREEIMAGEVIEW_H_ -#define _TREEIMAGEVIEW_H_ - -#include - -class TreeImagesView : - public QTreeView -{ - Q_OBJECT - -public: - - TreeImagesView( QWidget *parent = 0 ); - -protected: - - void paintEvent( QPaintEvent *event ); -}; - -#endif // _TREEIMAGEVIEW_H_ diff -Nru syncwall-1.6.0/SyncWall/src/WallpaperProvider.cpp syncwall-1.7.4/SyncWall/src/WallpaperProvider.cpp --- syncwall-1.6.0/SyncWall/src/WallpaperProvider.cpp 2012-01-16 09:14:56.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/WallpaperProvider.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,143 +0,0 @@ -/****************************************************************************** -SyncWall: Wallpaper manager -Copyright(C) 2011-2012 xbee@xbee.net - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*******************************************************************************/ - -#include -#include "WallpaperProvider.h" - -#include "LogHandler.h" -#include "MiscFunctions.h" - -WallpaperProvider::WallpaperProvider(const QString &dir, int mode, QObject *parent) - : QObject(parent), - m_mode(mode) -{ - m_inputList << dir; - refreshWallpaperList(); -} - -WallpaperProvider::WallpaperProvider(const QStringList &files, int mode, QObject *parent) -: QObject(parent), -m_mode(mode), -m_inputList(files) -{ - refreshWallpaperList(); -} - -WallpaperProvider::~WallpaperProvider() -{ - -} - -void WallpaperProvider::refreshWallpaperList() -{ - foreach (const QString &input, m_inputList) - { - if (m_mode == MODE_DIRECTORY) // scan directory - { - foreach (const QString &dir, m_inputList) - { - QStringList files = scanDirectory(dir); - m_listWallpaper << files; - } - } - else - { - if (QFileInfo(input).isDir()) // replace the input dir by all the included files - { - QStringList files = scanDirectory(input); - m_listWallpaper << files; - m_inputList << files; // add the files to the input list - m_inputList.removeOne(input); // delete the input directory - } - else - { - if (QFileInfo(input).isReadable()) - m_listWallpaper << input; - } - } - } - - m_inputList.removeDuplicates(); - m_listWallpaper.removeDuplicates (); -} - -QStringList WallpaperProvider::scanDirectory(const QString &val) -{ - QDir dir(val); - QStringList files; - - if (!dir.exists()) - { - LogHandler::getInstance()->reportError(tr("Cannot find the directory %1",val.toStdString().c_str())); - return files; - } - - QStringList formats = MiscFunctions::getAvailablesImageFormats().split(" "); -// QStringList ext; -// ext << "*.png" << "*.jpg" << "*.bmp" << "*.gif" ; - QFileInfoList list = dir.entryInfoList(formats); - - foreach (const QFileInfo &info, list) - { - files << info.absoluteFilePath(); - } - return files; -} - -bool WallpaperProvider::addInputs(const QStringList &inputs) -{ - bool ok = true; - foreach (const QString input, inputs) - ok &= addInput(input); - return ok; -} - -bool WallpaperProvider::addInput(const QString &input) -{ - if (m_inputList.indexOf(input) != -1) - return false; - - if (!QFileInfo(input).isReadable()) - return false; - - if (m_mode == MODE_DIRECTORY) - { - scanDirectory(input); - } - else - { - m_listWallpaper << input; - } - - return true; -} - -bool WallpaperProvider::deleteInput(const QString &input) -{ - m_inputList.removeAll(input); - if (m_listWallpaper.removeAll(input)) - { - // something delete => force refresh of filelist - //refreshWallpaperList(); - return true; - } - - return false; -} - diff -Nru syncwall-1.6.0/SyncWall/src/WallpaperProvider.h syncwall-1.7.4/SyncWall/src/WallpaperProvider.h --- syncwall-1.6.0/SyncWall/src/WallpaperProvider.h 2012-01-16 08:33:56.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/WallpaperProvider.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ - -/****************************************************************************** - SyncWall: Wallpaper manager - Copyright(C) 2011-2012 xbee@xbee.net - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *******************************************************************************/ - -#ifndef _WALLPAPERPROVIDER_H_ -#define _WALLPAPERPROVIDER_H_ - -#include -#include - -class WallpaperProvider : - public QObject -{ - Q_OBJECT - -public: - - enum - { - MODE_DIRECTORY = 0, - MODE_FILELIST - }; - - WallpaperProvider(const QString &, int mode = MODE_DIRECTORY, QObject *parent = NULL); - WallpaperProvider(const QStringList &, int mode = MODE_FILELIST, QObject *parent = NULL); - virtual ~WallpaperProvider(); - - bool addInput(const QString &); - bool addInputs(const QStringList &); - bool deleteInput(const QString &); - const QStringList & getInputList() const {return m_inputList; } - const QStringList & getWallpaperList() const {return m_listWallpaper; } - void refreshWallpaperList(); - int getMode() const {return m_mode; } - -signals: - -private: - - QStringList scanDirectory(const QString &val); - - QStringList m_listWallpaper; - int m_mode; - QStringList m_inputList; -}; - -#endif // _WALLPAPERPROVIDER_H_ diff -Nru syncwall-1.6.0/SyncWall/src/main.cpp syncwall-1.7.4/SyncWall/src/main.cpp --- syncwall-1.6.0/SyncWall/src/main.cpp 2012-03-19 13:14:50.000000000 +0000 +++ syncwall-1.7.4/SyncWall/src/main.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,152 +0,0 @@ -/****************************************************************************** -SyncWall: Wallpaper manager -Copyright(C) 2011-2012 xbee@xbee.net - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*******************************************************************************/ - -#include -#include -#include -#include -#include - -#include "SyncWall.h" -#include "SingleApplication.h" -#include "AppSettings.h" -#include "MiscFunctions.h" -#include "SplashScreen.h" - -#ifdef Q_OS_WIN -#include // for Sleep -#endif - -#ifdef Q_OS_UNIX -#include -#endif - -// extract from QTest ... -void qSleep(int ms) -{ -#ifdef Q_OS_WIN - Sleep(uint(ms)); -#else - struct timespec ts = { ms / 1000, (ms % 1000) * 1000 * 1000 }; - nanosleep(&ts, NULL); -#endif -} - -void usage() -{ - QTextStream out(stdout); - out << endl; - out << QObject::tr("Wallpaper manager.") << endl; - out << endl; - out << QObject::tr("Following options are known:") << endl; - out << QObject::tr(" --help : displays this help.") << endl; - out << QObject::tr(" --reset-config : clear the saved preference parameters.") << endl; - out << QObject::tr(" --no-singleinstance : enable the use of multiple instance of program (not recommended).") << endl; - out << endl; -} - -int main(int argc, char *argv[]) -{ - Q_INIT_RESOURCE(syncwall); - - qSleep(1000); // waiting sometimes for restart case ... - - SingleApplication app(argc, argv, PACKAGE_NAME); - - // update some application infos (use by some platform for temp storage, ...) - MiscFunctions::updateApplicationIdentity(); - - // add possible image plugin path - app.addLibraryPath( QApplication::applicationDirPath() + "./plugins"); - - // set default language for application (computed or saved) - MiscFunctions::setDefaultLanguage(); - - // modifying base look - QApplication::setStyle(new QPlastiqueStyle); - - // check for special argument - bool forceResetConfig = false; - bool ignoreSingleInstance = false; - QStringList args = QApplication::arguments(); - for ( int i = 1; i < args.count(); ++i ) - { - const QString arg = args.at(i); - - if ( arg == "--reset-config" ) - { - forceResetConfig = true; - } - else if ( arg == "--no-singleinstance" ) - { - ignoreSingleInstance = true; - } - else if (arg == "--help") - { - usage(); - return 0; - } - } - - // check for multiple instance of program - if (app.isRunning() && !ignoreSingleInstance) - { - app.sendMessage(QObject::tr("message from other instance.")); - QMessageBox::critical(0,PACKAGE_NAME,QObject::tr("%1 is already running !!").arg(PACKAGE_NAME)); - return 0; - } - - AppSettings settings; - - // in order to display splashscreen on the same screen than application ... - settings.beginGroup("MainWindow"); - int screenNumber = settings.value("screenNumber",0).toInt(); - settings.endGroup(); - - settings.beginGroup("Application"); - // reset the saved configuration if needed - bool resetConfig = settings.value("resetConfig",false).toBool(); - if (resetConfig || forceResetConfig) - { - settings.clear(); - settings.sync(); - } - - bool splashscreenAtStartup = settings.value("splashscreenAtStartup",true).toBool(); - bool splashscreenTransparentBackground = settings.value("splashscreenTransparentBackground",true).toBool(); - bool startInTray = settings.value("startInTray",false).toBool(); - settings.endGroup(); - - // splash screen - if (splashscreenAtStartup) - { - SplashScreen sScreen(QPixmap(":/syncwall/splashscreen.png"), 3000, screenNumber,splashscreenTransparentBackground); - sScreen.show(); - } - - SyncWall w; - QObject::connect(&app, SIGNAL(messageAvailable(const QString &)), &w, SLOT(wakeUp(const QString &))); - - if (!startInTray) - w.show(); - - QObject::connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit())); - - return app.exec(); -} diff -Nru syncwall-1.6.0/SyncWall/ui/BackgroundPainterConfigWidget.ui syncwall-1.7.4/SyncWall/ui/BackgroundPainterConfigWidget.ui --- syncwall-1.6.0/SyncWall/ui/BackgroundPainterConfigWidget.ui 2012-05-14 13:56:44.000000000 +0000 +++ syncwall-1.7.4/SyncWall/ui/BackgroundPainterConfigWidget.ui 1970-01-01 00:00:00.000000000 +0000 @@ -1,278 +0,0 @@ - - - BackgroundPainterConfigWidget - - - - 0 - 0 - 570 - 599 - - - - BackgroundPainterConfigWidget - - - - - - Preview desktop - - - - - - - 0 - 1 - - - - - 200 - 100 - - - - - - - - - 7 - - - - No data - - - - - - - - 7 - - - - Tips: You can reorder and align screens by drag&drop - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - Image parameters - - - false - - - false - - - - - - share image between monitors - - - - - - - Resizing method - - - - - - - - - - Image Alignment (in case of resizing) - - - - - - - - - - Background - - - - - - - - - - - 50 - 16777215 - - - - - - - false - - - - - - - - 50 - 16777215 - - - - - - - - - - - Special effect - - - - - - - - - - export image parameters to clients (server) - - - - - - - Multi monitor display - - - - - - - - - - skip image too small for resizing (<50% of final image) - - - - - - - Inverse gradient color - - - - - - - 360.000000000000000 - - - - - - - ignore image parameters from server (client) - - - - - - - Rotate image according to Metadata - - - - - - - - - - Qt::Vertical - - - QSizePolicy::Minimum - - - - 20 - 8 - - - - - - - - - - Qt::Horizontal - - - - 345 - 20 - - - - - - - - - - - :/syncwall/display_big.png - - - - - - - - - - - DesktopView - QGraphicsView -
DesktopView.h
-
-
- - - - - - - - - - - - - -
diff -Nru syncwall-1.6.0/SyncWall/ui/ImageViewer.ui syncwall-1.7.4/SyncWall/ui/ImageViewer.ui --- syncwall-1.6.0/SyncWall/ui/ImageViewer.ui 2011-12-17 10:38:12.000000000 +0000 +++ syncwall-1.7.4/SyncWall/ui/ImageViewer.ui 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ - - - ImageViewer - - - - 0 - 0 - 456 - 364 - - - - ImageViewer - - - - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - - - - - no info - - - - - labelInfos - graphicsView - graphicsView - - - - - ImageView - QGraphicsView -
ImageViewer.h
-
-
- - -
diff -Nru syncwall-1.6.0/SyncWall/ui/NetworkManagerConfigWidget.ui syncwall-1.7.4/SyncWall/ui/NetworkManagerConfigWidget.ui --- syncwall-1.6.0/SyncWall/ui/NetworkManagerConfigWidget.ui 2012-02-20 13:40:56.000000000 +0000 +++ syncwall-1.7.4/SyncWall/ui/NetworkManagerConfigWidget.ui 1970-01-01 00:00:00.000000000 +0000 @@ -1,125 +0,0 @@ - - - NetworkManagerConfigWidget - - - - 0 - 0 - 465 - 386 - - - - NetworkManagerConfigWidget - - - - - - Synchronise with server - - - true - - - - - - Server (name or IP) - - - - - - - - - - UDP Port - - - - - - - - - - - 0 - 0 - - - - Test Connection - - - - :/syncwall/check.png:/syncwall/check.png - - - - - - - - 0 - 0 - - - - No connection - - - - - - - - - - Qt::Vertical - - - - 20 - 116 - - - - - - - - Qt::Horizontal - - - - 310 - 20 - - - - - - - - - - - :/syncwall/network_big.png - - - - - - - - - - - - - - diff -Nru syncwall-1.6.0/SyncWall/ui/SchedulerConfigWidget.ui syncwall-1.7.4/SyncWall/ui/SchedulerConfigWidget.ui --- syncwall-1.6.0/SyncWall/ui/SchedulerConfigWidget.ui 2012-02-20 13:41:02.000000000 +0000 +++ syncwall-1.7.4/SyncWall/ui/SchedulerConfigWidget.ui 1970-01-01 00:00:00.000000000 +0000 @@ -1,331 +0,0 @@ - - - SchedulerConfigWidget - - - - 0 - 0 - 477 - 397 - - - - SchedulerConfigWidget - - - - - - Scheduling parameters - - - - - - Auto change at startup - - - - - - - false - - - Quit application after startup change (30s) - - - - - - - true - - - Change Interval - - - true - - - true - - - true - - - - - - Interval between change (h:m:s) - - - true - - - - - - - true - - - set time of day (h:m:s) - - - - - - - false - - - - - - - - - - false - - - - 0 - 0 - - - - Add to the timeofday list - - - - - - - :/syncwall/add.png:/syncwall/add.png - - - - - - - false - - - QAbstractItemView::ExtendedSelection - - - - - - - false - - - Delete selected timeofday - - - - - - - :/syncwall/delete.png:/syncwall/delete.png - - - - - - - Qt::Vertical - - - - 25 - 20 - - - - - - - - - - - h:mm:ss - - - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 2 - - - - - - - - Qt::Horizontal - - - - 322 - 58 - - - - - - - - - - - :/syncwall/scheduling_big.png - - - - - - - - - - - - - - - - - - - - - radioButtonInterval - toggled(bool) - timeEditInterval - setEnabled(bool) - - - 109 - 102 - - - 247 - 102 - - - - - radioButtonTimeOfDay - toggled(bool) - timeEditTOD - setEnabled(bool) - - - 84 - 134 - - - 247 - 138 - - - - - radioButtonTimeOfDay - toggled(bool) - listWidgetTOD - setEnabled(bool) - - - 130 - 137 - - - 241 - 174 - - - - - radioButtonTimeOfDay - toggled(bool) - pushButtonAddTOD - setEnabled(bool) - - - 60 - 135 - - - 433 - 149 - - - - - radioButtonTimeOfDay - toggled(bool) - pushButtonDeleteTOD - setEnabled(bool) - - - 48 - 139 - - - 433 - 179 - - - - - checkBoxStartup - toggled(bool) - checkBoxStartupAndQuit - setEnabled(bool) - - - 65 - 42 - - - 69 - 64 - - - - - diff -Nru syncwall-1.6.0/SyncWall/ui/SyncWall.ui syncwall-1.7.4/SyncWall/ui/SyncWall.ui --- syncwall-1.6.0/SyncWall/ui/SyncWall.ui 2012-04-24 09:07:54.000000000 +0000 +++ syncwall-1.7.4/SyncWall/ui/SyncWall.ui 1970-01-01 00:00:00.000000000 +0000 @@ -1,1326 +0,0 @@ - - - SyncWallClass - - - - 0 - 0 - 705 - 538 - - - - SyncWall - - - - :/syncwall/logo_big.png:/syncwall/logo_big.png - - - - - - - - - - - 0 - 0 - - - - 0 - - - - - :/syncwall/display_big.png:/syncwall/display_big.png - - - Preview - - - - - - - - - 0 - 0 - - - - Quit - - - - - - - - - - - - - - - - - - - :/syncwall/icon_quit.png:/syncwall/icon_quit.png - - - - 22 - 22 - - - - - - - - Qt::Vertical - - - - 31 - 50 - - - - - - - - - 0 - 0 - - - - Add a new folder - - - - - - - - - - - - - - - - - - - :/syncwall/folder_add.png:/syncwall/folder_add.png - - - - 22 - 22 - - - - - - - - - 0 - 0 - - - - Add new file(s) - - - Add new file(s) - - - - - - - - - - - - - :/syncwall/images_add.png:/syncwall/images_add.png - - - - 22 - 22 - - - - - - - - true - - - - 0 - 0 - - - - Delete selected wallpaper from list - - - - - - - :/syncwall/delete.png:/syncwall/delete.png - - - - 22 - 22 - - - - - - - - - 0 - 0 - - - - Refresh file list - - - - - - - - - - - - - - - - - - - :/syncwall/refresh.png:/syncwall/refresh.png - - - - 22 - 22 - - - - - - - - - 0 - 0 - - - - Set wallpaper - - - - - - - - - - - - - - - - - - - :/syncwall/monitor_paint.png:/syncwall/monitor_paint.png - - - - 22 - 22 - - - - - - - - Preview selected wallpaper - - - - - - - - - - - - - - - - - - - :/syncwall/preview.png:/syncwall/preview.png - - - - 22 - 22 - - - - - - - - - - - 1 - 0 - - - - - 0 - 0 - - - - - 16777215 - 170 - - - - - 256 - 200 - - - - Preview desktop - - - - - - false - - - - - - - - - - true - - - - 0 - 0 - - - - - 24 - 16777215 - - - - View simple list - - - - - - - :/syncwall/view-list.png:/syncwall/view-list.png - - - true - - - true - - - true - - - - - - - true - - - - 24 - 16777215 - - - - View list and infos - - - - - - - :/syncwall/view-detail.png:/syncwall/view-detail.png - - - true - - - true - - - - - - - true - - - - 24 - 16777215 - - - - View thumbnails - - - - - - - :/syncwall/view-thumbnail.png:/syncwall/view-thumbnail.png - - - true - - - true - - - - - - - - 0 - 0 - - - - QFrame::StyledPanel - - - 0 - - - - - - - Qt::CustomContextMenu - - - QAbstractItemView::ExtendedSelection - - - false - - - false - - - false - - - - - - - - - - - - 0 - 0 - - - - Qt::CustomContextMenu - - - QAbstractItemView::ExtendedSelection - - - - 100 - 100 - - - - Qt::ElideLeft - - - QListView::Static - - - QListView::Adjust - - - QListView::Batched - - - - 130 - 130 - - - - QListView::IconMode - - - true - - - false - - - - - - - - - - - - 0 - 0 - - - - No Wallpaper - - - Qt::AlignCenter - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::LeftToRight - - - Auto Change in random order - - - - - - - - - - 0 - 0 - - - - State ... - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - - - - - - 0 - 0 - - - - - 32 - 32 - - - - - - - :/syncwall/mode_standard.png - - - true - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - :/syncwall/preferences.png:/syncwall/preferences.png - - - Preferences - - - - - - QTabWidget::South - - - 0 - - - - - :/syncwall/startup_big.png:/syncwall/startup_big.png - - - Startup - - - - - - Startup - - - - - - Start in notification tray (minimized) - - - - - - - Display splashscreen at startup - - - - - - - Auto start with system - - - - - - - Reset preferences - - - - :/syncwall/reset.png:/syncwall/reset.png - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - false - - - Splashscreen with transparent background - - - true - - - - - - - - - - true - - - Use Global Hotkey for manual change of wallpaper - - - true - - - false - - - - - - - - - - 0 - 0 - - - - Next wallpaper: - - - - - - - - - - - 0 - 20 - - - - - - - - Qt::Vertical - - - - 20 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - :/syncwall/startup_big.png - - - - - - - Language - - - - - - - - - Detected language ... - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - :/syncwall/scheduling_big.png:/syncwall/scheduling_big.png - - - Scheduling - - - - - - - - - - - :/syncwall/display_big.png:/syncwall/display_big.png - - - Display Parameters - - - - - - - - - - - :/syncwall/network_big.png:/syncwall/network_big.png - - - Network - - - - - - - - - - - - - - - :/syncwall/about.png:/syncwall/about.png - - - About - - - - - - - - Supported formats (via Qt plugins) - - - - - - - 0 - 0 - - - - true - - - - - - - - - - Available translations - - - - - - - 0 - 0 - - - - true - - - - - - - - - - - - - 0 - 0 - - - - Release Number - - - false - - - - - - - Qt::Vertical - - - QSizePolicy::MinimumExpanding - - - - 20 - 40 - - - - - - - - QTabWidget::South - - - 0 - - - - Credits - - - - - - - 0 - 0 - - - - - 8 - - - - false - - - QFrame::NoFrame - - - QFrame::Plain - - - true - - - - - - - - Changelog - - - - - - - 0 - 0 - - - - - 8 - - - - false - - - QFrame::NoFrame - - - QFrame::Plain - - - true - - - - - - - - - - - - 0 - 0 - - - - - - - :/syncwall/logo_big.png - - - - - - - - - :/syncwall/scroll.png:/syncwall/scroll.png - - - Log - - - - - - - 0 - 0 - - - - Clear Log - - - - - - - :/syncwall/trash.png:/syncwall/trash.png - - - - - - - Qt::Horizontal - - - - 50 - 21 - - - - - - - - - - - Qt::Horizontal - - - - 529 - 20 - - - - - - - - - 0 - 0 - - - - - - - :/syncwall/scroll.png - - - - - - - - 0 - 0 - - - - Save log to file - - - - - - - :/syncwall/camera.png:/syncwall/camera.png - - - - - - - - - - - - - 0 - 0 - 705 - 22 - - - - - - - :/syncwall/preview.png:/syncwall/preview.png - - - Preview Image - - - - - - :/syncwall/monitor_paint.png:/syncwall/monitor_paint.png - - - Set wallpaper - - - - - - :/syncwall/delete.png:/syncwall/delete.png - - - Delete Image - - - - - - :/syncwall/display_big.png:/syncwall/display_big.png - - - Show main interface - - - Show User Interface - - - - - - :/syncwall/icon_quit.png:/syncwall/icon_quit.png - - - Quit - - - Quit application - - - - - - :/syncwall/refresh.png:/syncwall/refresh.png - - - Next Wallpaper - - - - - - :/syncwall/reset.png:/syncwall/reset.png - - - Previous Wallpaper - - - - - - - DesktopView - QGraphicsView -
DesktopView.h
-
- - SchedulerConfigWidget - QWidget -
SchedulerConfigWidget.h
- 1 -
- - BackgroundPainterConfigWidget - QWidget -
BackgroundPainterConfigWidget.h
- 1 -
- - NetworkManagerConfigWidget - QWidget -
NetworkManagerConfigWidget.h
- 1 -
- - SystemIntegrationConfigWidget - QWidget -
SystemIntegrationConfigWidget.h
- 1 -
- - QKeySequenceWidget - QWidget -
qkeysequencewidget.h
- 1 -
- - TreeImagesView - QTreeView -
TreeImagesView.h
-
-
- - - - - - - - - - - - - checkBoxSplashscreenAtStartup - toggled(bool) - checkBoxSplashscreenTransparentBackground - setEnabled(bool) - - - 136 - 136 - - - 276 - 155 - - - - - - - 5 - - - 5 - - - true - - - true - - - true - - -
diff -Nru syncwall-1.6.0/SyncWall/ui/SystemIntegrationConfigWidget.ui syncwall-1.7.4/SyncWall/ui/SystemIntegrationConfigWidget.ui --- syncwall-1.6.0/SyncWall/ui/SystemIntegrationConfigWidget.ui 2012-01-23 09:22:48.000000000 +0000 +++ syncwall-1.7.4/SyncWall/ui/SystemIntegrationConfigWidget.ui 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ - - - SystemIntegrationConfigWidget - - - - 0 - 0 - 536 - 186 - - - - SystemIntegrationConfigWidget - - - - 0 - - - - - Desktop integration - - - - - - - - - no detection ... - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - The auto detection can failed. In this case, you have to set manually your desktop ... - - - true - - - - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - - - - - - - - - - diff -Nru syncwall-1.6.0/SyncWall.pro syncwall-1.7.4/SyncWall.pro --- syncwall-1.6.0/SyncWall.pro 2012-01-10 00:04:52.000000000 +0000 +++ syncwall-1.7.4/SyncWall.pro 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ - -SUBDIRS += 3rdparty SyncWall -CONFIG += ordered -TEMPLATE = subdirs - - - - - - diff -Nru syncwall-1.6.0/TODO.txt syncwall-1.7.4/TODO.txt --- syncwall-1.6.0/TODO.txt 2012-08-18 06:27:20.000000000 +0000 +++ syncwall-1.7.4/TODO.txt 2013-04-20 01:33:32.000000000 +0000 @@ -1,4 +1,5 @@ - Bug hunt -- more translations (I need help ! Send them to xbee at xbee dot net) +- more translations (I need help !). Send them to xbee at xbee dot net or project is referenced on www.transifex.com, feel free to give help. - transfert image across network ? - And Feel free to write feedback, bug-reports and patches ! + diff -Nru syncwall-1.6.0/build/CMakeLists.txt syncwall-1.7.4/build/CMakeLists.txt --- syncwall-1.6.0/build/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/build/CMakeLists.txt 2013-07-13 06:06:40.000000000 +0000 @@ -0,0 +1,238 @@ +# +# SyncWall CMakeLists.txt +# +# To build SyncWall, you will need cmake 2.6 +# To build the application run this commands: +# +# cd build +# cmake ./ +# make +# +# If you don't kwon cmake, here are some links for you: +# http://wiki.qtcentre.org/index.php?title=Compiling_Qt4_apps_with_CMake +# http://qtnode.net/wiki/Qt_with_cmake#cmake_for_Qt_4 + +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) + +# set project's name +PROJECT(SyncWall) + +# note: change this BEFORE making a release !! +SET( MYAPP_VERSION "1.7.4" ) +set( PROGNAME syncwall ) + +IF( APPLE ) + SET( MACOSX_BUNDLE_ICON_FILE ${PROGNAME}.icns ) + SET( MACOSX_BUNDLE_SHORT_VERSION_STRING ${MYAPP_VERSION} ) + SET( MACOSX_BUNDLE_VERSION ${MYAPP_VERSION} ) + SET( MACOSX_BUNDLE_LONG_VERSION_STRING Version ${MYAPP_VERSION} ) + SET( MACOSX_BUNDLE_INFO_PLIST Version "../res/Info.plist" ) + SET( CMAKE_OSX_ARCHITECTURES ppc;i386 ) #Comment out if not universal binary +ENDIF( APPLE ) + +CMAKE_MINIMUM_REQUIRED(VERSION 2.4.4) +SET(CMAKE_COLOR_MAKEFILE ON) +SET(CMAKE_VERBOSE_MAKEFILE OFF) +SET(CMAKE_INCLUDE_CURRENT_DIR TRUE) + +# Packages path +SET (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) + +# this command finds Qt4 libraries and sets all required variables +FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui QtNetwork QtSql REQUIRED) + +IF (UNIX) + FIND_PACKAGE(Qxt COMPONENTS QxtGui REQUIRED) +ENDIF(UNIX) + +# add some useful macros and variables +# (QT_USE_FILE is a variable defined by FIND_PACKAGE( Qt4 ) that contains a path to CMake script) +INCLUDE(${QT_USE_FILE}) +INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR} "../src/" "../src/3rdparty/qkeysequencewidget" "../src/3rdparty/qimageblitz" "../src/3rdparty/qt-extended") + +IF (MSVC) +INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR} "../src/3rdparty/qxt") +ENDIF( MSVC ) + +IF (UNIX) + INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR} "/usr/include/qxt/QxtGui" "/usr/include/qxt/QxtCore") +ENDIF( UNIX ) + +FILE(GLOB include_file_list "../src/*.h" "../src/3rdparty/qkeysequencewidget/*.h" "../src/3rdparty/qt-extended/*.h") +FILE(GLOB cpp_file_list "../src/*.cpp" "../src/3rdparty/qkeysequencewidget/*.cpp" "../src/3rdparty/qt-extended/*.cpp") + + +FILE(GLOB resource_file_list "../res/*.qrc") +FILE(GLOB ui_file_list "../ui/*.ui") +FILE(GLOB trans_file_list "../lang/*.ts") + +SET(MYAPP_UIS + ${ui_file_list} +) + +SET(MYAPP_HDRS + ${include_file_list} +) + +SET(MYAPP_SRCS + ${cpp_file_list} +) + +SET(MYAPP_TRANS + ${trans_file_list} +) + +SET(MYAPP_RES + ${resource_file_list} +) + +# add special flags for compilation +ADD_DEFINITIONS( -DQXT_STATIC -DMAKE_QIMAGEBLITZ_LIB ) + +# enable warnings for GCC compiler +IF(CMAKE_COMPILER_IS_GNUCXX ) + ADD_DEFINITIONS( -Wall -Wextra ) +ENDIF(CMAKE_COMPILER_IS_GNUCXX ) + +# qt4 definitinos +QT4_WRAP_UI ( MYAPP_UIS_H ${MYAPP_UIS} ) +QT4_WRAP_CPP ( MYAPP_MOC_SRCS ${MYAPP_HDRS} ) +QT4_ADD_RESOURCES ( MYAPP_RESOURCES ${MYAPP_RES} ) +QT4_AUTOMOC ( ${MYAPP_SRCS} ) +QT4_ADD_TRANSLATION ( MYAPP_QM ${MYAPP_TRANS} ) + +IF(COMMAND CMAKE_POLICY) + CMAKE_POLICY(SET CMP0003 NEW) + CMAKE_POLICY(SET CMP0005 OLD) +ENDIF(COMMAND CMAKE_POLICY) + +# Arrange files in folder for Visual Studio ----------------------------------- +SOURCE_GROUP("Include Files" FILES ${MYAPP_HDRS}) +SOURCE_GROUP("Generated Files" FILES ${MYAPP_MOC_SRCS} ${MYAPP_UIS_H} ${MYAPP_RESOURCES}) +SOURCE_GROUP("UI Files" FILES ${MYAPP_UIS} ) + +# we need this to be able to include headers produced by uic in our code +# (CMAKE_BINARY_DIR holds a path to the build directory, while INCLUDE_DIRECTORIES() works just like INCLUDEPATH from qmake) +INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} ) + +# resource compilation for MinGW +IF( MINGW ) + ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${PROGNAME}ico.o + COMMAND windres.exe -I${CMAKE_CURRENT_SOURCE_DIR} -i${CMAKE_CURRENT_SOURCE_DIR}/../res/${PROGNAME}.rc -o ${CMAKE_CURRENT_BINARY_DIR}/${PROGNAME}ico.o ) + SET(MYAPP_RESOURCES ${MYAPP_RESOURCES} ${CMAKE_CURRENT_BINARY_DIR}/${PROGNAME}ico.o) +ELSE( MINGW ) + SET(MYAPP_RESOURCES ${MYAPP_RESOURCES} ../res/${PROGNAME}.rc ) +ENDIF( MINGW ) + +# Set some Win32 Specific Settings +IF(WIN32) + SET(GUI_TYPE WIN32) +ENDIF(WIN32) + +IF (MSVC) + # Turn off deprecation warnings + ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS) + ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_WARNINGS) + ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE) +ENDIF(MSVC) + +# Set some Apple MacOS Specific settings +IF (APPLE) + SET(GUI_TYPE MACOSX_BUNDLE) +ENDIF (APPLE) + +# here we instruct CMake to build "myapp" executable from all of the source files +IF( APPLE ) + ADD_EXECUTABLE( ${PROGNAME} ${GUI_TYPE} ${MYAPP_SRCS} ${MYAPP_UIS_H} ${MYAPP_RESOURCES} ${MYAPP_MOC_SRCS} ) + ADD_CUSTOM_COMMAND( TARGET ${PROGNAME} POST_BUILD + COMMAND mkdir ARGS ${CMAKE_CURRENT_BINARY_DIR}/${PROGNAME}.app/Contents/Resources + COMMAND cp ARGS ${MACOSX_BUNDLE_ICON_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${PROGNAME}.app/Contents/Resources + COMMAND cp ARGS *.qm ${CMAKE_CURRENT_BINARY_DIR}/${PROGNAME}.app/Contents/Resources ) +ELSE( APPLE ) + ADD_EXECUTABLE( ${PROGNAME} WIN32 ${MYAPP_SRCS} ${MYAPP_UIS_H} ${MYAPP_MOC_SRCS} ${MYAPP_RESOURCES} ${MYAPP_QM} ) +ENDIF( APPLE ) + +# last thing we have to do is to tell CMake what libraries our executable needs, +# luckily FIND_PACKAGE prepared QT_LIBRARIES variable for us: +IF (UNIX) + TARGET_LINK_LIBRARIES( ${PROGNAME} ${QT_LIBRARIES} -lQxtGui qimageblitz -lX11 -ldl ) +ELSE (UNIX) + TARGET_LINK_LIBRARIES( ${PROGNAME} ${QT_LIBRARIES} qxt qimageblitz ) +ENDIF (UNIX) + +IF(WIN32) + SET_TARGET_PROPERTIES(${PROGNAME} PROPERTIES + LINK_FLAGS "/VERSION:${MYAPP_VERSION}" + LINK_FLAGS_RELEASE "/ENTRY:\"mainCRTStartup\" /SUBSYSTEM:WINDOWS" + LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE" ) +ENDIF(WIN32) + +# compilation of others directories +ADD_SUBDIRECTORY("../src/3rdparty/qimageblitz" "${CMAKE_CURRENT_BINARY_DIR}/qimageblitz") +ADD_SUBDIRECTORY("../src/3rdparty/qxt" "${CMAKE_CURRENT_BINARY_DIR}/qxt") + +# build desktop file and manpage if needed +IF( UNIX AND NOT APPLE ) + IF( NOT DESKTOP_ENTRY ) + SET( DESKTOP_ENTRY ${PROGNAME}.desktop ) + ENDIF( NOT DESKTOP_ENTRY ) + + ADD_CUSTOM_COMMAND( OUTPUT ${DESKTOP_ENTRY} + COMMAND touch ${DESKTOP_ENTRY} + COMMAND sh ${PROGNAME}-desktop.sh ${CMAKE_INSTALL_PREFIX} ${MYAPP_VERSION} >${DESKTOP_ENTRY} + DEPENDS ${PROGNAME}-desktop.sh + COMMENT "Generating desktop entry file" + ) + ADD_CUSTOM_TARGET( DESKTOP_ENTRY_FILE ALL + DEPENDS ${DESKTOP_ENTRY} + ) + + SET( APP_ICON ../res/${PROGNAME}.png ) + + #Generate manpage + IF( NOT MANPAGE_DIRECTORY ) + set( MANPAGE_DIRECTORY /usr/share/man/man1 ) + ENDIF( NOT MANPAGE_DIRECTORY) + + ADD_CUSTOM_COMMAND( OUTPUT ${PROGNAME}.1.gz + COMMAND touch ${PROGNAME}.1 + COMMAND sh ${PROGNAME}-manpage.sh ${MYAPP_VERSION} >${PROGNAME}.1 + COMMAND gzip -f -9 ${PROGNAME}.1 + DEPENDS ${PROGNAME}-manpage.sh + COMMENT "Generating manpage" + ) + ADD_CUSTOM_TARGET( MANPAGE_FILE ALL + DEPENDS ${PROGNAME}.1.gz + ) + + SET_DIRECTORY_PROPERTIES( ADDITIONAL_MAKE_CLEAN_FILES ${PROGNAME}.1 ${PROGNAME}.1.gz ) +ENDIF (UNIX AND NOT APPLE) + +# install + +# windows +IF (WIN32 AND $ENV{QTDIR} NOT STREQUAL "") + ADD_CUSTOM_COMMAND( TARGET ${PROGNAME} POST_BUILD + # there is a nsi installer !!! + COMMAND makensis.exe /DVERSION=${MYAPP_VERSION} /DSETUP_DIR=../setup ../setup/setup.nsi + COMMENT "Generating setup via NSI installer" + ) +ENDIF (WIN32 AND $ENV{QTDIR} NOT STREQUAL "") + +# linux +if (UNIX AND NOT APPLE) + INSTALL ( TARGETS ${PROGNAME} RUNTIME DESTINATION bin ) + INSTALL ( FILES ${MYAPP_QM} DESTINATION share/locale ) + # freedesktop file + INSTALL(FILES ${PROGNAME}.desktop DESTINATION "${CMAKE_INSTALL_PREFIX}/share/applications/" ) + INSTALL(FILES ${PROGNAME}.1.gz DESTINATION "${MANPAGE_DIRECTORY}" ) + INSTALL(FILES ../res/${PROGNAME}.png DESTINATION "${CMAKE_INSTALL_PREFIX}/share/pixmaps/" ) + INSTALL(FILES ../CREDITS.txt ../README.txt ../AUTHORS.txt ../Changelog.txt DESTINATION share/${PROGNAME}) + +endif (UNIX AND NOT APPLE) + + + + + + diff -Nru syncwall-1.6.0/build/SyncWall.pro syncwall-1.7.4/build/SyncWall.pro --- syncwall-1.6.0/build/SyncWall.pro 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/build/SyncWall.pro 2013-05-05 06:54:12.000000000 +0000 @@ -0,0 +1,8 @@ + +SUBDIRS += libs.pro apps.pro +TEMPLATE = subdirs + + +CONFIG += ordered debug_and_release + + diff -Nru syncwall-1.6.0/build/apps.pro syncwall-1.7.4/build/apps.pro --- syncwall-1.6.0/build/apps.pro 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/build/apps.pro 2013-07-08 11:55:36.000000000 +0000 @@ -0,0 +1,233 @@ + +TARGET = syncwall +TEMPLATE = app + + +CONFIG += ordered debug_and_release + +CONFIG(debug,debug|release) { + LIBS+=-L../src/3rdparty/qimageblitz/debug/ +} else { + LIBS+=-L../src/3rdparty/qimageblitz/release/ +} + +unix:LIBS+= -lX11 + +# directories setup +isEmpty( INSTALL_PREFIX ) : INSTALL_PREFIX = /usr/local + +isEmpty( INSTALL_BINDIR ) : INSTALL_BINDIR = $$INSTALL_PREFIX/bin +isEmpty( INSTALL_LIBDIR ) { + INSTALL_LIBDIR = $$INSTALL_PREFIX/lib + #installing to lib64 on 64-bit platforms: + contains (QMAKE_HOST.arch, x86_64) : INSTALL_LIBDIR = $$INSTALL_PREFIX/lib64 +} + +isEmpty( INSTALL_MANDIR ) : INSTALL_MANDIR = $$INSTALL_PREFIX/share/man +isEmpty( INSTALL_DATADIR ) : INSTALL_DATADIR = $$INSTALL_PREFIX/share + +isEmpty( MYAPP_INSTALL_DESKTOP ) : MYAPP_INSTALL_DESKTOP = $$INSTALL_DATADIR/applications +isEmpty( MYAPP_INSTALL_PIXMAPS ) : MYAPP_INSTALL_PIXMAPS = $$INSTALL_DATADIR/pixmaps +isEmpty( MYAPP_INSTALL_DATA ) : MYAPP_INSTALL_DATA = $$INSTALL_DATADIR/$$TARGET +isEmpty( MYAPP_INSTALL_DIR ) : MYAPP_INSTALL_DIR = $$INSTALL_LIBDIR/$$TARGET +isEmpty( MYAPP_INSTALL_BINDIR ) : MYAPP_INSTALL_BINDIR = $$INSTALL_BINDIR +isEmpty( MYAPP_INSTALL_MAN ) : MYAPP_INSTALL_MAN = $$INSTALL_MANDIR/man1 +isEmpty( MYAPP_INSTALL_TRANS ) : MYAPP_INSTALL_TRANS = $$INSTALL_DATADIR/locale + +LIBS += -L../src/3rdparty/qimageblitz/ -lqimageblitz + +HEADERS += \ + ../src/AppSettings.h \ + ../src/BackgroundPainter.h \ + ../src/BackgroundPainterConfigWidget.h \ + ../src/DesktopScene.h \ + ../src/DesktopView.h \ + ../src/ImageView.h \ + ../src/ImageViewer.h \ + ../src/IMessageHandler.h \ + ../src/LogHandler.h \ + ../src/MiscFunctions.h \ + ../src/NetworkManager.h \ + ../src/NetworkManagerConfigWidget.h \ + ../src/Scheduler.h \ + ../src/SchedulerConfigWidget.h \ + ../src/ScreenItem.h \ + ../src/SingleApplication.h \ + ../src/SplashScreen.h \ + ../src/SyncWall.h \ + ../src/ImageInfos.h \ + ../src/SystemIntegration.h \ + ../src/SystemIntegrationConfigWidget.h \ + ../src/WallpaperProvider.h \ + ../src/ListImagesModel.h \ + ../src/TreeImagesView.h \ + ../src/InfosUpdater.h \ + ../src/IconViewDelegate.h \ + ../src/ThreadPool.h \ + ../src/DatabaseManager.h \ + ../src/BackgroundItem.h \ + ../src/StarRating.h \ + ../src/StarEditor.h \ + ../src/StarDelegate.h \ + ../src/3rdparty/qkeysequencewidget/qkeysequencewidget.h \ + ../src/3rdparty/qkeysequencewidget/qkeysequencewidget_p.h \ + ../src/3rdparty/qxt/qxtglobal.h \ + ../src/3rdparty/qxt/qxtglobalshortcut.h \ + ../src/3rdparty/qt-extended/qexifimageheader.h + +SOURCES += \ + ../src/AppSettings.cpp \ + ../src/BackgroundPainter.cpp \ + ../src/BackgroundPainterConfigWidget.cpp \ + ../src/DesktopScene.cpp \ + ../src/DesktopView.cpp \ + ../src/ImageView.cpp \ + ../src/ImageViewer.cpp \ + ../src/LogHandler.cpp \ + ../src/main.cpp \ + ../src/MiscFunctions.cpp \ + ../src/NetworkManager.cpp \ + ../src/NetworkManagerConfigWidget.cpp \ + ../src/Scheduler.cpp \ + ../src/SchedulerConfigWidget.cpp \ + ../src/ScreenItem.cpp \ + ../src/SingleApplication.cpp \ + ../src/SplashScreen.cpp \ + ../src/SyncWall.cpp \ + ../src/ImageInfos.cpp \ + ../src/SystemIntegration.cpp \ + ../src/SystemIntegrationConfigWidget.cpp \ + ../src/WallpaperProvider.cpp \ + ../src/ListImagesModel.cpp \ + ../src/TreeImagesView.cpp \ + ../src/InfosUpdater.cpp \ + ../src/IconViewDelegate.cpp \ + ../src/ThreadPool.cpp \ + ../src/DatabaseManager.cpp \ + ../src/BackgroundItem.cpp \ + ../src/StarRating.cpp \ + ../src/StarEditor.cpp \ + ../src/StarDelegate.cpp \ + ../src/3rdparty/qkeysequencewidget/qkeysequencewidget.cpp \ + ../src/3rdparty/qxt/qxtglobal.cpp \ + ../src/3rdparty/qxt/qxtglobalshortcut.cpp \ + ../src/3rdparty/qt-extended/qexifimageheader.cpp + + +FORMS += \ + ../ui/BackgroundPainterConfigWidget.ui \ + ../ui/ImageViewer.ui \ + ../ui/NetworkManagerConfigWidget.ui \ + ../ui/SchedulerConfigWidget.ui \ + ../ui/SyncWall.ui \ + ../ui/SystemIntegrationConfigWidget.ui + +INCLUDEPATH += \ + $${DESTDIR} \ + ../src/3rdparty/qimageblitz \ + ../src/3rdparty/qkeysequencewidget \ + ../src/3rdparty/qxt \ + ../src/3rdparty/qt-extended \ + ../src + +# OS2 specific +os2:SOURCES -= \ + ../src/3rdparty/qxt/qxtglobal.cpp \ + ../src/3rdparty/qxt/qxtglobalshortcut.cpp + +os2:HEADERS -= \ + ../src/3rdparty/qxt/qxtglobal.h \ + ../src/3rdparty/qxt/qxtglobalshortcut.h + +DEFINES += QXT_STATIC MAKE_QIMAGEBLITZ_LIB + +win32-msvc*:DEFINES += _CRT_NONSTDC_NO_DEPRECATE _CRT_SECURE_NO_WARNINGS _CRT_SECURE_NO_DEPRECATE + +RESOURCES += ../res/syncwall.qrc + +QT += core gui network sql + +TRANSLATIONS = ../lang/syncwall_fr.ts ../lang/syncwall_lt.ts ../lang/syncwall_nl.ts + +macx:ICON = ../res/syncwall.icns +macx:SOURCES += ../src/3rdparty/qxt/qxtglobalshortcut_mac.cpp +macx:QMAKE_INFO_PLIST = ../res/Info.plist + +win32:RC_FILE = ../res/syncwall.rc +win32:SOURCES += ../src/3rdparty/qxt/qxtglobalshortcut_win.cpp + +unix:SOURCES += ../src/3rdparty/qxt/qxtglobalshortcut_x11.cpp + + +Release:DESTDIR = release +Release:OBJECTS_DIR = release +Release:MOC_DIR = release +Release:RCC_DIR = release +Release:UI_DIR = release + +Debug:DESTDIR = debug +Debug:OBJECTS_DIR = debug +Debug:MOC_DIR = debug +Debug:RCC_DIR = debug +Debug:UI_DIR = debug + +# .qm file for mingw and before setup.nsi +win32-g++ { + # add auto compilation of .ts files + QMAKE_EXTRA_COMPILERS += copyQtTrans + for(TRANS,TRANSLATIONS){ + lang = $$replace(TRANS, .*_([^/]*)\\.ts, \\1) + GLOBALTRANSLATIONS += $$[QT_INSTALL_TRANSLATIONS]/qt_$${lang}.qm + } + copyQtTrans.input = GLOBALTRANSLATIONS + copyQtTrans.output = ${QMAKE_FILE_BASE}.qm + copyQtTrans.commands = cp ${QMAKE_FILE_IN} ../lang/ + copyQtTrans.CONFIG += no_link target_predeps + + # add auto compilation of .ts files + QMAKE_EXTRA_COMPILERS += lrelease + lrelease.input = TRANSLATIONS + lrelease.output = ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.qm + lrelease.commands = $$[QT_INSTALL_BINS]/lrelease ${QMAKE_FILE_IN} -qm ../lang/${QMAKE_FILE_BASE}.qm + lrelease.CONFIG += no_link target_predeps +} + + +unix { + # add auto compilation of .ts files + QMAKE_EXTRA_COMPILERS += lrelease + lrelease.input = TRANSLATIONS + lrelease.output = ${QMAKE_FILE_BASE}.qm + lrelease.commands = $$[QT_INSTALL_BINS]/lrelease ${QMAKE_FILE_IN} -qm ../lang/${QMAKE_FILE_BASE}.qm + lrelease.CONFIG += no_link target_predeps + + # to copy executable to /usr/local/bin directory + starter.files = $$PWD//release/syncwall + starter.path = $$MYAPP_INSTALL_BINDIR + + transl.files = $$PWD/../lang/*.qm + transl.path = $$MYAPP_INSTALL_TRANS + + data.files += $$PWD/../CREDITS.txt $$PWD/../README.txt $$PWD/../AUTHORS.txt $$PWD/../Changelog.txt + data.path = $$MYAPP_INSTALL_DATA + + # generate desktop file + VERSION = $$system(grep VERSION $$PWD/../src/AppSettings.h | awk \' { print $NF }\' | sed \'s/\"//g\') + system( sh $$PWD/syncwall-desktop.sh $$INSTALL_PREFIX $$VERSION > $$PWD/syncwall.desktop ) + desktop.files += syncwall.desktop + desktop.path = $$MYAPP_INSTALL_DESKTOP + + icons.files += $$PWD/../res/syncwall.png + icons.path = $$MYAPP_INSTALL_PIXMAPS + + # generate manpage + system( sh $$PWD/syncwall-manpage.sh > syncwall.1 ) + system( gzip -9 -f $$PWD/syncwall.1 ) + manual.files += $$PWD/syncwall.1.gz + manual.path = $$MYAPP_INSTALL_MAN + + INSTALLS += starter transl data desktop icons manual +} + + + diff -Nru syncwall-1.6.0/build/debian/changelog syncwall-1.7.4/build/debian/changelog --- syncwall-1.6.0/build/debian/changelog 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/build/debian/changelog 2012-02-25 07:55:28.000000000 +0000 @@ -0,0 +1,12 @@ +syncwall (1.3.0-1~webupd8~oneiric) oneiric; urgency=medium + + * new upstream release + * removed showwindowtray.patch (now available upstream) + + -- Alin Andrei Sat, 25 Feb 2012 14:55:25 +0000 + +syncwall (1.2.1-1~webupd8~oneiric4) oneiric; urgency=medium + + * Initial upload + + -- Alin Andrei Mon, 13 Feb 2012 12:23:35 +0000 diff -Nru syncwall-1.6.0/build/debian/control syncwall-1.7.4/build/debian/control --- syncwall-1.6.0/build/debian/control 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/build/debian/control 2012-02-13 05:39:00.000000000 +0000 @@ -0,0 +1,13 @@ +Source: syncwall +Section: x11 +Priority: optional +Maintainer: Alin Andrei +Build-Depends: debhelper, cdbs, libqt4-dev, libx11-dev +Standards-Version: 3.8.3 +Homepage: http://qt-apps.org/content/show.php/SyncWall?content=148311 + +Package: syncwall +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Wallpaper changer + SyncWall is quite a basic wallpaper changer with a special feature, it is the ability to synchronize wallpaper change between several workstations with a basic (and unsecured) client/server protocol. SyncWall has also some multi monitor support. diff -Nru syncwall-1.6.0/build/debian/copyright syncwall-1.7.4/build/debian/copyright --- syncwall-1.6.0/build/debian/copyright 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/build/debian/copyright 2012-02-13 05:22:46.000000000 +0000 @@ -0,0 +1,25 @@ +This package was debianized by: + + Alin Andrei on Mon, 13 Feb 2012 12:22:36 +0000 + +It was downloaded from: + + http://qt-apps.org/content/show.php/SyncWall?content=148311 + +Upstream Author(s): + + xbee + +Copyright: + + Copyright (C) 2012 xbee + +License: + + GPL 2.0+ + +The Debian packaging is: + + Copyright (C) 2011 Alin Andrei + +and is licensed under the GPL version 2.0+. diff -Nru syncwall-1.6.0/build/debian/install syncwall-1.7.4/build/debian/install --- syncwall-1.6.0/build/debian/install 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/build/debian/install 2012-02-13 05:24:00.000000000 +0000 @@ -0,0 +1 @@ +debian/syncwall.desktop /usr/share/applications/ diff -Nru syncwall-1.6.0/build/debian/patches/pathfix.patch syncwall-1.7.4/build/debian/patches/pathfix.patch --- syncwall-1.6.0/build/debian/patches/pathfix.patch 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/build/debian/patches/pathfix.patch 2012-02-13 05:25:22.000000000 +0000 @@ -0,0 +1,24 @@ +--- syncwall-1.2.1.orig/SyncWall/src/SyncWall.cpp ++++ syncwall-1.2.1/SyncWall/src/SyncWall.cpp +@@ -983,7 +983,7 @@ + paths << QApplication::applicationDirPath () + "/../" + file; + paths << QApplication::applicationDirPath () + "/../../" + file; + paths << QApplication::applicationDirPath () + "/../../../" + file; +- paths << "/usr/local/share/syncwall/" + file; ++ paths << "/usr/share/syncwall/" + file; + + + foreach (const QString &path, paths) + +--- syncwall-1.2.1.orig/SyncWall/build/build.pro ++++ syncwall-1.2.1/SyncWall/build/build.pro +@@ -12,7 +12,7 @@ + unix:LIBS+= -lX11 + + # directories setup +-isEmpty( INSTALL_PREFIX ) : INSTALL_PREFIX = /usr/local ++isEmpty( INSTALL_PREFIX ) : INSTALL_PREFIX = /usr + + isEmpty( INSTALL_BINDIR ) : INSTALL_BINDIR = $$INSTALL_PREFIX/bin + isEmpty( INSTALL_LIBDIR ) { + diff -Nru syncwall-1.6.0/build/debian/patches/series syncwall-1.7.4/build/debian/patches/series --- syncwall-1.6.0/build/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/build/debian/patches/series 2012-02-25 07:53:56.000000000 +0000 @@ -0,0 +1 @@ +pathfix.patch diff -Nru syncwall-1.6.0/build/debian/rules syncwall-1.7.4/build/debian/rules --- syncwall-1.6.0/build/debian/rules 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/build/debian/rules 2012-02-13 05:18:40.000000000 +0000 @@ -0,0 +1,7 @@ +#!/usr/bin/make -f + +%: + dh $@ + +override_dh_auto_configure: + qmake INSTALL_PREFIX=/usr -recursive diff -Nru syncwall-1.6.0/build/debian/source/format syncwall-1.7.4/build/debian/source/format --- syncwall-1.6.0/build/debian/source/format 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/build/debian/source/format 2012-01-27 06:08:26.000000000 +0000 @@ -0,0 +1 @@ +3.0 (quilt) diff -Nru syncwall-1.6.0/build/debian/syncwall.desktop syncwall-1.7.4/build/debian/syncwall.desktop --- syncwall-1.6.0/build/debian/syncwall.desktop 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/build/debian/syncwall.desktop 2012-02-13 04:46:36.000000000 +0000 @@ -0,0 +1,10 @@ +[Desktop Entry] +Version=1.0 +Encoding=UTF-8 +Name=SyncWall +Comment=Wallpaper changer +Type=Application +GenericName=Wallpaper changer +Exec=syncwall +Categories=Utility;Application; +Icon=syncwall diff -Nru syncwall-1.6.0/build/libs.pro syncwall-1.7.4/build/libs.pro --- syncwall-1.6.0/build/libs.pro 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/build/libs.pro 2013-05-04 12:53:34.000000000 +0000 @@ -0,0 +1,3 @@ +SUBDIRS += ../src/3rdparty +TEMPLATE = subdirs + diff -Nru syncwall-1.6.0/build/syncwall-desktop.sh syncwall-1.7.4/build/syncwall-desktop.sh --- syncwall-1.6.0/build/syncwall-desktop.sh 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/build/syncwall-desktop.sh 2013-04-20 09:39:42.000000000 +0000 @@ -0,0 +1,13 @@ +#!/bin/sh +cat < Sun, 18 Aug 2013 17:50:34 +0900 + syncwall (1.6.0-0~ppa5) precise; urgency=low * New upstream release - -- Sawa (ikoinoba) Sun, 19 Aug 2012 22:58:32 +0900 + -- Sawa (ikoinoba) Sun, 19 Aug 2012 22:58:32 +0900 syncwall (1.5.0-0~ppa5) precise; urgency=low * New upstream release - -- Sawa (ikoinoba) Thu, 03 May 2012 14:39:10 +0900 + -- Sawa (ikoinoba) Thu, 03 May 2012 14:39:10 +0900 syncwall (1.4.0-0~ppa5) precise; urgency=low * New upstream release - -- Sawa (ikoinoba) Mon, 09 Apr 2012 23:43:55 +0900 + -- Sawa (ikoinoba) Mon, 09 Apr 2012 23:43:55 +0900 syncwall (1.3.0-0.1~ppa4) oneiric; urgency=low * New upstream release - -- Sawa (ikoinoba) Tue, 28 Feb 2012 22:44:51 +0900 + -- Sawa (ikoinoba) Tue, 28 Feb 2012 22:44:51 +0900 syncwall (1.2.1-0.1~ppa4) oneiric; urgency=low * New upstream release - -- Sawa (ikoinoba) Mon, 30 Jan 2012 18:44:38 +0900 + -- Sawa (ikoinoba) Mon, 30 Jan 2012 18:44:38 +0900 syncwall (1.2.0-0.3~ppa4) oneiric; urgency=low * Initial release - -- Sawa (ikoinoba) Fri, 27 Jan 2012 22:09:10 +0900 + -- Sawa (ikoinoba) Fri, 27 Jan 2012 22:09:10 +0900 diff -Nru syncwall-1.6.0/debian/control syncwall-1.7.4/debian/control --- syncwall-1.6.0/debian/control 2012-01-30 09:45:14.000000000 +0000 +++ syncwall-1.7.4/debian/control 2013-08-18 10:18:05.000000000 +0000 @@ -1,14 +1,15 @@ Source: syncwall Section: x11 Priority: optional -Maintainer: Sawa (ikoinoba) -Build-Depends: debhelper, dos2unix, libqt4-dev, libx11-dev +Maintainer: Sawa (ikoinoba) +Build-Depends: debhelper, dos2unix, libqt4-dev, libx11-dev, libqt4-sql-sqlite Standards-Version: 3.9.2 Homepage: http://thehive.xbee.net/index.php?module=pages&func=display&pageid=1 Package: syncwall Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} +Pre-Depends: dpkg (>= 1.15.6) Description: Wallpaper management with synchronization features SyncWall is quite a basic wallpaper changer with a special feature, it is the ability to synchronize wallpaper change between several diff -Nru syncwall-1.6.0/debian/copyright syncwall-1.7.4/debian/copyright --- syncwall-1.6.0/debian/copyright 2012-01-28 04:57:12.000000000 +0000 +++ syncwall-1.7.4/debian/copyright 2013-08-18 08:51:34.000000000 +0000 @@ -7,7 +7,7 @@ License: GPL-2.0+ Files: debian/* -Copyright: 2012 Sawa +Copyright: 2012 Sawa License: GPL-2.0+ License: GPL-2.0+ diff -Nru syncwall-1.6.0/debian/docs syncwall-1.7.4/debian/docs --- syncwall-1.6.0/debian/docs 2012-01-28 04:57:12.000000000 +0000 +++ syncwall-1.7.4/debian/docs 2013-08-18 09:16:36.000000000 +0000 @@ -5,3 +5,4 @@ LICENSE.txt NEWS.txt README.txt +TODO.txt diff -Nru syncwall-1.6.0/debian/patches/doc_path.diff syncwall-1.7.4/debian/patches/doc_path.diff --- syncwall-1.6.0/debian/patches/doc_path.diff 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/debian/patches/doc_path.diff 2013-08-18 09:43:22.000000000 +0000 @@ -0,0 +1,12 @@ +diff -uNr syncwall-1.7.4.orig/src/SyncWall.cpp syncwall-1.7.4/src/SyncWall.cpp +--- syncwall-1.7.4.orig/src/SyncWall.cpp 2013-05-17 21:31:48.000000000 +0900 ++++ syncwall-1.7.4/src/SyncWall.cpp 2013-08-18 18:24:37.287416879 +0900 +@@ -1230,7 +1230,7 @@ + paths << QApplication::applicationDirPath () + "/../../" + file; + paths << QApplication::applicationDirPath () + "/../../../" + file; + paths << "/usr/share/" + QString("%1").arg(PACKAGE_NAME).toLower() + "/" + file; +- paths << "/usr/local/share/" + QString("%1").arg(PACKAGE_NAME).toLower() + "/" + file; ++ paths << "/usr/share/doc/syncwall/" + file; + + foreach (const QString &path, paths) + { diff -Nru syncwall-1.6.0/debian/patches/docpath.diff syncwall-1.7.4/debian/patches/docpath.diff --- syncwall-1.6.0/debian/patches/docpath.diff 2012-04-09 14:55:45.000000000 +0000 +++ syncwall-1.7.4/debian/patches/docpath.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -diff -uNr syncwall-1.4.0.orig/SyncWall/src/SyncWall.cpp syncwall-1.4.0/SyncWall/src/SyncWall.cpp ---- syncwall-1.4.0.orig/SyncWall/src/SyncWall.cpp 2012-03-19 22:11:26.000000000 +0900 -+++ syncwall-1.4.0/SyncWall/src/SyncWall.cpp 2012-04-09 23:55:35.547735404 +0900 -@@ -1021,7 +1021,7 @@ - paths << QApplication::applicationDirPath () + "/../../../" + file; - paths << "/usr/share/syncwall/" + file; - paths << "/usr/local/share/syncwall/" + file; -- -+ paths << "/usr/share/doc/syncwall/" + file; - - foreach (const QString &path, paths) - { diff -Nru syncwall-1.6.0/debian/patches/locale_path.diff syncwall-1.7.4/debian/patches/locale_path.diff --- syncwall-1.6.0/debian/patches/locale_path.diff 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/debian/patches/locale_path.diff 2013-08-18 10:13:02.000000000 +0000 @@ -0,0 +1,11 @@ +diff -uNr syncwall-1.7.4.orig/src/MiscFunctions.cpp syncwall-1.7.4/src/MiscFunctions.cpp +--- syncwall-1.7.4.orig/src/MiscFunctions.cpp 2013-07-13 14:30:42.000000000 +0900 ++++ syncwall-1.7.4/src/MiscFunctions.cpp 2013-08-18 19:00:57.471445444 +0900 +@@ -148,6 +148,7 @@ + { + // search in application path + QStringList ldir; ++ ldir << "/usr/share/" + QString("%1").arg(PACKAGE_NAME).toLower() + "/lang"; + ldir << QCoreApplication::applicationDirPath () + "/lang"; + ldir << QCoreApplication::applicationDirPath () + "/../lang"; + ldir << QCoreApplication::applicationDirPath () + "/../../lang"; diff -Nru syncwall-1.6.0/debian/patches/series syncwall-1.7.4/debian/patches/series --- syncwall-1.6.0/debian/patches/series 2012-01-28 04:57:18.000000000 +0000 +++ syncwall-1.7.4/debian/patches/series 2013-08-18 10:01:41.000000000 +0000 @@ -1 +1,2 @@ -docpath.diff +locale_path.diff +#doc_path.diff diff -Nru syncwall-1.6.0/debian/rules syncwall-1.7.4/debian/rules --- syncwall-1.6.0/debian/rules 2012-01-28 04:57:12.000000000 +0000 +++ syncwall-1.7.4/debian/rules 2013-08-18 10:13:16.000000000 +0000 @@ -12,16 +12,17 @@ %: dh $@ -override_dh_builddeb: - dh_builddeb -- -Z lzma - override_dh_auto_configure: dos2unix tounix.sh sh ./tounix.sh -# qmake-qt4 -recursive INSTALL_PREFIX=/usr ?? - qmake-qt4 -recursive + cd build && qmake -recursive INSTALL_PREFIX=$(CURDIR)/debian/syncwall/usr SyncWall.pro + +override_dh_auto_build: + cd build && $(MAKE) override_dh_auto_install: - sed -i 's|/usr/local|$(CURDIR)/debian/syncwall/usr|' SyncWall/build/build.pro - cd SyncWall/build && make install - rm -rf $(CURDIR)/debian/syncwall/usr/share/syncwall + cd build && $(MAKE) install + mv $(CURDIR)/debian/syncwall/usr/share/locale $(CURDIR)/debian/syncwall/usr/share/syncwall/lang + +override_dh_builddeb: + dh_builddeb -- -Zxz diff -Nru syncwall-1.6.0/debian/syncwall.desktop syncwall-1.7.4/debian/syncwall.desktop --- syncwall-1.6.0/debian/syncwall.desktop 2012-01-28 04:57:12.000000000 +0000 +++ syncwall-1.7.4/debian/syncwall.desktop 2013-08-18 09:22:52.000000000 +0000 @@ -1,6 +1,6 @@ [Desktop Entry] Name=SyncWall -Comment=Wallpaper management with synchronization features +Comment=SyncWall is quite a basic wallpaper changer with a special feature Type=Application GenericName=Wallpaper manager Exec=syncwall diff -Nru syncwall-1.6.0/formater.bat syncwall-1.7.4/formater.bat --- syncwall-1.6.0/formater.bat 2012-01-12 01:51:04.000000000 +0000 +++ syncwall-1.7.4/formater.bat 2013-05-04 12:26:32.000000000 +0000 @@ -1,3 +1,3 @@ -cd SyncWall\src +cd src dir /b *.cpp *.h > lfiles.txt -uncrustify.exe -F lfiles.txt -c ..\..\uncrustify.cfg +uncrustify.exe -F lfiles.txt --no-backup -c ..\uncrustify.cfg Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/lang/qt_fr.qm and /tmp/OqecVKC_d5/syncwall-1.7.4/lang/qt_fr.qm differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/lang/qt_lt.qm and /tmp/OqecVKC_d5/syncwall-1.7.4/lang/qt_lt.qm differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/lang/qt_nl.qm and /tmp/OqecVKC_d5/syncwall-1.7.4/lang/qt_nl.qm differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/lang/syncwall_fr.qm and /tmp/OqecVKC_d5/syncwall-1.7.4/lang/syncwall_fr.qm differ diff -Nru syncwall-1.6.0/lang/syncwall_fr.ts syncwall-1.7.4/lang/syncwall_fr.ts --- syncwall-1.6.0/lang/syncwall_fr.ts 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/lang/syncwall_fr.ts 2013-07-13 05:59:22.000000000 +0000 @@ -0,0 +1,1480 @@ + + + + + + release of translation and translator name please + put your name here dear translator and the release of the translation file !! + traduction 1.7.0 par xbee + + + + BackgroundPainterConfigWidget + + + BackgroundPainterConfigWidget + BackgroundPainterConfigWidget + + + + Image parameters + Paramètres d'images + + + + Basic + Réglages de base + + + + Horizontal alignment + Alignement horizontal + + + + Resizing method + Méthode de redimensionnement + + + + Vertical alignment + Alignement vertical + + + + Multi monitor support + Support multi-moniteurs + + + + Multi monitor display + Affichage multi-écrans + + + + Expert + Réglages avancées + + + + ignore image parameters from server (client) + Ignorer les paramètres d'image du serveur (client) + + + + skip image too small for resizing (<50% of final image) + Ignorer les images trop petites (<50% de la taille finale) + + + + export image parameters to clients (server) + Transmission des paramètres d'image aux clients (serveur) + + + + Background + Fond + + + + Inverse gradient color + Inverser les couleurs du gradient + + + + Special effect + Effets spéciaux + + + + Rotate image according to Metadata + Tourner l'image par rapport aux metadonnées + + + + Upsampling method + Méthode de suréchantillonnage + + + + (Can greatly increase the computation time) + (peut accroître de manière importance la charge CPU) + + + + Preview desktop + Prévisualisation bureau + + + + No data + Aucune donnée + + + + Tips: You can reorder and align screens by drag&drop + Remarque: vous pouvez réordonner et aligner les écrans par glisser & poser + + + + no resize + Aucun redimentionnement + + + + Stretch to fill (Ignore aspect ratio) + Remplissage (ignorer les proportions) + + + + Proportionally stretch to fit + Adapter en étirant proportionnellement + + + + Fill proportionally + Remplir proportionnellement + + + + No multi monitor support (wallpaper duplicated) + Pas de prise en compte du multi-écrans (fond d'écran dupliqué) + + + + Extend image (one file for all monitors) + Etendre l'image (une image pour tous les écrans) + + + + Extend image then crop (one file per monitor) + Etendre l'image (une image par écran) + + + + Top alignment + Alignement haut + + + + + Center alignment + Alignement Centré + + + + Bottom alignment + Alignement bas + + + + Left alignment + Alignement gauche + + + + Right alignment + Alignement droit + + + + Fixed color + Couleur fixe + + + + Smart color (extract from image) + Couleur automatique + + + + Blurred image + Image floue + + + + Vertical gradient + Gradient vertical + + + + Horizontal gradient + Gradient Horizontal + + + + Radial gradient + Gradient radial + + + + Qt default algorithm + Méthode par défaut + + + + Blackman smooth filter + Filtre de Blackman + + + + Cubic filter + Filter cubique + + + + Mitchell filter + Filtre de Mitchell + + + + Lanczos filter + Filtre Lanczos + + + + No effect + Aucun effet + + + + Grayscale + Niveau de gris + + + + Blur + Flou + + + + Gaussian blur + Flou gaussien + + + + Edge + Contours + + + + Sharpen + Netteté + + + + Gaussian sharpen + Netteté gaussienne + + + + Emboss + Gauffrage + + + + Desaturate + Désaturer + + + + Flatten + Applatir + + + + Swirl + Tourbillon + + + + Oilpaint + Peinture à l'huile + + + + Charcoal + Fusain + + + + Sepia + Sépia + + + + Invert colors + Inversion des couleurs + + + + Glow + Brillance + + + + Progressive blur + Flou progressif + + + + Random Effect + Effet aléatoire + + + + DatabaseManager + + + No SQLITE driver available + Aucun pilote SQLITE n'est accessible + + + + DatabaseManager::init: open db %1 ... + DatabaseManager::init: ouverture db %1 ... + + + + DatabaseManager::createDB: db connection failed ... (%1) + DatabaseManager::createDB: la connection à db à échouée ... (%1) + + + + DatabaseManager::createDB: cannot create table ... (%1) + DatabaseManager::createDB: impossible de créer la table ... (%1) + + + + DatabaseManager::openDB: database version don't match current one ! + DatabaseManager::openDB: la version de la base de données ne correspond pas à la version courante ! + + + + DatabaseManager::removeInfos: Error when removing data for %2 (%1) + DatabaseManager::removeInfos: Erreur lors de l'éffacement de %2 (%1) + + + + DatabaseManager::storeInfos: Error in query preparation ... (%1) + DatabaseManager::storeInfos: Erreur dans la préparation de la requête ... (%1) + + + + DatabaseManager::storeInfos: Error in query execution ... (%1) + DatabaseManager::storeInfos: Ereur lors de l'exécution de la requête ... (%1) + + + + ImageView + + + x: %1 y: %2 | r: %3 g: %4 b: %5 + x: %1 y: %2 | r: %3 v: %4 b: %5 + + + + a: %1 + a: %1 + + + + ImageViewer + + + ImageViewer + ImageViewer + + + + no info + aucune information + + + + ListImagesModel + + + Name + Nom + + + + Rate + Note + + + + Image size + Dimension + + + + File size + Taille + + + + Offset defined by user + Décalage utilisateur + + + + NetworkManagerConfigWidget + + + NetworkManagerConfigWidget + NetworkManagerConfigWidget + + + + Synchronise with server + Synchroniser avec un serveur + + + + Server (name or IP) + Serveur (nom ou IP) + + + + No connection + Aucune connection + + + + Test Connection + Tester la connexion + + + + UDP Port + Port UDP + + + + Server %1 reached ... + Serveur %1 atteint ... + + + + Disconnection from server %1 ... + Deconnection du serveur %1 ... + + + + QObject + + + BackgroundPainterConfigWidget: image %1 is reject because its size is too small (%2x%3/%4x%5)) + BackgroundPainterConfigWidget: l'image %1 est rejetée car trop petite (%2x%3/%4x%5)) + + + + BackgroundPainterConfigWidget: too many reject files => please change settings of add more hi-resolution images !! + BackgroundPainterConfigWidget:trop de fichier rejetés => changez le paramétrage of ajouter plus de fichiers en haute résolution !! + + + + BackgroundPainterConfigWidget: Message with invalid nb of parameters (%1 instead of %2) + BackgroundPainterConfigWidget: Message avec un nombre de parametres incorrects (%1 au lieu de %2) + + + + BackgroundPainterConfigWidget: Message with unknown version received (%1) + BackgroundPainterConfigWidget: Message ayant une version inconnue (%1) + + + + Bytes + Octets + + + + KB + Ko + + + + MB + Mo + + + + GB + Go + + + + TB + To + + + + Wallpaper manager. + Gestionnaire de fond d'écran. + + + + Usage: + Usage: + + + + [options] + [options] + + + + Following options are known: + Les options suivantes sont possibles : + + + + --help : displays this help. + --help : Affichage de cette aide. + + + + --reset-config : clear the saved preference parameters. + --reset-config : Effacement des paramètres de configuration sauvegardés. + + + + --no-singleinstance : enable the use of multiple instance of program (not recommended). + --no-singleinstance : autorise l'utilisation de plusieurs instances du programme (non recommandé). + + + + message from other instance. + message d'une autre instance. + + + + %1 is already running !! + %1 est déjà en fonctionnement !! + + + + Cleaning temp storage %1 ... + Nettoyage du répertoire temporaire %1 ... + + + + Deleting %1 + Effacement de %1 + + + + translations path %1 + chemin des traductions %1 + + + + setting language to : %1 + positionner le lauguage à %1 + + + + successfully loaded data from %1 + chargement réussi des données de %1 + + + + failed to load data from %1 + échec de chargement des données de %1 + + + + NetworkManager: Mode SERVER listen to %1 port + NetworkManager: Mode SERVEUR écoute sur le port %1 + + + + NetworkManager: Mode CLIENT listen to %1 port + NetworkManager: Mode CLIENT écoute sur le port %1 + + + + NetworkManager: Send Server Identification for "%1" on port %2 + NetworkManager: Envoie identification au serveur pour "%1" sur le port %2 + + + + NetworkManager: Received message on port %1 + NetworkManager: Réception message sur le port %1 + + + + NetworkManager: Received Server call datagram: "%1" + NetworkManager: Réception datagram appel serveur: "%1" + + + + NetworkManager: Adding %1 to client list + NetworkManager: Ajout %1 à la liste des clients + + + + NetworkManager: %1 is already in the client list + NetworkManager: %1 est déjà dans la liste des clients + + + + NetworkManager: Received background change: "%1" + NetworkManager: Réception changement de fond d'écran : "%1" + + + + NetworkManager: no address found for host %1 (%2) + NetworkManager: pas d'adresse trouvée pour %1 (%2) + + + + NetworkManager: Send Server Call for "%1" on port %2 + NetworkManager: Envoie appel serveur pour "%1" sur le port %2 + + + + NetworkManager: Send message to "%1" (%2) on port %3 + NetworkManager: Envoie message à "%1" (%2) sur le port %3 + + + + NetworkManager:: Sending new message to client %1 + NetworkManager:: Envoie nouveau message au client %1 + + + + NetworkManager:: Ping server %1 + NetworkManager:: Ping du serveur %1 + + + + %1 found + %1 trouvé + + + + KDE3 desktop + KDE3 + + + + KDE4 desktop + KDE4 + + + + GNOME desktop + Gnome + + + + GNOME3 desktop + Gnome3 + + + + XFCE desktop + XFCE + + + + XFCE4 desktop + XFCE4 + + + + FLUXBOX desktop + FLUXBOX + + + + BLACKBOX desktop + BlackBox + + + + Enlightenment desktop + Enlightenment + + + + ICEWM desktop + IceWM + + + + OPENBOX desktop + OpenBox + + + + LXDE desktop + LXDE + + + + WINDOWMAKER desktop + WindowMaker + + + + FVWM desktop + FVWM + + + + WINDOWS desktop + Windows + + + + MACOSX desktop + Max OSX + + + + OS/2 desktop + OS/2 + + + + Automatic detection + Détection automatique + + + + No Desktop Environment Detected + Aucun environnement détecté + + + + Scheduler + + + update interval is to low (%1) => force to %2 sec ... + l'intervalle de temps est trop faible (%1) => passage à %2 sec ... + + + + + Start new timer for %1 sec ... + Démarrage d'un nouveau minuteur pour %1 sec ... + + + + New Schedule fired ... + Nouvelle programmation démarrée ... + + + + SchedulerConfigWidgetClass + + + SchedulerConfigWidget + SchedulerConfigWidget + + + + Scheduling parameters + Paramètres de programmation + + + + + Auto change at startup + Changement automatique au démarrage + + + + Quit application after startup change (30s) + Quitter l'application après le démarrage (30sec) + + + + Change Interval + Intervale + + + + Interval between change (h:m:s) + Intervale entre les changements + + + + set time of day (h:m:s) + Ajouter un horaire + + + + Add to the timeofday list + Ajouter à la liste des horaires + + + + Delete selected timeofday + Effacer les horaires sélectionnés + + + + h:mm:ss + h:mm:ss + + + + SyncWall + + + Can't create storage location, check why ?! (%1) + Impossible de créer le répertoire de stockage, recherchez pourquoi ?! (%1) + + + + Active Desktop must be disabled !! + ActiveDesktop doit être désactivé !! + + + + The application can't find a valid SQLITE driver, its performance and functionality will be degraded + L'application ne trouve pas de pilote SQLITE, ses performances et fonctionnalités seront dégradées + + + + detected language: %1 + langue détectée : %1 + + + + Automatic detection + détection automatique + + + + Default (no use of translation files) + défaut (pas d'utilisation de traduction) + + + + The application need to restart in order to take into account new translation +, Do you want to restart application now ? + L'application a besoin de redémarrer pour tenir compte de la nouvelle langue +Voulez-vous redémarrer l'application maintenant ? + + + + Log file + Fichier de log + + + + Can't save log file !!: %1 + Impossible de sauver le fichier de log : %1 + + + + Add Wallpaper Directory + Ajouter un répertoire de fonds d'écran + + + + + Add all found directories recursively ? + Ajouter tous les répertoires récursivement ? + + + + + Watch for modifications in these directories at application startup ? + Suivre les modifications du contenu de ces répertoires au démarrage de l'application ? + + + + add %1 folder + ajouter répertoire %1 + + + + Select one or more wallpapers + Sélectionner un ou plusieurs fonds d'écran + + + + Images (%1) + Images (%1) + + + + Systray + Zone de notification + + + + The program will keep running in the system tray. To terminate the program, choose <b>Quit</b> in the context menu of the system tray entry. + Le programme va rester actif dans la zone de notification. Pour sortir définitivement, choisir <b>Quitter</b> dans le menu contextuel de la zone de notification. + + + + %1 images in list + %1 images dans la liste + + + + <a href="%1">Check for new release ...</a> + <a href="%1">Voir pour une nouvelle version ...</a> + + + + Qt version %1 + Qt version %1 + + + + new file received : %1 + nouveau fichier reçu : %1 + + + + Can't find local file as received : %1 + Impossible de trouver un fichier local correspondant à la réception : %1 + + + + Standard state. Scheduling is activated + Etat Standard . La programmation est activée + + + + Idle state. No scheduling and no server connection + Etat en attente: Aucune programmation et pas de synchronisation serveur + + + + Server state. Al least a client is connected + Etat serveur : Au moins un client est connecté + + + + Client state. Connected to server + Etat Client : connection au serveur active + + + + Client state but disconnected from server + Etat Client mais déconnecté du serveur + + + + Client state but the protocol isn't correct. Upgrade client or server ! + Etat Client mais le protocol n'est pas correct. Mettre à jour le client ou le serveur ! + + + + The %1 file can't be found, sorry ... + Le fichier %1 n'a pas été trouvé, désolé ... + + + + Do you want to reset all the preferences to default value ? + If yes, the application will be relaunch + Voulez-vous effacer toutes les préférences ? +Si oui, l'application va redémarrer + + + + Do you want to reset all cached data (thumbnails and ratings) ? + Voulez vous effacer les données en cache (imagettes et notes) ? + + + + SyncWallClass + + + SyncWall + SyncWall + + + + Preview + Prévisualisation + + + + No wallpaper + Aucun fond d'écran + + + + Auto change in random order + Changement automatique aléatoire + + + + + Quit + Quitter + + + + Online Help + Aide en ligne + + + + Add a new folder + Ajouter un nouveau répertoire + + + + + Add new file(s) + Ajouter de nouveaux fichiers + + + + Delete selected wallpaper from list + Effacer la sélection de la liste + + + + Refresh file list + Rafraîchir la liste de fichiers + + + + + Set wallpaper + Appliquer le fond d'écran + + + + Preview selected wallpaper + Prévisualiser le fond d'écran sélectionné + + + + Preview desktop + Prévisualiser le bureau + + + + Apply user positioning + Appliquer le décalage utilisateur + + + + Enter image positioning by user + Définir un décalage utilisateur + + + + Cancel user positioning + Annuler + + + + State ... + Etat ... + + + + View list and infos + Vue détaillée + + + + View thumbnails + View Imagettes + + + + Preferences + Préférences + + + + + Startup + Démarrage + + + + Use Global Hotkey for manual change of wallpaper + Utiliser un raccourcis clavier global pour changer de fond d'écran + + + + Next wallpaper: + Fond d'écran suivant : + + + + Previous wallpaper: + Fond d'écran précédent + + + + Open main interface: + Ouvrir l'interface principale + + + + Change image offset: + Modifier centrage de l'image + + + + Language + Langue + + + + Detected language ... + Langue détectée ... + + + + Start in notification tray (minimized) + Démarrer dans la zone de notification (minimisé) + + + + Display splashscreen at startup + Afficher l'écran d'accueil au démarrage + + + + Auto start with system + Démarrage automatique avec le système + + + + Reset all preferences + Effacer toutes les préférences + + + + Reset preferences + Réinitialiser les préférences + + + + Splashscreen with transparent background + Ecran d'acceuil avec fond transparent + + + + Reset cached data + Effacer les données en cache + + + + Reset cache + Effacer le cache + + + + Scheduling + Programmation + + + + Display Parameters + Paramètres d'affichage + + + + Network + Réseau + + + + About + A propos + + + + Release Number + Version + + + + Supported formats (via Qt plugins) + Formats supportés (via greffons Qt) + + + + Available translations + Traductions disponibles + + + + Credits + Remerciements + + + + Changelog + Journal des modifications + + + + Log + Journal + + + + Clear Log + Effacer le journal + + + + Save log to file + Sauve le journal dans un fichier + + + + Preview Image + Prévisualiser l'image + + + + Delete Image + Effacer l'image + + + + Show main interface + Afficherl'interface utilisateur + + + + Show User Interface + Afficher l'interface utilisateur + + + + Quit application + Quitter l'application + + + + Next Wallpaper + Prochain fond d'écran + + + + Previous Wallpaper + Fond d'écran précédent + + + + + Change Image Offset + Modifier le centrage de l'image + + + + Help + Aide + + + + SystemIntegration + + + Desktop selected: %1 + Bureau sélectionné : %1 + + + + Number of screen detected: %1 + Nombre des écrans détectés : %1 + + + + KDE4 is currently incompletely supported. Please select %1 as the current wallpaper with "centered" parameter (it's just a workaround) + KDE4 est supporté incomplètement pour l'instant. Prière de sélectionner le fichier produit par SyncWall (%1) en mode "centré". (C'est actuellement un contournement de cette limitation) + + + + Can't open %1 + Impossible d'ouvrir %1 + + + + SystemIntegration::applyImage: Problem during saving of temp image %1 !! + SystemIntegration::applyImage: Problème à la sauvagarde du fichier temporaire %1 !! + + + + Convert QImage to %1 + Convertion de QImage en %1 + + + + Saving temp file (%1) + Sauvegarde du fichier temporaire (%1) + + + + Failed to save temp file (%1) + Echec de la sauvegarde du fichier temporaire (%1) + + + + loop detected during environment processing => skip + Une bouvle a été détectée pendant le traitement des variables d'environnement => on saute + + + + detectCurrentDesktop => Detected: KDE3 + detectCurrentDesktop => Détecté: KDE3 + + + + detectCurrentDesktop => Detected: KDE4 + detectCurrentDesktop => Détecté: KDE4 + + + + detectCurrentDesktop => Detected: Gnome + detectCurrentDesktop => Détecté: Gnome + + + + detectCurrentDesktop => Gnome version %1 + detectCurrentDesktop =>détecté Gnome version %1 + + + + detectCurrentDesktop => Detected: Xfce + detectCurrentDesktop => Détecté: Xfce + + + + detectCurrentDesktop => Detected: Xfce4 + detectCurrentDesktop => Détecté: Xfce4 + + + + detectCurrentDesktop => Detected: Fluxbox + detectCurrentDesktop => Détecté: Fluxbox + + + + detectCurrentDesktop => Detected: FVWM + detectCurrentDesktop => Détecté: FVWM + + + + detectCurrentDesktop => Detected: Blackbox + detectCurrentDesktop => Détecté: Blackbox + + + + detectCurrentDesktop => Detected: WindowMaker + detectCurrentDesktop => Détecté: WindowMaker + + + + No Desktop Environment Detected + Aucun environnement détecté + + + + SystemIntegration: The process failed to start. Either the invoked program is missing, or you may have insufficient permissions to invoke the program. + SystemIntegration: Le processus n'a pas démarré. Ou le programme appelé est manquant ou vous n'avez pas les droits suffisants pour l'exécuter. + + + + SystemIntegration: The process crashed some time after starting successfully. + SystemIntegration: Le processus s'est stoppé quelques temps après son lancement réussi. + + + + SystemIntegration: The last waitFor...() function timed out. The state of QProcess is unchanged, and you can try calling waitFor...() again. + SystemIntegration: Le dernier waitFor...() a expiré. L'état du QProcess est inchangé et vous pouvez essayer d'appeler waitFor...() encore. + + + + SystemIntegration: An error occurred when attempting to write to the process. For example, the process may not be running, or it may have closed its input channel. + SystemIntegration: Une erreur est survenue lors de l'écriture au processus.Par exemple, le processus n'est pas en exécution ou il a fermé son canal d'entrée. + + + + SystemIntegration: An error occurred when attempting to read from the process. For example, the process may not be running. + SystemIntegration: Une erreur est survenue lor de la lecture à partir du processus. Par exemple, le processus ne doit pas être en exécution. + + + + SystemIntegration: An unknown error occurred. This is the default return value of error(). + SystemIntegration: Une erreur est survenue. C'est la valeur par défaut de la fonction error(). + + + + The command exited normally. + La commande s'est terminée normallement. + + + + The command crashed. + La commande s'est plantée. + + + + Running + Lancement + + + + Tips: KDE4 is currently incompletely supported. Please select the generated wallpaper in plasma with "centered" parameter (it's just a workaround). For multi monitor with KDE activities, you can create a splitted wallpaper (one file by monitor) by selecting the right option in the "Image parameters" panel. + Note : KDE4 est supporté incomplètement pour l'instant. Prière de sélectionner dans Plasma le fichier produit par SyncWall en mode "centré". (C'est actuellement un contournement de cette limitation). Dans le cas multi-écrans, vous pouvez créer un fond d'écran découpé (un fichier par écran) en sélectionnant l'option correspondante dans le panneau "Paramètres image". + + + + SystemIntegrationConfigWidget + + + SystemIntegrationConfigWidget + SystemIntegrationConfigWidget + + + + Desktop integration + Intégration au bureau + + + + no detection ... + aucune détection ... + + + + The auto detection can failed. In this case, you have to set manually your desktop ... + L'auto détection peut échoué. Dans ce cas, vous devez sélectionner vous même votre bureau dans la liste ... + + + + detected desktop: %1 + Bureau détecté : %1 + + + + TreeImagesView + + + Add some images to begin + Ajouter des images pour commencer + + + + WallpaperProvider + + + Cannot find the directory %1 + Impossible de trouver le répertoire %1 + + + \ No newline at end of file Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/lang/syncwall_lt.qm and /tmp/OqecVKC_d5/syncwall-1.7.4/lang/syncwall_lt.qm differ diff -Nru syncwall-1.6.0/lang/syncwall_lt.ts syncwall-1.7.4/lang/syncwall_lt.ts --- syncwall-1.6.0/lang/syncwall_lt.ts 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/lang/syncwall_lt.ts 2013-07-13 05:59:36.000000000 +0000 @@ -0,0 +1,1479 @@ + + + + + + release of translation and translator name please + put your name here dear translator and the release of the translation file !! + v1.0 Algimantas Margevičius <margevicius.algimantas@gmail.com> + + + + BackgroundPainterConfigWidget + + + BackgroundPainterConfigWidget + BackgroundPainterConfigWidget + + + + Image parameters + Paveikslėlio parametrai + + + + Basic + Pagrindiniai + + + + Horizontal alignment + Horizontalus lygiavimas + + + + Resizing method + Dydžio keitimo būdas + + + + Vertical alignment + Vertikalus lygiavimas + + + + Multi monitor support + Kelių monitorių palaikymas + + + + Multi monitor display + Kelių monitorių rodymas + + + + Expert + Ekspertams + + + + ignore image parameters from server (client) + nepaisyti paveikslėlio parametrų gautų iš severio (klientui) + + + + skip image too small for resizing (<50% of final image) + praleisti paveikslėlius kurie per maži dydžio keitimui (<50% galutinio paveikslėlio) + + + + export image parameters to clients (server) + eksportuoti paveiksėlio parametrus klientams (serveris) + + + + Background + Fonas + + + + Inverse gradient color + Atvirkščia gradiento spalva + + + + Special effect + Specialūs efektai + + + + Rotate image according to Metadata + Pasukti paveikslėlį pagal Metaduomenis + + + + Upsampling method + Kokybės gerinimo metodas + + + + (Can greatly increase the computation time) + (Gali smarkiai pailginti kompiliavimo laiką) + + + + Preview desktop + Darbastalio peržiūra + + + + No data + Nėra duomenų + + + + Tips: You can reorder and align screens by drag&drop + Patarimas: ekranų išdėstymą galite pervilkdami juos + + + + no resize + nekeisti dydžio + + + + Stretch to fill (Ignore aspect ratio) + Užpildyti ištempiant (nepaisyti kraštinių santykio) + + + + Proportionally stretch to fit + Proporcingai ištempti, kad tilptų + + + + Fill proportionally + Proporcingai užpildyti + + + + No multi monitor support (wallpaper duplicated) + Be kelių monitorių palaikymo (tas pats fonas) + + + + Extend image (one file for all monitors) + Išplėsti paveikslėlį (vienas visiems monitoriams) + + + + Extend image then crop (one file per monitor) + Išplėsti paveikslėlį tada apkirpti (kiekvienam monitoriui vienas) + + + + Top alignment + Viršutinė lygiuotė + + + + + Center alignment + Centrinė lygiuotė + + + + Bottom alignment + Apatinė lygiuotė + + + + Left alignment + Kairinė lygiuotė + + + + Right alignment + Dešininė lygiuotė + + + + Fixed color + Nustatyta spalva + + + + Smart color (extract from image) + Protinga spalva (išgauti iš paveikslėlio) + + + + Blurred image + Išblukęs paveikslėlis + + + + Vertical gradient + Vertikalus gradientas + + + + Horizontal gradient + Horizontalus gradientas + + + + Radial gradient + Spindulinis gradientas + + + + Qt default algorithm + Numatytasis Qt algoritmas + + + + Blackman smooth filter + „Blackman“ lygus filtras + + + + Cubic filter + Kubinis filtras + + + + Mitchell filter + „Mitchell“ filtras + + + + Lanczos filter + „Lanczos“ filtras + + + + No effect + Jokio efekto + + + + Grayscale + Nespalvotas + + + + Blur + Suliejimas + + + + Gaussian blur + Gauso vaizdo suliejimo filtras + + + + Edge + Kraštas + + + + Sharpen + Paryškinti + + + + Gaussian sharpen + Gauso ryškinimas + + + + Emboss + Iškyla + + + + Desaturate + Nusodrinti + + + + Flatten + Plokščias + + + + Swirl + Sūkurys + + + + Oilpaint + Aliejiniai dažai + + + + Charcoal + Piešinys anglimi + + + + Sepia + Sepija + + + + Invert colors + Invertuoti spalvas + + + + Glow + Švytėjimas + + + + Progressive blur + Progresyvus išsiliejimas + + + + Random Effect + Atsitiktinis efektas + + + + DatabaseManager + + + No SQLITE driver available + Nėra prieinamos SQLITE tvarkyklės + + + + DatabaseManager::init: open db %1 ... + DatabaseManager::init: atverti db %1 ... + + + + DatabaseManager::createDB: db connection failed ... (%1) + DatabaseManager::createDB: sukurti db nepavyko... (%1) + + + + DatabaseManager::createDB: cannot create table ... (%1) + DatabaseManager::createDB: sukurti lentelės neįmanoma... (%1) + + + + DatabaseManager::openDB: database version don't match current one ! + DatabaseManager::openDB: duomenų bazės versijos nesutampa! + + + + DatabaseManager::removeInfos: Error when removing data for %2 (%1) + DatabaseManager::removeInfos: Klaida šalinant duomenis %2 (%1) + + + + DatabaseManager::storeInfos: Error in query preparation ... (%1) + DatabaseManager::storeInfos: Klaida užklausos pasiruošime... (%1) + + + + DatabaseManager::storeInfos: Error in query execution ... (%1) + DatabaseManager::storeInfos: Klaida užklausos vykdyme... (%1) + + + + ImageView + + + x: %1 y: %2 | r: %3 g: %4 b: %5 + x: %1 y: %2 | r: %3 g: %4 b: %5 + + + + a: %1 + a: %1 + + + + ImageViewer + + + ImageViewer + Paveiksėlių žiūryklė + + + + no info + nėra informacijos + + + + ListImagesModel + + + Name + Pavadinimas + + + + Rate + Vertė + + + + Image size + Paveikslėlio dydis + + + + File size + Failo dydis + + + + Offset defined by user + Naudotojo nustatytas poslinkis + + + + NetworkManagerConfigWidget + + + NetworkManagerConfigWidget + NetworkManagerConfigWidget + + + + Synchronise with server + Sinchronizuoti su serveriu + + + + Server (name or IP) + Kompiuteris (IP adresas) + + + + No connection + Nėra ryšio + + + + Test Connection + Ryšio bandymas + + + + UDP Port + UDP prievadas + + + + Server %1 reached ... + Kompiuteris %1 pasiektas... + + + + Disconnection from server %1 ... + Atsijungti nuo serverio %1... + + + + QObject + + + BackgroundPainterConfigWidget: image %1 is reject because its size is too small (%2x%3/%4x%5)) + BackgroundPainterConfigWidget: paveikslėlis %1 atmestas, nes jis per mažas (%2x%3/%4x%5)) + + + + BackgroundPainterConfigWidget: too many reject files => please change settings of add more hi-resolution images !! + BackgroundPainterConfigWidget: per daug atmestų failų => pakeiskite nustatymus arba įdėkite didesnės raiškos paveikslėlių! + + + + BackgroundPainterConfigWidget: Message with invalid nb of parameters (%1 instead of %2) + BackgroundPainterConfigWidget: Pranešimas su netinkamais parametrais (%1 vietoj %2) + + + + BackgroundPainterConfigWidget: Message with unknown version received (%1) + BackgroundPainterConfigWidget: Gautas pranešimas su nežinoma versija (%1) + + + + Bytes + Bitai + + + + KB + KB + + + + MB + MB + + + + GB + GB + + + + TB + TB + + + + Wallpaper manager. + Fono tvarkyklė. + + + + Usage: + Naudojimas: + + + + [options] + [parinktys] + + + + Following options are known: + Šios parinktys yra žinomos: + + + + --help : displays this help. + --help - parodo šį pranešimą. + + + + --reset-config : clear the saved preference parameters. + --reset-config :išvalo išsaugotas parinktis. + + + + --no-singleinstance : enable the use of multiple instance of program (not recommended). + --no-singleinstance : leisti naudoti kelias programos kopijas (nerekomenduojama). + + + + message from other instance. + pranešimas iš kitos kopijos. + + + + %1 is already running !! + %1 jau paleistas! + + + + Cleaning temp storage %1 ... + Valoma laikinų failų saugykla %1... + + + + Deleting %1 + Šalinama %1 + + + + translations path %1 + vertimų kelias %1 + + + + setting language to : %1 + kalba nustatoma į: %1 + + + + successfully loaded data from %1 + duomenys iš „%1“ sėkmingai įkelti + + + + failed to load data from %1 + nepavyko įkelti duomenų iš „%1“ + + + + NetworkManager: Mode SERVER listen to %1 port + NetworkManager: Režimas SERVER klauso %1 prievado + + + + NetworkManager: Mode CLIENT listen to %1 port + NetworkManager: Režimas CLIENT klauso %1 prievado + + + + NetworkManager: Send Server Identification for "%1" on port %2 + NetworkManager: Siųsti severio identifikaciją „%1“ prievadu %2 + + + + NetworkManager: Received message on port %1 + NetworkManager: Gautas pranešimas prievadu %1 + + + + NetworkManager: Received Server call datagram: "%1" + NetworkManager: Gauta serverio kvietimo datagrama: „%1“ + + + + NetworkManager: Adding %1 to client list + NetworkManager: Pridedama %1 į klientų sąrašą + + + + NetworkManager: %1 is already in the client list + NetworkManager: %1 jau yra klientų sąraše + + + + NetworkManager: Received background change: "%1" + NetworkManager: gautas fono keitimo signalas: „%1“ + + + + NetworkManager: no address found for host %1 (%2) + NetworkManager: adresas kompiuteriui %1 nerastas (%2) + + + + NetworkManager: Send Server Call for "%1" on port %2 + NetworkManager: Siųsti serverio kvietimą „%1“ prievadu %2 + + + + NetworkManager: Send message to "%1" (%2) on port %3 + NetworkManager: siųsti pranešimą „%1“ (%2) prievadu %3 + + + + NetworkManager:: Sending new message to client %1 + NetworkManager: Siunčiamas naujas pranešimas klientui %1 + + + + NetworkManager:: Ping server %1 + NetworkManager: siųsti ping %1 + + + + %1 found + %1 rasta + + + + KDE3 desktop + KDE3 darbastalis + + + + KDE4 desktop + KDE4 darbastalis + + + + GNOME desktop + GNOME darbastalis + + + + GNOME3 desktop + GNOME3 darbastalis + + + + XFCE desktop + XFCE darbastalis + + + + XFCE4 desktop + XFCE4 darbastalis + + + + FLUXBOX desktop + FLUXBOX darbastalis + + + + BLACKBOX desktop + BLACKBOX darbastalis + + + + Enlightenment desktop + Enlightenment darbastalis + + + + ICEWM desktop + ICEWM darbastalis + + + + OPENBOX desktop + OPENBOX darbastalis + + + + LXDE desktop + LXDE darbastalis + + + + WINDOWMAKER desktop + WINDOWMAKER darbastalis + + + + FVWM desktop + FVWM darbastalis + + + + WINDOWS desktop + WINDOWS darbastalis + + + + MACOSX desktop + MACOSX darbastalis + + + + OS/2 desktop + OS/2 darbastalis + + + + Automatic detection + Automatinis aptikimas + + + + No Desktop Environment Detected + Darbastalio aplinka neaptikta + + + + Scheduler + + + update interval is to low (%1) => force to %2 sec ... + atnaujinimo intervalas per mažas (%1) => naudojama %2 s... + + + + + Start new timer for %1 sec ... + Paleisti naują laikrodį %1 s... + + + + New Schedule fired ... + Naujas tvarkaraštis paleistas... + + + + SchedulerConfigWidgetClass + + + SchedulerConfigWidget + SchedulerConfigWidget + + + + Scheduling parameters + Planavimo parametrai + + + + Auto change at startup + Paleidus automatiškai pakeisti + + + + Quit application after startup change (30s) + Išeiti iš programos pakeitus paleidžiant (30s) + + + + Change Interval + Keitimo intervalas + + + + Interval between change (h:m:s) + Intervalas tarp keitimų (h:m:s) + + + + set time of day (h:m:s) + nustatytu laiku (h:m:s) + + + + Add to the timeofday list + Pridėti į dienos laikų sąrašą + + + + Delete selected timeofday + Pašalinti pasirinktą dienos laiką + + + + h:mm:ss + h:mm:ss + + + + SyncWall + + + Can't create storage location, check why ?! (%1) + Nepavyko sukurti saugyklos, patikrinti kodėl?! (%1) + + + + Active Desktop must be disabled !! + Aktyvus darbastalis turi būti išjungtas! + + + + The application can't find a valid SQLITE driver, its performance and functionality will be degraded + Programa nerado tinkamos SQLITE tvarkyklės, greitaveikia ir funkcionalumas bus smarkiai apriboti + + + + detected language: %1 + aptikta kalba: %1 + + + + Automatic detection + Automatinis aptikimas + + + + Default (no use of translation files) + Numatytoji (jokios naudos iš vertimo) + + + + The application need to restart in order to take into account new translation +, Do you want to restart application now ? + Norint pritaikyti naują vertimą reikia paleisti programą iš naujo. +Ar norite paleisti programą iš naujo dabar? + + + + Log file + Žurnalo failas + + + + Can't save log file !!: %1 + Įrašyti žurnalo nepavyko!: %1 + + + + Add Wallpaper Directory + Pridėti fonų aplanką + + + + + Add all found directories recursively ? + Pridėti visus rekursyviai rastus aplankus? + + + + + Watch for modifications in these directories at application startup ? + Paleidžiant programą stebėti pakeitimus šiuose aplankuose? + + + + add %1 folder + pridėti %1 aplanką + + + + Select one or more wallpapers + Pasirinkite vieną ar daugiau fonų + + + + Images (%1) + Paveikslėliai (%1) + + + + Systray + Sistemos dėklas + + + + The program will keep running in the system tray. To terminate the program, choose <b>Quit</b> in the context menu of the system tray entry. + Programa toliau veiks sistemos dėkle. Norėdami išjungti programą, sistemos dėklo piktogramos kontekstiniame meniu pasirinkite <b>Išeiti</b>. + + + + %1 images in list + Sąraše %1 paveikslėlių + + + + <a href="%1">Check for new release ...</a> + <a href="%1">Tikrinti ar nėra atnaujinimų...</a> + + + + Qt version %1 + Qt versija %1 + + + + new file received : %1 + Gautas naujas failas: %1 + + + + Can't find local file as received : %1 + Nepavyko rasti vietinio failo: %1 + + + + Standard state. Scheduling is activated + Įprastinė būsena. Tvarkaraštis aktyvuotas + + + + Idle state. No scheduling and no server connection + Neveiklumo būsena. Nėra tvarkaraščio ir jokio prisijungimo prie serverio + + + + Server state. Al least a client is connected + Serverio būsena. Prisijungęs bent vienas klientas + + + + Client state. Connected to server + Kliento būsena. Prisijungta prie jokio serverio + + + + Client state but disconnected from server + Kliento būsena, bet vis dar atsijungta nuo serverio + + + + Client state but the protocol isn't correct. Upgrade client or server ! + Kliento būsena, bet protokolas netinkamas. Atnaujinkite klientą ar servery! + + + + The %1 file can't be found, sorry ... + Failas %1 nerastas... + + + + Do you want to reset all the preferences to default value ? + If yes, the application will be relaunch + Ar norite atstatyti visus nustatymus į jų numatytąsias reikšmes? +Jei taip, programa bus paleista iš naujo + + + + Do you want to reset all cached data (thumbnails and ratings) ? + Ar norite išvalyti visus duomenis iš podėlio (miniatiūros ir vertinimai)? + + + + SyncWallClass + + + SyncWall + SyncWall + + + + Preview + Peržiūra + + + + No wallpaper + Jokio fono + + + + Auto change in random order + Automatiškai keisti atsitiktine tvarka + + + + + Quit + Baigti + + + + Online Help + Žinynas internete + + + + Add a new folder + Pridėti naują aplanką + + + + + Add new file(s) + Pridėti naują failą(-us) + + + + Delete selected wallpaper from list + Pašalinti pasirinktą foną iš sąrašo + + + + Refresh file list + Atnaujinti failų sąrašą + + + + + Set wallpaper + Nustatyti foną + + + + Preview selected wallpaper + Peržiūrėti pasirinktą darbastalį + + + + Preview desktop + Darbastalio peržiūra + + + + Apply user positioning + Pritaikyti naudotojo pozicionavimą + + + + Enter image positioning by user + Įvesti naudotojo paveikslėlio pozicionavimą + + + + Cancel user positioning + Atsisakyti naudotojo pozicionavimo + + + + State ... + Būsena... + + + + View list and infos + Žiūrėti sąrašą ir informaciją + + + + View thumbnails + Rodyti miniatiūras + + + + Preferences + Nustatymai + + + + + Startup + Paleidimas + + + + Use Global Hotkey for manual change of wallpaper + Rankiniam paveikslėlio keitimui naudoti globalų spartųjį klavišą + + + + Next wallpaper: + Sekantis fonas: + + + + Previous wallpaper: + Ankstesnis fonas: + + + + Open main interface: + Atverti pagrindinę sąsają: + + + + Change image offset: + Keisti paveikslėlio poslinky: + + + + Language + Kalba + + + + Detected language ... + Aptikta kalba... + + + + Start in notification tray (minimized) + Paleisti pranešimų srityje (sumažintą) + + + + Display splashscreen at startup + Paleidžiant rodyti pasveikinimo ekraną + + + + Auto start with system + Paleisti kartu su kompiuteriu + + + + Reset all preferences + Atstatyti visus nustatymus + + + + Reset preferences + Atstatyti nustatymus + + + + Splashscreen with transparent background + Pasveikinimo ekranas su permatomu fonu + + + + Reset cached data + Atstatyti duomenis podėlyje + + + + Reset cache + Atstatyti podėlį + + + + Scheduling + Planavimas + + + + Display Parameters + Rodymo parametrai + + + + Network + Tinklas + + + + About + Apie + + + + Release Number + Leidimas + + + + Supported formats (via Qt plugins) + Palaikomi formatai (su Qt įskiepiais) + + + + Available translations + Prieinami vertimai + + + + Credits + Padėkos + + + + Changelog + Pakeitimai + + + + Log + Žurnalas + + + + Clear Log + Išvalyti žurnalą + + + + Save log to file + Saugoti žurnalą į failą + + + + Preview Image + Peržiūra + + + + Delete Image + Šalinti paveikslėlį + + + + Show main interface + Rodyti pagrindinį langą + + + + Show User Interface + Rodyti naudotojo sąsaja + + + + Quit application + Išjungti programą + + + + Next Wallpaper + Sekantis fonas + + + + Previous Wallpaper + Ankstesnis fonas + + + + + Change Image Offset + Keisti paveikslėlio poslinky + + + + Help + Žinynas + + + + SystemIntegration + + + Desktop selected: %1 + Pasirinktas darbastalis: %1 + + + + Number of screen detected: %1 + Aptikta ekranų: %1 + + + + KDE4 is currently incompletely supported. Please select %1 as the current wallpaper with "centered" parameter (it's just a workaround) + Šiuo metu KDE4 palaikomas nepilnai. Pasirinkite %1 kaip foną su „centruotas“ parametru (tai laikinas sprendimas) + + + + Can't open %1 + Nepavyko atverti %1 + + + + SystemIntegration::applyImage: Problem during saving of temp image %1 !! + SystemIntegration::applyImage: Problema saugant laikiną paveikslėlį %1! + + + + Convert QImage to %1 + Konvertuoti QImage į %1 + + + + Saving temp file (%1) + Išsaugojamas laikinas failas (%1) + + + + Failed to save temp file (%1) + Nepavyko įrašyti laikino failo (%1) + + + + loop detected during environment processing => skip + apdorojant aplinką aptiktas ciklas => praleidžiama + + + + detectCurrentDesktop => Detected: KDE3 + detectCurrentDesktop => Aptikta: KDE3 + + + + detectCurrentDesktop => Detected: KDE4 + detectCurrentDesktop => Aptikta: KDE4 + + + + detectCurrentDesktop => Detected: Gnome + detectCurrentDesktop => Aptikta: Gnome + + + + detectCurrentDesktop => Gnome version %1 + detectCurrentDesktop => Gnome versija %1 + + + + detectCurrentDesktop => Detected: Xfce + detectCurrentDesktop => Aptikta: Xfce + + + + detectCurrentDesktop => Detected: Xfce4 + detectCurrentDesktop => Aptikta: Xfce4 + + + + detectCurrentDesktop => Detected: Fluxbox + detectCurrentDesktop => Aptikta: Fluxbox + + + + detectCurrentDesktop => Detected: FVWM + detectCurrentDesktop => Aptikta: FVWM + + + + detectCurrentDesktop => Detected: Blackbox + detectCurrentDesktop => Aptikta: Blackbox + + + + detectCurrentDesktop => Detected: WindowMaker + detectCurrentDesktop => Aptikta: WindowMaker + + + + No Desktop Environment Detected + Neaptikta jokia darbastalio aplinka + + + + SystemIntegration: The process failed to start. Either the invoked program is missing, or you may have insufficient permissions to invoke the program. + SystemIntegration: Procesas nepasileido. Programos nėra arba neturite teisės ją paleisti. + + + + SystemIntegration: The process crashed some time after starting successfully. + SystemIntegration: po sėkmingo paleidimo procesas užlūžo. + + + + SystemIntegration: The last waitFor...() function timed out. The state of QProcess is unchanged, and you can try calling waitFor...() again. + SystemIntegration: baigėsi paskutinės waitFor...() funkcijos laukimo laikas. QProcess būsena lieka ta pati, galite pabandyti iškviesti waitFor...() dar kartą. + + + + SystemIntegration: An error occurred when attempting to write to the process. For example, the process may not be running, or it may have closed its input channel. + SystemIntegration: Bandant įrašyti į procesą įvyko klaida. Pavyzdžiui, procesas nepaleistas arba uždarė savo įvedimo kanalą. + + + + SystemIntegration: An error occurred when attempting to read from the process. For example, the process may not be running. + SystemIntegration: Bandant skaityti iš proceso įvyko klaida. Pavyzdžiui, procesas nepaleistas. + + + + SystemIntegration: An unknown error occurred. This is the default return value of error(). + SystemIntegration: Įvyko nežinoma klaida. Tai yra numatytoji error() reikšmė. + + + + The command exited normally. + Komanda išėjo įprastai. + + + + The command crashed. + Komanda nulūžo. + + + + Running + Veikia + + + + Tips: KDE4 is currently incompletely supported. Please select the generated wallpaper in plasma with "centered" parameter (it's just a workaround). For multi monitor with KDE activities, you can create a splitted wallpaper (one file by monitor) by selecting the right option in the "Image parameters" panel. + Patarimas: KDE4 šiuo metu nevisai palaikoma. Pasirinkite sugeneruotą foną su parametru „centruoti“. „Paveikslėlio parametrų“ skydelyje galite sukurti perskeltą foną (kiekvienam monitoriui po vieną) kelių monitorių veiksenai. + + + + SystemIntegrationConfigWidget + + + SystemIntegrationConfigWidget + SystemIntegrationConfigWidget + + + + Desktop integration + Integracija su darbastaliu + + + + no detection ... + neaptikta... + + + + The auto detection can failed. In this case, you have to set manually your desktop ... + Automatinis aptikimas gali nepavykti. Šiuo atveju galite nustatyti savo darbastalį rankiniu būdu... + + + + detected desktop: %1 + aptiktas darbastalis: %1 + + + + TreeImagesView + + + Add some images to begin + Pradžiai pridėkite kelis paveikslėlius + + + + WallpaperProvider + + + Cannot find the directory %1 + Aplankas %1 nerastas + + + \ No newline at end of file Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/lang/syncwall_nl.qm and /tmp/OqecVKC_d5/syncwall-1.7.4/lang/syncwall_nl.qm differ diff -Nru syncwall-1.6.0/lang/syncwall_nl.ts syncwall-1.7.4/lang/syncwall_nl.ts --- syncwall-1.6.0/lang/syncwall_nl.ts 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/lang/syncwall_nl.ts 2013-07-13 05:59:08.000000000 +0000 @@ -0,0 +1,1479 @@ + + + + + + release of translation and translator name please + put your name here dear translator and the release of the translation file !! + v1 by Philip Oostindiën <izumi_konata_1985@yahoo.co.jp> + + + + BackgroundPainterConfigWidget + + + BackgroundPainterConfigWidget + AchtergrondSchilderInstelWidget + + + + Image parameters + Afbeeldingsinstellingen + + + + Basic + Basis + + + + Horizontal alignment + Horizontale plaatsing + + + + Resizing method + Resizingsmethode + + + + Vertical alignment + Verticale plaatsing + + + + Multi monitor support + Multi-beeldscherm ondersteuning + + + + Multi monitor display + Multi-beeldscherm weergave + + + + Expert + Expert + + + + ignore image parameters from server (client) + negeer afbeeldingsinstellingen van server (client) + + + + skip image too small for resizing (<50% of final image) + skip image too small for resizing (<50% of final image) + + + + export image parameters to clients (server) + exporteer afbeeldingsinstellingen naar clients (server) + + + + Background + Achtergrond + + + + Inverse gradient color + Omgekeerde kleurverloop + + + + Special effect + Speciaal effect + + + + Rotate image according to Metadata + Afbeelding draaien op basis van Metadata + + + + Upsampling method + Upsamplingsmethode + + + + (Can greatly increase the computation time) + (Kan de rekentijd sterk doen toenemen) + + + + Preview desktop + Voorbeeld van achtergrond + + + + No data + Geen data + + + + Tips: You can reorder and align screens by drag&drop + Tip: Je kunt de schermen herschikken en afstellen door middel van slepen & loslaten + + + + no resize + niet resizen + + + + Stretch to fill (Ignore aspect ratio) + Rekken om te vullen (Negeer beeldverhouding) + + + + Proportionally stretch to fit + Proportioneel uitrekken om op het scherm te passen + + + + Fill proportionally + Proportioneel vullen + + + + No multi monitor support (wallpaper duplicated) + Geen multi-beeldschermweergave (achtergrond gedupliceerd) + + + + Extend image (one file for all monitors) + Breidt afbeelding uit (èèn bestand voor alle monitoren) + + + + Extend image then crop (one file per monitor) + Breidt afbeelding uit, dan bijsnijden (èèn bestand per monitor) + + + + Top alignment + Bovenkantuitlijning + + + + + Center alignment + Middenuitlijning + + + + Bottom alignment + Bodemuitlijning + + + + Left alignment + Linkeruitlijning + + + + Right alignment + Rechteruitlijning + + + + Fixed color + Vaste kleur + + + + Smart color (extract from image) + Slimme kleur (uit afbeelding halen) + + + + Blurred image + Wazige afbeelding + + + + Vertical gradient + Verticale kleurverloop + + + + Horizontal gradient + Horizontale kleurverloop + + + + Radial gradient + Radiaal verloop + + + + Qt default algorithm + Qt standaard algoritme + + + + Blackman smooth filter + Blackman gladde filter + + + + Cubic filter + Cubic filter + + + + Mitchell filter + Mitchell filter + + + + Lanczos filter + Lanczos filter + + + + No effect + Geen effect + + + + Grayscale + Grijstinten + + + + Blur + Vervagen + + + + Gaussian blur + Gaussiaanse vervaging + + + + Edge + rand + + + + Sharpen + Verscherpen + + + + Gaussian sharpen + Gaussiaanse verscherping + + + + Emboss + In reliëf maken + + + + Desaturate + Verzadiging verminderen + + + + Flatten + Platter maken + + + + Swirl + Wervelen + + + + Oilpaint + Olieverf + + + + Charcoal + Houtskool + + + + Sepia + Sepia + + + + Invert colors + Kleuren omkeren + + + + Glow + Gloei + + + + Progressive blur + Progressieve vervaging + + + + Random Effect + Willekeurig effect + + + + DatabaseManager + + + No SQLITE driver available + Geen SQLITE stuurprogramma beschikbaar + + + + DatabaseManager::init: open db %1 ... + DatabaseManager::init: open db %1 ... + + + + DatabaseManager::createDB: db connection failed ... (%1) + DatabaseManager::createDB: db verbinding mislukt ... (%1) + + + + DatabaseManager::createDB: cannot create table ... (%1) + DatabaseManager::createDB: kan tafel niet creëren ... (%1) + + + + DatabaseManager::openDB: database version don't match current one ! + DatabaseManager::openDB: database versie komt niet overeen met de huidige! + + + + DatabaseManager::removeInfos: Error when removing data for %2 (%1) + DatabaseManager::removeInfos: Fout bij het weghalen van data voor %2 (%1) + + + + DatabaseManager::storeInfos: Error in query preparation ... (%1) + DatabaseManager::storeInfos: Fout bij het voorbereiden van de vraag ... (%1) + + + + DatabaseManager::storeInfos: Error in query execution ... (%1) + DatabaseManager::storeInfos: Fout in uitvoering vraag ... (%1) + + + + ImageView + + + x: %1 y: %2 | r: %3 g: %4 b: %5 + x: %1 y: %2 | r: %3 g: %4 b: %5 + + + + a: %1 + a: %1 + + + + ImageViewer + + + ImageViewer + AfbeeldingsViewer + + + + no info + geen informatie + + + + ListImagesModel + + + Name + Naam + + + + Rate + Verhouding + + + + Image size + Afbeeldingsgrootte + + + + File size + Bestandsgrootte + + + + Offset defined by user + Offset gedefinieerd door de gebruiker + + + + NetworkManagerConfigWidget + + + NetworkManagerConfigWidget + NetwerkBeheerderConfiguratieWidget + + + + Synchronise with server + Met server synchroniseren + + + + Server (name or IP) + Server (naam of IP) + + + + No connection + Geen verbinding + + + + Test Connection + Test verbinding + + + + UDP Port + UDP Poort + + + + Server %1 reached ... + Server %1 bereikt ... + + + + Disconnection from server %1 ... + Verbindingsverbreking van server %1 ... + + + + QObject + + + BackgroundPainterConfigWidget: image %1 is reject because its size is too small (%2x%3/%4x%5)) + AchtergrondverfConfiguratieWidget: afbeelding %1 is verworpen omdat de grootte te klein is (%2x%3/%4x%5)) + + + + BackgroundPainterConfigWidget: too many reject files => please change settings of add more hi-resolution images !! + AchtergrondverfConfiguratieWidget: teveel verworpen bestanden => verander a.u.b. de instellingen, of voeg meer hoge-resolutie afbeeldingen toe !! + + + + BackgroundPainterConfigWidget: Message with invalid nb of parameters (%1 instead of %2) + AchtergrondverfConfiguratieWidget: Bericht met een ongeldig aantal parameters (%1 in plaats van %2) + + + + BackgroundPainterConfigWidget: Message with unknown version received (%1) + AchtergrondverfConfiguratieWidget: Bericht met onbekende versie ontvangen (%1) + + + + Bytes + Bytes + + + + KB + KB + + + + MB + MB + + + + GB + GB + + + + TB + TB + + + + Wallpaper manager. + Achtergrond beheerder. + + + + Usage: + Gebruik: + + + + [options] + [opties] + + + + Following options are known: + De volgende opties zijn bekend: + + + + --help : displays this help. + --help : Geeft deze hulp weer. + + + + --reset-config : clear the saved preference parameters. + --reset-config : verwijder de opgeslagen voorkeursparameters. + + + + --no-singleinstance : enable the use of multiple instance of program (not recommended). + --no-singleinstance : Zet het gebruik van meerdere instanties van het programma aan (niet aanbevolen). + + + + message from other instance. + bericht van andere instantie. + + + + %1 is already running !! + %1 draait al !! + + + + Cleaning temp storage %1 ... + Schoonmaken tijdelijke opslag %1 ... + + + + Deleting %1 + Verwijderen %1 + + + + translations path %1 + Pad vertalingen %1 + + + + setting language to : %1 + Taal veranderen naar : %1 + + + + successfully loaded data from %1 + Successvol data geladen van %1 + + + + failed to load data from %1 + Data laden van %1 mislukt + + + + NetworkManager: Mode SERVER listen to %1 port + NetwerkBeheerder: Modus SERVER luisteren naar %1 poort + + + + NetworkManager: Mode CLIENT listen to %1 port + NetwerkBeheerder: Modus CLIENT luisteren naar %1 poort + + + + NetworkManager: Send Server Identification for "%1" on port %2 + NetwerkBeheerder: Stuur Server identificatie voor "%1" op poort %2 + + + + NetworkManager: Received message on port %1 + NetwerkBeheerder: Bericht ontvangen op poort %1 + + + + NetworkManager: Received Server call datagram: "%1" + NetwerkBeheerder: Server bel datagram ontvangen: "%1" + + + + NetworkManager: Adding %1 to client list + NetwerkBeheerder: %1 aan het toevoegen aan clientlijst + + + + NetworkManager: %1 is already in the client list + NetwerkBeheerder: %1 staat al in de clientlijst + + + + NetworkManager: Received background change: "%1" + NetwerkBeheerder: Achtergrond verandering ontvangen: "%1" + + + + NetworkManager: no address found for host %1 (%2) + NetwerkBeheerder: geen adres gevonden voor host %1 (%2) + + + + NetworkManager: Send Server Call for "%1" on port %2 + NetwerkBeheerder: Stuur Server signaal voor "%1" op poort %2 + + + + NetworkManager: Send message to "%1" (%2) on port %3 + NetwerkBeheerder: Stuur bericht naar "%1" (%2) op poort %3 + + + + NetworkManager:: Sending new message to client %1 + NetwerkBeheerder: Nieuw bericht aan het sturen naar client %1 + + + + NetworkManager:: Ping server %1 + NetwerkBeheerder: Ping server %1 + + + + %1 found + %1 gevonden + + + + KDE3 desktop + KDE3 desktop + + + + KDE4 desktop + KDE4 desktop + + + + GNOME desktop + GNOME desktop + + + + GNOME3 desktop + GNOME3 desktop + + + + XFCE desktop + XFCE desktop + + + + XFCE4 desktop + XFCE4 desktop + + + + FLUXBOX desktop + FLUXBOX desktop + + + + BLACKBOX desktop + BLACKBOX desktop + + + + Enlightenment desktop + Enlightenment desktop + + + + ICEWM desktop + ICEWM desktop + + + + OPENBOX desktop + OPENBOX desktop + + + + LXDE desktop + LXDE desktop + + + + WINDOWMAKER desktop + WINDOWMAKER desktop + + + + FVWM desktop + FVWM desktop + + + + WINDOWS desktop + WINDOWS desktop + + + + MACOSX desktop + MACOSX desktop + + + + OS/2 desktop + OS/2 desktop + + + + Automatic detection + Automatische herkenning + + + + No Desktop Environment Detected + Geen desktopomgeving gedetecteerd + + + + Scheduler + + + update interval is to low (%1) => force to %2 sec ... + Verversingsinterval is te laag (%1) => forceren naar %2 sec ... + + + + + Start new timer for %1 sec ... + Start nieuwe timer voo %1 sec ... + + + + New Schedule fired ... + Nieuw schema gevuurt ... + + + + SchedulerConfigWidgetClass + + + SchedulerConfigWidget + SchemaConfiguratieWidget + + + + Scheduling parameters + Schema parameters + + + + Auto change at startup + Automatisch veranderen bij opstarten + + + + Quit application after startup change (30s) + Applicatie afsluiten na opstartverandering (30s) + + + + Change Interval + Veranderingsinterval + + + + Interval between change (h:m:s) + Interval tussen veranderingen (h:m:s) + + + + set time of day (h:m:s) + stel tijd in (h:m:s) + + + + Add to the timeofday list + Toevoegen aan tijd van de dag lijst + + + + Delete selected timeofday + Verwijder geselecteerde tijd van de dag + + + + h:mm:ss + h:mm:ss + + + + SyncWall + + + Can't create storage location, check why ?! (%1) + Kan opslaglocatie niet creëren, controleer waarom ?! (%1) + + + + Active Desktop must be disabled !! + Active Desktop moet uitgeschakeld zijn !! + + + + The application can't find a valid SQLITE driver, its performance and functionality will be degraded + De applicatie kan geen geldig SQLITE stuurprogramma vinden, de prestaties en functionaliteit zullen gedegradeerd worden + + + + detected language: %1 + gedetecteerde taal: %1 + + + + Automatic detection + Automatische herkenning + + + + Default (no use of translation files) + Standaard (geen gebruik van vertalingsbestanden) + + + + The application need to restart in order to take into account new translation +, Do you want to restart application now ? + De applicatie moet opnieuw worden opgestart om de nieuwe vertaling in werking te laten treden. +Wil je nu opnieuw opstarten? + + + + Log file + Logboekbestand + + + + Can't save log file !!: %1 + Kan logboekbestand niet opslaan !!: %1 + + + + Add Wallpaper Directory + Voeg achtergrondafbeeldingen map toe + + + + + Add all found directories recursively ? + Alle gevonden mappen recursief toevoegen? + + + + + Watch for modifications in these directories at application startup ? + Opletten voor modificaties in deze mappen bij het opstarten van de applicatie? + + + + add %1 folder + voeg %1 map toe + + + + Select one or more wallpapers + Selecteer 1 of meer achtergronden + + + + Images (%1) + Afbeeldingen (%1) + + + + Systray + Systeemvak + + + + The program will keep running in the system tray. To terminate the program, choose <b>Quit</b> in the context menu of the system tray entry. + Het programma zal blijven draaien in het systeemvak. Om het programma af te sluiten, kies je <b>Afsluiten</b> in het context menu van het icoon in het systeemvak. + + + + %1 images in list + %1 afbeeldingen in lijst + + + + <a href="%1">Check for new release ...</a> + <a href="%1">Controleren op een nieuwe release ...</a> + + + + Qt version %1 + Qt versie %1 + + + + new file received : %1 + nieuw bestand ontvangen : %1 + + + + Can't find local file as received : %1 + Kan lokaal bestand niet vinden zoals ontvangen : %1 + + + + Standard state. Scheduling is activated + Standaardstatus: Schema is geactiveerd + + + + Idle state. No scheduling and no server connection + Ijdele status: Geen schema en geen server verbinding + + + + Server state. Al least a client is connected + Server status. Minstens 1 client is verbonden + + + + Client state. Connected to server + Client status. Verbonden met server + + + + Client state but disconnected from server + Client status maar niet verbonden met server + + + + Client state but the protocol isn't correct. Upgrade client or server ! + Clientstatus maar het protocol is niet correct. Upgrade client of server ! + + + + The %1 file can't be found, sorry ... + Het %1 bestand kan niet worden gevonden, sorry ... + + + + Do you want to reset all the preferences to default value ? + If yes, the application will be relaunch + Wil je alle instellingen resetten naar hun standaardinstellingen? +Zo ja, zal deapplicatie opnieuw worden opgestart + + + + Do you want to reset all cached data (thumbnails and ratings) ? + Wil je alle gegevens in de cache (thumbnails en ratings) resetten? + + + + SyncWallClass + + + SyncWall + SyncWall + + + + Preview + Voorbeeld + + + + No wallpaper + Geen achtergrond + + + + Auto change in random order + Automatisch veranderen in willekeurige volgorde + + + + + Quit + Afsluiten + + + + Online Help + Online Hulp + + + + Add a new folder + Nieuwe map toevoegen + + + + + Add new file(s) + Nieuw(e) bestand(en) toevoegen + + + + Delete selected wallpaper from list + Geselecteerde achtergrond uit lijst werwijderen + + + + Refresh file list + Bestandslijst verversen + + + + + Set wallpaper + Achtergrond instellen + + + + Preview selected wallpaper + Voorbeeld weergeven van geselecteerde achtergrond + + + + Preview desktop + Voorbeeld van desktop weergeven + + + + Apply user positioning + Gebruikerspositionering toevoegen + + + + Enter image positioning by user + Voer afbeeldingspositionering door gebruiker in + + + + Cancel user positioning + Gebruikerspositionering anuleren + + + + State ... + Status ... + + + + View list and infos + Lijst en informatie weegeven + + + + View thumbnails + Thumbnails weergeven + + + + Preferences + Instellingen + + + + + Startup + Opstarten + + + + Use Global Hotkey for manual change of wallpaper + Gebruik Globale Sneltoets voor handmatige verandering van achtergrond + + + + Next wallpaper: + Volgende achtergrond: + + + + Previous wallpaper: + Vorige achtergrond: + + + + Open main interface: + Open hoofdinterface: + + + + Change image offset: + Wijzig afbeeldingsoffset: + + + + Language + Taal + + + + Detected language ... + Gedetecteerde taal ... + + + + Start in notification tray (minimized) + Starten in systeemvak (geminimaliseerd) + + + + Display splashscreen at startup + Geef splashscreen weer bij het opstarten + + + + Auto start with system + Automatisch opstarten met het systeem + + + + Reset all preferences + Alle instellingen resetten + + + + Reset preferences + Instellingen resetten + + + + Splashscreen with transparent background + Spashscreen met transparante achtergrond + + + + Reset cached data + Gecachete data resetten + + + + Reset cache + Cache resetten + + + + Scheduling + Schema + + + + Display Parameters + Beeldscherm parameters + + + + Network + Netwerk + + + + About + Over + + + + Release Number + Uitgave Nummer + + + + Supported formats (via Qt plugins) + Ondersteunde formaten (via Qt plugins) + + + + Available translations + Beschikbare vertalingen + + + + Credits + Eer + + + + Changelog + Veranderingenlogboek + + + + Log + Logboek + + + + Clear Log + Logboek leegmaken + + + + Save log to file + Logboek opslaan naar bestand + + + + Preview Image + Voorbeeldweergave afbeelding + + + + Delete Image + Afbeelding verwijderen + + + + Show main interface + Hoofdinterface weegeven + + + + Show User Interface + Gebruikersinterface weergeven + + + + Quit application + Applicatie afsluiten + + + + Next Wallpaper + Volgende achtergrond + + + + Previous Wallpaper + Vorige achtergrond + + + + + Change Image Offset + Wijzig afbeeldingsoffset + + + + Help + Hulp + + + + SystemIntegration + + + Desktop selected: %1 + Geselecteerde desktop: %1 + + + + Number of screen detected: %1 + Aantal schermen gedetecteerd: %1 + + + + KDE4 is currently incompletely supported. Please select %1 as the current wallpaper with "centered" parameter (it's just a workaround) + KDE4 wordt momenteel niet volledig ondersteund. Selecteer a.u.b. %1 als de huidige achtergrond met instelling gecentreerd (Het is enkel een workaround) + + + + Can't open %1 + Kan %1 niet openen + + + + SystemIntegration::applyImage: Problem during saving of temp image %1 !! + SysteenIntegratie::afbeeldingtoepassen: Probleem bij het opslaan van tijdelijke afbeelding %1 !! + + + + Convert QImage to %1 + QImage naar %1 converteren + + + + Saving temp file (%1) + Tijdelijk bestand opslaan (%1) + + + + Failed to save temp file (%1) + Tijdelijk bestand opslaan mislukt (%1) + + + + loop detected during environment processing => skip + loop ontdekt tijdens omgevingsverwerking => overslaan + + + + detectCurrentDesktop => Detected: KDE3 + HuidigeDesktopDetecteren => Gedetecteerd: KDE3 + + + + detectCurrentDesktop => Detected: KDE4 + HuidigeDesktopDetecteren => Gedetecteerd: KDE4 + + + + detectCurrentDesktop => Detected: Gnome + HuidigeDesktopDetecteren => Gedetecteerd: GNOME + + + + detectCurrentDesktop => Gnome version %1 + HuidigeDesktopDetecteren => Gedetecteerd: GNOME version %1 + + + + detectCurrentDesktop => Detected: Xfce + HuidigeDesktopDetecteren => Gedetecteerd: Xfce + + + + detectCurrentDesktop => Detected: Xfce4 + HuidigeDesktopDetecteren => Gedetecteerd: Xfce4 + + + + detectCurrentDesktop => Detected: Fluxbox + HuidigeDesktopDetecteren => Gedetecteerd: Fluxbox + + + + detectCurrentDesktop => Detected: FVWM + HuidigeDesktopDetecteren => Gedetecteerd: FVWM + + + + detectCurrentDesktop => Detected: Blackbox + HuidigeDesktopDetecteren => Gedetecteerd: Blackbox + + + + detectCurrentDesktop => Detected: WindowMaker + HuidigeDesktopDetecteren => Gedetecteerd: WindowMaker + + + + No Desktop Environment Detected + Geen desktopomgeving gedetecteerd + + + + SystemIntegration: The process failed to start. Either the invoked program is missing, or you may have insufficient permissions to invoke the program. + Systeemintegratie: Het proces kan niet worden gestart. Ofwel het aangeroepen programma ontbreekt, of u heeft mogelijk onvoldoende rechten om het programma uit te voeren. + + + + SystemIntegration: The process crashed some time after starting successfully. + Systeemintegratie: Het proces crashte enige tijd na het succesvol starten. + + + + SystemIntegration: The last waitFor...() function timed out. The state of QProcess is unchanged, and you can try calling waitFor...() again. + Systeemintegratie: De laatste waitFor ... ()-functie timede-out. De toestand van QProcess is ongewijzigd, en je kunt het opnieuw proberen waitFor ... () aan te roepen. + + + + SystemIntegration: An error occurred when attempting to write to the process. For example, the process may not be running, or it may have closed its input channel. + Systeemintegratie: Er is een fout opgetreden bij een poging om te schrijven naar het proces. Het proces draait bijvoorbeeld niet, of het invoerkanaal kan zijn gesloten. + + + + SystemIntegration: An error occurred when attempting to read from the process. For example, the process may not be running. + Systeemintegratie: Er is een fout opgetreden bij een poging om te lezen uit het proces. Bijvoorbeeld kan het zijn dat het proces niet draait. + + + + SystemIntegration: An unknown error occurred. This is the default return value of error(). + Systeemintegratie: Er is een onbekende fout opgetreden. Dit is de standaard terugkeer waarde van de fout (). + + + + The command exited normally. + Het commando is normaal afgesloten. + + + + The command crashed. + Het commando is vastgelopen. + + + + Running + Actief + + + + Tips: KDE4 is currently incompletely supported. Please select the generated wallpaper in plasma with "centered" parameter (it's just a workaround). For multi monitor with KDE activities, you can create a splitted wallpaper (one file by monitor) by selecting the right option in the "Image parameters" panel. + Tips: KDE4 is momenteel niet volledig ondersteund. Selecteer de gegenereerde achtergrond in Plasma met de parameter "gecentreerd" (het is maar een tijdelijke oplossing). Voor multi-monitor met KDE activiteiten, kunt u een gesplitste wallpaper (een bestand per monitor) creëren door de juiste optie te selecteren in het "Beeld parameters" paneel. + + + + SystemIntegrationConfigWidget + + + SystemIntegrationConfigWidget + SysteemIntergratieConfiguratieWidget + + + + Desktop integration + Desktop integratie + + + + no detection ... + geen detectie ... + + + + The auto detection can failed. In this case, you have to set manually your desktop ... + The automatische detectie is misgegaan. In dit geval, moet je je desktop handmatig instellen ... + + + + detected desktop: %1 + gedetecteerde desktop: %1 + + + + TreeImagesView + + + Add some images to begin + Voeg wat afbeeldingen toe om te beginnen + + + + WallpaperProvider + + + Cannot find the directory %1 + Kan de map %1 niet vinden + + + \ No newline at end of file diff -Nru syncwall-1.6.0/lang/syncwall_vi.ts syncwall-1.7.4/lang/syncwall_vi.ts --- syncwall-1.6.0/lang/syncwall_vi.ts 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/lang/syncwall_vi.ts 2013-07-13 06:00:28.000000000 +0000 @@ -0,0 +1,1477 @@ + + + + + + release of translation and translator name please + put your name here dear translator and the release of the translation file !! + + + + + BackgroundPainterConfigWidget + + + BackgroundPainterConfigWidget + + + + + Image parameters + + + + + Basic + + + + + Horizontal alignment + + + + + Resizing method + + + + + Vertical alignment + + + + + Multi monitor support + + + + + Multi monitor display + + + + + Expert + + + + + ignore image parameters from server (client) + + + + + skip image too small for resizing (<50% of final image) + + + + + export image parameters to clients (server) + + + + + Background + + + + + Inverse gradient color + + + + + Special effect + + + + + Rotate image according to Metadata + + + + + Upsampling method + + + + + (Can greatly increase the computation time) + + + + + Preview desktop + + + + + No data + + + + + Tips: You can reorder and align screens by drag&drop + + + + + no resize + + + + + Stretch to fill (Ignore aspect ratio) + + + + + Proportionally stretch to fit + + + + + Fill proportionally + + + + + No multi monitor support (wallpaper duplicated) + + + + + Extend image (one file for all monitors) + + + + + Extend image then crop (one file per monitor) + + + + + Top alignment + + + + + + Center alignment + + + + + Bottom alignment + + + + + Left alignment + + + + + Right alignment + + + + + Fixed color + + + + + Smart color (extract from image) + + + + + Blurred image + + + + + Vertical gradient + + + + + Horizontal gradient + + + + + Radial gradient + + + + + Qt default algorithm + + + + + Blackman smooth filter + + + + + Cubic filter + + + + + Mitchell filter + + + + + Lanczos filter + + + + + No effect + + + + + Grayscale + + + + + Blur + + + + + Gaussian blur + + + + + Edge + + + + + Sharpen + + + + + Gaussian sharpen + + + + + Emboss + + + + + Desaturate + + + + + Flatten + + + + + Swirl + + + + + Oilpaint + + + + + Charcoal + + + + + Sepia + + + + + Invert colors + + + + + Glow + + + + + Progressive blur + + + + + Random Effect + + + + + DatabaseManager + + + No SQLITE driver available + + + + + DatabaseManager::init: open db %1 ... + + + + + DatabaseManager::createDB: db connection failed ... (%1) + + + + + DatabaseManager::createDB: cannot create table ... (%1) + + + + + DatabaseManager::openDB: database version don't match current one ! + + + + + DatabaseManager::removeInfos: Error when removing data for %2 (%1) + + + + + DatabaseManager::storeInfos: Error in query preparation ... (%1) + + + + + DatabaseManager::storeInfos: Error in query execution ... (%1) + + + + + ImageView + + + x: %1 y: %2 | r: %3 g: %4 b: %5 + + + + + a: %1 + + + + + ImageViewer + + + ImageViewer + + + + + no info + + + + + ListImagesModel + + + Name + + + + + Rate + + + + + Image size + + + + + File size + + + + + Offset defined by user + + + + + NetworkManagerConfigWidget + + + NetworkManagerConfigWidget + + + + + Synchronise with server + + + + + Server (name or IP) + + + + + No connection + + + + + Test Connection + + + + + UDP Port + + + + + Server %1 reached ... + + + + + Disconnection from server %1 ... + + + + + QObject + + + BackgroundPainterConfigWidget: image %1 is reject because its size is too small (%2x%3/%4x%5)) + + + + + BackgroundPainterConfigWidget: too many reject files => please change settings of add more hi-resolution images !! + + + + + BackgroundPainterConfigWidget: Message with invalid nb of parameters (%1 instead of %2) + + + + + BackgroundPainterConfigWidget: Message with unknown version received (%1) + + + + + Bytes + + + + + KB + + + + + MB + + + + + GB + + + + + TB + + + + + Wallpaper manager. + + + + + Usage: + + + + + [options] + + + + + Following options are known: + + + + + --help : displays this help. + + + + + --reset-config : clear the saved preference parameters. + + + + + --no-singleinstance : enable the use of multiple instance of program (not recommended). + + + + + message from other instance. + + + + + %1 is already running !! + + + + + Cleaning temp storage %1 ... + + + + + Deleting %1 + + + + + translations path %1 + + + + + setting language to : %1 + + + + + successfully loaded data from %1 + + + + + failed to load data from %1 + + + + + NetworkManager: Mode SERVER listen to %1 port + + + + + NetworkManager: Mode CLIENT listen to %1 port + + + + + NetworkManager: Send Server Identification for "%1" on port %2 + + + + + NetworkManager: Received message on port %1 + + + + + NetworkManager: Received Server call datagram: "%1" + + + + + NetworkManager: Adding %1 to client list + + + + + NetworkManager: %1 is already in the client list + + + + + NetworkManager: Received background change: "%1" + + + + + NetworkManager: no address found for host %1 (%2) + + + + + NetworkManager: Send Server Call for "%1" on port %2 + + + + + NetworkManager: Send message to "%1" (%2) on port %3 + + + + + NetworkManager:: Sending new message to client %1 + + + + + NetworkManager:: Ping server %1 + + + + + %1 found + + + + + KDE3 desktop + + + + + KDE4 desktop + + + + + GNOME desktop + + + + + GNOME3 desktop + + + + + XFCE desktop + + + + + XFCE4 desktop + + + + + FLUXBOX desktop + + + + + BLACKBOX desktop + + + + + Enlightenment desktop + + + + + ICEWM desktop + + + + + OPENBOX desktop + + + + + LXDE desktop + + + + + WINDOWMAKER desktop + + + + + FVWM desktop + + + + + WINDOWS desktop + + + + + MACOSX desktop + + + + + OS/2 desktop + + + + + Automatic detection + + + + + No Desktop Environment Detected + + + + + Scheduler + + + update interval is to low (%1) => force to %2 sec ... + + + + + + Start new timer for %1 sec ... + + + + + New Schedule fired ... + + + + + SchedulerConfigWidgetClass + + + SchedulerConfigWidget + + + + + Scheduling parameters + + + + + Auto change at startup + + + + + Quit application after startup change (30s) + + + + + Change Interval + + + + + Interval between change (h:m:s) + + + + + set time of day (h:m:s) + + + + + Add to the timeofday list + + + + + Delete selected timeofday + + + + + h:mm:ss + + + + + SyncWall + + + Can't create storage location, check why ?! (%1) + + + + + Active Desktop must be disabled !! + + + + + The application can't find a valid SQLITE driver, its performance and functionality will be degraded + + + + + detected language: %1 + + + + + Automatic detection + + + + + Default (no use of translation files) + + + + + The application need to restart in order to take into account new translation +, Do you want to restart application now ? + + + + + Log file + + + + + Can't save log file !!: %1 + + + + + Add Wallpaper Directory + + + + + + Add all found directories recursively ? + + + + + + Watch for modifications in these directories at application startup ? + + + + + add %1 folder + + + + + Select one or more wallpapers + + + + + Images (%1) + + + + + Systray + + + + + The program will keep running in the system tray. To terminate the program, choose <b>Quit</b> in the context menu of the system tray entry. + + + + + %1 images in list + + + + + <a href="%1">Check for new release ...</a> + + + + + Qt version %1 + + + + + new file received : %1 + + + + + Can't find local file as received : %1 + + + + + Standard state. Scheduling is activated + + + + + Idle state. No scheduling and no server connection + + + + + Server state. Al least a client is connected + + + + + Client state. Connected to server + + + + + Client state but disconnected from server + + + + + Client state but the protocol isn't correct. Upgrade client or server ! + + + + + The %1 file can't be found, sorry ... + + + + + Do you want to reset all the preferences to default value ? + If yes, the application will be relaunch + + + + + Do you want to reset all cached data (thumbnails and ratings) ? + + + + + SyncWallClass + + + SyncWall + + + + + Preview + + + + + No wallpaper + + + + + Auto change in random order + + + + + + Quit + + + + + Online Help + + + + + Add a new folder + + + + + + Add new file(s) + + + + + Delete selected wallpaper from list + + + + + Refresh file list + + + + + + Set wallpaper + + + + + Preview selected wallpaper + + + + + Preview desktop + + + + + Apply user positioning + + + + + Enter image positioning by user + + + + + Cancel user positioning + + + + + State ... + + + + + View list and infos + + + + + View thumbnails + + + + + Preferences + + + + + + Startup + + + + + Use Global Hotkey for manual change of wallpaper + + + + + Next wallpaper: + + + + + Previous wallpaper: + + + + + Open main interface: + + + + + Change image offset: + + + + + Language + + + + + Detected language ... + + + + + Start in notification tray (minimized) + + + + + Display splashscreen at startup + Hiển thị màn hình giới thiệu khi khởi động chương trình + + + + Auto start with system + + + + + Reset all preferences + + + + + Reset preferences + + + + + Splashscreen with transparent background + Màn hình giới thiệu với hiệu ứng nền trong suốt + + + + Reset cached data + + + + + Reset cache + + + + + Scheduling + + + + + Display Parameters + + + + + Network + + + + + About + + + + + Release Number + + + + + Supported formats (via Qt plugins) + Định dạng được hỗ trợ (thông qua tiện ích Qt) + + + + Available translations + Các phần chuyển ngữ hiện có + + + + Credits + + + + + Changelog + + + + + Log + Nhật trình hệ thống + + + + Clear Log + + + + + Save log to file + + + + + Preview Image + + + + + Delete Image + + + + + Show main interface + + + + + Show User Interface + + + + + Quit application + + + + + Next Wallpaper + + + + + Previous Wallpaper + + + + + + Change Image Offset + + + + + Help + + + + + SystemIntegration + + + Desktop selected: %1 + + + + + Number of screen detected: %1 + + + + + KDE4 is currently incompletely supported. Please select %1 as the current wallpaper with "centered" parameter (it's just a workaround) + + + + + Can't open %1 + + + + + SystemIntegration::applyImage: Problem during saving of temp image %1 !! + + + + + Convert QImage to %1 + + + + + Saving temp file (%1) + + + + + Failed to save temp file (%1) + + + + + loop detected during environment processing => skip + + + + + detectCurrentDesktop => Detected: KDE3 + + + + + detectCurrentDesktop => Detected: KDE4 + + + + + detectCurrentDesktop => Detected: Gnome + + + + + detectCurrentDesktop => Gnome version %1 + + + + + detectCurrentDesktop => Detected: Xfce + + + + + detectCurrentDesktop => Detected: Xfce4 + + + + + detectCurrentDesktop => Detected: Fluxbox + + + + + detectCurrentDesktop => Detected: FVWM + + + + + detectCurrentDesktop => Detected: Blackbox + + + + + detectCurrentDesktop => Detected: WindowMaker + + + + + No Desktop Environment Detected + + + + + SystemIntegration: The process failed to start. Either the invoked program is missing, or you may have insufficient permissions to invoke the program. + + + + + SystemIntegration: The process crashed some time after starting successfully. + + + + + SystemIntegration: The last waitFor...() function timed out. The state of QProcess is unchanged, and you can try calling waitFor...() again. + + + + + SystemIntegration: An error occurred when attempting to write to the process. For example, the process may not be running, or it may have closed its input channel. + + + + + SystemIntegration: An error occurred when attempting to read from the process. For example, the process may not be running. + + + + + SystemIntegration: An unknown error occurred. This is the default return value of error(). + + + + + The command exited normally. + + + + + The command crashed. + + + + + Running + + + + + Tips: KDE4 is currently incompletely supported. Please select the generated wallpaper in plasma with "centered" parameter (it's just a workaround). For multi monitor with KDE activities, you can create a splitted wallpaper (one file by monitor) by selecting the right option in the "Image parameters" panel. + + + + + SystemIntegrationConfigWidget + + + SystemIntegrationConfigWidget + + + + + Desktop integration + + + + + no detection ... + + + + + The auto detection can failed. In this case, you have to set manually your desktop ... + + + + + detected desktop: %1 + + + + + TreeImagesView + + + Add some images to begin + + + + + WallpaperProvider + + + Cannot find the directory %1 + + + + \ No newline at end of file diff -Nru syncwall-1.6.0/recopy.bat syncwall-1.7.4/recopy.bat --- syncwall-1.6.0/recopy.bat 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/recopy.bat 2013-05-04 12:27:00.000000000 +0000 @@ -0,0 +1,4 @@ +d:\pskill.exe -t SyncWall.exe +xcopy /y /f \\XBEEHIVE\SyncWall\debug d:\SyncWall +pause + diff -Nru syncwall-1.6.0/res/Info.plist syncwall-1.7.4/res/Info.plist --- syncwall-1.6.0/res/Info.plist 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/res/Info.plist 2011-12-18 10:29:44.000000000 +0000 @@ -0,0 +1,22 @@ + + + + + CFBundleIconFile + syncwall.icns + CFBundlePackageType + APPL + CFBundleGetInfoString + Created by Qt/QMake + CFBundleSignature + ???? + CFBundleExecutable + SyncWall + CFBundleIdentifier + net.xbee.syncwall + NOTE + Author: xbee + NSHumanReadableCopyright + Copyright 2011 http://thehive.xbee.net + + Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/about.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/about.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/add.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/add.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/apply.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/apply.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/apply2.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/apply2.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/basic_user.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/basic_user.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/camera.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/camera.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/change.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/change.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/check.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/check.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/default.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/default.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/delete.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/delete.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/delete2.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/delete2.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/dir_add.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/dir_add.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/display_big.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/display_big.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/expert_user.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/expert_user.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/files_add.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/files_add.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/flower.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/flower.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/folder_add.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/folder_add.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/help.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/help.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/help_blue.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/help_blue.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/icon_quit.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/icon_quit.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/icon_quit2.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/icon_quit2.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/images_add.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/images_add.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/logo_big.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/logo_big.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/mode_client_connected.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/mode_client_connected.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/mode_client_disconnected.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/mode_client_disconnected.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/mode_client_invalid.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/mode_client_invalid.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/mode_idle.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/mode_idle.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/mode_server.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/mode_server.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/mode_standard.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/mode_standard.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/monitor_paint.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/monitor_paint.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/monitor_paint2.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/monitor_paint2.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/network_big.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/network_big.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/preferences.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/preferences.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/preview.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/preview.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/preview2.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/preview2.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/provider.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/provider.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/reflection.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/reflection.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/refresh.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/refresh.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/refresh2.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/refresh2.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/reset.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/reset.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/reset2.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/reset2.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/scheduling_big.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/scheduling_big.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/scroll.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/scroll.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/splashscreen.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/splashscreen.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/startup_big.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/startup_big.png differ diff -Nru syncwall-1.6.0/res/syncwall.desktop syncwall-1.7.4/res/syncwall.desktop --- syncwall-1.6.0/res/syncwall.desktop 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/res/syncwall.desktop 2011-12-18 10:51:12.000000000 +0000 @@ -0,0 +1,9 @@ +[Desktop Entry] +Version=1.0 +Name=SyncWall +Comment=Wallpaper management with synchronization features +Exec=SyncWall +Icon=SyncWall +Terminal=false +Type=Application +Categories=Utility;Application; \ No newline at end of file Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/syncwall.icns and /tmp/OqecVKC_d5/syncwall-1.7.4/res/syncwall.icns differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/syncwall.ico and /tmp/OqecVKC_d5/syncwall-1.7.4/res/syncwall.ico differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/syncwall.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/syncwall.png differ diff -Nru syncwall-1.6.0/res/syncwall.qrc syncwall-1.7.4/res/syncwall.qrc --- syncwall-1.6.0/res/syncwall.qrc 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/res/syncwall.qrc 2013-05-02 13:06:06.000000000 +0000 @@ -0,0 +1,58 @@ + + + help_blue.png + apply2.png + view-detail2.png + view-list2.png + view-thumbnail2.png + icon_quit2.png + monitor_paint2.png + preview2.png + delete2.png + refresh2.png + files_add.png + dir_add.png + reset2.png + basic_user.png + expert_user.png + apply.png + user_move.png + camera.png + default.png + syncwall.png + unavailable.png + view-detail.png + view-list.png + view-thumbnail.png + splashscreen.png + reset.png + flower.png + mode_client_invalid.png + mode_client_connected.png + mode_client_disconnected.png + mode_idle.png + mode_server.png + mode_standard.png + startup_big.png + display_big.png + network_big.png + scheduling_big.png + preview.png + provider.png + monitor_paint.png + add.png + images_add.png + refresh.png + scroll.png + trash.png + about.png + logo_big.png + change.png + check.png + delete.png + folder_add.png + icon_quit.png + reflection.png + preferences.png + + diff -Nru syncwall-1.6.0/res/syncwall.rc syncwall-1.7.4/res/syncwall.rc --- syncwall-1.6.0/res/syncwall.rc 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/res/syncwall.rc 2011-12-01 14:41:46.000000000 +0000 @@ -0,0 +1,2 @@ +IDI_ICON1 ICON DISCARDABLE "syncwall.ico" + Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/trash.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/trash.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/unavailable.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/unavailable.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/user_move.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/user_move.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/view-detail.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/view-detail.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/view-detail2.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/view-detail2.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/view-list.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/view-list.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/view-list2.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/view-list2.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/view-thumbnail.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/view-thumbnail.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/res/view-thumbnail2.png and /tmp/OqecVKC_d5/syncwall-1.7.4/res/view-thumbnail2.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/setup/banner.bmp and /tmp/OqecVKC_d5/syncwall-1.7.4/setup/banner.bmp differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/setup/icon.ico and /tmp/OqecVKC_d5/syncwall-1.7.4/setup/icon.ico differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/setup/icon_install.ico and /tmp/OqecVKC_d5/syncwall-1.7.4/setup/icon_install.ico differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/setup/icon_uninstall.ico and /tmp/OqecVKC_d5/syncwall-1.7.4/setup/icon_uninstall.ico differ diff -Nru syncwall-1.6.0/setup/setup.nsi syncwall-1.7.4/setup/setup.nsi --- syncwall-1.6.0/setup/setup.nsi 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/setup/setup.nsi 2013-07-06 03:21:42.000000000 +0000 @@ -0,0 +1,233 @@ + +;NSIS Modern User Interface +;Written by Joost Verburg + +XPStyle on +!define PROGRAM_NAME "SyncWall" +!define TARGET_NAME "${PROGRAM_NAME}" +!define ORGANIZATION_NAME "TheHive" +!define SHCNE_ASSOCCHANGED 0x8000000 +!define SHCNF_IDLIST 0 + + +BrandingText "${PROGRAM_NAME} installation"; remove the nsis release on the gui + +########################################################################################### +# init functions +########################################################################################### + +Function .onInit + + # fading splashscreen !! + # the plugins dir is automatically deleted when the installer exits + InitPluginsDir + File /oname=$PLUGINSDIR\splash.bmp "splashscreen.bmp" + #optional + #File /oname=$PLUGINSDIR\splash.wav "C:\myprog\sound.wav" + + advsplash::show 2000 600 400 -1 $PLUGINSDIR\splash + + Pop $0 ; $0 has '1' if the user closed the splash screen early, + ; '0' if everything closed normally, and '-1' if some error occurred. + + Delete $PLUGINSDIR\splash.bmp + + # uninstall previous release before installing a new one + ReadRegStr $R0 HKLM \ + "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROGRAM_NAME}" \ + "UninstallString" + StrCmp $R0 "" done + + MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \ + "${PROGRAM_NAME} is already installed. $\n$\nClick `OK` to remove the \ + previous version or `Cancel` to cancel this upgrade." \ + IDOK uninst + Abort + + ;Run the uninstaller + uninst: + ClearErrors + Exec "$INSTDIR\uninstall.exe /S" + + done: + +FunctionEnd + +;-------------------------------- + +Function LaunchLink + ExecShell "" "$INSTDIR\${PROGRAM_NAME}.exe" +FunctionEnd + +;-------------------------------- +;Include Modern UI + + !include "MUI2.nsh" + +;-------------------------------- +;General + + ;Name and file + !ifndef VERSION + !define VERSION 'bxx' + !endif + + ;Name and file + Name "${PROGRAM_NAME}" + +;-------------------------------- +;Configuration + + ; output directory if not set by batch + !ifndef SETUP_DIR + !define SETUP_DIR '.\' + !endif + + ; output setup file + !ifdef OUTFILE + OutFile "${SETUP_DIR}\${OUTFILE}" + !else + OutFile "${SETUP_DIR}\${PROGRAM_NAME}-${VERSION}-setup.exe" + !endif + + ;Default installation folder + InstallDir $PROGRAMFILES\${ORGANIZATION_NAME}\${PROGRAM_NAME} + + ;Get installation folder from registry if available + InstallDirRegKey HKLM "Software\${ORGANIZATION_NAME}\${PROGRAM_NAME}" "Install_Dir" + + ;Request application privileges for Windows Vista + RequestExecutionLevel admin + +;-------------------------------- +;Interface Settings + + !define MUI_HEADERIMAGE + !define MUI_HEADERIMAGE_RIGHT + !define MUI_HEADERIMAGE_BITMAP "banner.bmp" ; optional installer pages + !define MUI_HEADERIMAGE_UNBITMAP "banner.bmp" ; uninstaller pages + !define MUI_ABORTWARNING + !define MUI_ICON "icon_install.ico" + !define MUI_UNICON "icon_uninstall.ico" + !define MUI_WELCOMEFINISHPAGE_BITMAP "welcome.bmp" ; welcome/finish banner + !define MUI_FINISHPAGE_NOAUTOCLOSE + + !define MUI_FINISHPAGE_RUN + !define MUI_FINISHPAGE_RUN_NOTCHECKED + !define MUI_FINISHPAGE_RUN_TEXT "Start ${PROGRAM_NAME} after install" + !define MUI_FINISHPAGE_RUN_FUNCTION "LaunchLink" + !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED + +;-------------------------------- +;Pages + + ;!insertmacro MUI_PAGE_LICENSE "License.txt" + ;!insertmacro MUI_PAGE_COMPONENTS + !insertmacro MUI_PAGE_WELCOME ; affiche un welcome + !insertmacro MUI_PAGE_DIRECTORY + !insertmacro MUI_PAGE_INSTFILES + !insertmacro MUI_PAGE_FINISH ; affiche une page de fin + + !insertmacro MUI_UNPAGE_CONFIRM + !insertmacro MUI_UNPAGE_INSTFILES + +;-------------------------------- +;Languages + + !insertmacro MUI_LANGUAGE "English" + +;-------------------------------- +;Installer Sections + +Section "Dummy Section" SecDummy + + SectionIn RO + + ; Program files there + SetOutPath $INSTDIR + File "..\build\Release\${PROGRAM_NAME}.exe" + File "$%QTDIR%\bin\QtCore4.dll" + File "$%QTDIR%\bin\QtGui4.dll" + File "$%QTDIR%\bin\QtSql4.dll" + File "$%QTDIR%\bin\QtNetwork4.dll" + ; Minggw case ... + File /nonfatal "$%QTDIR%\bin\mingwm10.dll" + File /nonfatal "$%QTDIR%\bin\libgcc_s_dw2-1.dll" + + ; qt image plugin + SetOutPath "$INSTDIR\plugins\imageformats" + File "$%QTDIR%\plugins\imageformats\*.dll" + + ; qt sql plugin + SetOutPath "$INSTDIR\plugins\sqldrivers" + File "$%QTDIR%\plugins\sqldrivers\qsqlite4.dll" + + ; Lang files + SetOutPath "$INSTDIR\lang" + File /nonfatal "..\lang\*.qm" + File /nonfatal "*.qm" + + ; Other files + SetOutPath $INSTDIR + File "..\CREDITS.txt" + File "..\AUTHORS.txt" + File "..\LICENSE.txt" + File "..\Changelog.txt" + + ; resources files + SetOutPath $INSTDIR + File "icon.ico" + + ; Write the installation path into the registry + WriteRegStr HKLM SOFTWARE\${ORGANIZATION_NAME}\${PROGRAM_NAME} "Install_Dir" "$INSTDIR" + WriteRegStr HKLM SOFTWARE\${ORGANIZATION_NAME}\${PROGRAM_NAME} "Version" "${VERSION}" + + ; Write the uninstall keys for Windows + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROGRAM_NAME}" "DisplayName" "${PROGRAM_NAME}" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROGRAM_NAME}" "UninstallString" '"$INSTDIR\uninstall.exe"' + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROGRAM_NAME}" "NoModify" 1 + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROGRAM_NAME}" "NoRepair" 1 + WriteUninstaller "$INSTDIR\uninstall.exe" + +SectionEnd + +;-------------------------------- +; Optional section (can be disabled by the user) +Section "Start Menu Shortcuts" + + SetShellVarContext all ; scope is "All Users" + CreateDirectory "$SMPROGRAMS\${ORGANIZATION_NAME}\${PROGRAM_NAME}" + CreateShortCut "$SMPROGRAMS\${ORGANIZATION_NAME}\${PROGRAM_NAME}\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0 + CreateShortCut "$SMPROGRAMS\${ORGANIZATION_NAME}\${PROGRAM_NAME}\${PROGRAM_NAME}.lnk" "$INSTDIR\${PROGRAM_NAME}.exe" "" "$INSTDIR\${PROGRAM_NAME}.exe" 0 + + ;create desktop shortcut + CreateShortCut "$DESKTOP\${PROGRAM_NAME}.lnk" "$INSTDIR\${PROGRAM_NAME}.exe" "" "$INSTDIR\icon.ico" + +SectionEnd + +;-------------------------------- +;Uninstaller Section + +Section "Uninstall" + + ; Remove registry keys + DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROGRAM_NAME}" + DeleteRegKey HKLM SOFTWARE\${ORGANIZATION_NAME}\${PROGRAM_NAME} + + ; Remove files and uninstaller + Delete "$INSTDIR\*.*" + + ; Remove shortcuts, if any + SetShellVarContext all ; scope is "All Users" + Delete "$SMPROGRAMS\${ORGANIZATION_NAME}\${PROGRAM_NAME}\*.*" + + ; remove desktop link + Delete "$DESKTOP\${PROGRAM_NAME}.lnk" + + ; Remove directories used + RMDir "$SMPROGRAMS\${ORGANIZATION_NAME}\${PROGRAM_NAME}" + RMDir "$SMPROGRAMS\${ORGANIZATION_NAME}\" + RMDir /r "$INSTDIR\plugins" + RMDir /r "$INSTDIR" + +SectionEnd Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/setup/splashscreen.bmp and /tmp/OqecVKC_d5/syncwall-1.7.4/setup/splashscreen.bmp differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/setup/welcome.bmp and /tmp/OqecVKC_d5/syncwall-1.7.4/setup/welcome.bmp differ diff -Nru syncwall-1.6.0/src/3rdparty/3rdparty.pro syncwall-1.7.4/src/3rdparty/3rdparty.pro --- syncwall-1.6.0/src/3rdparty/3rdparty.pro 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/3rdparty.pro 2012-01-20 14:38:04.000000000 +0000 @@ -0,0 +1,5 @@ +TEMPLATE = subdirs + +CONFIG += warn_on debug_and_release +SUBDIRS += qimageblitz + diff -Nru syncwall-1.6.0/src/3rdparty/qimageblitz/CMakeLists.txt syncwall-1.7.4/src/3rdparty/qimageblitz/CMakeLists.txt --- syncwall-1.6.0/src/3rdparty/qimageblitz/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qimageblitz/CMakeLists.txt 2012-01-08 15:07:42.000000000 +0000 @@ -0,0 +1,63 @@ +project(blitz_lib) +include(CheckCXXSourceCompiles) +include(CheckIncludeFile) + +CMAKE_MINIMUM_REQUIRED(VERSION 2.4.4) + +if (APPLE) + set(CMAKE_INSTALL_NAME_DIR ${LIB_INSTALL_DIR}) + set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) +endif (APPLE) + +include_directories( +${CMAKE_SOURCE_DIR} +${blitz_lib_BINARY_DIR} +${QT_INCLUDE_DIR} +${QT_QTCORE_INCLUDE_DIR} +${QT_QTGUI_INCLUDE_DIR} +) + +CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H) + +if(NOT MSVC) + CHECK_CXX_SOURCE_COMPILES(" int main() { __asm__(\"pxor %mm0, %mm0\") ; }" HAVE_MMX) + CHECK_CXX_SOURCE_COMPILES(" int main() { __asm__(\"xorps %xmm0, %xmm0\"); }" HAVE_SSE) + CHECK_CXX_SOURCE_COMPILES(" int main() { __asm__(\"xorpd %xmm0, %xmm0\"); }" HAVE_SSE2) + CHECK_CXX_SOURCE_COMPILES(" int main() { __asm__(\"pi2fd %mm0, %mm0\"); }" HAVE_3DNOW) + CHECK_CXX_SOURCE_COMPILES(" int main() { __asm__(\"mtspr 256, %0; vand %%v0, %%v0, %%v0\" : : \"r\"(-1) ); }" HAVE_ALTIVEC) +endif(NOT MSVC) + +SET(BLITZ_LIB_MAJOR_VERSION "4") +SET(BLITZ_LIB_MINOR_VERSION "0") +SET(BLITZ_LIB_PATCH_VERSION "0") + +SET(BLITZ_LIB_VERSION_STRING "${BLITZ_LIB_MAJOR_VERSION}.${BLITZ_LIB_MINOR_VERSION}.${BLITZ_LIB_PATCH_VERSION}") + +set(blitz_LIB_SRCS blitz.cpp colors.cpp convolve.cpp histogram.cpp +blitzcpu.cpp scale.cpp scalefilter.cpp gradient.cpp) + +if(HAVE_MMX) + if(NOT APPLE AND NOT WIN32) + set( blitz_LIB_SRCS ${blitz_LIB_SRCS} asm_scale.S ) + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/asm_scale.o + COMMAND gcc -c ${CMAKE_CURRENT_SOURCE_DIR}/asm_scale.S + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/asm_scale.S ) + set( blitz_LIB_EXTRA_SRCS ${CMAKE_CURRENT_BINARY_DIR}/asm_scale.o ) + set(HAVE_EXTERNAL_ASM TRUE) + endif(NOT APPLE AND NOT WIN32) +endif(HAVE_MMX) +configure_file (config-processor.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-processor.h ) +configure_file (config-externalasm.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-externalasm.h ) + +add_library(qimageblitz STATIC ${blitz_LIB_SRCS} ${blitz_LIB_EXTRA_SRCS}) + +target_link_libraries(qimageblitz ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY}) + +set_target_properties(qimageblitz PROPERTIES + VERSION ${BLITZ_LIB_MAJOR_VERSION}.${BLITZ_LIB_MINOR_VERSION}.${BLITZ_LIB_PATCH_VERSION} + SOVERSION ${BLITZ_LIB_MAJOR_VERSION} + DEFINE_SYMBOL MAKE_QIMAGEBLITZ_LIB +) + + + diff -Nru syncwall-1.6.0/src/3rdparty/qimageblitz/asm_scale.S syncwall-1.7.4/src/3rdparty/qimageblitz/asm_scale.S --- syncwall-1.6.0/src/3rdparty/qimageblitz/asm_scale.S 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qimageblitz/asm_scale.S 2008-02-26 19:31:00.000000000 +0000 @@ -0,0 +1,816 @@ + +#if defined(__EMX__) +/* Due to strange behaviour of as.exe we use this macros */ +/* For all OS/2 coders - please use PGCC to compile this code */ +#define PR_(foo) ___##foo +#define PT_(foo,func) ___##foo,##func +#define SIZE(sym) \ + .___end_##sym:; \ + .size ___##sym,.___end_##sym-___##sym; \ + .align 8; +#elif defined(__APPLE__) +#define PR_(foo) ___##foo +#define PT_(foo,func) ___##foo,##func +#define SIZE(sym) \ + .__end_##sym:; \ + .align 8; +#else +#define PR_(foo) __##foo +#define PT_(foo,func) __##foo,##func +#define SIZE(sym) \ + .__end_##sym:; \ + .size __##sym,.__end_##sym-__##sym; \ + .align 8; +#endif + +#if defined(__i386__) && ( defined(__GNUC__) || defined(__INTEL_COMPILER) ) + + +/*\ +|*| MMX assembly scaling routine for Imlib2 +|*| Written by Willem Monsuwe +\*/ + +.text + .align 8 +.globl PR_(qimageScale_mmx_AARGBA) +/* .type PT_(qimageScale_mmx_AARGBA,@function) */ + + +/*\ Prototype: __qimageScale_mmx_AARGBA(ImlibScaleInfo *isi, DATA32 *dest, +|*| int dxx, int dyy, int dx, int dy, int dw, int dh, int dow, int sow) +\*/ + +#define isi 8(%ebp) +#define dest 12(%ebp) +#define dxx 16(%ebp) +#define dyy 20(%ebp) +#define dx 24(%ebp) +#define dy 28(%ebp) +#define dw 32(%ebp) +#define dh 36(%ebp) +#define dow 40(%ebp) +#define sow 44(%ebp) + +/*\ Local variables that didn't fit in registers \*/ +#define y -4(%ebp) +#define yp -8(%ebp) +#define yap -12(%ebp) +#define xp -16(%ebp) +#define xap -20(%ebp) +#define Cx -24(%ebp) +#define Mx -28(%ebp) +#define Cy -32(%ebp) +#define My -36(%ebp) +#define sow_4 -40(%ebp) + +/*\ When %edx points to ImlibScaleInfo, these are the members \*/ +#define xpoints (%edx) +#define ypoints 4(%edx) +#define xapoints 8(%edx) +#define yapoints 12(%edx) +#define xup_yup 16(%edx) + +PR_(qimageScale_mmx_AARGBA): + pushl %ebp + movl %esp, %ebp + subl $40, %esp + pushl %ebx + pushl %ecx + pushl %edx + pushl %edi + pushl %esi + movl isi, %edx + + /*\ Check (dw > 0) && (dh > 0) \*/ + cmpl $0, dw + jle .scale_leave + cmpl $0, dh + jle .scale_leave + + /*\ X-based array pointers point to the end; we're looping up to 0 \*/ + /*\ %edi = dest + dow * dy + dx + dw \*/ + movl dow, %eax + imull dy, %eax + addl dx, %eax + addl dw, %eax + movl dest, %edi + leal (%edi, %eax, 4), %edi + /*\ xp = xpoints + dxx + dw \*/ + movl dxx, %ebx + addl dw, %ebx + movl xpoints, %eax + leal (%eax, %ebx, 4), %eax + movl %eax, xp + /*\ xap = xapoints + dxx + dw \*/ + movl xapoints, %eax + leal (%eax, %ebx, 4), %eax + movl %eax, xap + /*\ y = dh \*/ + movl dh, %eax + movl %eax, y + /*\ yp = ypoints + dyy \*/ + movl dyy, %ebx + movl ypoints, %eax + leal (%eax, %ebx, 4), %eax + movl %eax, yp + /*\ yap = yapoints + dyy \*/ + movl yapoints, %eax + leal (%eax, %ebx, 4), %eax + movl %eax, yap + + pxor %mm7, %mm7 + + /*\ Test xup bit \*/ + movl xup_yup, %eax + sarl $1, %eax + jnc .scale_x_down + +.scale_x_up: + /*\ Test yup bit \*/ + sarl $1, %eax + jnc .scale_x_up_y_down + + +/*\ Scaling up both ways \*/ + +.scale_x_up_y_up: + movl sow, %ebx + +.up_up_loop_y: + + /*\ x = -dw \*/ + movl dw, %ecx + negl %ecx + + /*\ %eax = *yap << 4 \*/ + movl yap, %eax + movl (%eax), %eax + sall $4, %eax + jz .up_up_yap_0 + movd %eax, %mm1 + punpcklwd %mm1, %mm1 + punpckldq %mm1, %mm1 + +.up_up_loop1_x: + /*\ %esi = *yp + xp[x] \*/ + movl yp, %eax + movl (%eax), %esi + movl xp, %eax + movl (%eax, %ecx, 4), %eax + leal (%esi, %eax, 4), %esi + + /*\ %eax = xap[x] << 4 \*/ + movl xap, %eax + movl (%eax, %ecx, 4), %eax + sall $4, %eax + jz .up_up_xap_0 + + /*\ %mm0 = xap[x] << 4 \*/ + movd %eax, %mm0 + punpcklwd %mm0, %mm0 + punpckldq %mm0, %mm0 + + /*\ Load and unpack four pixels in parralel + |*| %mm2 = ptr[0], %mm3 = ptr[1] + |*| %mm4 = ptr[sow], %mm5 = ptr[sow + 1] + \*/ + movq (%esi), %mm2 + movq (%esi, %ebx, 4), %mm4 + movq %mm2, %mm3 + movq %mm4, %mm5 + punpcklbw %mm7, %mm2 + punpcklbw %mm7, %mm4 + punpckhbw %mm7, %mm3 + punpckhbw %mm7, %mm5 + + /*\ X interpolation: r = l + (r - l) * xap \*/ + psubw %mm2, %mm3 + psubw %mm4, %mm5 + psllw $4, %mm3 + psllw $4, %mm5 + pmulhw %mm0, %mm3 + pmulhw %mm0, %mm5 + paddw %mm2, %mm3 + paddw %mm4, %mm5 + /*\ Now %mm3 = I(ptr[0], ptr[1]), %mm5 = I(ptr[sow], ptr[sow + 1]) \*/ + jmp .up_up_common +.up_up_xap_0: + /*\ Load and unpack two pixels + |*| %mm3 = ptr[0], %mm5 = ptr[sow] + \*/ + movd (%esi), %mm3 + movd (%esi, %ebx, 4), %mm5 + punpcklbw %mm7, %mm3 + punpcklbw %mm7, %mm5 +.up_up_common: + /*\ Y interpolation: d = u + (d - u) * yap \*/ + psubw %mm3, %mm5 + psllw $4, %mm5 + pmulhw %mm1, %mm5 + paddw %mm3, %mm5 + packuswb %mm5, %mm5 + movd %mm5, (%edi, %ecx, 4) + + /*\ while (++x) \*/ + incl %ecx + jnz .up_up_loop1_x + jmp .up_up_yap_end +.up_up_yap_0: + +.up_up_loop2_x: + /*\ %esi = *yp + xp[x] \*/ + movl yp, %eax + movl (%eax), %esi + movl xp, %eax + movl (%eax, %ecx, 4), %eax + leal (%esi, %eax, 4), %esi + + /*\ %eax = xap[x] << 4 \*/ + movl xap, %eax + movl (%eax, %ecx, 4), %eax + sall $4, %eax + jz .up_up_0 + + /*\ %mm0 = xap[x] << 4 \*/ + movd %eax, %mm0 + punpcklwd %mm0, %mm0 + punpckldq %mm0, %mm0 + + /*\ Load and unpack two pixels in parralel + |*| %mm2 = ptr[0], %mm3 = ptr[1] + \*/ + movq (%esi), %mm2 + movq %mm2, %mm3 + punpcklbw %mm7, %mm2 + punpckhbw %mm7, %mm3 + + /*\ X interpolation: r = l + (r - l) * xap \*/ + psubw %mm2, %mm3 + psllw $4, %mm3 + pmulhw %mm0, %mm3 + paddw %mm2, %mm3 + packuswb %mm3, %mm3 + movd %mm3, (%edi, %ecx, 4) + jmp .up_up_1 +.up_up_0: + /*\ dptr[x] = *sptr \*/ + movl (%esi), %eax + movl %eax, (%edi, %ecx, 4) +.up_up_1: + incl %ecx + jnz .up_up_loop2_x + +.up_up_yap_end: + /*\ dptr += dow \*/ + movl dow, %eax + leal (%edi, %eax, 4), %edi + /*\ yap++; yp++ \*/ + addl $4, yap + addl $4, yp + /*\ while (y--) \*/ + decl y + jnz .up_up_loop_y + + jmp .scale_leave + + +/*\ Scaling down vertically \*/ + +.scale_x_up_y_down: + /*\ sow_4 = sow * 4 \*/ + movl sow, %eax + sall $2, %eax + movl %eax, sow_4 + +.up_down_loop_y: + + /*\ Setup My and Cy \*/ + movl yap, %eax + movzwl (%eax), %ebx + movl %ebx, My + movzwl 2(%eax), %eax + movl %eax, Cy + + /*\ mm4 = Cy \*/ + movd %eax, %mm4 + punpcklwd %mm4, %mm4 + punpckldq %mm4, %mm4 + /*\ mm5 = My \*/ + movd %ebx, %mm5 + punpcklwd %mm5, %mm5 + punpckldq %mm5, %mm5 + + /*\ x = -dw \*/ + movl dw, %ecx + negl %ecx +.up_down_loop_x: + /*\ %esi = *yp + xp[x] \*/ + movl yp, %eax + movl (%eax), %esi + movl xp, %eax + movl (%eax, %ecx, 4), %eax + leal (%esi, %eax, 4), %esi + + movl %esi, %eax + /*\ v = (*p * My) >> 10 \*/ + movd (%eax), %mm0 + punpcklbw %mm7, %mm0 + psllw $6, %mm0 + pmulhw %mm5, %mm0 + + /*\ i = 0x4000 - My \*/ + movl $0x4000, %ebx + subl My, %ebx + jbe 5f + jmp 2f +1: + /*\ p += sow; v += (*p * Cy) >> 10 \*/ + addl sow_4, %eax + movd (%eax), %mm1 + punpcklbw %mm7, %mm1 + psllw $6, %mm1 + pmulhw %mm4, %mm1 + paddw %mm1, %mm0 + + /*\ i -= Cy; while (i > Cy) \*/ + subl Cy, %ebx +2: + cmpl Cy, %ebx + jg 1b + + /*\ mm6 = i \*/ + movd %ebx, %mm6 + punpcklwd %mm6, %mm6 + punpckldq %mm6, %mm6 + + /*\ p += sow; v += (*p * i) >> 10 \*/ + addl sow_4, %eax + movd (%eax), %mm1 + punpcklbw %mm7, %mm1 + psllw $6, %mm1 + pmulhw %mm6, %mm1 + paddw %mm1, %mm0 +5: + /*\ %eax = xap[x] << 5 \*/ + movl xap, %eax + movl (%eax, %ecx, 4), %eax + sall $5, %eax + jz 6f + /*\ mm3 = xap[x] << 5 \*/ + movd %eax, %mm3 + punpcklwd %mm3, %mm3 + punpckldq %mm3, %mm3 + + /*\ p + 1 \*/ + movl %esi, %eax + addl $4, %eax + /*\ vv = (*p * My) >> 10 \*/ + movd (%eax), %mm2 + punpcklbw %mm7, %mm2 + psllw $6, %mm2 + pmulhw %mm5, %mm2 + + /*\ i = 0x4000 - My \*/ + movl $0x4000, %ebx + subl My, %ebx + jbe 5f + jmp 2f +1: + /*\ p += sow; vv += (*p * Cy) >> 10 \*/ + addl sow_4, %eax + movd (%eax), %mm1 + punpcklbw %mm7, %mm1 + psllw $6, %mm1 + pmulhw %mm4, %mm1 + paddw %mm1, %mm2 + + /*\ i -= Cy; while (i > Cy) \*/ + subl Cy, %ebx +2: + cmpl Cy, %ebx + jg 1b + + /*\ p += sow; v += (*p * i) >> 10 \*/ + addl sow_4, %eax + movd (%eax), %mm1 + punpcklbw %mm7, %mm1 + psllw $6, %mm1 + pmulhw %mm6, %mm1 + paddw %mm1, %mm2 +5: + /*\ v = v + (vv - v) * xap \*/ + psubw %mm0, %mm2 + psllw $3, %mm2 + pmulhw %mm3, %mm2 + paddw %mm2, %mm0 +6: + /*\ dest[x] = v >> 4 \*/ + psrlw $4, %mm0 + packuswb %mm0, %mm0 + movd %mm0, (%edi, %ecx, 4) + + /*\ while (++x) \*/ + incl %ecx + jnz .up_down_loop_x + + /*\ dptr += dow \*/ + movl dow, %eax + leal (%edi, %eax, 4), %edi + /*\ yap++; yp++ \*/ + addl $4, yap + addl $4, yp + /*\ while (y--) \*/ + decl y + jnz .up_down_loop_y + + jmp .scale_leave + +.scale_x_down: + /*\ Test yup bit \*/ + sarl $1, %eax + jnc .scale_x_down_y_down + + +/*\ Scaling down horizontally \*/ + +.scale_x_down_y_up: + /*\ sow_4 = sow * 4 \*/ + movl sow, %eax + sall $2, %eax + movl %eax, sow_4 + +.down_up_loop_y: + + /*\ %eax = *yap << 5 \*/ + movl yap, %eax + movl (%eax), %eax + sall $5, %eax + /*\ mm3 = *yap << 5 \*/ + movd %eax, %mm3 + punpcklwd %mm3, %mm3 + punpckldq %mm3, %mm3 + + /*\ x = -dw \*/ + movl dw, %ecx + negl %ecx +.down_up_loop_x: + /*\ %esi = *yp + xp[x] \*/ + movl yp, %eax + movl (%eax), %esi + movl xp, %eax + movl (%eax, %ecx, 4), %eax + leal (%esi, %eax, 4), %esi + + /*\ Setup Mx and Cx \*/ + movl xap, %eax + movzwl (%eax, %ecx, 4), %ebx + movl %ebx, Mx + movzwl 2(%eax, %ecx, 4), %eax + movl %eax, Cx + + /*\ mm4 = Cx \*/ + movd %eax, %mm4 + punpcklwd %mm4, %mm4 + punpckldq %mm4, %mm4 + /*\ mm5 = Mx \*/ + movd %ebx, %mm5 + punpcklwd %mm5, %mm5 + punpckldq %mm5, %mm5 + + movl %esi, %eax + /*\ v = (*p * Mx) >> 10 \*/ + movd (%eax), %mm0 + punpcklbw %mm7, %mm0 + psllw $6, %mm0 + pmulhw %mm5, %mm0 + + /*\ i = 0x4000 - Mx \*/ + movl $0x4000, %ebx + subl Mx, %ebx + jbe 5f + jmp 2f +1: + /*\ p += sow; v += (*p * Cx) >> 10 \*/ + addl $4, %eax + movd (%eax), %mm1 + punpcklbw %mm7, %mm1 + psllw $6, %mm1 + pmulhw %mm4, %mm1 + paddw %mm1, %mm0 + + /*\ i -= Cx; while (i > Cx) \*/ + subl Cx, %ebx +2: + cmpl Cx, %ebx + jg 1b + + /*\ mm6 = i \*/ + movd %ebx, %mm6 + punpcklwd %mm6, %mm6 + punpckldq %mm6, %mm6 + + /*\ p += sow; v += (*p * i) >> 10 \*/ + addl $4, %eax + movd (%eax), %mm1 + punpcklbw %mm7, %mm1 + psllw $6, %mm1 + pmulhw %mm6, %mm1 + paddw %mm1, %mm0 +5: + movd %mm3, %eax + testl %eax, %eax + jz 6f + /*\ p + sow \*/ + movl %esi, %eax + addl sow_4, %eax + /*\ vv = (*p * Mx) >> 10 \*/ + movd (%eax), %mm2 + punpcklbw %mm7, %mm2 + psllw $6, %mm2 + pmulhw %mm5, %mm2 + + /*\ i = 0x4000 - Mx \*/ + movl $0x4000, %ebx + subl Mx, %ebx + jbe 5f + jmp 2f +1: + /*\ p += sow; vv += (*p * Cx) >> 10 \*/ + addl $4, %eax + movd (%eax), %mm1 + punpcklbw %mm7, %mm1 + psllw $6, %mm1 + pmulhw %mm4, %mm1 + paddw %mm1, %mm2 + + /*\ i -= Cx; while (i > Cx) \*/ + subl Cx, %ebx +2: + cmpl Cx, %ebx + jg 1b + + /*\ p += sow; v += (*p * i) >> 10 \*/ + addl $4, %eax + movd (%eax), %mm1 + punpcklbw %mm7, %mm1 + psllw $6, %mm1 + pmulhw %mm6, %mm1 + paddw %mm1, %mm2 +5: + /*\ v = v + (vv - v) * yap \*/ + psubw %mm0, %mm2 + psllw $3, %mm2 + pmulhw %mm3, %mm2 + paddw %mm2, %mm0 +6: + /*\ dest[x] = v >> 4 \*/ + psrlw $4, %mm0 + packuswb %mm0, %mm0 + movd %mm0, (%edi, %ecx, 4) + + /*\ while (++x) \*/ + incl %ecx + jnz .down_up_loop_x + + /*\ dptr += dow \*/ + movl dow, %eax + leal (%edi, %eax, 4), %edi + /*\ yap++; yp++ \*/ + addl $4, yap + addl $4, yp + /*\ while (y--) \*/ + decl y + jnz .down_up_loop_y + + jmp .scale_leave + + +/*\ Scaling down both ways \*/ + +.scale_x_down_y_down: + /*\ sow_4 = sow * 4 \*/ + movl sow, %eax + sall $2, %eax + movl %eax, sow_4 + +.down_down_loop_y: + + /*\ Setup My and Cy \*/ + movl yap, %eax + movzwl (%eax), %ebx + movl %ebx, My + movzwl 2(%eax), %eax + movl %eax, Cy + + /*\ x = -dw \*/ + movl dw, %ecx + negl %ecx +.down_down_loop_x: + /*\ %esi = *yp + xp[x] \*/ + movl yp, %eax + movl (%eax), %esi + movl xp, %eax + movl (%eax, %ecx, 4), %eax + leal (%esi, %eax, 4), %esi + + /*\ Setup Mx and Cx \*/ + movl xap, %eax + movzwl (%eax, %ecx, 4), %ebx + movl %ebx, Mx + movzwl 2(%eax, %ecx, 4), %eax + movl %eax, Cx + + /*\ mm3 = Cx \*/ + movd %eax, %mm3 + punpcklwd %mm3, %mm3 + punpckldq %mm3, %mm3 + /*\ mm5 = Mx \*/ + movd %ebx, %mm5 + punpcklwd %mm5, %mm5 + punpckldq %mm5, %mm5 + + /*\ p = sptr; v = (*p * Mx) >> 9 \*/ + movl %esi, %eax + movd (%eax), %mm0 + punpcklbw %mm7, %mm0 + psllw $7, %mm0 + pmulhw %mm5, %mm0 + + /*\ i = 0x4000 - Mx \*/ + movl $0x4000, %ebx + subl Mx, %ebx + jbe 5f + jmp 2f +1: + /*\ v += (*++p * Cx) >> 9 \*/ + addl $4, %eax + movd (%eax), %mm1 + punpcklbw %mm7, %mm1 + psllw $7, %mm1 + pmulhw %mm3, %mm1 + paddw %mm1, %mm0 + + /*\ i -= Cx; while (i > Cx) \*/ + subl Cx, %ebx +2: + cmpl Cx, %ebx + jg 1b + + /*\ mm6 = i \*/ + movd %ebx, %mm6 + punpcklwd %mm6, %mm6 + punpckldq %mm6, %mm6 + + /*\ v += (*++p * i) >> 9 \*/ + addl $4, %eax + movd (%eax), %mm1 + punpcklbw %mm7, %mm1 + psllw $7, %mm1 + pmulhw %mm6, %mm1 + paddw %mm1, %mm0 +5: + /*\ v *= My \*/ + movd My, %mm4 + punpcklwd %mm4, %mm4 + punpckldq %mm4, %mm4 + psllw $2, %mm0 + pmulhw %mm4, %mm0 + + /*\ j = 0x4000 - My \*/ + movl $0x4000, %edx + subl My, %edx + jbe 6f + jmp 4f +3: + /*\ sptr += sow; p = sptr \*/ + addl sow_4, %esi + movl %esi, %eax + /*\ vx = (*p * Mx) >> 9 \*/ + movd (%eax), %mm1 + punpcklbw %mm7, %mm1 + psllw $7, %mm1 + pmulhw %mm5, %mm1 + + /*\ i = 0x4000 - Mx \*/ + movl $0x4000, %ebx + subl Mx, %ebx + jbe 5f + jmp 2f +1: + /*\ vx += (*++p * Cx) >> 9 \*/ + addl $4, %eax + movd (%eax), %mm2 + punpcklbw %mm7, %mm2 + psllw $7, %mm2 + pmulhw %mm3, %mm2 + paddw %mm2, %mm1 + + /*\ i -= Cx; while (i > Cx) \*/ + subl Cx, %ebx +2: + cmpl Cx, %ebx + jg 1b + + /*\ vx += (*++p * i) >> 9 \*/ + addl $4, %eax + movd (%eax), %mm2 + punpcklbw %mm7, %mm2 + psllw $7, %mm2 + pmulhw %mm6, %mm2 + paddw %mm2, %mm1 +5: + /*\ v += (vx * Cy) >> 14 \*/ + movd Cy, %mm4 + punpcklwd %mm4, %mm4 + punpckldq %mm4, %mm4 + psllw $2, %mm1 + pmulhw %mm4, %mm1 + paddw %mm1, %mm0 + + /*\ j -= Cy; while (j > Cy) \*/ + subl Cy, %edx +4: + cmpl Cy, %edx + jg 3b + + /*\ sptr += sow; p = sptr \*/ + addl sow_4, %esi + movl %esi, %eax + /*\ vx = (*p * Mx) >> 9 \*/ + movd (%eax), %mm1 + punpcklbw %mm7, %mm1 + psllw $7, %mm1 + pmulhw %mm5, %mm1 + + /*\ i = 0x4000 - Mx \*/ + movl $0x4000, %ebx + subl Mx, %ebx + jbe 5f + jmp 2f +1: + /*\ vx += (*++p * Cx) >> 9 \*/ + addl $4, %eax + movd (%eax), %mm2 + punpcklbw %mm7, %mm2 + psllw $7, %mm2 + pmulhw %mm3, %mm2 + paddw %mm2, %mm1 + + /*\ i -= Cx; while (i > Cx) \*/ + subl Cx, %ebx +2: + cmpl Cx, %ebx + jg 1b + + /*\ vx += (*++p * i) >> 9 \*/ + addl $4, %eax + movd (%eax), %mm2 + punpcklbw %mm7, %mm2 + psllw $7, %mm2 + pmulhw %mm6, %mm2 + paddw %mm2, %mm1 +5: + /*\ v += (vx * j) >> 14 \*/ + movd %edx, %mm4 + punpcklwd %mm4, %mm4 + punpckldq %mm4, %mm4 + psllw $2, %mm1 + pmulhw %mm4, %mm1 + paddw %mm1, %mm0 +6: + /*\ dptr[x] = mm0 >> 5 \*/ + psrlw $5, %mm0 + packuswb %mm0, %mm0 + movd %mm0, (%edi, %ecx, 4) + + /*\ while (++x) \*/ + incl %ecx + jnz .down_down_loop_x + + /*\ dptr += dow \*/ + movl dow, %eax + leal (%edi, %eax, 4), %edi + /*\ yap++; yp++ \*/ + addl $4, yap + addl $4, yp + /*\ while (y--) \*/ + decl y + jnz .down_down_loop_y + + jmp .scale_leave + +.scale_leave: + emms + popl %esi + popl %edi + popl %edx + popl %ecx + popl %ebx + movl %ebp, %esp + popl %ebp + ret + +SIZE(qimageScale_mmx_AARGBA) + +#endif diff -Nru syncwall-1.6.0/src/3rdparty/qimageblitz/blitz.cpp syncwall-1.7.4/src/3rdparty/qimageblitz/blitz.cpp --- syncwall-1.6.0/src/3rdparty/qimageblitz/blitz.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qimageblitz/blitz.cpp 2012-01-15 04:35:02.000000000 +0000 @@ -0,0 +1,1054 @@ +/* + Copyright (C) 1998, 1999, 2001, 2002, 2004, 2005, 2007 + Daniel M. Duley + (C) 2004 Zack Rusin + (C) 2000 Josef Weidendorfer + (C) 1999 Geert Jansen + (C) 1998, 1999 Christian Tibirna + (C) 1998, 1999 Dirk Mueller + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +/* + Portions of this software are were originally based on ImageMagick's + algorithms. ImageMagick is copyrighted under the following conditions: + +Copyright (C) 2003 ImageMagick Studio, a non-profit organization dedicated to +making software imaging solutions freely available. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files ("ImageMagick"), to deal +in ImageMagick without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of ImageMagick, and to permit persons to whom the ImageMagick is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of ImageMagick. + +The software is provided "as is", without warranty of any kind, express or +implied, including but not limited to the warranties of merchantability, +fitness for a particular purpose and noninfringement. In no event shall +ImageMagick Studio be liable for any claim, damages or other liability, +whether in an action of contract, tort or otherwise, arising from, out of or +in connection with ImageMagick or the use or other dealings in ImageMagick. + +Except as contained in this notice, the name of the ImageMagick Studio shall +not be used in advertising or otherwise to promote the sale, use or other +dealings in ImageMagick without prior written authorization from the +ImageMagick Studio. +*/ + +#define _USE_MATH_DEFINES // for msvc + +#include "qimageblitz.h" +#include "private/blitz_p.h" +#include +#include "blitzcpu.h" +#include "private/interpolate.h" +#include "private/inlinehsv.h" +#include +#ifndef M_PI +// Some cmath doesn't define it, try from the older source +#include "math.h" +#endif +#include +#include +#include + +#if defined(__i386__) && ( defined(__GNUC__) || defined(__INTEL_COMPILER) ) +# if defined(HAVE_MMX ) +# define USE_MMX_INLINE_ASM +# endif +#endif + +QImage& Blitz::despeckle(QImage &img) +{ + if(img.isNull()) + return(img); + + int length, x, y, j, i; + QRgb *src, *dest; + unsigned char *buffer, *pixels; + int w = img.width(); + int h = img.height(); + + static const int + X[4]= {0, 1, 1,-1}, + Y[4]= {1, 0, 1, 1}; + + length = (img.width()+2)*(img.height()+2); + pixels = new unsigned char[length]; + buffer = new unsigned char[length]; + + if(img.depth() != 32){ + img = img.convertToFormat(img.hasAlphaChannel() ? + QImage::Format_ARGB32 : + QImage::Format_RGB32); + } + else if(img.format() == QImage::Format_ARGB32_Premultiplied) + img = img.convertToFormat(QImage::Format_ARGB32); + + // Do each channel. This originally was in one loop with an "if" statement + // for each channel, but I unrolled it because a lot goes on and it needs + // any speed help it can get >:/ (mosfet) + + // Red + (void)memset(pixels, 0, length); + j = w+2; + for(y=0; y < h; ++y, ++j){ + src = (QRgb *)img.scanLine(y); + ++j; + for(x=w-1; x >= 0; --x, ++src, ++j) + pixels[j] = qRed(*src); + } + (void)memset(buffer, 0, length); + for(i=0; i < 4; ++i){ + BlitzPrivate::hull(X[i], Y[i], w, h, pixels, buffer, 1); + BlitzPrivate::hull(-X[i], -Y[i], w, h, pixels, buffer, 1); + BlitzPrivate::hull(-X[i], -Y[i], w, h, pixels, buffer, -1); + BlitzPrivate::hull(X[i], Y[i], w, h, pixels, buffer, -1); + } + j = w+2; + for(y=0; y < h; ++y, ++j){ + dest = (QRgb *)img.scanLine(y); + ++j; + for(x=w-1; x >= 0; --x, ++dest, ++j) + *dest = qRgba(pixels[j], qGreen(*dest), qBlue(*dest), + qAlpha(*dest)); + } + + // Green + (void)memset(pixels, 0, length); + j = w+2; + for(y=0; y < h; ++y, ++j){ + src = (QRgb *)img.scanLine(y); + ++j; + for(x=w-1; x >= 0; --x, ++src, ++j) + pixels[j] = qGreen(*src); + } + (void)memset(buffer, 0, length); + for(i=0; i < 4; ++i){ + BlitzPrivate::hull(X[i], Y[i], w, h, pixels, buffer, 1); + BlitzPrivate::hull(-X[i], -Y[i], w, h, pixels, buffer, 1); + BlitzPrivate::hull(-X[i], -Y[i], w, h, pixels, buffer, -1); + BlitzPrivate::hull(X[i], Y[i], w, h, pixels, buffer, -1); + } + j = w+2; + for(y=0; y < h; ++y, ++j){ + dest = (QRgb *)img.scanLine(y); + ++j; + for(x=w-1; x >= 0; --x, ++dest, ++j) + *dest = qRgba(qRed(*dest), pixels[j], qBlue(*dest), + qAlpha(*dest)); + } + + // Blue + (void)memset(pixels, 0, length); + j = w+2; + for(y=0; y < h; ++y, ++j){ + src = (QRgb *)img.scanLine(y); + ++j; + for(x=w-1; x >= 0; --x, ++src, ++j) + pixels[j] = qBlue(*src); + } + (void)memset(buffer, 0, length); + for(i=0; i < 4; ++i){ + BlitzPrivate::hull(X[i], Y[i], w, h, pixels, buffer, 1); + BlitzPrivate::hull(-X[i], -Y[i], w, h, pixels, buffer, 1); + BlitzPrivate::hull(-X[i], -Y[i], w, h, pixels, buffer, -1); + BlitzPrivate::hull(X[i], Y[i], w, h, pixels, buffer, -1); + } + j = w+2; + for(y=0; y < h; ++y, ++j){ + dest = (QRgb *)img.scanLine(y); + ++j; + for(x=w-1; x >= 0; --x, ++dest, ++j) + *dest = qRgba(qRed(*dest), qGreen(*dest), pixels[j], + qAlpha(*dest)); + } + + delete[] pixels; + delete[] buffer; + return(img); +} + +QImage Blitz::blur(QImage &img, int radius) +{ + QRgb *p1, *p2; + int x, y, w, h, mx, my, mw, mh, mt, xx, yy; + int a, r, g, b; + int *as, *rs, *gs, *bs; + + if(radius < 1 || img.isNull() || img.width() < (radius << 1)) + return(img); + + w = img.width(); + h = img.height(); + + if(img.depth() < 8) + img = img.convertToFormat(QImage::Format_Indexed8); + QImage buffer(w, h, img.hasAlphaChannel() ? + QImage::Format_ARGB32 : QImage::Format_RGB32); + + as = new int[w]; + rs = new int[w]; + gs = new int[w]; + bs = new int[w]; + + QVector colorTable; + if(img.format() == QImage::Format_Indexed8) + colorTable = img.colorTable(); + + for(y = 0; y < h; y++){ + my = y - radius; + mh = (radius << 1) + 1; + if(my < 0){ + mh += my; + my = 0; + } + if((my + mh) > h) + mh = h - my; + + p1 = (QRgb *)buffer.scanLine(y); + memset(as, 0, w * sizeof(int)); + memset(rs, 0, w * sizeof(int)); + memset(gs, 0, w * sizeof(int)); + memset(bs, 0, w * sizeof(int)); + + if(img.format() == QImage::Format_ARGB32_Premultiplied){ + QRgb pixel; + for(yy = 0; yy < mh; yy++){ + p2 = (QRgb *)img.scanLine(yy + my); + for(x = 0; x < w; x++, p2++){ + pixel = BlitzPrivate::convertFromPremult(*p2); + as[x] += qAlpha(pixel); + rs[x] += qRed(pixel); + gs[x] += qGreen(pixel); + bs[x] += qBlue(pixel); + } + } + } + else if(img.format() == QImage::Format_Indexed8){ + QRgb pixel; + unsigned char *ptr; + for(yy = 0; yy < mh; yy++){ + ptr = (unsigned char *)img.scanLine(yy + my); + for(x = 0; x < w; x++, ptr++){ + pixel = colorTable[*ptr]; + as[x] += qAlpha(pixel); + rs[x] += qRed(pixel); + gs[x] += qGreen(pixel); + bs[x] += qBlue(pixel); + } + } + } + else{ + for(yy = 0; yy < mh; yy++){ + p2 = (QRgb *)img.scanLine(yy + my); + for(x = 0; x < w; x++, p2++){ + as[x] += qAlpha(*p2); + rs[x] += qRed(*p2); + gs[x] += qGreen(*p2); + bs[x] += qBlue(*p2); + } + } + } + + for(x = 0; x < w; x++){ + a = r = g = b = 0; + mx = x - radius; + mw = (radius << 1) + 1; + if(mx < 0){ + mw += mx; + mx = 0; + } + if((mx + mw) > w) + mw = w - mx; + mt = mw * mh; + for(xx = mx; xx < (mw + mx); xx++){ + a += as[xx]; + r += rs[xx]; + g += gs[xx]; + b += bs[xx]; + } + a = a / mt; + r = r / mt; + g = g / mt; + b = b / mt; + *p1++ = qRgba(r, g, b, a); + } + } + delete[] as; + delete[] rs; + delete[] gs; + delete[] bs; + + return(buffer); +} + +QImage Blitz::sharpen(QImage &img, int radius) +{ + if(img.isNull() || radius < 1) + return(img); + if(img.depth() != 32){ + img = img.convertToFormat(img.hasAlphaChannel() ? + QImage::Format_ARGB32 : + QImage::Format_RGB32); + } + else if(img.format() == QImage::Format_ARGB32_Premultiplied) + img = img.convertToFormat(QImage::Format_ARGB32); + + QImage buffer(img.width(), img.height(), img.format()); + int a, r, g, b, x, y; + int w = img.width(); + int h = img.height(); + QRgb *src, *dest; + + memcpy(buffer.scanLine(0), img.scanLine(0), img.bytesPerLine()); + for(y=1; y < h-1; ++y){ + src = (QRgb *)img.scanLine(y); + dest = (QRgb *)buffer.scanLine(y); + *dest++ = *src++; + for(x=1; x < w-1; ++x){ + r = qRed(*src)*5; + g = qGreen(*src)*5; + b = qBlue(*src)*5; + a = qAlpha(*src)*5; + + r -= qRed(*(src-1)); + g -= qGreen(*(src-1)); + b -= qBlue(*(src-1)); + a -= qAlpha(*(src-1)); + r -= qRed(*(src+1)); + g -= qGreen(*(src+1)); + b -= qBlue(*(src+1)); + a -= qAlpha(*(src+1)); + + r -= qRed(*(src-w)); + g -= qGreen(*(src-w)); + b -= qBlue(*(src-w)); + a -= qAlpha(*(src-w)); + r -= qRed(*(src+w)); + g -= qGreen(*(src+w)); + b -= qBlue(*(src+w)); + a -= qAlpha(*(src+w)); + + r = (r & ((~r) >> 16)); + r = ((r | ((r & 256) - ((r & 256) >> 8)))); + g = (g & ((~g) >> 16)); + g = ((g | ((g & 256) - ((g & 256) >> 8)))); + b = (b & ((~b) >> 16)); + b = ((b | ((b & 256) - ((b & 256) >> 8)))); + a = (a & ((~a) >> 16)); + a = ((a | ((a & 256) - ((a & 256) >> 8)))); + + *dest = qRgba(r, g, b, a); + ++src; ++dest; + } + *dest++ = *src++; + } + memcpy(buffer.scanLine(h-1), img.scanLine(h-1), img.bytesPerLine()); + return(buffer); +} + +/* + * I was looking for a quick way to do edge detection and found + * the Sobel method. This is a gradient method that applies two 3x3 + * matrixes. These matrixes are: + * + * x: -1, 0, 1 y: 1, 2, 1 + * -2, 0, 2 0, 0, 0 + * -1, 0, 1 -1, -2, -1 + * + * After the matrix is applied you simply calculate the magnitude by + * |x| + |y|. + * + * The one problem w/ this is most descriptions of the algorithm I've + * seen assume grayscale data so your working with the intensity of the + * pixel. We do each color channel separately. This is probably wrong, + * but all the implementations I've seen do this... + * (mosfet) + */ + +// Accumulates the results of applying x and y Sobel masks +#define SOBEL(xm, ym, pixel) \ + xR += qRed((pixel))*(xm); xG += qGreen((pixel))*(xm); \ + xB += qBlue((pixel))*(xm); \ + yR += qRed((pixel))*(ym); yG += qGreen((pixel))*(ym); \ + yB += qBlue((pixel))*(ym); + +QImage Blitz::edge(QImage &img) +{ + + int x, y, w = img.width(), h = img.height(); + if(w < 3 || h < 3){ + qWarning("Blitz::edge(): Image is too small!"); + return(img); + } + if(img.isNull()) + return(img); + + if(img.depth() != 32){ + img = img.convertToFormat(img.hasAlphaChannel() ? + QImage::Format_ARGB32 : + QImage::Format_RGB32); + } + else if(img.format() == QImage::Format_ARGB32_Premultiplied) + img = img.convertToFormat(QImage::Format_ARGB32); + + QImage buffer(w, h, QImage::Format_RGB32); + QRgb *dest; + QRgb *s, *scanblock[3]; + + +#ifdef USE_MMX_INLINE_ASM +#ifdef __GNUC__ +#warning Using MMX sobel edge +#endif + if(BlitzCPUInfo::haveExtension(BlitzCPUInfo::MMX)){ + int xmatrix[] = {-1, 0, 1, -2, 0, 2, -1, 0, 1}; + int ymatrix[] = {1, 2, 1, 0, 0, 0, -1, -2, -1}; + int i, *xm, *ym; + + for(y=0; y < h; ++y){ + scanblock[1] = (QRgb *)img.scanLine(y); + dest = (QRgb *)buffer.scanLine(y); + if(y == 0){ + scanblock[0] = (QRgb *)img.scanLine(y); + scanblock[2] = (QRgb *)img.scanLine(y+1); + } + else if(y == h-1){ + scanblock[0] = (QRgb *)img.scanLine(y-1); + scanblock[2] = (QRgb *)img.scanLine(y); + } + else{ + scanblock[0] = (QRgb *)img.scanLine(y-1); + scanblock[2] = (QRgb *)img.scanLine(y+1); + } + // + // x == 0, double over first pixel + // + __asm__ __volatile__ + ("pxor %%mm7, %%mm7\n\t" // used for unpacking + "pxor %%mm5, %%mm5\n\t" // clear accumulator + "pxor %%mm6, %%mm6\n\t" // "" + : : ); + for(i=0, xm=xmatrix, ym=ymatrix; i < 3; ++i, xm+=3, ym+=3){ + s = scanblock[i]; + __asm__ __volatile__ + (// first pixel + "movd (%0), %%mm0\n\t" // load pixel into mm0 + "punpcklbw %%mm7, %%mm0\n\t" // upgrade to quad + "movq %%mm0, %%mm1\n\t" // copy pixel to mm1 + "movq %%mm0, %%mm4\n\t" // and mm4 since we are doubling over + "movd 0(%1), %%mm2\n\t" // load x matrix into mm2 + "punpckldq %%mm2, %%mm2\n\t" // expand to all words + "packssdw %%mm2, %%mm2\n\t" + "movd 0(%2), %%mm3\n\t" // load y matrix into mm3 + "punpckldq %%mm3, %%mm3\n\t" // expand + "packssdw %%mm3, %%mm3\n\t" + "pmullw %%mm2, %%mm0\n\t" // multiply pixel w/ x matrix + "pmullw %%mm3, %%mm1\n\t" // and multiply copy w/ y matrix + "paddw %%mm0, %%mm5\n\t" // add to accumulators + "paddw %%mm1, %%mm6\n\t" + // second pixel (doubled over) + "movq %%mm4, %%mm1\n\t" // copy saved pixel to mm1 + "movd 4(%1), %%mm2\n\t" // load x matrix into mm2 + "punpckldq %%mm2, %%mm2\n\t" // expand to all words + "packssdw %%mm2, %%mm2\n\t" + "movd 4(%2), %%mm3\n\t" // load y matrix into mm3 + "punpckldq %%mm3, %%mm3\n\t" // expand + "packssdw %%mm3, %%mm3\n\t" + "pmullw %%mm2, %%mm4\n\t" // multiply pixel w/ x matrix + "pmullw %%mm3, %%mm1\n\t" // and multiply copy w/ y matrix + "paddw %%mm4, %%mm5\n\t" // add to accumulators + "paddw %%mm1, %%mm6\n\t" + // third pixel + "movd 4(%0), %%mm0\n\t" // load pixel into mm0 + "punpcklbw %%mm7, %%mm0\n\t" // upgrade to quad + "movq %%mm0, %%mm1\n\t" // copy pixel to mm1 + "movd 8(%1), %%mm2\n\t" // load x matrix into mm2 + "punpckldq %%mm2, %%mm2\n\t" // expand to all words + "packssdw %%mm2, %%mm2\n\t" + "movd 8(%2), %%mm3\n\t" // load y matrix into mm3 + "punpckldq %%mm3, %%mm3\n\t" // expand + "packssdw %%mm3, %%mm3\n\t" + "pmullw %%mm2, %%mm0\n\t" // multiply pixel w/ x matrix + "pmullw %%mm3, %%mm1\n\t" // and multiply copy w/ y matrix + "paddw %%mm0, %%mm5\n\t" // add to accumulators + "paddw %%mm1, %%mm6\n\t" + : : "r"(s), "r"(xm), "r"(ym)); + } + __asm__ __volatile__ + (// calculate abs, sum, and write + "movq %%mm5, %%mm0\n\t" // calculate abs of x accumulator + "psraw $15, %%mm0\n\t" + "pxor %%mm0, %%mm5\n\t" + "psubw %%mm0, %%mm5\n\t" + "movq %%mm6, %%mm0\n\t" // calculate abs of y accumulator + "psraw $15, %%mm0\n\t" + "pxor %%mm0, %%mm6\n\t" + "psubw %%mm0, %%mm6\n\t" + "paddw %%mm5, %%mm6\n\t" // add together + "packuswb %%mm6, %%mm6\n\t" // and write + "movd %%mm6, (%0)\n\t" + : : "r"(dest)); + dest++; + + // + // Now x == 1, process middle of image + // + + for(x=1; x < w-1; ++x){ + __asm__ __volatile__ + ("pxor %%mm5, %%mm5\n\t" // clear accumulator + "pxor %%mm6, %%mm6\n\t" + : : ); + for(i=0, xm=xmatrix, ym=ymatrix; i < 3; ++i, xm+=3, ym+=3){ + s = scanblock[i]; + __asm__ __volatile__ + (// first pixel + "movd (%0), %%mm0\n\t" // load pixel into mm0 + "punpcklbw %%mm7, %%mm0\n\t" // upgrade to quad + "movq %%mm0, %%mm1\n\t" // copy pixel to mm1 + "movd (%1), %%mm2\n\t" // load x matrix into mm2 + "punpckldq %%mm2, %%mm2\n\t" // expand to all words + "packssdw %%mm2, %%mm2\n\t" + "movd (%2), %%mm3\n\t" // load y matrix into mm3 + "punpckldq %%mm3, %%mm3\n\t" // expand + "packssdw %%mm3, %%mm3\n\t" + "pmullw %%mm2, %%mm0\n\t" // multiply pixel w/ x matrix + "pmullw %%mm3, %%mm1\n\t" // and multiply copy w/ y matrix + "paddw %%mm0, %%mm5\n\t" // add to accumulators + "paddw %%mm1, %%mm6\n\t" + // second pixel + "movd 4(%0), %%mm0\n\t" // load pixel into mm0 + "punpcklbw %%mm7, %%mm0\n\t" // upgrade to quad + "movq %%mm0, %%mm1\n\t" // copy pixel to mm1 + "movd 4(%1), %%mm2\n\t" // load x matrix into mm2 + "punpckldq %%mm2, %%mm2\n\t" // expand to all words + "packssdw %%mm2, %%mm2\n\t" + "movd 4(%2), %%mm3\n\t" // load y matrix into mm3 + "punpckldq %%mm3, %%mm3\n\t" // expand + "packssdw %%mm3, %%mm3\n\t" + "pmullw %%mm2, %%mm0\n\t" // multiply pixel w/ x matrix + "pmullw %%mm3, %%mm1\n\t" // and multiply copy w/ y matrix + "paddw %%mm0, %%mm5\n\t" // add to accumulators + "paddw %%mm1, %%mm6\n\t" + // third pixel + "movd 8(%0), %%mm0\n\t" // load pixel into mm0 + "punpcklbw %%mm7, %%mm0\n\t" // upgrade to quad + "movq %%mm0, %%mm1\n\t" // copy pixel to mm1 + "movd 8(%1), %%mm2\n\t" // load x matrix into mm2 + "punpckldq %%mm2, %%mm2\n\t" // expand to all words + "packssdw %%mm2, %%mm2\n\t" + "movd 8(%2), %%mm3\n\t" // load y matrix into mm3 + "punpckldq %%mm3, %%mm3\n\t" // expand + "packssdw %%mm3, %%mm3\n\t" + "pmullw %%mm2, %%mm0\n\t" // multiply pixel w/ x matrix + "pmullw %%mm3, %%mm1\n\t" // and multiply copy w/ y matrix + "paddw %%mm0, %%mm5\n\t" // add to accumulators + "paddw %%mm1, %%mm6\n\t" + : : "r"(s), "r"(xm), "r"(ym)); + } + __asm__ __volatile__ + (// calculate abs, sum, and write + "movq %%mm5, %%mm0\n\t" // calculate abs of x accumulator + "psraw $15, %%mm0\n\t" + "pxor %%mm0, %%mm5\n\t" + "psubw %%mm0, %%mm5\n\t" + "movq %%mm6, %%mm0\n\t" // calculate abs of y accumulator + "psraw $15, %%mm0\n\t" + "pxor %%mm0, %%mm6\n\t" + "psubw %%mm0, %%mm6\n\t" + "paddw %%mm5, %%mm6\n\t" // add together + "packuswb %%mm6, %%mm6\n\t" // and write + "movd %%mm6, (%0)\n\t" + : : "r"(dest)); + dest++; + ++scanblock[0], ++scanblock[1], ++scanblock[2]; + } + + // + // x = w-1, double over last pixel + // + + __asm__ __volatile__ + ("pxor %%mm5, %%mm5\n\t" // clear accumulator + "pxor %%mm6, %%mm6\n\t" + : : ); + for(i=0, xm=xmatrix, ym=ymatrix; i < 3; ++i, xm+=3, ym+=3){ + s = scanblock[i]; + __asm__ __volatile__ + (// first pixel + "movd (%0), %%mm0\n\t" // load pixel into mm0 + "punpcklbw %%mm7, %%mm0\n\t" // upgrade to quad + "movq %%mm0, %%mm1\n\t" // copy pixel to mm1 + "movd (%1), %%mm2\n\t" // load x matrix into mm2 + "punpckldq %%mm2, %%mm2\n\t" // expand to all words + "packssdw %%mm2, %%mm2\n\t" + "movd (%2), %%mm3\n\t" // load y matrix into mm3 + "punpckldq %%mm3, %%mm3\n\t" // expand + "packssdw %%mm3, %%mm3\n\t" + "pmullw %%mm2, %%mm0\n\t" // multiply pixel w/ x matrix + "pmullw %%mm3, %%mm1\n\t" // and multiply copy w/ y matrix + "paddw %%mm0, %%mm5\n\t" // add to accumulators + "paddw %%mm1, %%mm6\n\t" + // second pixel + "movd 4(%0), %%mm0\n\t" // load pixel into mm0 + "punpcklbw %%mm7, %%mm0\n\t" // upgrade to quad + "movq %%mm0, %%mm1\n\t" // copy pixel to mm1 + "movd 4(%1), %%mm2\n\t" // load x matrix into mm2 + "punpckldq %%mm2, %%mm2\n\t" // expand to all words + "packssdw %%mm2, %%mm2\n\t" + "movd 4(%2), %%mm3\n\t" // load y matrix into mm3 + "punpckldq %%mm3, %%mm3\n\t" // expand + "packssdw %%mm3, %%mm3\n\t" + "pmullw %%mm2, %%mm0\n\t" // multiply pixel w/ x matrix + "pmullw %%mm3, %%mm1\n\t" // and multiply copy w/ y matrix + "paddw %%mm0, %%mm5\n\t" // add to accumulators + "paddw %%mm1, %%mm6\n\t" + // third pixel + "movd 4(%0), %%mm0\n\t" // load pixel into mm0 + "punpcklbw %%mm7, %%mm0\n\t" // upgrade to quad + "movq %%mm0, %%mm1\n\t" // copy pixel to mm1 + "movd 8(%1), %%mm2\n\t" // load x matrix into mm2 + "punpckldq %%mm2, %%mm2\n\t" // expand to all words + "packssdw %%mm2, %%mm2\n\t" + "movd 8(%2), %%mm3\n\t" // load y matrix into mm3 + "punpckldq %%mm3, %%mm3\n\t" // expand + "packssdw %%mm3, %%mm3\n\t" + "pmullw %%mm2, %%mm0\n\t" // multiply pixel w/ x matrix + "pmullw %%mm3, %%mm1\n\t" // and multiply copy w/ y matrix + "paddw %%mm0, %%mm5\n\t" // add to accumulators + "paddw %%mm1, %%mm6\n\t" + : : "r"(s), "r"(xm), "r"(ym)); + } + __asm__ __volatile__ + (// calculate abs, sum, and write + "movq %%mm5, %%mm0\n\t" // calculate abs of x accumulator + "psraw $15, %%mm0\n\t" + "pxor %%mm0, %%mm5\n\t" + "psubw %%mm0, %%mm5\n\t" + "movq %%mm6, %%mm0\n\t" // calculate abs of y accumulator + "psraw $15, %%mm0\n\t" + "pxor %%mm0, %%mm6\n\t" + "psubw %%mm0, %%mm6\n\t" + "paddw %%mm5, %%mm6\n\t" // add together + "packuswb %%mm6, %%mm6\n\t" // and write + "movd %%mm6, (%0)\n\t" + : : "r"(dest)); + dest++; + } + __asm__ __volatile__ ("emms\n\t" : :); + } + else +#endif + { + int xR, xG, xB, yR, yG, yB; + for(y=0; y < h; ++y){ + scanblock[1] = (QRgb *)img.scanLine(y); + dest = (QRgb *)buffer.scanLine(y); + if(y == 0){ + scanblock[0] = (QRgb *)img.scanLine(y); + scanblock[2] = (QRgb *)img.scanLine(y+1); + } + else if(y == h-1){ + scanblock[0] = (QRgb *)img.scanLine(y-1); + scanblock[2] = (QRgb *)img.scanLine(y); + } + else{ + scanblock[0] = (QRgb *)img.scanLine(y-1); + scanblock[2] = (QRgb *)img.scanLine(y+1); + } + + // x == 0, double over first pixel + xR = xG = xB = yR = yG = yB = 0; + s = scanblock[0]; + SOBEL(-1, 1, *s); SOBEL(0, 2, *s); ++s; SOBEL(1, 1, *s); + s = scanblock[1]; + SOBEL(-2, 0, *s); SOBEL(0, 0, *s); ++s; SOBEL(2, 0, *s); + s = scanblock[2]; + SOBEL(-1, -1, *s); SOBEL(0, -2, *s); ++s; SOBEL(1, -1, *s); + xR = qAbs(xR)+qAbs(yR); xG = qAbs(xG)+qAbs(yG); + xB = qAbs(xB)+qAbs(yB); + *dest++ = qRgb(qMin(xR, 255), qMin(xG, 255), qMin(xB, 255)); + + // x == 1, process middle of image + for(x=1; x < w-1; ++x){ + xR = xG = xB = yR = yG = yB = 0; + s = scanblock[0]; + SOBEL(-1, 1, *s); ++s; SOBEL(0, 2, *s); ++s; SOBEL(1, 1, *s); + s = scanblock[1]; + SOBEL(-2, 0, *s); ++s; SOBEL(0, 0, *s); ++s; SOBEL(2, 0, *s); + s = scanblock[2]; + SOBEL(-1, -1, *s); ++s; SOBEL(0, -2, *s); ++s; SOBEL(1, -1, *s); + ++scanblock[0]; ++scanblock[1]; ++scanblock[2]; + xR = qAbs(xR)+qAbs(yR); xG = qAbs(xG)+qAbs(yG); + xB = qAbs(xB)+qAbs(yB); + *dest++ = qRgb(qMin(xR, 255), qMin(xG, 255), qMin(xB, 255)); + } + + // x == w-1, double over last pixel + xR = xG = xB = yR = yG = yB = 0; + s = scanblock[0]; + SOBEL(-1, 1, *s); ++s; SOBEL(0, 2, *s); SOBEL(1, 1, *s); + s = scanblock[1]; + SOBEL(-2, 0, *s); ++s; SOBEL(0, 0, *s); SOBEL(2, 0, *s); + s = scanblock[2]; + SOBEL(-1, -1, *s); ++s; SOBEL(0, -2, *s); SOBEL(1, -1, *s); + xR = qAbs(xR)+qAbs(yR); xG = qAbs(xG)+qAbs(yG); + xB = qAbs(xB)+qAbs(yB); + *dest++ = qRgb(qMin(xR, 255), qMin(xG, 255), qMin(xB, 255)); + } + } + return(buffer); +} + +QImage Blitz::charcoal(QImage &img) +{ + QImage buffer(edge(img)); + buffer = blur(buffer, 1); + normalize(buffer); + buffer.invertPixels(); + grayscale(buffer, true); + return(buffer); +} + +QImage Blitz::swirl(QImage &img, float degrees) +{ + float sine, cosine, distance, radius, factor; + float x_center, x_distance, x_scale; + float y_center, y_distance, y_scale; + int x, y, w, h; + QRgb *dest; + + w = img.width(); + h = img.height(); + + if(img.format() == QImage::Format_ARGB32_Premultiplied) + img = img.convertToFormat(QImage::Format_ARGB32); + else if(img.depth() < 8) + img = img.convertToFormat(QImage::Format_Indexed8); + + QImage buffer(w, h, img.hasAlphaChannel() ? + QImage::Format_ARGB32 : QImage::Format_RGB32); + + x_center = w/2.0; + y_center = h/2.0; + radius = qMax(x_center, y_center); + x_scale = y_scale = 1.0; + if(w > h) + y_scale = (float)(w/h); + else if(w < h) + x_scale = (float)(h/w); + degrees = (M_PI*degrees)/180.0; + + InlineInterpolate interpolate(&img, 0); + if(img.depth() > 8){ + QRgb *src; + for(y=0; y < h; ++y){ + src = (QRgb *)img.scanLine(y); + dest = (QRgb *)buffer.scanLine(y); + y_distance = y_scale*(y-y_center); + for(x=0; x < w; ++x){ + x_distance = x_scale*(x-x_center); + distance = x_distance*x_distance + y_distance*y_distance; + if(distance >= (radius*radius)) + *dest = src[x]; + else{ + factor = 1.0-std::sqrt(distance)/radius; + sine = std::sin(degrees*factor*factor); + cosine = std::cos(degrees*factor*factor); + *dest = interpolate. + interpolate((cosine*x_distance-sine*y_distance)/ + x_scale+x_center, + (sine*x_distance+cosine*y_distance)/ + y_scale+y_center); + } + ++dest; + } + } + } + else{ + QVector cTable(img.colorTable()); + unsigned char *src; + for(y=0; y < h; ++y){ + src = img.scanLine(y); + dest = (QRgb *)buffer.scanLine(y); + y_distance = y_scale*(y-y_center); + for(x=0; x < w; ++x){ + x_distance = x_scale*(x-x_center); + distance = x_distance*x_distance + y_distance*y_distance; + if(distance >= (radius*radius)) + *dest = cTable.at(src[x]); + else{ + factor = 1.0-std::sqrt(distance)/radius; + sine = std::sin(degrees*factor*factor); + cosine = std::cos(degrees*factor*factor); + *dest = interpolate. + interpolate((cosine*x_distance-sine*y_distance)/ + x_scale+x_center, + (sine*x_distance+cosine*y_distance)/ + y_scale+y_center); + } + ++dest; + } + } + } + return(buffer); +} + +QImage Blitz::implode(QImage &img, float amount) +{ + float distance, radius, factor; + float x_center, x_distance, x_scale; + float y_center, y_distance, y_scale; + int x, y, w, h; + QRgb *dest; + + w = img.width(); + h = img.height(); + + if(img.format() == QImage::Format_ARGB32_Premultiplied) + img = img.convertToFormat(QImage::Format_ARGB32); + else if(img.depth() < 8) + img = img.convertToFormat(QImage::Format_Indexed8); + + QImage buffer(w, h, img.hasAlphaChannel() ? + QImage::Format_ARGB32 : QImage::Format_RGB32); + + x_scale = y_scale = 1.0; + x_center = 0.5*w; + y_center = 0.5*h; + radius = x_center; + if(w > h) + y_scale = (float)(w/h); + else if(w < h){ + x_scale = (float)(h/w); + radius = y_center; + } + + InlineInterpolate interpolate(&img, 0); + if(img.depth() > 8){ + QRgb *src; + for(y=0; y < h; ++y){ + src = (QRgb *)img.scanLine(y); + dest = (QRgb *)buffer.scanLine(y); + y_distance = y_scale*(y-y_center); + for(x=0; x < w; ++x){ + x_distance = x_scale*(x-x_center); + distance = x_distance*x_distance + y_distance*y_distance; + if(distance >= (radius*radius)) + *dest = src[x]; + else{ + factor = 1.0; + if(distance > 0.0) + factor = std::pow(std::sin(((float)M_PI)* + std::sqrt(distance)/ + radius/2), -amount); + *dest = interpolate. + interpolate(factor*x_distance/x_scale+x_center, + factor*y_distance/y_scale+y_center); + } + ++dest; + } + } + } + else{ + QVector cTable(img.colorTable()); + unsigned char *src; + for(y=0; y < h; ++y){ + src = img.scanLine(y); + dest = (QRgb *)buffer.scanLine(y); + y_distance = y_scale*(y-y_center); + for(x=0; x < w; ++x){ + x_distance = x_scale*(x-x_center); + distance = x_distance*x_distance + y_distance*y_distance; + if(distance >= (radius*radius)) + *dest = cTable.at(src[x]); + else{ + factor = 1.0; + if(distance > 0.0) + factor = std::pow(std::sin(((float)M_PI)* + std::sqrt(distance)/ + radius/2), -amount); + *dest = interpolate. + interpolate(factor*x_distance/x_scale+x_center, + factor*y_distance/y_scale+y_center); + } + ++dest; + } + } + } + return(buffer); +} + +QImage Blitz::wave(QImage &img, float amplitude, float length, + unsigned int background) +{ + int x, y, w, h; + QRgb *dest; + float *sine_map; + + if(img.format() == QImage::Format_ARGB32_Premultiplied) + img = img.convertToFormat(QImage::Format_ARGB32); + else if(img.depth() < 8) + img = img.convertToFormat(QImage::Format_Indexed8); + + QImage buffer(img.width(), (int)(img.height()+2.0*std::abs(amplitude)), + QImage::Format_RGB32); + w = buffer.width(); + h = buffer.height(); + + sine_map = new float[w]; + for(x=0; x < w; ++x) + sine_map[x] = std::abs(amplitude)+amplitude*std::sin((2*M_PI*x)/length); + + InlineInterpolate interpolate(&img, background); + for(y=0; y < h; ++y){ + dest = (QRgb *)buffer.scanLine(y); + for(x=0; x < w; ++x) + *dest++ = interpolate. + interpolateBackground(x, y-sine_map[x]); + } + delete[] sine_map; + return(buffer); +} + +QImage& Blitz::modulate(QImage &img, QImage &modImg, bool reverse, + ModulationType type, int factor, RGBChannel channel) +{ + if(img.isNull() || modImg.isNull()) + return(img); + + // for image, we handle only depth 32 + if(img.depth() < 32 || img.format() == QImage::Format_ARGB32_Premultiplied) + img = img.convertToFormat(img.hasAlphaChannel() ? + QImage::Format_ARGB32 : + QImage::Format_RGB32); + + // for modImage, we handle depth 8 and 32 + if(modImg.depth() < 8) + modImg = modImg.convertToFormat(QImage::Format_Indexed8); + else if(modImg.format() == QImage::Format_ARGB32_Premultiplied) + modImg = modImg.convertToFormat(QImage::Format_ARGB32); + + unsigned int x1 = img.width(), y1 = img.height(); + unsigned int x2 = modImg.width(), y2 = modImg.height(); + unsigned int x, y; + unsigned int *src, *modulation_colorTable; + unsigned char *modulation_src; + int r, g, b, mod = 0; + QRgb color1, color2; + InlineHSV hsv; + + QVector cTable; + if(modImg.format() == QImage::Format_Indexed8){ + cTable = modImg.colorTable(); + modulation_colorTable = cTable.data(); + } + else + modulation_colorTable = NULL; + + for(y=0; y < y1; ++y){ + src = (QRgb *)img.scanLine(y); + modulation_src = modImg.scanLine(y%y2); + x=0; + while(x < x1){ + color2 = (!modulation_colorTable) ? + *((QRgb *)modulation_src) : + modulation_colorTable[*modulation_src]; + if(reverse){ + color1 = color2; + color2 = *src; + } + else + color1 = *src; + + if(type == Intensity || type == Contrast){ + r = qRed(color1); g = qGreen(color1); b = qBlue(color1); + if(channel != All){ + mod = (channel == Red) ? qRed(color2) : + (channel == Green) ? qGreen(color2) : + (channel == Blue) ? qBlue(color2) : + (channel == Grayscale) ? qGray(color2) : 0; + mod = mod*factor/50; + } + + if(type == Intensity){ + if(channel == All){ + r += r * factor/50 * qRed(color2)/256; + g += g * factor/50 * qGreen(color2)/256; + b += b * factor/50 * qBlue(color2)/256; + } + else{ + r += r * mod/256; + g += g * mod/256; + b += b * mod/256; + } + } + else{ // Contrast + if(channel == All){ + r += (r-128) * factor/50 * qRed(color2)/128; + g += (g-128) * factor/50 * qGreen(color2)/128; + b += (b-128) * factor/50 * qBlue(color2)/128; + } + else{ + r += (r-128) * mod/128; + g += (g-128) * mod/128; + b += (b-128) * mod/128; + } + } + *src = qRgba(qBound(0, r, 255), qBound(0, g, 255), + qBound(0, b, 255), qAlpha(*src)); + } + else if(type == Saturation || type == HueShift){ + mod = (channel == Red) ? qRed(color2) : + (channel == Green) ? qGreen(color2) : + (channel == Blue) ? qBlue(color2) : + (channel == Grayscale||channel == All) ? qGray(color2) : 0; + mod = mod*factor/50; + hsv.convertRGB2HSV(color1); + if(type == Saturation) + hsv.setSaturation(qBound(0, hsv.saturation()- + hsv.saturation()*mod/256, 255)); + else{ + int h = hsv.hue() + mod; + while(h<0) h+=360; + hsv.setHue(h %= 360); + } + hsv.convertHSV2RGB(); + *src = qRgba(hsv.red(), hsv.green(), hsv.blue(), qAlpha(*src)); + } + ++src; ++x; + modulation_src += (!modulation_colorTable) ? 4 : 1; + + if((x%x2) == 0) + modulation_src -= (!modulation_colorTable) ? x2*4 : x2; + } + } + return(img); +} diff -Nru syncwall-1.6.0/src/3rdparty/qimageblitz/blitz.pri syncwall-1.7.4/src/3rdparty/qimageblitz/blitz.pri --- syncwall-1.6.0/src/3rdparty/qimageblitz/blitz.pri 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qimageblitz/blitz.pri 2008-02-26 19:31:00.000000000 +0000 @@ -0,0 +1,3 @@ + +INCLUDEPATH += $$BLITZ_DIR +LIBS += -lqimageblitz diff -Nru syncwall-1.6.0/src/3rdparty/qimageblitz/blitzcpu.cpp syncwall-1.7.4/src/3rdparty/qimageblitz/blitzcpu.cpp --- syncwall-1.6.0/src/3rdparty/qimageblitz/blitzcpu.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qimageblitz/blitzcpu.cpp 2008-02-26 19:31:00.000000000 +0000 @@ -0,0 +1,193 @@ +#include "blitzcpu.h" +#include +#include +#include + +/** + * CPUID code: This tests the CPU id flags for MMX, SSE, 3dnow, etc... + * support. This is based on KCPUInfo by Fredrik Hoglund. + * + * Copyright (C) 2003 Fredrik Hoglund + * Copyright (C) 2004 Daniel M. Duley + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#if defined(__i386__) && ( defined(__GNUC__) || defined(__INTEL_COMPILER) ) +# if defined(HAVE_MMX) +# define USE_MMX_INLINE_ASM +# endif +#endif + +#ifdef USE_MMX_INLINE_ASM +// Sighandler for the SSE OS support check +typedef void (*blitz_sighandler_t)(int); +static jmp_buf env; +static void blitz_sighandler(int) +{ + std::longjmp(env, 1); +} +#elif defined __PPC__ && defined HAVE_PPC_ALTIVEC +// Sighandler for PPC AltiVec check +static sigjmp_buf jmpbuf; +static sig_atomic_t canjump = 0; +static void blitz_sighandler(int sig) +{ + if(!canjump) { + signal(sig, SIG_DFL); + raise(sig); + } + canjump = 0; + siglongjmp(jmpbuf, 1); +} +#endif + +static unsigned int checkCPUID() +{ + volatile unsigned int flags = 0; +#ifdef USE_MMX_INLINE_ASM // Intel/AMD checks + bool hasCPUID = false; + unsigned int result = 0; + + __asm__ __volatile__ + (// Try to toggle the CPUID bit in the EFLAGS register + "pushf \n\t" // Push the EFLAGS register onto the stack + "popl %%ecx \n\t" // Pop the value into ECX + "movl %%ecx, %%edx \n\t" // Copy ECX to EDX + "xorl $0x00200000, %%ecx \n\t" // Toggle bit 21 (CPUID) in ECX + "pushl %%ecx \n\t" // Push the modified value onto the stack + "popf \n\t" // Pop it back into EFLAGS + + // Check if the CPUID bit was successfully toggled + "pushf \n\t" // Push EFLAGS back onto the stack + "popl %%ecx \n\t" // Pop the value into ECX + "xorl %%eax, %%eax \n\t" // Zero out the EAX register + "cmpl %%ecx, %%edx \n\t" // Compare ECX with EDX + "je .Lno_cpuid_support%= \n\t" // Jump if they're identical + "movl $1, %%eax \n\t" // Set EAX to true + ".Lno_cpuid_support%=: \n\t" + : "=a"(hasCPUID) : : "%ecx", "%edx" ); + if(!hasCPUID) + return(flags); + + // Execute CPUID with the feature request bit set + __asm__ __volatile__ + ("pushl %%ebx \n\t" // Save EBX + "movl $1, %%eax \n\t" // Set EAX to 1 (features request) + "cpuid \n\t" // Call CPUID + "popl %%ebx \n\t" // Restore EBX + : "=d"(result) : : "%eax", "%ecx"); + + // Test bit 23 (MMX support) + // 25: SSE + // 26: SSE2 + if(result & 0x00800000) + flags |= BlitzCPUInfo::MMX; + if(result & 0x00200000) + flags |= BlitzCPUInfo::SSE; + if(result & 0x00400000) + flags |= BlitzCPUInfo::SSE2; + + // Now try extended feature request + result = 0; + __asm__ __volatile__ + ("pushl %%ebx \n\t" + "movl $0x80000000, %%eax \n\t" + "cpuid \n\t" + "cmpl $0x80000000, %%eax \n\t" + "jbe .Lno_extended%= \n\t" + "movl $0x80000001, %%eax \n\t" + "cpuid \n\t" + ".Lno_extended%=: \n\t" + "popl %%ebx \n\t" // Restore EBX + : "=d"(result) : : "%eax", "%ecx"); + + // Bit 31: 3dNow + // Bit 30: 3dNow+ + // Bit 22: MMX SSE (Integer SSE) - AMD Only + if(result & 0x80000000){ + flags |= BlitzCPUInfo::AMD3DNOW; + if(result & 0x40000000) + flags |= BlitzCPUInfo::AMD3DNOW2; + if(result & 0x00400000) // This is only valid on AMD cpu's w/ 3dnow + flags |= BlitzCPUInfo::IntegerSSE; + } + else if(flags & BlitzCPUInfo::SSE) + flags |= BlitzCPUInfo::IntegerSSE; + + if((flags & BlitzCPUInfo::SSE) || (flags & BlitzCPUInfo::SSE2)){ + // SSE OS support check + // Install our own sighandler for SIGILL. + blitz_sighandler_t oldhandler = + std::signal(SIGILL, blitz_sighandler); + + // Try executing an SSE insn to see if we get a SIGILL + if(setjmp(env)){ + // No go. MMX-SSE should still be okay, tho. + if(flags & BlitzCPUInfo::SSE) + flags -= BlitzCPUInfo::SSE; + if(flags & BlitzCPUInfo::SSE2) + flags -= BlitzCPUInfo::SSE2; + } + else + __asm__ __volatile__("xorps %xmm0, %xmm0"); + + // Restore the default sighandler + std::signal( SIGILL, oldhandler ); + } + +#elif defined __PPC__ && defined HAVE_PPC_ALTIVEC + signal(SIGILL, blitz_sighandler); + if(sigsetjmp(jmpbuf, 1)){ + signal(SIGILL, SIG_DFL); + } + else{ + canjump = 1; + __asm__ __volatile__( "mtspr 256, %0\n\t" + "vand %%v0, %%v0, %%v0" + : /* none */ + : "r" (-1) ); + signal(SIGILL, SIG_DFL); + flags |= BlitzCPUInfo::AltiVec; + } +#endif + return(flags); +} + +bool BlitzCPUInfo::haveExtension(unsigned int extension) +{ + static bool checked = false; + static unsigned int flags = 0; + if(!checked){ + flags = checkCPUID(); + checked = true; + qWarning("MMX: %d, SSE: %d, SSE2: %d, MMX-SSE: %d, 3dNow: %d, 3dNow+: %d", + haveExtension(BlitzCPUInfo::MMX), + haveExtension(BlitzCPUInfo::SSE), + haveExtension(BlitzCPUInfo::SSE2), + haveExtension(BlitzCPUInfo::IntegerSSE), + haveExtension(BlitzCPUInfo::AMD3DNOW), + haveExtension(BlitzCPUInfo::AMD3DNOW2)); + } + return(flags & extension); +} + diff -Nru syncwall-1.6.0/src/3rdparty/qimageblitz/blitzcpu.h syncwall-1.7.4/src/3rdparty/qimageblitz/blitzcpu.h --- syncwall-1.6.0/src/3rdparty/qimageblitz/blitzcpu.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qimageblitz/blitzcpu.h 2008-02-26 19:31:00.000000000 +0000 @@ -0,0 +1,77 @@ +#ifndef __BLITZ_CPU_H +#define __BLITZ_CPU_H + +/** + * CPUID code: This tests the CPU id flags for MMX, SSE, 3dnow, etc... + * support. This is based on KCPUInfo by Fredrik Hoglund. + * + * Copyright (C) 2003 Fredrik Hoglund + * Copyright (C) 2004 Daniel M. Duley + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "qimageblitz_export.h" +#include + +/** + * MMX packed value data types. If you don't write MMX assembler code you + * can ignore these. + * + * @author Daniel M. Duley + * @short MMX data types + */ +namespace MMX{ + typedef struct { quint32 d[2]; } Pack2; + typedef struct { quint16 d[4]; } Pack4; + typedef struct { quint8 d[8]; } Pack8; +} + +/** + * This class determines what extensions the computer's CPU supports. These + * include MMX, SSE, 3dnow, and AltiVec. If you don't write assembler code + * you probably can ignore this class. + * + * @short CPU features identification + * @author Fredrik Hoglund + * @author Daniel M. Duley + */ +class BlitzCPUInfo{ +public: + enum Extension { + MMX = 1 << 0, + IntegerSSE = 1 << 1, + SSE = 1 << 2, + SSE2 = 1 << 3, + AMD3DNOW = 1 << 4, + AMD3DNOW2 = 1 << 5, + AltiVec = 1 << 6 + }; + /** + * Returns true if the CPU supports the given extension. + */ + static bool haveExtension(unsigned int extension); +}; + + +#endif + diff -Nru syncwall-1.6.0/src/3rdparty/qimageblitz/colors.cpp syncwall-1.7.4/src/3rdparty/qimageblitz/colors.cpp --- syncwall-1.6.0/src/3rdparty/qimageblitz/colors.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qimageblitz/colors.cpp 2008-02-26 19:31:00.000000000 +0000 @@ -0,0 +1,1051 @@ +/* + Copyright (C) 1998, 1999, 2001, 2002, 2004, 2005, 2007 + Daniel M. Duley + (C) 2000 Josef Weidendorfer + (C) 1999 Geert Jansen + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#include "qimageblitz.h" +#include +#include "private/inlinehsv.h" +#include "private/blitz_p.h" +#include "blitzcpu.h" +#include + +#if defined(__i386__) && ( defined(__GNUC__) || defined(__INTEL_COMPILER) ) +# if defined(HAVE_MMX ) +# define USE_MMX_INLINE_ASM +# endif +#endif + +/** + * Precalculated increment values for HSV contrast. Saves some expensive + * floating point math. These are half the integer results of: + * + * alpha*(alpha*(sin(M_PI*(brightness-alpha))+1.0)-brightness) + * + * where alpha is 0.5+M_EPSILON and brightness is the percentage for values + * ranging from 0 to 255, (Qt compatible HSV brightness values). The other + * half of the lookup table is the inverse of these values. I am so clever :) + * (mosfet) + */ +static char contrast_table[128] = { + 0, 1, 1, 2, 3, 3, 4, 4, 5, 5, 6, 7, 7, 8, 8, 9, 9, + 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, + 17, 18, 18, 19, 19, 19, 20, 20, 21, 21, 21, 22, 22, 22, 23, + 23, 23, 24, 24, 24, 24, 25, 25, 25, 25, 25, 26, 26, 26, 26, + 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 26, 26, 26, 26, 26, 26, 26, 25, 25, 25, 25, 24, 24, 24, + 23, 23, 23, 22, 22, 21, 21, 20, 20, 20, 19, 18, 18, 17, 17, + 16, 16, 15, 14, 14, 13, 12, 11, 11, 10, 9, 8, 7, 7, 6, 5, + 4, 3, 2, 1, 0 +}; + +bool Blitz::grayscale(QImage &img, bool reduceDepth) +{ + if(img.isNull()) + return(false); + + if(img.format() == QImage::Format_ARGB32_Premultiplied) + img = img.convertToFormat(QImage::Format_ARGB32); + else if(img.depth() < 8) + img = img.convertToFormat(QImage::Format_Indexed8); + +#ifdef USE_MMX_INLINE_ASM +#ifdef __GNUC__ +#warning Using MMX grayscale +#endif + if(BlitzCPUInfo::haveExtension(BlitzCPUInfo::IntegerSSE)){ + MMX::Pack4 packedmult = {{5, 16, 11, 1}}; + MMX::Pack4 alphamask = {{0x0000, 0x0000, 0x0000, 0xFFFF}}; + MMX::Pack4 noalphamask = {{0xFFFF, 0xFFFF, 0xFFFF, 0x0000}}; + + if(reduceDepth && !img.hasAlphaChannel()){ + int y, w = img.width(), h = img.height(); + QImage buffer(w, h, QImage::Format_Indexed8); + + QVector cTable(256); + unsigned int *src = cTable.data(); + for(y=0; y < 256; ++y) + *src++ = qRgb(y, y, y); + buffer.setColorTable(cTable); + + src = (unsigned int *)img.scanLine(0); + unsigned char *end, *dest; + + __asm__ __volatile__ + ("pxor %%mm7, %%mm7\n\t" + "movq (%0), %%mm4\n\t" + "movq (%1), %%mm5\n\t" + "movq (%2), %%mm6\n\t" + : : "r"(&packedmult), "r"(&alphamask), "r"(&noalphamask)); + for(y=0; y < h; ++y){ + dest = buffer.scanLine(y); + end = dest+w; + while(dest != end){ + __asm__ __volatile__ + ("movd (%0), %%mm0\n\t" // load pixel + "punpcklbw %%mm7, %%mm0\n\t" // upgrade to quad + "pand %%mm6, %%mm0\n\t" // zero alpha so we can use pmaddwd + + "pmaddwd %%mm4, %%mm0\n\t" // 2 multiplies and sum BG, RA + "pshufw $0xE4, %%mm0, %%mm1\n\t" + "punpckhwd %%mm7, %%mm1\n\t" // sum R + "paddw %%mm1, %%mm0\n\t" + "psrlw $0x05, %%mm0\n\t" // divide by 32 + "movd %%mm0, %%eax\n\t" + "movb %%al, (%1)\n\t" + : : "r"(src), "r"(dest) : "%eax"); + ++src; + ++dest; + } + } + __asm__ __volatile__ ("emms\n\t" : :); + img = buffer; + } + else{ + // 8bpp or 32bpp w/ no conversion + int count = img.depth() > 8 ? img.width()*img.height() : img.numColors(); + + QVector cTable; + if(img.depth() == 8) + cTable = img.colorTable(); + + unsigned int *data = (img.depth() > 8) ? + (unsigned int *)img.scanLine(0) : cTable.data(); + unsigned int *end = data+count; + + __asm__ __volatile__ + ("pxor %%mm7, %%mm7\n\t" + "movq (%0), %%mm4\n\t" + "movq (%1), %%mm5\n\t" + "movq (%2), %%mm6\n\t" + : : "r"(&packedmult), "r"(&alphamask), "r"(&noalphamask)); + while(data != end){ + __asm__ __volatile__ + ("movd (%0), %%mm0\n\t" // load pixel + "punpcklbw %%mm7, %%mm0\n\t" // upgrade to quad + "pshufw $0xE4, %%mm0, %%mm2\n\t" // copy for alpha later + "pand %%mm6, %%mm0\n\t" // zero alpha so we can use pmaddwd + + "pmaddwd %%mm4, %%mm0\n\t" // 2 multiplies and sum BG, RA + "pshufw $0xE4, %%mm0, %%mm1\n\t" + "punpckhwd %%mm7, %%mm1\n\t" // sum R + "paddw %%mm1, %%mm0\n\t" + "psrlw $0x05, %%mm0\n\t" // divide by 32 + + "pshufw $0x00, %%mm0, %%mm0\n\t" // copy to all pixels + "pand %%mm6, %%mm0\n\t" // reset original alpha + "pand %%mm5, %%mm2\n\t" + "por %%mm2, %%mm0\n\t" + + "packuswb %%mm0, %%mm0\n\t" // pack and write + "movd %%mm0, (%0)\n\t" + : : "r"(data)); + ++data; + } + __asm__ __volatile__ ("emms\n\t" : :); + if(img.depth() == 8) + img.setColorTable(cTable); + } + } + else +#endif + { + // Non MMX version + if(reduceDepth && img.format() == QImage::Format_RGB32){ + // 32bpp w/ conversion to palette + int y, w = img.width(), h = img.height(); + QImage buffer(w, h, QImage::Format_Indexed8); + + QVector cTable(256); + unsigned int *src = cTable.data(); + for(y=0; y < 256; ++y) + *src++ = qRgb(y, y, y); + buffer.setColorTable(cTable); + + src = (unsigned int *)img.scanLine(0); + unsigned char *end, *dest; + unsigned int pixel; + for(y=0; y < h; ++y){ + dest = buffer.scanLine(y); + end = dest+w; + while(dest != end){ + pixel = *src++; + *dest++ = qGray(qRed(pixel), qGreen(pixel), qBlue(pixel)); + } + } + img = buffer; + } + else{ + // 8bpp or 32bpp w/ no conversion + int count = img.depth() > 8 ? img.width()*img.height() : img.numColors(); + + QVector cTable; + if(img.depth() == 8) + cTable = img.colorTable(); + + unsigned int *data = (img.depth() > 8) ? + (unsigned int *)img.scanLine(0) : cTable.data(); + unsigned int *end = data+count; + unsigned int pixel; + unsigned char c; + while(data != end){ + pixel = *data; + c = qGray(qRed(pixel), qGreen(pixel), qBlue(pixel)); + *data++ = qRgba(c, c, c, qAlpha(pixel)); + } + if(img.depth() == 8) + img.setColorTable(cTable); + } + } + return(true); +} + +bool Blitz::invert(QImage &img, QImage::InvertMode mode) +{ + if(img.isNull()) + return(false); + +#ifdef USE_MMX_INLINE_ASM +#ifdef __GNUC__ +#warning Using MMX invert +#endif + if(BlitzCPUInfo::haveExtension(BlitzCPUInfo::MMX)){ + if(img.format() == QImage::Format_ARGB32_Premultiplied) + img = img.convertToFormat(QImage::Format_ARGB32); + else if(img.depth() < 8) + img = img.convertToFormat(QImage::Format_Indexed8); + + unsigned int mask = (mode == QImage::InvertRgba ? 0xFFFFFFFF : + 0x00FFFFFF); + MMX::Pack2 packedmask = {{mask, mask}}; + + int remainder, count; + unsigned int *data, *end; + QVector cTable; + + if(img.depth() <= 8){ + cTable = img.colorTable(); + remainder = img.numColors() % 4; + count = img.numColors()-remainder; + data = (unsigned int *)cTable.data(); + } + else{ + remainder = (img.width()*img.height()) % 4; + count = (img.width()*img.height())-remainder; + data = (unsigned int *)img.scanLine(0); + } + end = data+count; + + __asm__ __volatile__ ("movq (%0), %%mm7\n\t" : : "r"(&packedmask)); + while(data != end){ + __asm__ __volatile__ + ("movq (%0), %%mm0\n\t" + "pxor %%mm7, %%mm0\n\t" + "movq %%mm0, (%0)\n\t" + : : "r"(data)); + data += 2; + } + end += remainder; + while(data != end){ + __asm__ __volatile__ + ("movd (%0), %%mm0\n\t" + "pxor %%mm7, %%mm0\n\t" + "movd %%mm0, (%0)\n\t" + : : "r"(data)); + ++data; + } + __asm__ __volatile__ ("emms\n\t" : :); + if(img.depth() <= 8) + img.setColorTable(cTable); + } + else +#endif + { + img.invertPixels(mode); + } + return(true); +} + +QImage& Blitz::contrast(QImage &img, bool sharpen, int weight) +{ + if(img.isNull()) + return(img); + + if(img.format() == QImage::Format_ARGB32_Premultiplied) + img = img.convertToFormat(QImage::Format_ARGB32); + else if(img.depth() < 8) + img = img.convertToFormat(QImage::Format_Indexed8); + + QVector cTable; + if(img.depth() == 8) + cTable = img.colorTable(); + + unsigned int *end, *data; + int count; + if(img.depth() > 8){ + count = img.width()*img.height(); + data = (unsigned int *)img.scanLine(0); + } + else{ + count = img.numColors(); + data = (unsigned int *)cTable.data(); + } + end = data+count; + + InlineHSV hsv; + int v; + if(sharpen){ + while(data != end){ + hsv.convertRGB2HSV(*data); + v = hsv.value(); + if(v > 127){ + v += contrast_table[v-128]+weight; + if(v > 255) v = 255; + } + else{ + v -= contrast_table[v]+weight; + if(v < 0) v = 0; + } + hsv.setValue(v); + hsv.convertHSV2RGB(); + *data = qRgba(hsv.red(), hsv.green(), hsv.blue(), qAlpha(*data)); + ++data; + } + } + else{ + while(data != end){ + hsv.convertRGB2HSV(*data); + v = hsv.value(); + if(v > 127){ + v -= contrast_table[v-128]+weight; + if(v < 0) v = 0; + } + else{ + v += contrast_table[v]+weight; + if(v > 255) v = 255; + } + hsv.setValue(v); + hsv.convertHSV2RGB(); + *data = qRgba(hsv.red(), hsv.green(), hsv.blue(), qAlpha(*data)); + ++data; + } + } + + if(img.depth() == 8) + img.setColorTable(cTable); + return(img); +} + +QImage& Blitz::intensity(QImage &img, float percent) +{ + if(img.isNull()) + return(img); + + if(img.format() == QImage::Format_ARGB32_Premultiplied) + img = img.convertToFormat(QImage::Format_ARGB32); + else if(img.depth() < 8) + img = img.convertToFormat(QImage::Format_Indexed8); + + QVector colorTable; + int segmentColors, pixels; + unsigned int *data; + + if(img.format() == QImage::Format_Indexed8){ + segmentColors = pixels = img.numColors(); + colorTable = img.colorTable(); + data = colorTable.data(); + } + else{ + segmentColors = 256; + pixels = img.width()*img.height(); + data = (unsigned int *)img.scanLine(0); + } + + percent = qBound(-1.0f, percent, 1.0f); + bool brighten = (percent >= 0); + if(percent < 0) + percent = -percent; + +#ifdef USE_MMX_INLINE_ASM +#ifdef __GNUC__ +#warning Using MMX intensity +#endif + if(BlitzCPUInfo::haveExtension(BlitzCPUInfo::IntegerSSE)){ + unsigned int rem = pixels % 4; + pixels -= rem; + quint32 *end = ( data + pixels ); + + quint16 p = (quint16)(256.0f*(percent)); + MMX::Pack4 mult = {{p,p,p,0}}; + + __asm__ __volatile__( + "pxor %%mm7, %%mm7\n\t" // zero mm7 for unpacking + "movq (%0), %%mm6\n\t" // copy intensity change to mm6 + : : "r"(&mult), "m"(mult)); + if (brighten) + { + while ( data != end ) { + __asm__ __volatile__( + "movq (%0), %%mm0\n\t" + "movq 8(%0), %%mm4\n\t" // copy 4 pixels of data to mm0 and mm4 + "movq %%mm0, %%mm1\n\t" + "movq %%mm0, %%mm3\n\t" + "movq %%mm4, %%mm5\n\t" // copy to registers for unpacking + "punpcklbw %%mm7, %%mm0\n\t" + "punpckhbw %%mm7, %%mm1\n\t" // unpack the two pixels from mm0 + "pmullw %%mm6, %%mm0\n\t" + "punpcklbw %%mm7, %%mm4\n\t" + "pmullw %%mm6, %%mm1\n\t" // multiply by intensity*256 + "psrlw $8, %%mm0\n\t" // divide by 256 + "pmullw %%mm6, %%mm4\n\t" + "psrlw $8, %%mm1\n\t" + "psrlw $8, %%mm4\n\t" + "packuswb %%mm1, %%mm0\n\t" // pack solution into mm0. saturates at 255 + "movq %%mm5, %%mm1\n\t" + + "punpckhbw %%mm7, %%mm1\n\t" // unpack 4th pixel in mm1 + + "pmullw %%mm6, %%mm1\n\t" + "paddusb %%mm3, %%mm0\n\t" // add intesity result to original of mm0 + "psrlw $8, %%mm1\n\t" + "packuswb %%mm1, %%mm4\n\t" // pack upper two pixels into mm4 + + "movq %%mm0, (%0)\n\t" // rewrite to memory lower two pixels + "paddusb %%mm5, %%mm4\n\t" + "movq %%mm4, 8(%0)\n\t" // rewrite upper two pixels + : : "r"(data) ); + data += 4; + } + + end += rem; + while ( data != end ) { + __asm__ __volatile__( + "movd (%0), %%mm0\n\t" // repeat above but for + "punpcklbw %%mm7, %%mm0\n\t" // one pixel at a time + "movq %%mm0, %%mm3\n\t" + "pmullw %%mm6, %%mm0\n\t" + "psrlw $8, %%mm0\n\t" + "paddw %%mm3, %%mm0\n\t" + "packuswb %%mm0, %%mm0\n\t" + "movd %%mm0, (%0)\n\t" + : : "r"(data) ); + data++; + } + } + else + { + while ( data != end ) { + __asm__ __volatile__( + "movq (%0), %%mm0\n\t" + "movq 8(%0), %%mm4\n\t" + "movq %%mm0, %%mm1\n\t" + "movq %%mm0, %%mm3\n\t" + + "movq %%mm4, %%mm5\n\t" + + "punpcklbw %%mm7, %%mm0\n\t" + "punpckhbw %%mm7, %%mm1\n\t" + "pmullw %%mm6, %%mm0\n\t" + "punpcklbw %%mm7, %%mm4\n\t" + "pmullw %%mm6, %%mm1\n\t" + "psrlw $8, %%mm0\n\t" + "pmullw %%mm6, %%mm4\n\t" + "psrlw $8, %%mm1\n\t" + "psrlw $8, %%mm4\n\t" + "packuswb %%mm1, %%mm0\n\t" + "movq %%mm5, %%mm1\n\t" + + "punpckhbw %%mm7, %%mm1\n\t" + + "pmullw %%mm6, %%mm1\n\t" + "psubusb %%mm0, %%mm3\n\t" // subtract darkening amount + "psrlw $8, %%mm1\n\t" + "packuswb %%mm1, %%mm4\n\t" + + "movq %%mm3, (%0)\n\t" + "psubusb %%mm4, %%mm5\n\t" // only change for this version is + "movq %%mm5, 8(%0)\n\t" // subtraction here as we are darkening image + : : "r"(data) ); + data += 4; + } + + end += rem; + while ( data != end ) { + __asm__ __volatile__( + "movd (%0), %%mm0\n\t" + "punpcklbw %%mm7, %%mm0\n\t" + "movq %%mm0, %%mm3\n\t" + "pmullw %%mm6, %%mm0\n\t" + "psrlw $8, %%mm0\n\t" + "psubusw %%mm0, %%mm3\n\t" + "packuswb %%mm3, %%mm3\n\t" + "movd %%mm3, (%0)\n\t" + : : "r"(data) ); + data++; + } + } + __asm__ __volatile__("emms"); // clear mmx state + } + else +#endif // USE_MMX_INLINE_ASM + { + unsigned char *segmentTable = new unsigned char[segmentColors]; + if(brighten){ + for(int i=0; i < segmentColors; ++i) + segmentTable[i] = qMin((int)(i*percent), 255); + + int r, g, b; + for(int i=0; i < pixels; ++i){ + r = qRed(data[i]); + g = qGreen(data[i]); + b = qBlue(data[i]); + data[i] = qRgba(qMin(255, r+segmentTable[r]), + qMin(255, g+segmentTable[g]), + qMin(255, b+segmentTable[b]), qAlpha(data[i])); + } + } + else{ + for(int i=0; i < segmentColors; ++i) + segmentTable[i] = qMax((int)(i*percent), 0); + + int r, g, b; + for(int i=0; i < pixels; ++i){ + r = qRed(data[i]); + g = qGreen(data[i]); + b = qBlue(data[i]); + data[i] = qRgba(qMax(0, r-segmentTable[r]), + qMax(0, g-segmentTable[g]), + qMax(0, b-segmentTable[b]), qAlpha(data[i])); + } + } + delete[] segmentTable; + } + + if(img.depth() == 8) + img.setColorTable(colorTable); + return(img); +} + +QImage& Blitz::channelIntensity(QImage &img, float percent, RGBChannel channel) +{ + if(img.isNull() || (channel != Red && channel != Blue && + channel != Green)) + return(img); + if(img.format() == QImage::Format_ARGB32_Premultiplied) + img = img.convertToFormat(QImage::Format_ARGB32); + else if(img.depth() < 8) + img = img.convertToFormat(QImage::Format_Indexed8); + + QVector colorTable; + int segmentColors, pixels; + unsigned int *data; + + if(img.format() == QImage::Format_Indexed8){ + segmentColors = pixels = img.numColors(); + colorTable = img.colorTable(); + data = colorTable.data(); + } + else{ + segmentColors = 256; + pixels = img.width()*img.height(); + data = (unsigned int *)img.scanLine(0); + } + + percent = qBound(-1.0f, percent, 1.0f); + bool brighten = (percent >= 0); + if(percent < 0) + percent = -percent; + + unsigned char *segmentTable = new unsigned char[segmentColors]; + if(brighten){ + for(int i=0; i < segmentColors; ++i) + segmentTable[i] = qMin((int)(i*percent), 255); + + int color; + if(channel == Red){ // and here ;-) + for(int i=0; i < pixels; ++i){ + color = qRed(data[i]); + data[i] = qRgba(qMin(255, color+segmentTable[color]), + qGreen(data[i]), qBlue(data[i]), + qAlpha(data[i])); + } + } + else if(channel == Green){ + for(int i=0; i < pixels; ++i){ + color = qGreen(data[i]); + data[i] = qRgba(qRed(data[i]), + qMin(255, color+segmentTable[color]), + qBlue(data[i]), qAlpha(data[i])); + } + } + else{ + for(int i=0; i < pixels; ++i){ + color = qBlue(data[i]); + data[i] = qRgba(qRed(data[i]), qGreen(data[i]), + qMin(255, color+segmentTable[color]), + qAlpha(data[i])); + } + } + } + else{ + for(int i=0; i < segmentColors; ++i) + segmentTable[i] = qMax((int)(i*percent), 0); + + int color; + if(channel == Red){ + for(int i=0; i < pixels; ++i){ + color = qRed(data[i]); + data[i] = qRgba(qMax(0, color-segmentTable[color]), + qGreen(data[i]), qBlue(data[i]), + qAlpha(data[i])); + } + } + else if(channel == Green){ + for(int i=0; i < pixels; ++i){ + color = qGreen(data[i]); + data[i] = qRgba(qRed(data[i]), + qMax(0, color-segmentTable[color]), + qBlue(data[i]), qAlpha(data[i])); + } + } + else{ + for(int i=0; i < pixels; ++i){ + color = qBlue(data[i]); + data[i] = qRgba(qRed(data[i]), qGreen(data[i]), + qMax(0, color-segmentTable[color]), + qAlpha(data[i])); + } + } + } + delete[] segmentTable; + if(img.format() == QImage::Format_Indexed8) + img.setColorTable(colorTable); + return(img); +} + +QImage& Blitz::desaturate(QImage &img, float desat) +{ + if(img.isNull()) + return(img); + if(img.depth() < 8) + img = img.convertToFormat(QImage::Format_Indexed8); + + desat = qBound(0.0f, desat, 1.0f); + + unsigned int *data, *end; + InlineHSV hsv; + if(img.format() == QImage::Format_ARGB32 || + img.format() == QImage::Format_RGB32 || + img.format() == QImage::Format_Indexed8){ + QVector cTable; + if(img.format() == QImage::Format_Indexed8){ + cTable = img.colorTable(); + data = (unsigned int *)cTable.data(); + end = data + img.numColors(); + + } + else{ + data = (unsigned int *)img.scanLine(0); + end = data + (img.width()*img.height()); + } + while(data != end){ + hsv.convertRGB2HSV(*data); + hsv.setSaturation((int)(hsv.saturation() * (1.0 - desat))); + hsv.convertHSV2RGB(); + *data = qRgba(hsv.red(), hsv.green(), hsv.blue(), qAlpha(*data)); + ++data; + } + if(img.format() == QImage::Format_Indexed8) + img.setColorTable(cTable); + + } + else if(img.format() == QImage::Format_ARGB32_Premultiplied){ + data = (unsigned int *)img.scanLine(0); + end = data + (img.width()*img.height()); + while(data != end){ + hsv.convertRGB2HSV(BlitzPrivate::convertFromPremult(*data)); + hsv.setSaturation((int)(hsv.saturation() * (1.0 - desat))); + hsv.convertHSV2RGB(); + *data = BlitzPrivate::convertToPremult(qRgba(hsv.red(), hsv.green(), + hsv.blue(), qAlpha(*data))); + ++data; + } + } + return(img); +} + + +QImage Blitz::threshold(QImage &img, unsigned char thresholdValue, + RGBChannel channel, unsigned int c_on, + unsigned int c_off) +{ + if(img.isNull()) + return(img); + else if(img.depth() < 8) + img = img.convertToFormat(QImage::Format_Indexed8); + + int x, y, w, h; + w = img.width(); h = img.height(); + QImage buffer(img.width(), img.height(), QImage::Format_Indexed8); + + QVector cTable(2); + cTable[0] = c_off; cTable[1] = c_on; + buffer.setColorTable(cTable); + + unsigned char *dest; + if(img.format() == QImage::Format_RGB32 || + img.format() == QImage::Format_ARGB32){ + QRgb *src = (QRgb *)img.scanLine(0); + switch(channel){ + case Grayscale: + case All:{ + for(y=0; y < h; ++y){ + dest = buffer.scanLine(y); + for(x=0; x < w; ++x) + *dest++ = (qGray(*src++) >= thresholdValue) ? 1 : 0; + } + break; + } + case Brightness:{ + for(y=0; y < h; ++y){ + dest = buffer.scanLine(y); + for(x=0; x < w; ++x) + *dest++ = (BlitzPrivate::brightness(*src++) >= thresholdValue) ? 1 : 0; + } + break; + } + case Red:{ + for(y=0; y < h; ++y){ + dest = buffer.scanLine(y); + for(x=0; x < w; ++x) + *dest++ = (qRed(*src++) >= thresholdValue) ? 1 : 0; + } + break; + } + case Green:{ + for(y=0; y < h; ++y){ + dest = buffer.scanLine(y); + for(x=0; x < w; ++x) + *dest++ = (qGreen(*src++) >= thresholdValue) ? 1 : 0; + } + break; + } + case Blue:{ + for(y=0; y < h; ++y){ + dest = buffer.scanLine(y); + for(x=0; x < w; ++x) + *dest++ = (qBlue(*src++) >= thresholdValue) ? 1 : 0; + } + break; + } + case Alpha:{ + for(y=0; y < h; ++y){ + dest = buffer.scanLine(y); + for(x=0; x < w; ++x) + *dest++ = (qAlpha(*src++) >= thresholdValue) ? 1 : 0; + } + break; + } + } + } + else if(img.format() == QImage::Format_ARGB32_Premultiplied){ + QRgb *src = (QRgb *)img.scanLine(0); + switch(channel){ + case Grayscale: + case All:{ + for(y=0; y < h; ++y){ + dest = buffer.scanLine(y); + for(x=0; x < w; ++x, ++src) + *dest++ = (qGray(BlitzPrivate::convertFromPremult(*src)) >= + thresholdValue) ? 1 : 0; + } + break; + } + case Brightness:{ + for(y=0; y < h; ++y){ + dest = buffer.scanLine(y); + for(x=0; x < w; ++x, ++src) + *dest++ = (BlitzPrivate::brightness(BlitzPrivate::convertFromPremult(*src)) >= + thresholdValue) ? 1 : 0; + } + break; + } + case Red:{ + for(y=0; y < h; ++y){ + dest = buffer.scanLine(y); + for(x=0; x < w; ++x, ++src) + *dest++ = (qRed(BlitzPrivate::convertFromPremult(*src)) >= + thresholdValue) ? 1 : 0; + } + break; + } + case Green:{ + for(y=0; y < h; ++y){ + dest = buffer.scanLine(y); + for(x=0; x < w; ++x, ++src) + *dest++ = (qGreen(BlitzPrivate::convertFromPremult(*src)) >= + thresholdValue) ? 1 : 0; + } + break; + } + case Blue:{ + for(y=0; y < h; ++y){ + dest = buffer.scanLine(y); + for(x=0; x < w; ++x, ++src) + *dest++ = (qBlue(BlitzPrivate::convertFromPremult(*src)) >= + thresholdValue) ? 1 : 0; + } + break; + } + case Alpha:{ + for(y=0; y < h; ++y){ + dest = buffer.scanLine(y); + for(x=0; x < w; ++x, ++src) + *dest++ = (qAlpha(BlitzPrivate::convertFromPremult(*src)) >= + thresholdValue) ? 1 : 0; + } + break; + } + } + } + else{ + // would be quicker to just threshold the color table, but we return + // images w/ only 2 colors for easy conversion to bitmap + QVector srcTable(img.colorTable()); + unsigned char *src; + switch(channel){ + case Grayscale: + case All:{ + for(y=0; y < h; ++y){ + src = img.scanLine(y); dest = buffer.scanLine(y); + for(x=0; x < w; ++x){ + *dest++ = (qGray(srcTable[*src++]) >= thresholdValue) ? + 1 : 0; + } + } + break; + } + case Brightness:{ + for(y=0; y < h; ++y){ + src = img.scanLine(y); dest = buffer.scanLine(y); + for(x=0; x < w; ++x){ + *dest++ = (BlitzPrivate::brightness(srcTable[*src++]) >= thresholdValue) ? + 1 : 0; + } + } + break; + } + case Red:{ + for(y=0; y < h; ++y){ + src = img.scanLine(y); dest = buffer.scanLine(y); + for(x=0; x < w; ++x){ + *dest++ = (qRed(srcTable[*src++]) >= thresholdValue) ? + 1 : 0; + } + } + break; + } + case Green:{ + for(y=0; y < h; ++y){ + src = img.scanLine(y); dest = buffer.scanLine(y); + for(x=0; x < w; ++x){ + *dest++ = (qGreen(srcTable[*src++]) >= thresholdValue) ? + 1 : 0; + } + } + break; + } + case Blue:{ + for(y=0; y < h; ++y){ + src = img.scanLine(y); dest = buffer.scanLine(y); + for(x=0; x < w; ++x){ + *dest++ = (qBlue(srcTable[*src++]) >= thresholdValue) ? + 1 : 0; + } + } + break; + } + case Alpha:{ + for(y=0; y < h; ++y){ + src = img.scanLine(y); dest = buffer.scanLine(y); + for(x=0; x < w; ++x){ + *dest++ = (qAlpha(srcTable[*src++]) >= thresholdValue) ? + 1 : 0; + } + } + break; + } + } + } + return(buffer); + +} + +QImage& Blitz::fade(QImage &img, float val, const QColor &color) +{ + if(img.isNull() || img.depth() == 1) + return(img); + + val = qBound(0.0f, val, 1.0f); + unsigned char tbl[256]; + for(int i=0; i < 256; ++i) + tbl[i] = (int)(val * i + 0.5); + + int red = color.red(); + int green = color.green(); + int blue = color.blue(); + + int r, g, b; + QRgb *data, *end; + QVector cTable; + + if(img.format() == QImage::Format_Indexed8){ + cTable = img.colorTable(); + data = (unsigned int *)cTable.data(); + end = data + img.numColors(); + + } + else{ + data = (unsigned int *)img.scanLine(0); + end = data + (img.width()*img.height()); + } + + if(img.format() == QImage::Format_ARGB32_Premultiplied){ + QRgb col; + while(data != end){ + col = BlitzPrivate::convertFromPremult(*data); + r = qRed(col); g = qGreen(col); b = qBlue(col); + *data++ = + BlitzPrivate::convertToPremult(qRgba((r > red) ? r - tbl[r - red] : r + tbl[red - r], + (g > green) ? g - tbl[g - green] : g + tbl[green - g], + (b > blue) ? b - tbl[b - blue] : b + tbl[blue - b], + qAlpha(col))); + } + } + else{ + while(data != end){ + r = qRed(*data); g = qGreen(*data); b = qBlue(*data); + *data = qRgba((r > red) ? r - tbl[r - red] : r + tbl[red - r], + (g > green) ? g - tbl[g - green] : g + tbl[green - g], + (b > blue) ? b - tbl[b - blue] : b + tbl[blue - b], + qAlpha(*data)); + ++data; + } + } + if(img.format() == QImage::Format_Indexed8) + img.setColorTable(cTable); + return(img); +} + +QImage& Blitz::flatten(QImage &img, const QColor &ca, const QColor &cb) +{ + if(img.isNull()) + return(img); + + if(img.depth() == 1) { + img.setColor(0, ca.rgb()); + img.setColor(1, cb.rgb()); + return(img); + } + + int r1 = ca.red(); int r2 = cb.red(); + int g1 = ca.green(); int g2 = cb.green(); + int b1 = ca.blue(); int b2 = cb.blue(); + int min = 0, max = 255; + + QRgb *data, *end; + QVector cTable; + if(img.format() == QImage::Format_Indexed8){ + cTable = img.colorTable(); + data = (unsigned int *)cTable.data(); + end = data + img.numColors(); + + } + else{ + data = (unsigned int *)img.scanLine(0); + end = data + (img.width()*img.height()); + } + + // get minimum and maximum graylevel + QRgb *ptr = data; + int mean; + + if(img.format() != QImage::Format_ARGB32_Premultiplied){ + while(ptr != end){ + mean = (qRed(*ptr) + qGreen(*ptr) + qBlue(*ptr)) / 3; + min = qMin(min, mean); + max = qMax(max, mean); + ++ptr; + } + } + else{ + QRgb pixel; + while(ptr != end){ + pixel = BlitzPrivate::convertFromPremult(*ptr); + mean = (qRed(pixel) + qGreen(pixel) + qBlue(pixel)) / 3; + min = qMin(min, mean); + max = qMax(max, mean); + ++ptr; + } + } + + // conversion factors + float sr = ((float) r2 - r1) / (max - min); + float sg = ((float) g2 - g1) / (max - min); + float sb = ((float) b2 - b1) / (max - min); + + if(img.format() != QImage::Format_ARGB32_Premultiplied){ + while(data != end){ + mean = (qRed(*data) + qGreen(*data) + qBlue(*data)) / 3; + *data = qRgba((unsigned char)(sr * (mean - min) + r1 + 0.5), + (unsigned char)(sg * (mean - min) + g1 + 0.5), + (unsigned char)(sb * (mean - min) + b1 + 0.5), + qAlpha(*data)); + ++data; + } + } + else{ + QRgb pixel; + while(data != end){ + pixel = BlitzPrivate::convertFromPremult(*data); + mean = (qRed(pixel) + qGreen(pixel) + qBlue(pixel)) / 3; + *data = + BlitzPrivate:: + convertToPremult(qRgba((unsigned char)(sr * (mean - min) + r1 + 0.5), + (unsigned char)(sg * (mean - min) + g1 + 0.5), + (unsigned char)(sb * (mean - min) + b1 + 0.5), + qAlpha(*data))); + ++data; + } + } + + if(img.format() == QImage::Format_Indexed8) + img.setColorTable(cTable); + return(img); +} + + diff -Nru syncwall-1.6.0/src/3rdparty/qimageblitz/config-externalasm.h syncwall-1.7.4/src/3rdparty/qimageblitz/config-externalasm.h --- syncwall-1.6.0/src/3rdparty/qimageblitz/config-externalasm.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qimageblitz/config-externalasm.h 2012-01-08 14:28:14.000000000 +0000 @@ -0,0 +1,2 @@ +/* #undef HAVE_EXTERNAL_ASM */ + diff -Nru syncwall-1.6.0/src/3rdparty/qimageblitz/config-processor.h syncwall-1.7.4/src/3rdparty/qimageblitz/config-processor.h --- syncwall-1.6.0/src/3rdparty/qimageblitz/config-processor.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qimageblitz/config-processor.h 2012-01-08 14:28:14.000000000 +0000 @@ -0,0 +1,20 @@ +/********** processor stuff *************/ + +/* Defined to 1 if the assembler supports MMX instructions. */ +/* #undef HAVE_MMX */ + +/* Defined to 1 if the assembler supports SSE instructions. */ +/* #undef HAVE_SSE */ + +/* Defined to 1 if the assembler supports SSE2 instructions. */ +/* #undef HAVE_SSE2 */ + +/* Defined to 1 if the assembler supports 3DNow instructions. */ +/* #undef HAVE_3DNOW */ + +/* Defined to 1 if the assembler supports AltiVec instructions. */ +/* #undef HAVE_PPC_ALTIVEC */ + +/* Defined to 1 if you have stdint.h */ +/* #undef HAVE_STDINT_H */ + diff -Nru syncwall-1.6.0/src/3rdparty/qimageblitz/convolve.cpp syncwall-1.7.4/src/3rdparty/qimageblitz/convolve.cpp --- syncwall-1.6.0/src/3rdparty/qimageblitz/convolve.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qimageblitz/convolve.cpp 2011-12-17 13:07:04.000000000 +0000 @@ -0,0 +1,1387 @@ +/* + Copyright (C) 2004, 2005, 2007 Daniel M. Duley + + Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +/* + Portions of this software are were originally based on ImageMagick's + algorithms. ImageMagick is copyrighted under the following conditions: + +Copyright (C) 2003 ImageMagick Studio, a non-profit organization dedicated to +making software imaging solutions freely available. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files ("ImageMagick"), to deal +in ImageMagick without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of ImageMagick, and to permit persons to whom the ImageMagick is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of ImageMagick. + +The software is provided "as is", without warranty of any kind, express or +implied, including but not limited to the warranties of merchantability, +fitness for a particular purpose and noninfringement. In no event shall +ImageMagick Studio be liable for any claim, damages or other liability, +whether in an action of contract, tort or otherwise, arising from, out of or +in connection with ImageMagick or the use or other dealings in ImageMagick. + +Except as contained in this notice, the name of the ImageMagick Studio shall +not be used in advertising or otherwise to promote the sale, use or other +dealings in ImageMagick without prior written authorization from the +ImageMagick Studio. +*/ + +#include "qimageblitz.h" +#include "private/blitz_p.h" +#include +#include "blitzcpu.h" +#include +#include +#include +#include +#ifdef HAVE_STDINT_H + #include +#endif + +#if defined(__i386__) && ( defined(__GNUC__) || defined(__INTEL_COMPILER) ) +# if defined(HAVE_MMX ) +# define USE_MMX_INLINE_ASM +# endif +#endif + +#define M_EPSILON 1.0e-6 +#define M_SQ2PI 2.50662827463100024161235523934010416269302368164062 +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +#define RoundToPixel(value) ((unsigned char) ((value) < 0.0 ? 0.0 : \ + ((value) > (float) 255) ? (float) 255 : (value)+0.5)) + +typedef struct +{ + float red, green, blue, alpha; +} FloatPixel; + + +#define CONVOLVE_ACC(weight, pixel) \ + r+=((weight))*(qRed((pixel))); g+=((weight))*(qGreen((pixel))); \ + b+=((weight))*(qBlue((pixel))); + + +QImage Blitz::convolve(QImage &img, int matrix_size, float *matrix) +{ + int i, x, y, w, h, matrix_x, matrix_y; + int edge = matrix_size/2; + QRgb *dest, *src, *s, **scanblock; + float *m, *normalize_matrix, normalize; + bool overflow = false; + + if(!(matrix_size % 2)){ + qWarning("Blitz::convolve(): kernel width must be an odd number!"); + return(img); + } + + w = img.width(); + h = img.height(); + if(w < 3 || h < 3){ + qWarning("Blitz::convolve(): Image is too small!"); + return(img); + } + + if(img.format() == QImage::Format_ARGB32_Premultiplied) + img = img.convertToFormat(QImage::Format_ARGB32); + else if(img.depth() < 32){ + img = img.convertToFormat(img.hasAlphaChannel() ? + QImage::Format_ARGB32 : + QImage::Format_RGB32); + } + QImage buffer(w, h, img.format()); + + scanblock = new QRgb* [matrix_size]; + normalize_matrix = new float[matrix_size*matrix_size]; + + // create normalized matrix + normalize = 0.0; + for(i=0; i < matrix_size*matrix_size; ++i) + normalize += matrix[i]; + if(std::abs(normalize) <= M_EPSILON) + normalize = 1.0; + normalize = 1.0/normalize; + for(i=0; i < matrix_size*matrix_size; ++i){ + normalize_matrix[i] = normalize*matrix[i]; + if(normalize_matrix[i] < 0.0) + overflow = true; + } + + // apply + +#ifdef USE_MMX_INLINE_ASM +#ifdef __GNUC__ +#warning Using MMX floating point convolve +#endif + if(BlitzCPUInfo::haveExtension(BlitzCPUInfo::AMD3DNOW) && + BlitzCPUInfo::haveExtension(BlitzCPUInfo::IntegerSSE)){ + // + // + // MMX/3dnow version + // + // + + __asm__ __volatile__ + ("pxor %%mm7, %%mm7\n\t" : :); // clear for unpacking + for(y=0; y < h; ++y){ + dest = (QRgb *)buffer.scanLine(y); + src = (QRgb *)img.scanLine(y); + // Read in scanlines to pixel neighborhood. If the scanline is outside + // the image use the top or bottom edge. + for(x=y-edge, i=0; x <= y+edge; ++i, ++x){ + scanblock[i] = (QRgb *) + img.scanLine((x < 0) ? 0 : (x > h-1) ? h-1 : x); + } + // Now we are about to start processing scanlines. First handle the + // part where the pixel neighborhood extends off the left edge. + for(x=0; x-edge < 0 ; ++x){ + m = normalize_matrix; + __asm__ __volatile__ + ("pxor %%mm0, %%mm0\n\t" + "pxor %%mm1, %%mm1\n\t" + : :); + for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ + s = scanblock[matrix_y]; + matrix_x = -edge; + while(x+matrix_x < 0){ + __asm__ __volatile__ + ("movd (%0), %%mm2\n\t" // mm2: m doubleword + "punpckldq %%mm2, %%mm2\n\t" + "movd (%1), %%mm3\n\t" // load pixel + "punpcklbw %%mm7, %%mm3\n\t" + "pshufw $0xE4, %%mm3, %%mm4\n\t" + "punpcklwd %%mm7, %%mm3\n\t" // mm3: BG + "punpckhwd %%mm7, %%mm4\n\t" // mm4: RA + + "pi2fd %%mm3, %%mm3\n\t" // convert to fp... + "pi2fd %%mm4, %%mm4\n\t" + "pfmul %%mm2, %%mm3\n\t" // ...and multiply + "pfmul %%mm2, %%mm4\n\t" + + "pfadd %%mm3, %%mm0\n\t" // add to accumulator + "pfadd %%mm4, %%mm1\n\t" + : : "r"(m), "r"(s)); + ++matrix_x; ++m; + } + while(matrix_x <= edge){ + __asm__ __volatile__ + ("movd (%0), %%mm2\n\t" // mm2: m doubleword + "punpckldq %%mm2, %%mm2\n\t" + "movd (%1), %%mm3\n\t" // load pixel + "punpcklbw %%mm7, %%mm3\n\t" + "pshufw $0xE4, %%mm3, %%mm4\n\t" + "punpcklwd %%mm7, %%mm3\n\t" // mm3: BG + "punpckhwd %%mm7, %%mm4\n\t" // mm4: RA + + "pi2fd %%mm3, %%mm3\n\t" // convert to fp... + "pi2fd %%mm4, %%mm4\n\t" + "pfmul %%mm2, %%mm3\n\t" // ...and multiply + "pfmul %%mm2, %%mm4\n\t" + + "pfadd %%mm3, %%mm0\n\t" // add to accumulator + "pfadd %%mm4, %%mm1\n\t" + : : "r"(m), "r"(s)); + ++matrix_x; ++m; ++s; + } + } + __asm__ __volatile__ + ("pf2id %%mm0, %%mm0\n\t" + "pf2id %%mm1, %%mm1\n\t" + + "packssdw %%mm0, %%mm1\n\t" + "pshufw $0x4E, %%mm1, %%mm1\n\t" + "packuswb %%mm7, %%mm1\n\t" + "movd %%mm1, (%0)\n\t" + : : "r"(dest)); + *dest = BlitzPrivate::setAlpha(*dest, qAlpha(*src++)); + ++dest; + } + // Okay, now process the middle part where the entire neighborhood + // is on the image. + for(; x+edge < w; ++x){ + m = normalize_matrix; + __asm__ __volatile__ + ("pxor %%mm0, %%mm0\n\t" + "pxor %%mm1, %%mm1\n\t" + : :); + for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ + s = scanblock[matrix_y] + (x-edge); + for(matrix_x = -edge; matrix_x <= edge; ++matrix_x, ++m, ++s){ + __asm__ __volatile__ + ("movd (%0), %%mm2\n\t" // mm2: m doubleword + "punpckldq %%mm2, %%mm2\n\t" + "movd (%1), %%mm3\n\t" // load pixel + "punpcklbw %%mm7, %%mm3\n\t" + "pshufw $0xE4, %%mm3, %%mm4\n\t" + "punpcklwd %%mm7, %%mm3\n\t" // mm3: BG + "punpckhwd %%mm7, %%mm4\n\t" // mm4: RA + + "pi2fd %%mm3, %%mm3\n\t" // convert to fp... + "pi2fd %%mm4, %%mm4\n\t" + "pfmul %%mm2, %%mm3\n\t" // ...and multiply + "pfmul %%mm2, %%mm4\n\t" + + "pfadd %%mm3, %%mm0\n\t" // add to accumulator + "pfadd %%mm4, %%mm1\n\t" + : : "r"(m), "r"(s)); + } + } + __asm__ __volatile__ + ("pf2id %%mm0, %%mm0\n\t" + "pf2id %%mm1, %%mm1\n\t" + + "packssdw %%mm0, %%mm1\n\t" + "pshufw $0x4E, %%mm1, %%mm1\n\t" + "packuswb %%mm7, %%mm1\n\t" + "movd %%mm1, (%0)\n\t" + : : "r"(dest)); + *dest = BlitzPrivate::setAlpha(*dest, qAlpha(*src++)); + ++dest; + } + // Finally process the right part where the neighborhood extends off + // the right edge of the image + for(; x < w; ++x){ + m = normalize_matrix; + __asm__ __volatile__ + ("pxor %%mm0, %%mm0\n\t" + "pxor %%mm1, %%mm1\n\t" + : :); + for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ + s = scanblock[matrix_y]; + s += x-edge; + matrix_x = -edge; + while(x+matrix_x < w){ + __asm__ __volatile__ + ("movd (%0), %%mm2\n\t" // mm2: m doubleword + "punpckldq %%mm2, %%mm2\n\t" + "movd (%1), %%mm3\n\t" // load pixel + "punpcklbw %%mm7, %%mm3\n\t" + "pshufw $0xE4, %%mm3, %%mm4\n\t" + "punpcklwd %%mm7, %%mm3\n\t" // mm3: BG + "punpckhwd %%mm7, %%mm4\n\t" // mm4: RA + + "pi2fd %%mm3, %%mm3\n\t" // convert to fp... + "pi2fd %%mm4, %%mm4\n\t" + "pfmul %%mm2, %%mm3\n\t" // ...and multiply + "pfmul %%mm2, %%mm4\n\t" + + "pfadd %%mm3, %%mm0\n\t" // add to accumulator + "pfadd %%mm4, %%mm1\n\t" + : : "r"(m), "r"(s)); + ++matrix_x, ++m, ++s; + } + --s; + while(matrix_x <= edge){ + __asm__ __volatile__ + ("movd (%0), %%mm2\n\t" // mm2: m doubleword + "punpckldq %%mm2, %%mm2\n\t" + "movd (%1), %%mm3\n\t" // load pixel + "punpcklbw %%mm7, %%mm3\n\t" + "pshufw $0xE4, %%mm3, %%mm4\n\t" + "punpcklwd %%mm7, %%mm3\n\t" // mm3: BG + "punpckhwd %%mm7, %%mm4\n\t" // mm4: RA + + "pi2fd %%mm3, %%mm3\n\t" // convert to fp... + "pi2fd %%mm4, %%mm4\n\t" + "pfmul %%mm2, %%mm3\n\t" // ...and multiply + "pfmul %%mm2, %%mm4\n\t" + + "pfadd %%mm3, %%mm0\n\t" // add to accumulator + "pfadd %%mm4, %%mm1\n\t" + : : "r"(m), "r"(s)); + ++matrix_x, ++m; + } + } + __asm__ __volatile__ + ("pf2id %%mm0, %%mm0\n\t" + "pf2id %%mm1, %%mm1\n\t" + + "packssdw %%mm0, %%mm1\n\t" + "pshufw $0x4E, %%mm1, %%mm1\n\t" + "packuswb %%mm7, %%mm1\n\t" + "movd %%mm1, (%0)\n\t" + : : "r"(dest)); + *dest = BlitzPrivate::setAlpha(*dest, qAlpha(*src++)); + ++dest; + } + } + __asm__ __volatile__ ("emms\n\t" : :); + } + else +#endif + { + // + // + // Non-MMX version + // + // + + float r, g, b; + for(y=0; y < h; ++y){ + src = (QRgb *)img.scanLine(y); + dest = (QRgb *)buffer.scanLine(y); + // Read in scanlines to pixel neighborhood. If the scanline is outside + // the image use the top or bottom edge. + for(x=y-edge, i=0; x <= y+edge; ++i, ++x){ + scanblock[i] = (QRgb *) + img.scanLine((x < 0) ? 0 : (x > h-1) ? h-1 : x); + } + // Now we are about to start processing scanlines. First handle the + // part where the pixel neighborhood extends off the left edge. + for(x=0; x-edge < 0 ; ++x){ + r = g = b = 0.0; + m = normalize_matrix; + for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ + s = scanblock[matrix_y]; + matrix_x = -edge; + while(x+matrix_x < 0){ + CONVOLVE_ACC(*m, *s); + ++matrix_x; ++m; + } + while(matrix_x <= edge){ + CONVOLVE_ACC(*m, *s); + ++matrix_x; ++m; ++s; + } + } + r = r < 0.0 ? 0.0 : r > 255.0 ? 255.0 : r+0.5; + g = g < 0.0 ? 0.0 : g > 255.0 ? 255.0 : g+0.5; + b = b < 0.0 ? 0.0 : b > 255.0 ? 255.0 : b+0.5; + *dest++ = qRgba((unsigned char)r, (unsigned char)g, + (unsigned char)b, qAlpha(*src++)); + } + // Okay, now process the middle part where the entire neighborhood + // is on the image. + for(; x+edge < w; ++x){ + m = normalize_matrix; + r = g = b = 0.0; + for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ + s = scanblock[matrix_y] + (x-edge); + for(matrix_x = -edge; matrix_x <= edge; ++matrix_x, ++m, ++s){ + CONVOLVE_ACC(*m, *s); + } + } + r = r < 0.0 ? 0.0 : r > 255.0 ? 255.0 : r+0.5; + g = g < 0.0 ? 0.0 : g > 255.0 ? 255.0 : g+0.5; + b = b < 0.0 ? 0.0 : b > 255.0 ? 255.0 : b+0.5; + *dest++ = qRgba((unsigned char)r, (unsigned char)g, + (unsigned char)b, qAlpha(*src++)); + } + // Finally process the right part where the neighborhood extends off + // the right edge of the image + for(; x < w; ++x){ + r = g = b = 0.0; + m = normalize_matrix; + for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ + s = scanblock[matrix_y]; + s += x-edge; + matrix_x = -edge; + while(x+matrix_x < w){ + CONVOLVE_ACC(*m, *s); + ++matrix_x, ++m, ++s; + } + --s; + while(matrix_x <= edge){ + CONVOLVE_ACC(*m, *s); + ++matrix_x, ++m; + } + } + r = r < 0.0 ? 0.0 : r > 255.0 ? 255.0 : r+0.5; + g = g < 0.0 ? 0.0 : g > 255.0 ? 255.0 : g+0.5; + b = b < 0.0 ? 0.0 : b > 255.0 ? 255.0 : b+0.5; + *dest++ = qRgba((unsigned char)r, (unsigned char)g, + (unsigned char)b, qAlpha(*src++)); + } + } + } + + delete[] scanblock; + delete[] normalize_matrix; + return(buffer); +} + +QImage Blitz::convolveInteger(QImage &img, int matrix_size, + int *matrix, int divisor) +{ + int i, x, y, w, h, matrix_x, matrix_y, *m; + int edge = matrix_size/2; + QRgb *dest, *src, *s, **scanblock; + + if(!(matrix_size % 2)){ + qWarning("Blitz::convolve(): kernel width must be an odd number!"); + return(img); + } + + w = img.width(); + h = img.height(); + if(w < 3 || h < 3){ + qWarning("Blitz::convolve(): Image is too small!"); + return(img); + } + + if(img.format() == QImage::Format_ARGB32_Premultiplied) + img = img.convertToFormat(QImage::Format_ARGB32); + else if(img.depth() < 32){ + img = img.convertToFormat(img.hasAlphaChannel() ? + QImage::Format_ARGB32 : + QImage::Format_RGB32); + } + + QImage buffer(w, h, img.format()); + scanblock = new QRgb* [matrix_size]; + + if(!divisor){ +#ifdef USE_MMX_INLINE_ASM +#ifdef __GNUC__ +#warning Using MMX integer convolve +#endif + if(BlitzCPUInfo::haveExtension(BlitzCPUInfo::MMX)){ + // + // No divisor MMX version + // + __asm__ __volatile__ + ("pxor %%mm7, %%mm7\n\t" : :); // clear for unpacking + for(y=0; y < h; ++y){ + src = (QRgb *)img.scanLine(y); + dest = (QRgb *)buffer.scanLine(y); + // Read in scanlines to pixel neighborhood. If the scanline is outside + // the image use the top or bottom edge. + for(x=y-edge, i=0; x <= y+edge; ++i, ++x){ + scanblock[i] = (QRgb *) + img.scanLine((x < 0) ? 0 : (x > h-1) ? h-1 : x); + } + // Now we are about to start processing scanlines. First handle the + // part where the pixel neighborhood extends off the left edge. + for(x=0; x-edge < 0 ; ++x){ + m = matrix; + __asm__ __volatile__ + ("pxor %%mm0, %%mm0\n\t" : :); // clear acc + + for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ + s = scanblock[matrix_y]; + matrix_x = -edge; + while(x+matrix_x < 0){ + __asm__ __volatile__ + ("movd (%0), %%mm1\n\t" // mm1: matrix + "punpckldq %%mm1, %%mm1\n\t" + "packssdw %%mm1, %%mm1\n\t" + "movd (%1), %%mm2\n\t" // mm2: pixel + "punpcklbw %%mm7, %%mm2\n\t" + "pmullw %%mm1, %%mm2\n\t" // multiply + "paddsw %%mm2, %%mm0\n\t" // add to acc + : : "r"(m), "r"(s)); + ++matrix_x; ++m; + } + while(matrix_x <= edge){ + __asm__ __volatile__ + ("movd (%0), %%mm1\n\t" // mm1: matrix + "punpckldq %%mm1, %%mm1\n\t" + "packssdw %%mm1, %%mm1\n\t" + "movd (%1), %%mm2\n\t" // mm2: pixel + "punpcklbw %%mm7, %%mm2\n\t" + "pmullw %%mm1, %%mm2\n\t" // multiply + "paddsw %%mm2, %%mm0\n\t" // add to acc + : : "r"(m), "r"(s)); + ++matrix_x; ++m; ++s; + } + } + __asm__ __volatile__ + ("packuswb %%mm0, %%mm0\n\t" // pack and write + "movd %%mm0, (%0)\n\t" + : : "r"(dest)); + *dest = BlitzPrivate::setAlpha(*dest, qAlpha(*src++)); + ++dest; + } + // Okay, now process the middle part where the entire neighborhood + // is on the image. + for(; x+edge < w; ++x){ + m = matrix; + __asm__ __volatile__ + ("pxor %%mm0, %%mm0\n\t" : :); // clear acc + for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ + s = scanblock[matrix_y] + (x-edge); + for(matrix_x = -edge; matrix_x <= edge; ++matrix_x, ++m, ++s){ + __asm__ __volatile__ + ("movd (%0), %%mm1\n\t" // mm1: matrix + "punpckldq %%mm1, %%mm1\n\t" + "packssdw %%mm1, %%mm1\n\t" + "movd (%1), %%mm2\n\t" // mm2: pixel + "punpcklbw %%mm7, %%mm2\n\t" + "pmullw %%mm1, %%mm2\n\t" // multiply + "paddsw %%mm2, %%mm0\n\t" // add to acc + : : "r"(m), "r"(s)); + } + } + + __asm__ __volatile__ + ("packuswb %%mm0, %%mm0\n\t" // pack and write + "movd %%mm0, (%0)\n\t" + : : "r"(dest)); + *dest = BlitzPrivate::setAlpha(*dest, qAlpha(*src++)); + ++dest; + } + // Finally process the right part where the neighborhood extends off + // the right edge of the image + for(; x < w; ++x){ + m = matrix; + __asm__ __volatile__ + ("pxor %%mm0, %%mm0\n\t" : :); // clear acc + for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ + s = scanblock[matrix_y]; + s += x-edge; + matrix_x = -edge; + while(x+matrix_x < w){ + __asm__ __volatile__ + ("movd (%0), %%mm1\n\t" // mm1: matrix + "punpckldq %%mm1, %%mm1\n\t" + "packssdw %%mm1, %%mm1\n\t" + "movd (%1), %%mm2\n\t" // mm2: pixel + "punpcklbw %%mm7, %%mm2\n\t" + "pmullw %%mm1, %%mm2\n\t" // multiply + "paddsw %%mm2, %%mm0\n\t" // add to acc + : : "r"(m), "r"(s)); + ++matrix_x, ++m, ++s; + } + --s; + while(matrix_x <= edge){ + __asm__ __volatile__ + ("movd (%0), %%mm1\n\t" // mm1: matrix + "punpckldq %%mm1, %%mm1\n\t" + "packssdw %%mm1, %%mm1\n\t" + "movd (%1), %%mm2\n\t" // mm2: pixel + "punpcklbw %%mm7, %%mm2\n\t" + "pmullw %%mm1, %%mm2\n\t" // multiply + "paddsw %%mm2, %%mm0\n\t" // add to acc + : : "r"(m), "r"(s)); + ++matrix_x, ++m; + } + } + __asm__ __volatile__ + ("packuswb %%mm0, %%mm0\n\t" // pack and write + "movd %%mm0, (%0)\n\t" + : : "r"(dest)); + *dest = BlitzPrivate::setAlpha(*dest, qAlpha(*src++)); + ++dest; + } + } + __asm__ __volatile__ ("emms\n\t" : :); + } + else +#endif + { + // + // No divisor non-MMX version + // + int r, g, b; + for(y=0; y < h; ++y){ + src = (QRgb *)img.scanLine(y); + dest = (QRgb *)buffer.scanLine(y); + // Read in scanlines to pixel neighborhood. If the scanline is outside + // the image use the top or bottom edge. + for(x=y-edge, i=0; x <= y+edge; ++i, ++x){ + scanblock[i] = (QRgb *) + img.scanLine((x < 0) ? 0 : (x > h-1) ? h-1 : x); + } + // Now we are about to start processing scanlines. First handle the + // part where the pixel neighborhood extends off the left edge. + for(x=0; x-edge < 0 ; ++x){ + r = g = b = 0; + m = matrix; + for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ + s = scanblock[matrix_y]; + matrix_x = -edge; + while(x+matrix_x < 0){ + CONVOLVE_ACC(*m, *s); + ++matrix_x; ++m; + } + while(matrix_x <= edge){ + CONVOLVE_ACC(*m, *s); + ++matrix_x; ++m; ++s; + } + } + *dest++ = qRgba((unsigned char)qBound(0, r, 255), + (unsigned char)qBound(0, g, 255), + (unsigned char)qBound(0, b, 255), + qAlpha(*src++)); + } + // Okay, now process the middle part where the entire neighborhood + // is on the image. + for(; x+edge < w; ++x){ + r = g = b = 0; + m = matrix; + for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ + s = scanblock[matrix_y] + (x-edge); + for(matrix_x = -edge; matrix_x <= edge; ++matrix_x, ++m, ++s){ + CONVOLVE_ACC(*m, *s); + } + } + *dest++ = qRgba((unsigned char)qBound(0, r, 255), + (unsigned char)qBound(0, g, 255), + (unsigned char)qBound(0, b, 255), + qAlpha(*src++)); + } + // Finally process the right part where the neighborhood extends off + // the right edge of the image + for(; x < w; ++x){ + r = g = b = 0; + m = matrix; + for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ + s = scanblock[matrix_y]; + s += x-edge; + matrix_x = -edge; + while(x+matrix_x < w){ + CONVOLVE_ACC(*m, *s); + ++matrix_x, ++m, ++s; + } + --s; + while(matrix_x <= edge){ + CONVOLVE_ACC(*m, *s); + ++matrix_x, ++m; + } + } + *dest++ = qRgba((unsigned char)qBound(0, r, 255), + (unsigned char)qBound(0, g, 255), + (unsigned char)qBound(0, b, 255), + qAlpha(*src++)); + } + } + } + } + else{ +#ifdef USE_MMX_INLINE_ASM + // FIXME: TODO + if(/*BlitzCPUInfo::haveExtension(BlitzCPUInfo::AMD3DNOW)*/false){ + // + // Divisor 3dnow version + // + __asm__ __volatile__ + ("pxor %%mm7, %%mm7\n\t" : :); // clear for unpacking + + for(y=0; y < h; ++y){ + src = (QRgb *)img.scanLine(y); + dest = (QRgb *)buffer.scanLine(y); + // Read in scanlines to pixel neighborhood. If the scanline is outside + // the image use the top or bottom edge. + for(x=y-edge, i=0; x <= y+edge; ++i, ++x){ + scanblock[i] = (QRgb *) + img.scanLine((x < 0) ? 0 : (x > h-1) ? h-1 : x); + } + // Now we are about to start processing scanlines. First handle the + // part where the pixel neighborhood extends off the left edge. + for(x=0; x-edge < 0 ; ++x){ + m = matrix; + __asm__ __volatile__ + ("pxor %%mm0, %%mm0\n\t" : :); // clear acc + + for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ + s = scanblock[matrix_y]; + matrix_x = -edge; + while(x+matrix_x < 0){ + __asm__ __volatile__ + ("movd (%0), %%mm1\n\t" // mm1: matrix + "punpckldq %%mm1, %%mm1\n\t" + "packssdw %%mm1, %%mm1\n\t" + "movd (%1), %%mm2\n\t" // mm2: pixel + "punpcklbw %%mm7, %%mm2\n\t" + "pmullw %%mm1, %%mm2\n\t" // multiply + "paddsw %%mm2, %%mm0\n\t" // add to acc + : : "r"(m), "r"(s)); + ++matrix_x; ++m; + } + while(matrix_x <= edge){ + __asm__ __volatile__ + ("movd (%0), %%mm1\n\t" // mm1: matrix + "punpckldq %%mm1, %%mm1\n\t" + "packssdw %%mm1, %%mm1\n\t" + "movd (%1), %%mm2\n\t" // mm2: pixel + "punpcklbw %%mm7, %%mm2\n\t" + "pmullw %%mm1, %%mm2\n\t" // multiply + "paddsw %%mm2, %%mm0\n\t" // add to acc + : : "r"(m), "r"(s)); + ++matrix_x; ++m; ++s; + } + } + __asm__ __volatile__ + ("packuswb %%mm0, %%mm0\n\t" // pack and write + "movd %%mm0, (%0)\n\t" + : : "r"(dest)); + *dest = BlitzPrivate::setAlpha(*dest, qAlpha(*src++)); + ++dest; + } + // Okay, now process the middle part where the entire neighborhood + // is on the image. + for(; x+edge < w; ++x){ + m = matrix; + __asm__ __volatile__ + ("pxor %%mm0, %%mm0\n\t" : :); // clear acc + for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ + s = scanblock[matrix_y] + (x-edge); + for(matrix_x = -edge; matrix_x <= edge; ++matrix_x, ++m, ++s){ + __asm__ __volatile__ + ("movd (%0), %%mm1\n\t" // mm1: matrix + "punpckldq %%mm1, %%mm1\n\t" + "packssdw %%mm1, %%mm1\n\t" + "movd (%1), %%mm2\n\t" // mm2: pixel + "punpcklbw %%mm7, %%mm2\n\t" + "pmullw %%mm1, %%mm2\n\t" // multiply + "paddsw %%mm2, %%mm0\n\t" // add to acc + : : "r"(m), "r"(s)); + } + } + + __asm__ __volatile__ + ("packuswb %%mm0, %%mm0\n\t" // pack and write + "movd %%mm0, (%0)\n\t" + : : "r"(dest)); + *dest = BlitzPrivate::setAlpha(*dest, qAlpha(*src++)); + ++dest; + } + // Finally process the right part where the neighborhood extends off + // the right edge of the image + for(; x < w; ++x){ + m = matrix; + __asm__ __volatile__ + ("pxor %%mm0, %%mm0\n\t" : :); // clear acc + for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ + s = scanblock[matrix_y]; + s += x-edge; + matrix_x = -edge; + while(x+matrix_x < w){ + __asm__ __volatile__ + ("movd (%0), %%mm1\n\t" // mm1: matrix + "punpckldq %%mm1, %%mm1\n\t" + "packssdw %%mm1, %%mm1\n\t" + "movd (%1), %%mm2\n\t" // mm2: pixel + "punpcklbw %%mm7, %%mm2\n\t" + "pmullw %%mm1, %%mm2\n\t" // multiply + "paddsw %%mm2, %%mm0\n\t" // add to acc + : : "r"(m), "r"(s)); + ++matrix_x, ++m, ++s; + } + --s; + while(matrix_x <= edge){ + __asm__ __volatile__ + ("movd (%0), %%mm1\n\t" // mm1: matrix + "punpckldq %%mm1, %%mm1\n\t" + "packssdw %%mm1, %%mm1\n\t" + "movd (%1), %%mm2\n\t" // mm2: pixel + "punpcklbw %%mm7, %%mm2\n\t" + "pmullw %%mm1, %%mm2\n\t" // multiply + "paddsw %%mm2, %%mm0\n\t" // add to acc + : : "r"(m), "r"(s)); + ++matrix_x, ++m; + } + } + __asm__ __volatile__ + ("packuswb %%mm0, %%mm0\n\t" // pack and write + "movd %%mm0, (%0)\n\t" + : : "r"(dest)); + *dest = BlitzPrivate::setAlpha(*dest, qAlpha(*src++)); + ++dest; + } + } + __asm__ __volatile__ ("emms\n\t" : :); + } + else +#endif + { + // + // Divisor, no 3dnow + // + int r, g, b; + for(y=0; y < h; ++y){ + src = (QRgb *)img.scanLine(y); + dest = (QRgb *)buffer.scanLine(y); + // Read in scanlines to pixel neighborhood. If the scanline is outside + // the image use the top or bottom edge. + for(x=y-edge, i=0; x <= y+edge; ++i, ++x){ + scanblock[i] = (QRgb *) + img.scanLine((x < 0) ? 0 : (x > h-1) ? h-1 : x); + } + // Now we are about to start processing scanlines. First handle the + // part where the pixel neighborhood extends off the left edge. + for(x=0; x-edge < 0 ; ++x){ + r = g = b = 0; + m = matrix; + for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ + s = scanblock[matrix_y]; + matrix_x = -edge; + while(x+matrix_x < 0){ + CONVOLVE_ACC(*m, *s); + ++matrix_x; ++m; + } + while(matrix_x <= edge){ + CONVOLVE_ACC(*m, *s); + ++matrix_x; ++m; ++s; + } + } + r /= divisor; g /= divisor; b /= divisor; + *dest++ = qRgba((unsigned char)qBound(0, r, 255), + (unsigned char)qBound(0, g, 255), + (unsigned char)qBound(0, b, 255), + qAlpha(*src++)); + } + // Okay, now process the middle part where the entire neighborhood + // is on the image. + for(; x+edge < w; ++x){ + r = g = b = 0; + m = matrix; + for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ + s = scanblock[matrix_y] + (x-edge); + for(matrix_x = -edge; matrix_x <= edge; ++matrix_x, ++m, ++s){ + CONVOLVE_ACC(*m, *s); + } + } + r /= divisor; g /= divisor; b /= divisor; + *dest++ = qRgba((unsigned char)qBound(0, r, 255), + (unsigned char)qBound(0, g, 255), + (unsigned char)qBound(0, b, 255), + qAlpha(*src++)); + } + // Finally process the right part where the neighborhood extends off + // the right edge of the image + for(; x < w; ++x){ + r = g = b = 0; + m = matrix; + for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ + s = scanblock[matrix_y]; + s += x-edge; + matrix_x = -edge; + while(x+matrix_x < w){ + CONVOLVE_ACC(*m, *s); + ++matrix_x, ++m, ++s; + } + --s; + while(matrix_x <= edge){ + CONVOLVE_ACC(*m, *s); + ++matrix_x, ++m; + } + } + r /= divisor; g /= divisor; b /= divisor; + *dest++ = qRgba((unsigned char)qBound(0, r, 255), + (unsigned char)qBound(0, g, 255), + (unsigned char)qBound(0, b, 255), + qAlpha(*src++)); + } + } + } + } + + delete[] scanblock; + return(buffer); +} + +int BlitzPrivate::defaultConvolveMatrixSize(float radius, float sigma, + bool quality) +{ + int i, matrix_size; + float normalize, value; + float sigma2 = sigma*sigma*2.0; + float sigmaSQ2PI = M_SQ2PI*sigma; + int max = quality ? 65535 : 255; + + if(sigma == 0.0){ + qWarning("Blitz::convolve(): Zero sigma is invalid!"); + return(5); + } + + if(radius > 0.0) + return((int)(2.0*std::ceil(radius)+1.0)); + + matrix_size = 5; + do{ + normalize = 0.0; + for(i=(-matrix_size/2); i <= (matrix_size/2); ++i) + normalize += std::exp(-((float) i*i)/sigma2) / sigmaSQ2PI; + i = matrix_size/2; + value = std::exp(-((float) i*i)/sigma2) / sigmaSQ2PI / normalize; + matrix_size += 2; + } while((int)(max*value) > 0); + + matrix_size-=4; + return(matrix_size); +} + +float* BlitzPrivate::getBlurKernel(int &kernel_width, float sigma) +{ +#define KernelRank 3 + + float alpha, normalize, *kernel; + int bias; + long i; + + if(sigma == 0.0) + return(false); + if(kernel_width == 0) + kernel_width = 3; + + kernel = new float[kernel_width+1]; + memset(kernel, 0, (kernel_width+1)*sizeof(float)); + bias = KernelRank*kernel_width/2; + for(i=(-bias); i <= bias; ++i){ + alpha = std::exp(-((float) i*i)/(2.0*KernelRank*KernelRank*sigma*sigma)); + kernel[(i+bias)/KernelRank] += alpha/(M_SQ2PI*sigma); + } + + normalize = 0; + for(i=0; i < kernel_width; ++i) + normalize += kernel[i]; + for(i=0; i < kernel_width; ++i) + kernel[i] /= normalize; + return(kernel); +} + +void BlitzPrivate::blurScanLine(float *kernel, int kern_width, + QRgb *source, QRgb *destination, + int columns, int offset) +{ + FloatPixel aggregate, zero; + float scale, *k; + QRgb *src, *dest; + int i, x; + +#ifdef USE_MMX_INLINE_ASM +#ifdef __GNUC__ +#warning Using MMX gaussian blur +#endif + // + // + // MMX Version + // + // + + if(BlitzCPUInfo::haveExtension(BlitzCPUInfo::AMD3DNOW) && + BlitzCPUInfo::haveExtension(BlitzCPUInfo::IntegerSSE)){ + if(kern_width > columns){ + memset(&zero, 0, sizeof(FloatPixel)); + for(dest=destination, x=0; x < columns; ++x, dest+=offset){ + aggregate = zero; + scale = 0.0; + k = kernel; + src = source; + for(i=0; i < columns; ++k, src+=offset){ + if((i >= (x-kern_width/2)) && (i <= (x+kern_width/2))){ + aggregate.red += (*k)*qRed(*src); + aggregate.green += (*k)*qGreen(*src); + aggregate.blue += (*k)*qBlue(*src); + aggregate.alpha += (*k)*qAlpha(*src); + } + + if(((i+kern_width/2-x) >= 0) && ((i+kern_width/2-x) < kern_width)) + scale += kernel[i+kern_width/2-x]; + } + scale = 1.0/scale; + *dest = qRgba((unsigned char)(scale*(aggregate.red+0.5)), + (unsigned char)(scale*(aggregate.green+0.5)), + (unsigned char)(scale*(aggregate.blue+0.5)), + (unsigned char)(scale*(aggregate.alpha+0.5))); + } + return; + } + + // blur + __asm__ __volatile__ ("pxor %%mm7, %%mm7\n\t" : : ); // for unpacking + for(dest=destination, x=0; x < kern_width/2; ++x, dest+=offset){ + k = kernel+kern_width/2-x; + src = source; + __asm__ __volatile__ ("pxor %%mm0, %%mm0\n\t" // mm0: BG acc + "pxor %%mm1, %%mm1\n\t" // mm1: RA acc + "pxor %%mm6, %%mm6\n\t" // mm6: scale + : : ); + for(i=kern_width/2-x; i < kern_width; ++i, ++k, src+=offset){ + __asm__ __volatile__ + ("movd (%0), %%mm2\n\t" // mm2: k doubleword + "punpckldq %%mm2, %%mm2\n\t" + "pfadd %%mm2, %%mm6\n\t" // add to scale + + "movd (%1), %%mm3\n\t" // load pixel + "punpcklbw %%mm7, %%mm3\n\t" + "pshufw $0xE4, %%mm3, %%mm4\n\t" + "punpcklwd %%mm7, %%mm3\n\t" // mm3: BG + "punpckhwd %%mm7, %%mm4\n\t" // mm4: RA + + "pi2fd %%mm3, %%mm3\n\t" // convert to fp... + "pi2fd %%mm4, %%mm4\n\t" + "pfmul %%mm2, %%mm3\n\t" // ...and multiply + "pfmul %%mm2, %%mm4\n\t" + + "pfadd %%mm3, %%mm0\n\t" // add to accumulator + "pfadd %%mm4, %%mm1\n\t" + : : "r"(k), "r"(src)); + } + __asm__ __volatile__ + ("pfrcp %%mm6, %%mm5\n\t" // reciprocal + "pfrcpit1 %%mm5, %%mm6\n\t" // expand to 24bit + "pfrcpit2 %%mm5, %%mm6\n\t" + + "pfmul %%mm6, %%mm0\n\t" // multiply + "pfmul %%mm6, %%mm1\n\t" + + "pf2id %%mm0, %%mm0\n\t" // and write + "pf2id %%mm1, %%mm1\n\t" + "packssdw %%mm0, %%mm1\n\t" + "pshufw $0x4E, %%mm1, %%mm1\n\t" + "packuswb %%mm7, %%mm1\n\t" + "movd %%mm1, (%0)\n\t" + : : "r"(dest)); + } + for(; x < (columns-kern_width/2); ++x, dest+=offset){ + __asm__ __volatile__ ("pxor %%mm0, %%mm0\n\t" // mm0: BG acc + "pxor %%mm1, %%mm1\n\t" // mm1: RA acc + : : ); + k = kernel; + src = source+((x-kern_width/2)*offset); + for(i=0; i < kern_width; ++i, ++k, src+=offset){ + __asm__ __volatile__ + ("movd (%0), %%mm2\n\t" // mm2: k doubleword + "punpckldq %%mm2, %%mm2\n\t" + + "movd (%1), %%mm3\n\t" // load pixel + "punpcklbw %%mm7, %%mm3\n\t" + "pshufw $0xE4, %%mm3, %%mm4\n\t" + "punpcklwd %%mm7, %%mm3\n\t" // mm3: BG + "punpckhwd %%mm7, %%mm4\n\t" // mm4: RA + + "pi2fd %%mm3, %%mm3\n\t" // convert to fp... + "pi2fd %%mm4, %%mm4\n\t" + "pfmul %%mm2, %%mm3\n\t" // ...and multiply + "pfmul %%mm2, %%mm4\n\t" + + "pfadd %%mm3, %%mm0\n\t" // add to accumulator + "pfadd %%mm4, %%mm1\n\t" + : : "r"(k), "r"(src)); + } + __asm__ __volatile__ + ("pf2id %%mm0, %%mm0\n\t" // write + "pf2id %%mm1, %%mm1\n\t" + "packssdw %%mm0, %%mm1\n\t" + "pshufw $0x4E, %%mm1, %%mm1\n\t" + "packuswb %%mm7, %%mm1\n\t" + "movd %%mm1, (%0)\n\t" + : : "r"(dest)); + } + for(; x < columns; ++x, dest+=offset){ + k = kernel; + src = source+((x-kern_width/2)*offset); + __asm__ __volatile__ ("pxor %%mm0, %%mm0\n\t" // mm0: BG acc + "pxor %%mm1, %%mm1\n\t" // mm1: RA acc + "pxor %%mm6, %%mm6\n\t" // mm6: scale + : : ); + for(i=0; i < (columns-x+kern_width/2); ++i, ++k, src+=offset){ + __asm__ __volatile__ + ("movd (%0), %%mm2\n\t" // mm2: k doubleword + "punpckldq %%mm2, %%mm2\n\t" + "pfadd %%mm2, %%mm6\n\t" // add to scale + + "movd (%1), %%mm3\n\t" // load pixel + "punpcklbw %%mm7, %%mm3\n\t" + "pshufw $0xE4, %%mm3, %%mm4\n\t" + "punpcklwd %%mm7, %%mm3\n\t" // mm3: BG + "punpckhwd %%mm7, %%mm4\n\t" // mm4: RA + + "pi2fd %%mm3, %%mm3\n\t" // convert to fp... + "pi2fd %%mm4, %%mm4\n\t" + "pfmul %%mm2, %%mm3\n\t" // ...and multiply + "pfmul %%mm2, %%mm4\n\t" + + "pfadd %%mm3, %%mm0\n\t" // add to accumulator + "pfadd %%mm4, %%mm1\n\t" + : : "r"(k), "r"(src)); + } + __asm__ __volatile__ + ("pfrcp %%mm6, %%mm5\n\t" // reciprocal + "pfrcpit1 %%mm5, %%mm6\n\t" // expand to 24bit + "pfrcpit2 %%mm5, %%mm6\n\t" + + "pfmul %%mm6, %%mm0\n\t" // multiply + "pfmul %%mm6, %%mm1\n\t" + + "pf2id %%mm0, %%mm0\n\t" // and write + "pf2id %%mm1, %%mm1\n\t" + "packssdw %%mm0, %%mm1\n\t" + "pshufw $0x4E, %%mm1, %%mm1\n\t" + "packuswb %%mm7, %%mm1\n\t" + "movd %%mm1, (%0)\n\t" + : : "r"(dest)); + } + + __asm__ __volatile__ ("emms\n\t" : :); + } + else +#endif + { + // + // + // Non-MMX version + // + // + + memset(&zero, 0, sizeof(FloatPixel)); + if(kern_width > columns){ + for(dest=destination, x=0; x < columns; ++x, dest+=offset){ + aggregate = zero; + scale = 0.0; + k = kernel; + src = source; + for(i=0; i < columns; ++k, src+=offset){ + if((i >= (x-kern_width/2)) && (i <= (x+kern_width/2))){ + aggregate.red += (*k)*qRed(*src); + aggregate.green += (*k)*qGreen(*src); + aggregate.blue += (*k)*qBlue(*src); + aggregate.alpha += (*k)*qAlpha(*src); + } + + if(((i+kern_width/2-x) >= 0) && ((i+kern_width/2-x) < kern_width)) + scale += kernel[i+kern_width/2-x]; + } + scale = 1.0/scale; + *dest = qRgba((unsigned char)(scale*(aggregate.red+0.5)), + (unsigned char)(scale*(aggregate.green+0.5)), + (unsigned char)(scale*(aggregate.blue+0.5)), + (unsigned char)(scale*(aggregate.alpha+0.5))); + } + return; + } + + // blur + for(dest=destination, x=0; x < kern_width/2; ++x, dest+=offset){ + aggregate = zero; // put this stuff in loop initializer once tested + scale = 0.0; + k = kernel+kern_width/2-x; + src = source; + for(i=kern_width/2-x; i < kern_width; ++i, ++k, src+=offset){ + aggregate.red += (*k)*qRed(*src); + aggregate.green += (*k)*qGreen(*src); + aggregate.blue += (*k)*qBlue(*src); + aggregate.alpha += (*k)*qAlpha(*src); + scale += (*k); + } + scale = 1.0/scale; + *dest = qRgba((unsigned char)(scale*(aggregate.red+0.5)), + (unsigned char)(scale*(aggregate.green+0.5)), + (unsigned char)(scale*(aggregate.blue+0.5)), + (unsigned char)(scale*(aggregate.alpha+0.5))); + } + for(; x < (columns-kern_width/2); ++x, dest+=offset){ + aggregate = zero; + k = kernel; + src = source+((x-kern_width/2)*offset); + for(i=0; i < kern_width; ++i, ++k, src+=offset){ + aggregate.red += (*k)*qRed(*src); + aggregate.green += (*k)*qGreen(*src); + aggregate.blue += (*k)*qBlue(*src); + aggregate.alpha += (*k)*qAlpha(*src); + } + *dest = qRgba((unsigned char)(aggregate.red+0.5), + (unsigned char)(aggregate.green+0.5), + (unsigned char)(aggregate.blue+0.5), + (unsigned char)(aggregate.alpha+0.5)); + } + for(; x < columns; ++x, dest+=offset){ + aggregate = zero; + scale = 0; + k = kernel; + src = source+((x-kern_width/2)*offset); + for(i=0; i < (columns-x+kern_width/2); ++i, ++k, src+=offset){ + aggregate.red += (*k)*qRed(*src); + aggregate.green += (*k)*qGreen(*src); + aggregate.blue += (*k)*qBlue(*src); + aggregate.alpha += (*k)*qAlpha(*src); + scale += (*k); + } + scale = 1.0/scale; + *dest = qRgba((unsigned char)(scale*(aggregate.red+0.5)), + (unsigned char)(scale*(aggregate.green+0.5)), + (unsigned char)(scale*(aggregate.blue+0.5)), + (unsigned char)(scale*(aggregate.alpha+0.5))); + } + } +} + +QImage Blitz::gaussianBlur(QImage &img, float radius, float sigma) +{ + int kern_width, x, y, w, h; + QRgb *src; + float *k = NULL; + + if(sigma == 0.0){ + qWarning("Blitz::gaussianBlur(): Zero sigma is not valid!"); + return(img); + } + + // figure out optimal kernel width + if(radius > 0){ + kern_width = (int)(2*std::ceil(radius)+1); + k = BlitzPrivate::getBlurKernel(kern_width, sigma); + } + else{ + float *last_kernel = NULL; + kern_width = 3; + k = BlitzPrivate::getBlurKernel(kern_width, sigma); + while((long)(255*k[0]) > 0){ + if(last_kernel != NULL) + delete[] last_kernel; + last_kernel = k; + kern_width += 2; + k = BlitzPrivate::getBlurKernel(kern_width, sigma); + } + if(last_kernel != NULL){ + delete[] k; + kern_width -= 2; + k = last_kernel; + } + } + + if(kern_width < 3){ + qWarning("Blitz::gaussianBlur(): radius is too small!"); + return(img); + } + + // allocate destination image + w = img.width(); + h = img.height(); + if(img.format() == QImage::Format_ARGB32_Premultiplied) + img = img.convertToFormat(QImage::Format_ARGB32); + else if(img.depth() < 32){ + img = img.convertToFormat(img.hasAlphaChannel() ? + QImage::Format_ARGB32 : + QImage::Format_RGB32); + } + QImage buffer(w, h, img.format()); + + //blur image rows + for(y=0; y < h; ++y) + BlitzPrivate::blurScanLine(k, kern_width, (QRgb *)img.scanLine(y), + (QRgb *)buffer.scanLine(y), img.width(), 1); + + // blur image columns + src = (QRgb *)buffer.scanLine(0); + for(x=0; x < w; ++x) + BlitzPrivate::blurScanLine(k, kern_width, src+x, src+x, img.height(), + img.width()); + // finish up + delete[] k; + return(buffer); +} + +QImage Blitz::gaussianSharpen(QImage &img, float radius, float sigma, + EffectQuality quality) +{ + if(sigma == 0.0){ + qWarning("Blitz::gaussianSharpen(): Zero sigma is invalid!"); + return(img); + } + + int matrix_size = BlitzPrivate::defaultConvolveMatrixSize(radius, sigma, + quality == High); + int len = matrix_size*matrix_size; + float alpha, *matrix = new float[len]; + float sigma2 = sigma*sigma*2.0; + float sigmaPI2 = 2.0*M_PI*sigma*sigma; + + int half = matrix_size/2; + int x, y, i=0, j=half; + float normalize=0.0; + for(y=(-half); y <= half; ++y, --j){ + for(x=(-half); x <= half; ++x, ++i){ + alpha = std::exp(-((float)x*x+y*y)/sigma2); + matrix[i] = alpha/sigmaPI2; + normalize += matrix[i]; + } + } + + matrix[i/2]=(-2.0)*normalize; + QImage result(convolve(img, matrix_size, matrix)); + delete[] matrix; + return(result); +} + +QImage Blitz::antialias(QImage &img) +{ + // nice little example method + int matrix[] = { + 1, 2, 1, + 2, 8, 2, + 1, 2, 1 + }; + return(convolveInteger(img, 3, matrix, 20)); +} + +QImage Blitz::emboss(QImage &img, float radius, float sigma, + EffectQuality quality) +{ + if(sigma == 0.0){ + qWarning("Blitz::emboss(): Zero sigma is invalid!"); + return(img); + } + + int matrix_size = BlitzPrivate::defaultConvolveMatrixSize(radius, sigma, + quality == High); + int len = matrix_size*matrix_size; + + float alpha, *matrix = new float[len]; + float sigma2 = sigma*sigma*2.0; + float sigmaPI2 = 2.0*M_PI*sigma*sigma; + + int half = matrix_size/2; + int x, y, i=0, j=half; + for(y=(-half); y <= half; ++y, --j){ + for(x=(-half); x <= half; ++x, ++i){ + alpha = std::exp(-((float)x*x+y*y)/sigma2); + matrix[i]=((x < 0) || (y < 0) ? -8.0 : 8.0)*alpha/sigmaPI2; + if(x == j) + matrix[i]=0.0; + } + } + QImage result(convolve(img, matrix_size, matrix)); + delete[] matrix; + equalize(result); + return(result); +} + +QImage Blitz::convolveEdge(QImage &img, float radius, + EffectQuality quality) +{ + int i, matrix_size = BlitzPrivate::defaultConvolveMatrixSize(radius, 0.5, + quality == High); + int len = matrix_size*matrix_size; + int *matrix = new int[len]; + for(i=0; i < len; ++i) + matrix[i] = -1; + matrix[i/2] = len-1; + + QImage result(convolveInteger(img, matrix_size, matrix, 0)); + delete[] matrix; + return(result); +} + + diff -Nru syncwall-1.6.0/src/3rdparty/qimageblitz/gradient.cpp syncwall-1.7.4/src/3rdparty/qimageblitz/gradient.cpp --- syncwall-1.6.0/src/3rdparty/qimageblitz/gradient.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qimageblitz/gradient.cpp 2008-02-26 19:31:00.000000000 +0000 @@ -0,0 +1,602 @@ +/* + Copyright (C) 1998, 1999, 2001, 2002, 2004, 2005, 2007 + Daniel M. Duley + (C) 2004 Zack Rusin + (C) 2000 Josef Weidendorfer + (C) 1999 Geert Jansen + (C) 1998, 1999 Christian Tibirna + (C) 1998, 1999 Dirk Mueller + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* + Diagonal gradient code was inspired by BlackBox. BlackBox gradients are + (C) Brad Hughes, and Mike Cole . + */ + +#define _USE_MATH_DEFINES // for msvc + +#include "qimageblitz.h" +#include +#include +#include + +QImage Blitz::gradient(const QSize &size, const QColor &ca, + const QColor &cb, GradientType eff) +{ + QImage image(size, QImage::Format_RGB32); + if(!size.isValid()) + return(image); + + int rca, gca, bca, rcb, gcb, bcb; + int rDiff = (rcb = cb.red()) - (rca = ca.red()); + int gDiff = (gcb = cb.green()) - (gca = ca.green()); + int bDiff = (bcb = cb.blue()) - (bca = ca.blue()); + int x, y; + QRgb rgb; + + if(eff == VerticalGradient || eff == HorizontalGradient){ + register int rl = rca << 16; + register int gl = gca << 16; + register int bl = bca << 16; + QRgb *p; + if(eff == VerticalGradient){ + int rcdelta = ((1<<16) / size.height()) * rDiff; + int gcdelta = ((1<<16) / size.height()) * gDiff; + int bcdelta = ((1<<16) / size.height()) * bDiff; + for(y=0; y < size.height(); ++y){ + rl += rcdelta; + gl += gcdelta; + bl += bcdelta; + rgb = qRgb( (rl>>16), (gl>>16), (bl>>16) ); + + p = (QRgb *)image.scanLine(y); + for(x = 0; x < size.width(); ++x) + *p++ = rgb; + } + } + else{ // must be HorizontalGradient + int rcdelta = ((1<<16) / size.width()) * rDiff; + int gcdelta = ((1<<16) / size.width()) * gDiff; + int bcdelta = ((1<<16) / size.width()) * bDiff; + p = (QRgb *)image.scanLine(0); + for(x = 0; x < size.width(); ++x){ + rl += rcdelta; + gl += gcdelta; + bl += bcdelta; + *p++ = qRgb((rl>>16), (gl>>16), (bl>>16)); + } + p = (QRgb *)image.scanLine(0); + for(y = 1; y < size.height(); ++y) + memcpy(image.scanLine(y), p, size.width()*sizeof(QRgb)); + } + } + else{ + float rfd, gfd, bfd; + float rd = rca, gd = gca, bd = bca; + + int w = size.width(), h = size.height(); + int dw = w*2, dh = h*2; + unsigned char *xtable = new unsigned char[w*3]; + unsigned char *ytable = new unsigned char[h*3]; + + if(eff == DiagonalGradient || eff == CrossDiagonalGradient){ + rfd = (float)rDiff/dw; + gfd = (float)gDiff/dw; + bfd = (float)bDiff/dw; + + int dir; + for(x=0; x < w; x++, rd+=rfd, gd+=gfd, bd+=bfd) { + dir = eff == DiagonalGradient? x : w - x - 1; + xtable[dir*3] = (unsigned char) rd; + xtable[dir*3+1] = (unsigned char) gd; + xtable[dir*3+2] = (unsigned char) bd; + } + rfd = (float)rDiff/dh; + gfd = (float)gDiff/dh; + bfd = (float)bDiff/dh; + rd = gd = bd = 0; + for(y = 0; y < h; y++, rd+=rfd, gd+=gfd, bd+=bfd){ + ytable[y*3] = (unsigned char) rd; + ytable[y*3+1] = (unsigned char) gd; + ytable[y*3+2] = (unsigned char) bd; + } + + for(y = 0; y < h; y++){ + QRgb *p = (QRgb *)image.scanLine(y); + for(x = 0; x < w; x++){ + *p++ = qRgb(xtable[x*3] + ytable[y*3], + xtable[x*3+1] + ytable[y*3+1], + xtable[x*3+2] + ytable[y*3+2]); + } + } + } + else{ + int rSign = rDiff>0? 1: -1; + int gSign = gDiff>0? 1: -1; + int bSign = bDiff>0? 1: -1; + + rfd = (float)rDiff/w; + gfd = (float)gDiff/w; + bfd = (float)bDiff/w; + + rd = (float)rDiff/2; + gd = (float)gDiff/2; + bd = (float)bDiff/2; + + for(x=0; x < w; x++, rd-=rfd, gd-=gfd, bd-=bfd){ + xtable[x*3] = (unsigned char) qAbs((int)rd); + xtable[x*3+1] = (unsigned char) qAbs((int)gd); + xtable[x*3+2] = (unsigned char) qAbs((int)bd); + } + + rfd = (float)rDiff/h; + gfd = (float)gDiff/h; + bfd = (float)bDiff/h; + + rd = (float)rDiff/2; + gd = (float)gDiff/2; + bd = (float)bDiff/2; + + for(y=0; y < h; y++, rd-=rfd, gd-=gfd, bd-=bfd){ + ytable[y*3] = (unsigned char) qAbs((int)rd); + ytable[y*3+1] = (unsigned char) qAbs((int)gd); + ytable[y*3+2] = (unsigned char) qAbs((int)bd); + } + + dw = (w+1)>>1; + dh = (h+1)>>1; + int x2; + QRgb *sl1, *sl2; + for(y = 0; y < dh; y++){ + sl1 = (QRgb *)image.scanLine(y); + sl2 = (QRgb *)image.scanLine(qMax(h-y-1, y)); + for(x = 0, x2 = w-1; x < dw; x++, x2--){ + switch(eff){ + case PyramidGradient: + rgb = qRgb(rcb-rSign*(xtable[x*3]+ytable[y*3]), + gcb-gSign*(xtable[x*3+1]+ytable[y*3+1]), + bcb-bSign*(xtable[x*3+2]+ytable[y*3+2])); + break; + case RectangleGradient: + rgb = qRgb(rcb - rSign * + qMax(xtable[x*3], ytable[y*3]) * 2, + gcb - gSign * + qMax(xtable[x*3+1], ytable[y*3+1]) * 2, + bcb - bSign * + qMax(xtable[x*3+2], ytable[y*3+2]) * 2); + break; + case PipeCrossGradient: + rgb = qRgb(rcb - rSign * + qMin(xtable[x*3], ytable[y*3]) * 2, + gcb - gSign * + qMin(xtable[x*3+1], ytable[y*3+1]) * 2, + bcb - bSign * + qMin(xtable[x*3+2], ytable[y*3+2]) * 2); + break; + case EllipticGradient: + default: + rgb = qRgb(rcb - rSign * + (int)std::sqrt((xtable[x*3]*xtable[x*3] + + ytable[y*3]*ytable[y*3])*2.0f), + gcb - gSign * + (int)std::sqrt((xtable[x*3+1]*xtable[x*3+1] + + ytable[y*3+1]*ytable[y*3+1])*2.0f), + bcb - bSign * + (int)std::sqrt((xtable[x*3+2]*xtable[x*3+2] + + ytable[y*3+2]*ytable[y*3+2])*2.0f)); + break; + } + sl1[x] = sl2[x] = rgb; + sl1[x2] = sl2[x2] = rgb; + } + } + } + delete [] xtable; + delete [] ytable; + } + return(image); +} + +QImage Blitz::grayGradient(const QSize &size, unsigned char ca, + unsigned char cb, GradientType eff) +{ + QImage image(size, QImage::Format_Indexed8); + if(!size.isValid()) + return(image); + QVector colorTable(256); + for(int i=0; i < 256; ++i) + colorTable[i] = qRgba(i, i, i, 255); + image.setColorTable(colorTable); + + int diff = cb - ca; + int x, y; + unsigned char idx; + + if(eff == VerticalGradient || eff == HorizontalGradient){ + register int val = ca << 16; + unsigned char *p; + if(eff == VerticalGradient){ + int delta = ((1<<16) / size.height()) * diff; + for(y=0; y < size.height(); ++y){ + val += delta; + idx = val >> 16; + p = image.scanLine(y); + for(x = 0; x < size.width(); ++x) + *p++ = idx; + } + } + else{ // must be HorizontalGradient + int delta = ((1<<16) / size.width()) * diff; + p = image.scanLine(0); + for(x = 0; x < size.width(); ++x){ + val += delta; + *p++ = val >> 16; + } + p = image.scanLine(0); + for(y = 1; y < size.height(); ++y) + memcpy(image.scanLine(y), p, image.bytesPerLine()); + } + } + else{ + float delta, val=ca; + + unsigned int w = size.width(), h = size.height(); + unsigned char *xtable = new unsigned char[w]; + unsigned char *ytable = new unsigned char[h]; + w*=2, h*=2; + + if(eff == DiagonalGradient || eff == CrossDiagonalGradient){ + delta = (float)diff/w; + int dir; + for(x=0; x < size.width(); x++, val+=delta){ + dir = eff == DiagonalGradient? x : size.width() - x - 1; + xtable[dir] = (unsigned char) val; + } + delta = (float)diff/h; + val = 0; + for(y = 0; y < size.height(); y++, val+=delta) + ytable[y] = (unsigned char) val; + + for(y = 0; y < size.height(); y++){ + unsigned char *p = image.scanLine(y); + for(x = 0; x < size.width(); x++) + *p++ = xtable[x] + ytable[y]; + } + } + else{ + int sign = diff>0? 1: -1; + delta = (float)diff / size.width(); + val = (float)diff/2; + for(x=0; x < size.width(); x++, val-=delta) + xtable[x] = (unsigned char) qAbs((int)val); + + delta = (float)diff/size.height(); + val = (float)diff/2; + for(y=0; y < size.height(); y++, val-=delta) + ytable[y] = (unsigned char) qAbs((int)val); + + int w = (size.width()+1)>>1; + int h = (size.height()+1)>>1; + int x2; + unsigned char *sl1, *sl2; + for(y = 0; y < h; y++){ + sl1 = image.scanLine(y); + sl2 = image.scanLine(qMax(size.height()-y-1, y)); + for(x = 0, x2 = size.width()-1; x < w; x++, x2--){ + switch(eff){ + case PyramidGradient: + idx = cb-sign*(xtable[x]+ytable[y]); + break; + case RectangleGradient: + idx = cb-sign*qMax(xtable[x], ytable[y])*2; + break; + case PipeCrossGradient: + idx = cb-sign*qMin(xtable[x], ytable[y])*2; + break; + case EllipticGradient: + default: + idx = cb - sign * + (int)std::sqrt((xtable[x]*xtable[x] + + ytable[y]*ytable[y])*2.0f); + break; + } + sl1[x] = sl2[x] = idx; + sl1[x2] = sl2[x2] = idx; + } + } + } + delete [] xtable; + delete [] ytable; + } + return(image); +} + +QImage Blitz::unbalancedGradient(const QSize &size, const QColor &ca, + const QColor &cb, GradientType eff, + int xfactor, int yfactor) +{ + QImage image(size, QImage::Format_RGB32); + if(!size.isValid()) + return image; + + int dir; // general parameter used for direction switches + bool _xanti = (xfactor < 0); // negative on X direction + bool _yanti = (yfactor < 0); // negative on Y direction + xfactor = qBound(1, qAbs(xfactor), 200); + yfactor = qBound(1, qAbs(yfactor), 200); + // float xbal = xfactor/5000.; + // float ybal = yfactor/5000.; + float xbal = xfactor/30.0f/size.width(); + float ybal = yfactor/30.0f/size.height(); + float rat; + + register int x, y; + int rca, gca, bca, rcb, gcb, bcb; + int rDiff = (rcb = cb.red()) - (rca = ca.red()); + int gDiff = (gcb = cb.green()) - (gca = ca.green()); + int bDiff = (bcb = cb.blue()) - (bca = ca.blue()); + + if(eff == VerticalGradient || eff == HorizontalGradient){ + QRgb *p; + if(eff == VerticalGradient){ + QRgb rgbRow; + for(y=0; y < size.height(); y++){ + dir = _yanti ? y : size.height() - 1 - y; + rat = 1 - std::exp( - (float)y * ybal ); + p = (QRgb *) image.scanLine(dir); + rgbRow = qRgb(rcb - (int) ( rDiff * rat ), + gcb - (int) ( gDiff * rat ), + bcb - (int) ( bDiff * rat )); + for(x = 0; x < size.width(); x++) + *p++ = rgbRow; + } + } + else{ + p = (QRgb *)image.scanLine(0); + for(x = 0; x < size.width(); x++){ + dir = _xanti ? x : size.width() - 1 - x; + rat = 1 - std::exp( - (float)x * xbal ); + p[dir] = qRgb(rcb - (int) ( rDiff * rat ), + gcb - (int) ( gDiff * rat ), + bcb - (int) ( bDiff * rat )); + } + + p = (QRgb *)image.scanLine(0); + for(y = 1; y < size.height(); ++y){ + memcpy(image.scanLine(y), p, + size.width()*sizeof(QRgb)); + } + } + } + else{ + int w=size.width(), h=size.height(); + unsigned char *xtable = new unsigned char[w*3]; + unsigned char *ytable = new unsigned char[h*3]; + QRgb *p; + + if(eff == DiagonalGradient || eff == CrossDiagonalGradient){ + for(x = 0; x < w; x++){ + dir = _xanti ? x : w - 1 - x; + rat = 1 - std::exp( - (float)x * xbal ); + + xtable[dir*3] = (unsigned char) ( rDiff/2 * rat ); + xtable[dir*3+1] = (unsigned char) ( gDiff/2 * rat ); + xtable[dir*3+2] = (unsigned char) ( bDiff/2 * rat ); + } + + for(y = 0; y < h; y++){ + dir = _yanti ? y : h - 1 - y; + rat = 1 - std::exp( - (float)y * ybal ); + + ytable[dir*3] = (unsigned char) ( rDiff/2 * rat ); + ytable[dir*3+1] = (unsigned char) ( gDiff/2 * rat ); + ytable[dir*3+2] = (unsigned char) ( bDiff/2 * rat ); + } + + for(y = 0; y < h; y++){ + p = (QRgb *)image.scanLine(y); + for(x = 0; x < w; x++){ + *p++ = qRgb(rcb - (xtable[x*3] + ytable[y*3]), + gcb - (xtable[x*3+1] + ytable[y*3+1]), + bcb - (xtable[x*3+2] + ytable[y*3+2])); + } + } + } + else{ + int rSign = rDiff>0? 1: -1; + int gSign = gDiff>0? 1: -1; + int bSign = bDiff>0? 1: -1; + + for(x = 0; x < w; x++){ + dir = _xanti ? x : w - 1 - x; + rat = 1 - std::exp( - (float)x * xbal ); + + xtable[dir*3] = (unsigned char) qAbs((int)(rDiff*(0.5-rat))); + xtable[dir*3+1] = (unsigned char) qAbs((int)(gDiff*(0.5-rat))); + xtable[dir*3+2] = (unsigned char) qAbs((int)(bDiff*(0.5-rat))); + } + + for(y = 0; y < h; y++){ + dir = _yanti ? y : h - 1 - y; + rat = 1 - std::exp( - (float)y * ybal ); + + ytable[dir*3] = (unsigned char) qAbs((int)(rDiff*(0.5-rat))); + ytable[dir*3+1] = (unsigned char) qAbs((int)(gDiff*(0.5-rat))); + ytable[dir*3+2] = (unsigned char) qAbs((int)(bDiff*(0.5-rat))); + } + + for(y = 0; y < h; y++){ + p = (QRgb *)image.scanLine(y); + for(x = 0; x < w; x++) { + if (eff == PyramidGradient){ + *p++ = qRgb(rcb-rSign*(xtable[x*3]+ytable[y*3]), + gcb-gSign*(xtable[x*3+1]+ytable[y*3+1]), + bcb-bSign*(xtable[x*3+2]+ytable[y*3+2])); + } + else if (eff == RectangleGradient){ + *p++ = qRgb(rcb - rSign * + qMax(xtable[x*3], ytable[y*3]) * 2, + gcb - gSign * + qMax(xtable[x*3+1], ytable[y*3+1]) * 2, + bcb - bSign * + qMax(xtable[x*3+2], ytable[y*3+2]) * 2); + } + else if (eff == PipeCrossGradient){ + *p++ = qRgb(rcb - rSign * + qMin(xtable[x*3], ytable[y*3]) * 2, + gcb - gSign * + qMin(xtable[x*3+1], ytable[y*3+1]) * 2, + bcb - bSign * + qMin(xtable[x*3+2], ytable[y*3+2]) * 2); + } + else if (eff == EllipticGradient){ + *p++ = qRgb(rcb - rSign * + (int)std::sqrt((xtable[x*3]*xtable[x*3] + + ytable[y*3]*ytable[y*3])*2.0), + gcb - gSign * + (int)std::sqrt((xtable[x*3+1]*xtable[x*3+1] + + ytable[y*3+1]*ytable[y*3+1])*2.0), + bcb - bSign * + (int)std::sqrt((xtable[x*3+2]*xtable[x*3+2] + + ytable[y*3+2]*ytable[y*3+2])*2.0)); + } + } + } + } + delete [] xtable; + delete [] ytable; + } + return(image); +} + +QImage Blitz::grayUnbalancedGradient(const QSize &size, unsigned char ca, + unsigned char cb, GradientType eff, + int xfactor, int yfactor) +{ + QImage image(size, QImage::Format_Indexed8); + if(!size.isValid()) + return(image); + QVector colorTable(256); + for(int i=0; i < 256; ++i) + colorTable[i] = qRgba(i, i, i, 255); + image.setColorTable(colorTable); + + int dir; // general parameter used for direction switches + bool _xanti = (xfactor < 0); // negative on X direction + bool _yanti = (yfactor < 0); // negative on Y direction + xfactor = qBound(1, qAbs(xfactor), 200); + yfactor = qBound(1, qAbs(yfactor), 200); + float xbal = xfactor/30.0f/size.width(); + float ybal = yfactor/30.0f/size.height(); + float rat; + + register int x, y; + int diff = cb-ca; + + if(eff == VerticalGradient || eff == HorizontalGradient){ + unsigned char *p; + if(eff == VerticalGradient){ + unsigned char idx; + for(y=0; y < size.height(); y++){ + dir = _yanti ? y : size.height() - 1 - y; + rat = 1 - std::exp( - (float)y * ybal ); + p = image.scanLine(dir); + idx = cb - (int)( diff * rat ); + for(x = 0; x < size.width(); x++) + *p++ = idx; + } + } + else{ + p = image.scanLine(0); + for(x = 0; x < size.width(); x++){ + dir = _xanti ? x : size.width() - 1 - x; + rat = 1 - std::exp( - (float)x * xbal ); + p[dir] = cb - (int)( diff * rat ); + } + + p = image.scanLine(0); + for(y = 1; y < size.height(); ++y) + memcpy(image.scanLine(y), p, image.bytesPerLine()); + } + } + else{ + int w=size.width(), h=size.height(); + unsigned char *xtable = new unsigned char[w]; + unsigned char *ytable = new unsigned char[h]; + unsigned char *p; + + if(eff == DiagonalGradient || eff == CrossDiagonalGradient){ + for(x = 0; x < w; x++){ + dir = _xanti ? x : w - 1 - x; + rat = 1 - std::exp( - (float)x * xbal ); + xtable[dir] = (unsigned char) ( diff/2 * rat ); + } + + for(y = 0; y < h; y++){ + dir = _yanti ? y : h - 1 - y; + rat = 1 - std::exp( - (float)y * ybal ); + ytable[dir] = (unsigned char) ( diff/2 * rat ); + } + + for(y = 0; y < h; y++){ + p = image.scanLine(y); + for(x = 0; x < w; x++) + *p++ = cb - (xtable[x] + ytable[y]); + } + } + else{ + int sign = diff>0? 1: -1; + for(x = 0; x < w; x++){ + dir = _xanti ? x : w - 1 - x; + rat = 1 - std::exp( - (float)x * xbal ); + xtable[dir] = (unsigned char) qAbs((int)(diff*(0.5-rat))); + } + + for(y = 0; y < h; y++){ + dir = _yanti ? y : h - 1 - y; + rat = 1 - std::exp( - (float)y * ybal ); + ytable[dir] = (unsigned char) qAbs((int)(diff*(0.5-rat))); + } + + for(y = 0; y < h; y++){ + p = image.scanLine(y); + for(x = 0; x < w; x++) { + if (eff == PyramidGradient) + *p++ = cb-sign*(xtable[x]+ytable[y]); + else if (eff == RectangleGradient) + *p++ = cb -sign*qMax(xtable[x], ytable[y])*2; + else if (eff == PipeCrossGradient) + *p++ = cb-sign*qMin(xtable[x], ytable[y])*2; + else if (eff == EllipticGradient) + *p++ = cb-sign * (int)std::sqrt((xtable[x]*xtable[x] + + ytable[y]*ytable[y])*2.0); + } + } + } + delete [] xtable; + delete [] ytable; + } + return(image); +} + diff -Nru syncwall-1.6.0/src/3rdparty/qimageblitz/histogram.cpp syncwall-1.7.4/src/3rdparty/qimageblitz/histogram.cpp --- syncwall-1.6.0/src/3rdparty/qimageblitz/histogram.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qimageblitz/histogram.cpp 2012-01-01 04:36:36.000000000 +0000 @@ -0,0 +1,472 @@ +/* + Copyright (C) 1998, 1999, 2001, 2002, 2004, 2005, 2007 + Daniel M. Duley + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +/* + Portions of this software are were originally based on ImageMagick's + algorithms. ImageMagick is copyrighted under the following conditions: + +Copyright (C) 2003 ImageMagick Studio, a non-profit organization dedicated to +making software imaging solutions freely available. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files ("ImageMagick"), to deal +in ImageMagick without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of ImageMagick, and to permit persons to whom the ImageMagick is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of ImageMagick. + +The software is provided "as is", without warranty of any kind, express or +implied, including but not limited to the warranties of merchantability, +fitness for a particular purpose and noninfringement. In no event shall +ImageMagick Studio be liable for any claim, damages or other liability, +whether in an action of contract, tort or otherwise, arising from, out of or +in connection with ImageMagick or the use or other dealings in ImageMagick. + +Except as contained in this notice, the name of the ImageMagick Studio shall +not be used in advertising or otherwise to promote the sale, use or other +dealings in ImageMagick without prior written authorization from the +ImageMagick Studio. +*/ + + +#include "qimageblitz.h" +#include "private/blitz_p.h" +#include +#include + +// These are used as accumulators + +typedef struct +{ + qint32 red, green, blue, alpha; +} IntegerPixel; + +typedef struct +{ + qint16 red, green, blue, alpha; +} ShortPixel; + +typedef struct +{ + // Yes, a normal pixel can be used instead but this is easier to read + // and no shifts to get components. + qint8 red, green, blue, alpha; +} CharPixel; + +typedef struct +{ + quint32 red, green, blue, alpha; +} HistogramListItem; + + +bool Blitz::equalize(QImage &img) +{ + if(img.isNull()) + return(false); + + HistogramListItem *histogram; + IntegerPixel *map; + IntegerPixel intensity, high, low; + CharPixel *equalize_map; + int i, count; + QRgb pixel, *dest; + unsigned char r, g, b; + + if(img.depth() < 32){ + img = img.convertToFormat(img.hasAlphaChannel() ? + QImage::Format_ARGB32 : + QImage::Format_RGB32); + } + count = img.width()*img.height(); + + map = new IntegerPixel[256]; + histogram = new HistogramListItem[256]; + equalize_map = new CharPixel[256]; + + // form histogram + memset(histogram, 0, 256*sizeof(HistogramListItem)); + dest = (QRgb *)img.bits(); + + if(img.format() == QImage::Format_ARGB32_Premultiplied){ + for(i=0; i < count; ++i, ++dest){ + pixel = BlitzPrivate::convertFromPremult(*dest); + histogram[qRed(pixel)].red++; + histogram[qGreen(pixel)].green++; + histogram[qBlue(pixel)].blue++; + histogram[qAlpha(pixel)].alpha++; + } + } + else{ + for(i=0; i < count; ++i){ + pixel = *dest++; + histogram[qRed(pixel)].red++; + histogram[qGreen(pixel)].green++; + histogram[qBlue(pixel)].blue++; + histogram[qAlpha(pixel)].alpha++; + } + } + + // integrate the histogram to get the equalization map + memset(&intensity, 0, sizeof(IntegerPixel)); + for(i=0; i < 256; ++i){ + intensity.red += histogram[i].red; + intensity.green += histogram[i].green; + intensity.blue += histogram[i].blue; + map[i] = intensity; + } + + low = map[0]; + high = map[255]; + memset(equalize_map, 0, 256*sizeof(CharPixel)); + for(i=0; i < 256; ++i){ + if(high.red != low.red) + equalize_map[i].red=(unsigned char) + ((255*(map[i].red-low.red))/(high.red-low.red)); + if(high.green != low.green) + equalize_map[i].green=(unsigned char) + ((255*(map[i].green-low.green))/(high.green-low.green)); + if(high.blue != low.blue) + equalize_map[i].blue=(unsigned char) + ((255*(map[i].blue-low.blue))/(high.blue-low.blue)); + } + + // stretch the histogram and write + dest = (QRgb *)img.bits(); + if(img.format() == QImage::Format_ARGB32_Premultiplied){ + for(i=0; i < count; ++i, ++dest){ + pixel = BlitzPrivate::convertFromPremult(*dest); + r = (low.red != high.red) ? equalize_map[qRed(pixel)].red : + qRed(pixel); + g = (low.green != high.green) ? equalize_map[qGreen(pixel)].green : + qGreen(pixel); + b = (low.blue != high.blue) ? equalize_map[qBlue(pixel)].blue : + qBlue(pixel); + *dest = BlitzPrivate::convertToPremult(qRgba(r, g, b, qAlpha(pixel))); + } + } + else{ + for(i=0; i < count; ++i){ + pixel = *dest; + r = (low.red != high.red) ? equalize_map[qRed(pixel)].red : + qRed(pixel); + g = (low.green != high.green) ? equalize_map[qGreen(pixel)].green : + qGreen(pixel); + b = (low.blue != high.blue) ? equalize_map[qBlue(pixel)].blue : + qBlue(pixel); + *dest++ = qRgba(r, g, b, qAlpha(pixel)); + } + } + + delete[] histogram; + delete[] map; + delete[] equalize_map; + return(true); +} + +bool Blitz::normalize(QImage &img) +{ + if(img.isNull()) + return(false); + + IntegerPixel intensity; + HistogramListItem *histogram; + CharPixel *normalize_map; + ShortPixel high, low; + + int threshold_intensity; + int i, count; + QRgb pixel, *dest; + unsigned char r, g, b; + + if(img.depth() < 32){ + img = img.convertToFormat(img.hasAlphaChannel() ? + QImage::Format_ARGB32 : + QImage::Format_RGB32); + } + count = img.width()*img.height(); + + histogram = new HistogramListItem[256]; + normalize_map = new CharPixel[256]; + + // form histogram + memset(histogram, 0, 256*sizeof(HistogramListItem)); + dest = (QRgb *)img.bits(); + + if(img.format() == QImage::Format_ARGB32_Premultiplied){ + for(i=0; i < count; ++i, ++dest){ + pixel = BlitzPrivate::convertFromPremult(*dest); + histogram[qRed(pixel)].red++; + histogram[qGreen(pixel)].green++; + histogram[qBlue(pixel)].blue++; + histogram[qAlpha(pixel)].alpha++; + } + } + else{ + for(i=0; i < count; ++i){ + pixel = *dest++; + histogram[qRed(pixel)].red++; + histogram[qGreen(pixel)].green++; + histogram[qBlue(pixel)].blue++; + histogram[qAlpha(pixel)].alpha++; + } + } + + // find the histogram boundaries by locating the .01 percent levels. + threshold_intensity = count/1000; + + memset(&intensity, 0, sizeof(IntegerPixel)); + for(low.red=0; low.red < 256; ++low.red){ + intensity.red += histogram[low.red].red; + if(intensity.red > threshold_intensity) + break; + } + memset(&intensity, 0, sizeof(IntegerPixel)); + for(high.red=255; high.red >= 0; --high.red){ + intensity.red += histogram[high.red].red; + if(intensity.red > threshold_intensity) + break; + } + memset(&intensity, 0, sizeof(IntegerPixel)); + for(low.green=low.red; low.green < high.red; ++low.green){ + intensity.green += histogram[low.green].green; + if(intensity.green > threshold_intensity) + break; + } + memset(&intensity, 0, sizeof(IntegerPixel)); + for(high.green=high.red; high.green != low.red; --high.green){ + intensity.green += histogram[high.green].green; + if(intensity.green > threshold_intensity) + break; + } + memset(&intensity, 0, sizeof(IntegerPixel)); + for(low.blue=low.green; low.blue < high.green; ++low.blue){ + intensity.blue += histogram[low.blue].blue; + if(intensity.blue > threshold_intensity) + break; + } + memset(&intensity, 0, sizeof(IntegerPixel)); + for(high.blue=high.green; high.blue != low.green; --high.blue){ + intensity.blue += histogram[high.blue].blue; + if(intensity.blue > threshold_intensity) + break; + } + + delete[] histogram; + + // stretch the histogram to create the normalized image mapping. + for(i=0; i < 256; i++){ + if(i < low.red) + normalize_map[i].red = 0; + else{ + if(i > high.red) + normalize_map[i].red = (qint8)255; + else if(low.red != high.red) + normalize_map[i].red = (255*(i-low.red))/ + (high.red-low.red); + } + + if(i < low.green) + normalize_map[i].green = 0; + else{ + if(i > high.green) + normalize_map[i].green = (qint8)255; + else if(low.green != high.green) + normalize_map[i].green = (255*(i-low.green))/ + (high.green-low.green); + } + + if(i < low.blue) + normalize_map[i].blue = 0; + else{ + if(i > high.blue) + normalize_map[i].blue = (qint8)255; + else if(low.blue != high.blue) + normalize_map[i].blue = (255*(i-low.blue))/ + (high.blue-low.blue); + } + } + + // write + dest = (QRgb *)img.bits(); + if(img.format() == QImage::Format_ARGB32_Premultiplied){ + for(i=0; i < count; ++i, ++dest){ + pixel = BlitzPrivate::convertFromPremult(*dest); + r = (low.red != high.red) ? normalize_map[qRed(pixel)].red : + qRed(pixel); + g = (low.green != high.green) ? normalize_map[qGreen(pixel)].green : + qGreen(pixel); + b = (low.blue != high.blue) ? normalize_map[qBlue(pixel)].blue : + qBlue(pixel); + *dest = BlitzPrivate::convertToPremult(qRgba(r, g, b, qAlpha(pixel))); + } + } + else{ + for(i=0; i < count; ++i){ + pixel = *dest; + r = (low.red != high.red) ? normalize_map[qRed(pixel)].red : + qRed(pixel); + g = (low.green != high.green) ? normalize_map[qGreen(pixel)].green : + qGreen(pixel); + b = (low.blue != high.blue) ? normalize_map[qBlue(pixel)].blue : + qBlue(pixel); + *dest++ = qRgba(r, g, b, qAlpha(pixel)); + } + } + + delete[] normalize_map; + return(true); +} + +QImage Blitz::oilPaint(QImage &img, float radius, + EffectQuality quality) +{ + int matrix_size = BlitzPrivate::defaultConvolveMatrixSize(radius, 0.5, + quality == High); + int i, x, y, w, h, matrix_x, matrix_y; + int edge = matrix_size/2; + unsigned int max, value; + QRgb *dest, *src, *s, **scanblock; + + w = img.width(); + h = img.height(); + if(w < 3 || h < 3){ + qWarning("Blitz::oilPaint(): Image is too small!"); + return(img); + } + + if(img.format() == QImage::Format_ARGB32_Premultiplied) + img = img.convertToFormat(QImage::Format_ARGB32); + else if(img.depth() < 32){ + img = img.convertToFormat(img.hasAlphaChannel() ? + QImage::Format_ARGB32 : + QImage::Format_RGB32); + } + QImage buffer(w, h, img.format()); + + scanblock = new QRgb* [matrix_size]; + unsigned int *histogram = new unsigned int[256]; + + for(y=0; y < h; ++y){ + src = (QRgb *)img.scanLine(y); + dest = (QRgb *)buffer.scanLine(y); + // Read in scanlines to pixel neighborhood. If the scanline is outside + // the image use the top or bottom edge. + for(x=y-edge, i=0; x <= y+edge; ++i, ++x){ + scanblock[i] = (QRgb *) + img.scanLine((x < 0) ? 0 : (x > h-1) ? h-1 : x); + } + + // Now we are about to start processing scanlines. First handle the + // part where the pixel neighborhood extends off the left edge. + for(x=0; x-edge < 0 ; ++x){ + (void)memset(histogram, 0, 256*sizeof(unsigned int)); + max = 0; + for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ + s = scanblock[matrix_y]; + matrix_x = -edge; + while(x+matrix_x < 0){ + value = qGray(*s); + histogram[value]++; + if(histogram[value] > max){ + max = histogram[value]; + *dest = *s; + } + ++matrix_x; + } + while(matrix_x <= edge){ + value = qGray(*s); + histogram[value]++; + if(histogram[value] > max){ + max = histogram[value]; + *dest = *s; + } + ++matrix_x; ++s; + } + } + ++dest; + } + + // Okay, now process the middle part where the entire neighborhood + // is on the image. + for(; x+edge < w; ++x){ + (void)memset(histogram, 0, 256*sizeof(unsigned int)); + max = 0; + for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ + s = scanblock[matrix_y] + (x-edge); + for(matrix_x = -edge; matrix_x <= edge; ++matrix_x, ++s){ + value = qGray(*s); + histogram[value]++; + if(histogram[value] > max){ + max = histogram[value]; + *dest = *s; + } + } + } + ++dest; + } + + // Finally process the right part where the neighborhood extends off + // the right edge of the image + for(; x < w; ++x){ + (void)memset(histogram, 0, 256*sizeof(unsigned int)); + max = 0; + for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ + s = scanblock[matrix_y]; + s += x-edge; + matrix_x = -edge; + while(x+matrix_x < w){ + value = qGray(*s); + histogram[value]++; + if(histogram[value] > max){ + max = histogram[value]; + *dest = *s; + } + ++matrix_x, ++s; + } + --s; + while(matrix_x <= edge){ + value = qGray(*s); + histogram[value]++; + if(histogram[value] > max){ + max = histogram[value]; + *dest = *s; + } + ++matrix_x; + } + } + ++dest; + } + } + + delete[] histogram; + delete[] scanblock; + return(buffer); +} + diff -Nru syncwall-1.6.0/src/3rdparty/qimageblitz/private/blitz_p.h syncwall-1.7.4/src/3rdparty/qimageblitz/private/blitz_p.h --- syncwall-1.6.0/src/3rdparty/qimageblitz/private/blitz_p.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qimageblitz/private/blitz_p.h 2008-02-26 19:31:00.000000000 +0000 @@ -0,0 +1,159 @@ +#ifndef __BLITZ_PRIVATE_H +#define __BLITZ_PRIVATE_H + +/* + Copyright (C) 1998, 1999, 2001, 2002, 2004, 2005, 2007 + Daniel M. Duley + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include + +class BlitzPrivate +{ +public: + static inline QRgb convertFromPremult(QRgb); + static inline QRgb convertToPremult(QRgb); + static inline QRgb byteMul(QRgb x, unsigned int a); + static inline QRgb interpolate255(QRgb x, unsigned int a, + QRgb y, unsigned int b); + static inline QRgb setAlpha(QRgb rgb, unsigned int a); + static inline int brightness(QRgb rgb); + static inline void hull(int x_offset, int y_offset, int w, int h, + unsigned char *f, unsigned char *g, int polarity); + static int defaultConvolveMatrixSize(float radius, float sigma, + bool quality); + static float* getBlurKernel(int &kernel_width, float sigma); + static void blurScanLine(float *kernel, int kern_width, + QRgb *source, QRgb *destination, + int columns, int offset); +}; + +inline QRgb BlitzPrivate::byteMul(QRgb x, unsigned int a) +{ + unsigned int t = (x & 0xff00ff) * a; + t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8; + t &= 0xff00ff; + + x = ((x >> 8) & 0xff00ff) * a; + x = (x + ((x >> 8) & 0xff00ff) + 0x800080); + x &= 0xff00ff00; + x |= t; + return(x); +} + +inline QRgb BlitzPrivate::interpolate255(QRgb x, unsigned int a, + QRgb y, unsigned int b) +{ + unsigned int t = (x & 0xff00ff) * a + (y & 0xff00ff) * b; + t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8; + t &= 0xff00ff; + + x = ((x >> 8) & 0xff00ff) * a + ((y >> 8) & 0xff00ff) * b; + x = (x + ((x >> 8) & 0xff00ff) + 0x800080); + x &= 0xff00ff00; + x |= t; + return(x); +} + +inline QRgb BlitzPrivate::convertFromPremult(QRgb p) +{ + int alpha = qAlpha(p); + return(!alpha ? 0 : qRgba(255*qRed(p)/alpha, + 255*qGreen(p)/alpha, + 255*qBlue(p)/alpha, + alpha)); +} + +inline QRgb BlitzPrivate::convertToPremult(QRgb p) +{ + unsigned int a = p >> 24; + unsigned int t = (p & 0xff00ff) * a; + t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8; + t &= 0xff00ff; + + p = ((p >> 8) & 0xff) * a; + p = (p + ((p >> 8) & 0xff) + 0x80); + p &= 0xff00; + p |= t | (a << 24); + return(p); +} + +inline void BlitzPrivate::hull(int x_offset, int y_offset, int w, int h, + unsigned char *f, unsigned char *g, + int polarity) +{ + int x, y, v; + unsigned char *p, *q, *r, *s; + p = f+(w+2); q = g+(w+2); + r = p+(y_offset*(w+2)+x_offset); + for(y=0; y < h; ++y, ++p, ++q, ++r){ + ++p; ++q; ++r; + if(polarity > 0){ + for(x=w; x > 0; --x, ++p, ++q, ++r){ + v = (*p); + if((int)*r >= (v+2)) v += 1; + *q = (unsigned char)v; + } + } + else{ + for(x=w; x > 0; --x, ++p, ++q, ++r){ + v = (*p); + if((int)*r <= (v-2)) v -= 1; + *q = (unsigned char)v; + } + } + } + p = f+(w+2); q = g+(w+2); + r = q+(y_offset*(w+2)+x_offset); s = q-(y_offset*(w+2)+x_offset); + for(y=0; y < h; ++y, ++p, ++q, ++r, ++s){ + ++p; ++q; ++r; ++s; + if(polarity > 0){ + for(x=w; x > 0; --x, ++p, ++q, ++r, ++s){ + v = (*q); + if(((int)*s >= (v+2)) && ((int)*r > v)) v+=1; + *p = (unsigned char)v; + } + } + else{ + for(x=w; x > 0; --x, ++p, ++q, ++r, ++s){ + v = (int)(*q); + if (((int)*s <= (v-2)) && ((int)*r < v)) v -= 1; + *p = (unsigned char)v; + } + } + } +} + +inline int BlitzPrivate::brightness(QRgb rgb) +{ + return(qMax(qRed((rgb)), qMax(qBlue((rgb)), qGreen((rgb))))); +} + +inline QRgb BlitzPrivate::setAlpha(QRgb rgb, unsigned int a) +{ + return(((a & 0xFF) << 24) | (rgb & 0x00FFFFFF)); +} + +#endif + diff -Nru syncwall-1.6.0/src/3rdparty/qimageblitz/private/inlinehsv.h syncwall-1.7.4/src/3rdparty/qimageblitz/private/inlinehsv.h --- syncwall-1.6.0/src/3rdparty/qimageblitz/private/inlinehsv.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qimageblitz/private/inlinehsv.h 2008-02-26 19:31:00.000000000 +0000 @@ -0,0 +1,163 @@ +#ifndef __PIXIE_INLINEHSV_H +#define __PIXIE_INLINEHSV_H + +/* + Copyright (C) 2005, 2007 Daniel M. Duley + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#include + +/** + * HSV to RGB conversion is required often for some algorithms. This + * class inlines, (at least with gcc), most of the code required for this + * conversion in order to increase performance in loops. The idea is you + * create an instance of this class outside your main loop then call + * convertRGB2HSV() and convertHSV2RGB when you need it. + * + * @author Daniel M. Duley + * @short Inline HSV conversion + */ +class InlineHSV +{ +public: + InlineHSV(){;} + /** + * Converts the given RGB value to HSV. The hue(), saturation(), and + * value() methods will be valid after calling this. The red, green, + * and blue items are also set the the supplied values. + */ + inline void convertRGB2HSV(unsigned int rgb); + inline void convertRGB2HSV(int red, int green, int blue); + /** + * Converts the given HSV value to RGB. The red(), green(), and + * blue() methods will be valid after calling this. The hue, + * saturation, and value methods are also set to the supplied values. + */ + inline void convertHSV2RGB(int hue, int saturation, int value); + /** + * Converts the current hue, saturation, and value settings to RGB. + */ + inline void convertHSV2RGB(); + + inline void setHSV(int hue, int saturation, int value) + {h = hue; s = saturation; v = value;} + inline void setHue(int hue){h = hue;} + inline void setSaturation(int saturation){s = saturation;} + inline void setValue(int value){v = value;} + inline int hue(){return(h);} + inline int saturation(){return(s);} + inline int value(){return(v);} + + inline void setRGB(int red, int green, int blue) + {r = red; g = green; b=blue;} + inline void setRed(int red){r = red;} + inline void setGreen(int green){g = green;} + inline void setBlue(int blue){b = blue;} + inline int red(){return(r);} + inline int green(){return(g);} + inline int blue(){return(b);} +private: + int h, s, v; + int r, g, b; + int max, whatmax, min, delta; + unsigned int f, p, q, t; +}; + +inline void InlineHSV::convertRGB2HSV(unsigned int pixel) +{ + convertRGB2HSV(qRed(pixel), qGreen(pixel), qBlue(pixel)); +} + +inline void InlineHSV::convertRGB2HSV(int red, int green, int blue) +{ + r = red; g = green; b = blue; + h = 0; + max = r; // maximum RGB component + whatmax = 0; // r=>0, g=>1, b=>2 + if(g > max) { max = g; whatmax = 1; } + if(b > max) { max = b; whatmax = 2; } + min = r; // find minimum value + if(g < min) min = g; + if(b < min) min = b; + delta = max-min; + v = max; // calc value + s = max ? (510*delta+max)/(2*max) : 0; + if(s == 0) + h = -1; // undefined hue + else{ + switch(whatmax){ + case 0: // red is max component + h = (g >= b) ? (120*(g-b)+delta)/(2*delta) : + (120*(g-b+delta)+delta)/(2*delta) + 300; + break; + case 1: // green is max component + h = (b > r) ? h = 120 + (120*(b-r)+delta)/(2*delta) : + 60 + (120*(b-r+delta)+delta)/(2*delta); + break; + case 2: // blue is max component + h = (r > g) ? h = 240 + (120*(r-g)+delta)/(2*delta) : + h = 180 + (120*(r-g+delta)+delta)/(2*delta); + break; + } + } +} + +inline void InlineHSV::convertHSV2RGB(int hue, int saturation, int value) +{ + h = hue; s = saturation; v = value; + convertHSV2RGB(); +} + +inline void InlineHSV::convertHSV2RGB() +{ + if(h < -1 || s > 255 || v > 255) + return; + + r = g = b = v; + if(s > 0 && h != -1){ + if(h >= 360) h %= 360; + f = h%60; + h /= 60; + p = (2*v*(255-s)+255)/510; + if(h&1){ + q = (2*v*(15300-s*f)+15300)/30600; + switch( h ) { + case 1: r=q; g=v, b=p; break; + case 3: r=p; g=q, b=v; break; + case 5: r=v; g=p, b=q; break; + } + } else { + t = (2*v*(15300-(s*(60-f)))+15300)/30600; + switch( h ) { + case 0: r=v; g=t, b=p; break; + case 2: r=p; g=v, b=t; break; + case 4: r=t; g=p, b=v; break; + } + } + } +} + +#endif + diff -Nru syncwall-1.6.0/src/3rdparty/qimageblitz/private/interpolate.h syncwall-1.7.4/src/3rdparty/qimageblitz/private/interpolate.h --- syncwall-1.6.0/src/3rdparty/qimageblitz/private/interpolate.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qimageblitz/private/interpolate.h 2008-02-26 19:31:00.000000000 +0000 @@ -0,0 +1,143 @@ +#ifndef __PIXIE_INTERPOLATE_H +#define __PIXIE_INTERPOLATE_H + +/* + Copyright (C) 2005, 2007 Daniel M. Duley + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#include +#include +#include + +/** + * Performs interpolation between a pixel's colors and it's neighbors. + * Handles 32bpp and 8bpp source images transparently. + * + * @short Inline interpolation + * @author Daniel M. Duley + */ +class InlineInterpolate +{ +public: + /** + * Constructs an interpolation object. Do this outside your main loop then + * call the inline interpolate methods when you need them. + * + * @param image The image whose pixels you will be interpolating. Once + * you have created an interpolation object you can change the image's + * pixel data, but do not resize or reset it. + * @param background The background color to use if a pixel's neighbor + * is off the edge of the image. + */ + InlineInterpolate(QImage *image, unsigned int background){ + img = image; ptr = img->bits(); + colorTable = img->colorTable(); + w=img->width(); h=img->height(); + bg=background; truecolor = img->depth() > 8; + } + /** + * Interpolates the pixel at the given x,y position. If the pixel's + * neighbor is off the edge of the image the last pixel is extended. + */ + inline unsigned int interpolate(float x_offset, float y_offset); + /** + * Interpolates the pixel at the given x,y position. If the pixel's + * neighbor is off the edge of the image the background color is used. + */ + inline unsigned int interpolateBackground(float x_offset, float y_offset); +private: + int w, h; + unsigned int p, q, r, s, bg; + unsigned char *ptr; + QVector colorTable; + bool truecolor; + QImage *img; +}; + +inline unsigned int InlineInterpolate::interpolate(float x_offset, + float y_offset) +{ + int x = qBound(0, (int)x_offset, w-2); + int y = qBound(0, (int)y_offset, h-2); + + if(truecolor){ + p = *(((QRgb *)ptr)+(y*w)+x); + q = *(((QRgb *)ptr)+(y*w)+x+1); + r = *(((QRgb *)ptr)+((y+1)*w)+x); + s = *(((QRgb *)ptr)+((y+1)*w)+x+1); + } + else{ + p = colorTable[*(ptr+(y*w)+x)]; + q = colorTable[*(ptr+(y*w)+x+1)]; + r = colorTable[*(ptr+((y+1)*w)+x)]; + s = colorTable[*(ptr+((y+1)*w)+x+1)]; + } + x_offset -= std::floor(x_offset); y_offset -= std::floor(y_offset); + unsigned int alpha = (unsigned int)(255*x_offset); + unsigned int beta = (unsigned int)(255*y_offset); + + p = BlitzPrivate::interpolate255(p, 255-alpha, q, alpha); + r = BlitzPrivate::interpolate255(r, 255-alpha, s, alpha); + return(BlitzPrivate::interpolate255(p, 255-beta, r, beta)); +} + +inline unsigned int InlineInterpolate::interpolateBackground(float x_offset, + float y_offset) +{ + int x = (int)x_offset; + int y = (int)y_offset; + p = q = r = s = bg; + + if(truecolor){ + if(y >= 0 && y < h && x >= 0 && x < w){ + p = *(((QRgb *)ptr)+(y*w)+x); + if(y+1 < h) r = *(((QRgb *)ptr)+((y+1)*w)+x); + if(x+1 < w){ + q = *(((QRgb *)ptr)+(y*w)+x+1); + if(y+1 < h) q = *(((QRgb *)ptr)+((y+1)*w)+x+1); + } + } + } + else{ + if(y >= 0 && y < h && x >= 0 && x < w){ + p = colorTable[*(ptr+(y*w)+x)]; + if(y+1 < h) r = colorTable[*(ptr+((y+1)*w)+x)]; + if(x+1 < w){ + q = colorTable[*(ptr+(y*w)+x+1)]; + if(y+1 < h) s = colorTable[*(ptr+((y+1)*w)+x+1)]; + } + } + } + x_offset -= std::floor(x_offset); y_offset -= std::floor(y_offset); + unsigned int alpha = (unsigned int)(255*x_offset); + unsigned int beta = (unsigned int)(255*y_offset); + + p = BlitzPrivate::interpolate255(p, 255-alpha, q, alpha); + r = BlitzPrivate::interpolate255(r, 255-alpha, s, alpha); + return(BlitzPrivate::interpolate255(p, 255-beta, r, beta)); +} + +#endif + diff -Nru syncwall-1.6.0/src/3rdparty/qimageblitz/qimageblitz.h syncwall-1.7.4/src/3rdparty/qimageblitz/qimageblitz.h --- syncwall-1.6.0/src/3rdparty/qimageblitz/qimageblitz.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qimageblitz/qimageblitz.h 2012-11-07 11:48:26.000000000 +0000 @@ -0,0 +1,440 @@ +#ifndef __BLITZ_H +#define __BLITZ_H + +/* + Copyright (C) 1998, 1999, 2001, 2002, 2004, 2005, 2007 + Daniel M. Duley + (C) 2004 Zack Rusin + (C) 2000 Josef Weidendorfer + (C) 1999 Geert Jansen + (C) 1998, 1999 Christian Tibirna + (C) 1998, 1999 Dirk Mueller + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#include +#include "qimageblitz_export.h" + +class QIMAGEBLITZ_EXPORT Blitz +{ +public: + enum GradientType {VerticalGradient=0, HorizontalGradient, DiagonalGradient, + CrossDiagonalGradient, PyramidGradient, RectangleGradient, + PipeCrossGradient, EllipticGradient}; + + enum RGBChannel{Grayscale=0, Brightness, Red, Green, Blue, Alpha, All}; + enum EffectQuality{Low=0, High}; + + enum ScaleFilterType{UndefinedFilter=0, PointFilter, BoxFilter, + TriangleFilter, HermiteFilter, HanningFilter, HammingFilter, + BlackmanFilter, GaussianFilter, QuadraticFilter, CubicFilter, + CatromFilter, MitchellFilter, LanczosFilter, BesselFilter, + SincFilter}; + + enum ModulationType{Intensity=0, Saturation, HueShift, Contrast}; + + /** + * Inverts an image. If the machine supports MMX this can do two pixels + * at a time, otherwise it's the same as QImage::invertPixels(). + * + * @param img The image to invert. + * @param mode If to invert the alpha channel or not. + * @author Daniel M. Duley (mosfet) + */ + static bool invert(QImage &img, QImage::InvertMode mode = + QImage::InvertRgb); + /** + * Grayscales an image. + * + * @param img The image to grayscale. + * @param reduceDepth If true the result will be an 8bit palette image. + * @author Daniel M. Duley (mosfet) + */ + static bool grayscale(QImage &img, bool reduceDepth=false); + /** + * A fast smoothscale method with MMX support. + * + * @param img The image to smoothscale. + * @param sz The size to scale to. + * @param aspectRatio What aspect ratio to use, if any. + * @return The processed image. The original is not changed. + * @author Daniel M. Duley (mosfet) + */ + static QImage smoothScale(QImage &img, const QSize &sz, + Qt::AspectRatioMode aspectRatio = + Qt::IgnoreAspectRatio); + static QImage smoothScale(QImage &img, int dw, int dh, + Qt::AspectRatioMode aspectRatio = + Qt::IgnoreAspectRatio); + /** + * Smoothscales an image using a high-quality filter. + * + * @param img The image to smoothscale. + * @param sz The size to scale to. + * @param blur A blur factor. Values greater than 1.0 blur while values + * less than 1.0 sharpen. + * @param filter The filter type. + * @param aspectRatio What aspect ratio to use, if any. + * @return The processed image. The original is not changed. + * @author Daniel M. Duley (mosfet) + */ + static QImage smoothScaleFilter(const QImage &img, const QSize &sz, + float blur=1.0, + ScaleFilterType filter=BlackmanFilter, + Qt::AspectRatioMode aspectRatio = + Qt::IgnoreAspectRatio); + static QImage smoothScaleFilter(const QImage &img, int dwX, int dwY, + float blur=1.0, + ScaleFilterType filter=BlackmanFilter, + Qt::AspectRatioMode aspectRatio = + Qt::IgnoreAspectRatio); + + /** + * Convolves an image using a convolution matrix, (kernel), and provides + * the basis for many different image filters and effects. + * + * @param img The image to process. + * @param matrix_size The size of one side of the convolution matrix, ie: + * a 3x3 matrix would be 3, not 9. + * @param matrix The convolution matrix. + * @return The processed image. The original is not changed. + * @author Daniel M. Duley (mosfet) + */ + static QImage convolve(QImage &img, int matrix_size, float *matrix); + /** + * Same as above but with a faster integer matrix. + */ + static QImage convolveInteger(QImage &img, int matrix_size, int *matrix, + int divisor=0); + /** + * A fast blur algorithm. + * + * @param img The image to process. + * @param radius The radius of the blur. Larger values blur more. + * @return The processed image. The original is not changed. + * @author Daniel M. Duley (mosfet) + */ + static QImage blur(QImage &img, int radius=3); + /** + * A high quality gaussian/convolve-based blur. + * + * @param img The image to process. + * @param radius The radius of the gaussian, not counting the center + * pixel. Use 0, (recommended), and an appropriate one will be used. + * @param sigma The standard deviation of the gaussian in pixels. Use + * 1.0, (recommended), for the default value. + * @return The processed image. The original is not changed. + * @author Daniel M. Duley (mosfet) + */ + static QImage gaussianBlur(QImage &img, float radius=0.0, float sigma=1.0); + /** + * Detects edges in an image using the Sobel algorithm. + * + * @param img The image to process. + * @return The processed image. The original is not changed. + * @author Daniel M. Duley (mosfet) + */ + static QImage edge(QImage &img); + /** + * Detects edges in an image using a convolution matrix. + * + * @param img The image to process. + * @param radius The radius of the gaussian, not counting the center + * pixel. Use 0, (recommended), and an appropriate one will be used. + * @param quality Determines if to use a small or large convolution matrix. + * @return The processed image. The original is not changed. + * @author Daniel M. Duley (mosfet) + */ + static QImage convolveEdge(QImage &img, float radius=0.0, + EffectQuality quality=High); + /** + * Sharpens an image. + * + * @param img The image to process. + * @param radius The radius of the gaussian, not counting the center + * pixel. Use 0, (recommended), and an appropriate one will be used. + * @param sigma The standard deviation of the gaussian in pixels. Use + * 1.0, (recommended), for the default value. + * @param quality Determines if to use a small or large convolution matrix. + * @return The processed image. The original is not changed. + * @author Daniel M. Duley (mosfet) + */ + static QImage gaussianSharpen(QImage &img, float radius=0.0, float sigma=1.0, + EffectQuality quality=High); + /** + * A cheap, fast sharpen. + * + * @param radius The radius. Larger values sharpen more. + * @return The processed image. The original is not changed. + * @author Daniel M. Duley (mosfet) + */ + static QImage sharpen(QImage &img, int radius=3); + /** + * Embosses an image. + * + * @param img The image to process. + * @param radius The radius of the gaussian, not counting the center + * pixel. Use 0, (recommended), and an appropriate one will be used. + * @param sigma The standard deviation of the gaussian in pixels. Use + * 1.0, (recommended), for the default value. + * @param quality Determines if to use a small or large convolution matrix. + * @return The processed image. The original is not changed. + * @author Daniel M. Duley (mosfet) + */ + static QImage emboss(QImage &img, float radius=0.0, float sigma=1.0, + EffectQuality quality=High); + /** + * Antialiases an image. + * + * @param img The image to process. + * @return The processed image. The original is not changed. + * @author Daniel M. Duley (mosfet) + */ + static QImage antialias(QImage &img); + /** + * Minimizes speckle noise in the source image using the 8 hull + * algorithm. + * + * @param img The image to process. + * @return A reference to the image for convenience. + * @author Daniel M. Duley (mosfet) + */ + static QImage& despeckle(QImage &img); + /** + * High quality, fast HSV contrast. + * + * @param img The image to process. + * @param sharpen If true sharpness is increase, (spiffed). Otherwise + * it is decreased, (dulled). + * @param weight How much to spiff or dull. + * @return A reference to the image for convenience. + * @author Daniel M. Duley (mosfet) + */ + static QImage& contrast(QImage &img, bool sharpen, int weight=3); + /** + * Performs histogram equalization. + * + * @param img The image to equalize. + * @author Daniel M. Duley (mosfet) + */ + static bool equalize(QImage &img); + /** + * Normalizes the pixel values to span the full range of color values. + * This is a contrast enhancement technique. + * + * @param img The image to normalize + * @author Daniel M. Duley (mosfet) + */ + static bool normalize(QImage &img); + /** + * Either brighten or dim the image by a specified percent. For example, + * 0.50 will modify the colors by 50%. + * + * @param img The image to process. + * @param percent The percent value. Use a negative value to dim. + * @return A reference to the image for convenience. + * @author Daniel M. Duley (mosfet) + * @author Benjamin Roe (ben@benroe.com) + */ + static QImage& intensity(QImage &img, float percent); + /** + * Modifies the intensity of an image's RGB channel. + * + * @param img The image to process. + * @param percent Percent value. Use a negative value to dim. + * @param channel Which channel(s) should be modified. Only Red, Green, + * and Blue are valid. + * @return A reference to the image for convenience. + * @author Daniel M. Duley (mosfet) + */ + static QImage& channelIntensity(QImage &img, float percent, + RGBChannel channel); + /** + * Desaturate an image evenly. + * + * @param img The image to process. + * @param desat A value between 0 and 1 setting the degree of desaturation + * @return A reference to the image for convenience. + * @author Daniel M. Duley (mosfet) + */ + static QImage& desaturate(QImage &img, float desat = 0.5); + /** + * Fade an image to a certain background color. The number of colors will + * not be changed. + * + * @param img The image to process. + * @param val The strength of the effect. 0 <= val <= 1. + * @param color The background color. + * @return A reference to the image for convenience. + */ + static QImage& fade(QImage &img, float val, const QColor &color); + + /** + * This recolors a pixmap. The most dark color will become color a, + * the most bright one color b, and in between. + * + * @param img The image to process. + * @param ca Color a + * @param cb Color b + */ + static QImage& flatten(QImage &img, const QColor &ca, const QColor &cb); + /** + * Thresholds an image based on a given channel and threshold value. + * + * @param img The image to process. + * @param thresholdValue The value that separates "on" colors from "off" + * ones. + * @param channel The channel to use when thresholding. + * @param aboveColor The color to use for values at or above the threshold. + * @param belowColor The color to use for values below the threshold. + * @return The processed image. The original is not changed. + * @author Daniel M. Duley (mosfet) + */ + static QImage threshold(QImage &img, unsigned char thresholdValue=127, + RGBChannel channel=Grayscale, + unsigned int aboveColor=qRgb(255, 255, 255), + unsigned int belowColor=qRgb(0, 0, 0)); + /** + * Swirls the image by a specified amount + * + * @param img The image to process. + * @param degrees The tightness of the swirl. + * @return The processed image. The original is not changed. + * @author Daniel M. Duley (mosfet) + */ + static QImage swirl(QImage &img, float degrees=60.0); + /** + * Implodes an image by a specified percent. + * + * @param img The QImage to process. + * @param amount The extent of the implosion. + * @return The processed image. The original is not changed. + * @author Daniel M. Duley (mosfet) + */ + static QImage implode(QImage &img, float amount=0.3); + /** + * Modifies the pixels along a sine wave. + * + * @param img The image to process. + * @param amplitude The amplitude of the sine wave. + * @param frequency The frequency of the sine wave. + * @param background An RGBA value to use for the background. After the + * effect some pixels may be "empty". This value is used for those pixels. + * @return The processed image. The original is not changed. + * @author Daniel M. Duley (mosfet) + */ + static QImage wave(QImage &img, float amplitude=25.0, float frequency=150.0, + unsigned int background=0); + /** + * Produces an oil painting effect. + * + * @param img The image to process. + * @param radius The radius of the gaussian, not counting the center + * pixel. Use 0, (recommended), and an appropriate one will be used. + * @param quality Determines if to use a small or large convolution matrix. + * @return The processed image. The original is not changed. + * @author Daniel M. Duley (mosfet) + */ + static QImage oilPaint(QImage &img, float radius=0.0, + EffectQuality quality=High); + /** + * Produces a "charcoal" image effect. + * + * @param img The image to process. + * @return The processed image. The original is not changed. + * @author Daniel M. Duley (mosfet) + */ + static QImage charcoal(QImage &img); + /** + * Create a gradient from color a to color b of the specified type. + * + * @param size The desired size of the gradient. + * @param ca Color a + * @param cb Color b + * @param type The type of gradient. + * @return The gradient. + */ + static QImage gradient(const QSize &size, const QColor &ca, + const QColor &cb, GradientType type); + /** + * Creates an 8bit grayscale gradient suitable for use as an alpha channel + * using QImage::setAlphaChannel(). + * + * @param size The desired size of the gradient. + * @param ca The grayscale start value. + * @param cb The grayscale end value. + * @param type The type of gradient. + * @return The gradient. + */ + static QImage grayGradient(const QSize &size, unsigned char ca, + unsigned char cb, GradientType type); + /** + * Create an unbalanced gradient. An unbalanced gradient is a gradient + * where the transition from color a to color b is not linear, but in this + * case exponential. + * + * @param size The desired size of the gradient. + * @param ca Color a + * @param cb Color b + * @param type The type of gradient. + * @param xfactor The x decay length. Use a value between -200 and 200. + * @param yfactor The y decay length. + * @return The gradient. + */ + static QImage unbalancedGradient(const QSize &size, const QColor &ca, + const QColor &cb, GradientType type, + int xfactor=100, int yfactor=100); + /** + * Creates an 8bit grayscale gradient suitable for use as an alpha channel + * using QImage::setAlphaChannel(). + * + * @param size The desired size of the gradient. + * @param type The type of gradient. + * @param ca The grayscale start value. + * @param cb The grayscale end value. + * @param xfactor The x decay length. Use a value between -200 and 200. + * @param yfactor The y decay length. + * @return The gradient. + */ + static QImage grayUnbalancedGradient(const QSize &size, unsigned char ca, + unsigned char cb, GradientType type, + int xfactor=100, int yfactor=100); + /** + * Modulate the image with a color channel of another image. + * + * @param img The QImage to modulate and result. + * @param modImg The QImage to use for modulation. + * @param reverse Invert the meaning of image/modImage; result is image! + * @param type The modulation Type to use. + * @param factor The modulation amplitude; with 0 no effect [-200;200]. + * @param channel The RBG channel of image2 to use for modulation. + * @return Returns the image(), provided for convenience. + */ + static QImage& modulate(QImage &img, QImage &modImg, bool reverse, + ModulationType type, int factor, + RGBChannel channel); +}; + +#endif + diff -Nru syncwall-1.6.0/src/3rdparty/qimageblitz/qimageblitz.pc.cmake syncwall-1.7.4/src/3rdparty/qimageblitz/qimageblitz.pc.cmake --- syncwall-1.6.0/src/3rdparty/qimageblitz/qimageblitz.pc.cmake 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qimageblitz/qimageblitz.pc.cmake 2007-11-07 04:58:44.000000000 +0000 @@ -0,0 +1,11 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=@CMAKE_INSTALL_PREFIX@ +libdir=@LIB_INSTALL_DIR@ +includedir=@INCLUDE_INSTALL_DIR@ + +Name: Blitz +Description: Blitz image effect and filter library +Version: @BLITZ_LIB_VERSION_STRING@ +Requires: QtGui +Libs: -L${libdir} -lqimageblitz +Cflags: -I${includedir} diff -Nru syncwall-1.6.0/src/3rdparty/qimageblitz/qimageblitz.pro syncwall-1.7.4/src/3rdparty/qimageblitz/qimageblitz.pro --- syncwall-1.6.0/src/3rdparty/qimageblitz/qimageblitz.pro 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qimageblitz/qimageblitz.pro 2012-01-24 04:13:50.000000000 +0000 @@ -0,0 +1,50 @@ +###################################################################### +# Automatically generated by qmake (2.01a) Mon Sep 17 09:51:23 2007 +###################################################################### + +TARGET = qimageblitz +TEMPLATE = lib + +win32 { +INSTALLS += target +target.path = /lib/ +} + +CONFIG += staticlib + +DEFINES += MAKE_QIMAGEBLITZ_LIB + +DEPENDPATH += . private +INCLUDEPATH += . private + +# Input +HEADERS += blitzcpu.h \ + config-externalasm.h \ + config-processor.h \ + qimageblitz.h \ + qimageblitz_export.h \ + private/blitz_p.h \ + private/inlinehsv.h \ + private/interpolate.h +SOURCES += blitz.cpp \ + blitzcpu.cpp \ + colors.cpp \ + convolve.cpp \ + gradient.cpp \ + histogram.cpp \ + scale.cpp \ + scalefilter.cpp + + +!win32 { +!macx { + +contains(QONF_FEATURES, mmx) { +SOURCES += asm_scale.S +} + +} +} + + + diff -Nru syncwall-1.6.0/src/3rdparty/qimageblitz/qimageblitz_export.h syncwall-1.7.4/src/3rdparty/qimageblitz/qimageblitz_export.h --- syncwall-1.6.0/src/3rdparty/qimageblitz/qimageblitz_export.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qimageblitz/qimageblitz_export.h 2008-02-26 19:31:00.000000000 +0000 @@ -0,0 +1,44 @@ +/* + Copyright (C) 2007 Christian Ehrlicher + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef QIMAGEBLITZ_EXPORT_H +#define QIMAGEBLITZ_EXPORT_H + +#include + +#ifndef QIMAGEBLITZ_EXPORT +# ifdef Q_OS_WIN +# ifdef MAKE_QIMAGEBLITZ_LIB +# define QIMAGEBLITZ_EXPORT Q_DECL_EXPORT +# else +# define QIMAGEBLITZ_EXPORT Q_DECL_IMPORT +# endif +# else +# define QIMAGEBLITZ_EXPORT Q_DECL_EXPORT +# endif +#endif + +#endif // QIMAGEBLITZ_EXPORT_H diff -Nru syncwall-1.6.0/src/3rdparty/qimageblitz/scale.cpp syncwall-1.7.4/src/3rdparty/qimageblitz/scale.cpp --- syncwall-1.6.0/src/3rdparty/qimageblitz/scale.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qimageblitz/scale.cpp 2008-02-26 19:31:00.000000000 +0000 @@ -0,0 +1,301 @@ +#include +#include +#include "blitzcpu.h" +#include "qimageblitz.h" +#include +#include + +/* + * Copyright (C) 2004, 2005, 2007 Daniel M. Duley + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* OTHER CREDITS: + * + * This is the normal smoothscale method, based on Imlib2's smoothscale. + * + * Originally I took the algorithm used in NetPBM and Qt and added MMX/3dnow + * optimizations. It ran in about 1/2 the time as Qt. Then I ported Imlib's + * C algorithm and it ran at about the same speed as my MMX optimized one... + * Finally I ported Imlib's MMX version and it ran in less than half the + * time as my MMX algorithm, (taking only a quarter of the time Qt did). + * After further optimization it seems to run at around 1/6th. + * + * Changes include formatting, namespaces and other C++'ings, removal of old + * #ifdef'ed code, and removal of unneeded border calculation code. + * + * Imlib2 is (C) Carsten Haitzler and various contributors. The MMX code + * is by Willem Monsuwe . All other modifications are + * (C) Daniel M. Duley. + */ + +#if defined(__i386__) && ( defined(__GNUC__) || defined(__INTEL_COMPILER) ) +# if defined(HAVE_MMX) && defined(HAVE_EXTERNAL_ASM) +# define USE_MMX_INLINE_ASM +# endif +#endif + +namespace QImageScale{ + typedef struct __qimage_scale_info + { + int *xpoints; + unsigned int **ypoints; + int *xapoints, *yapoints; + int xup_yup; + } QImageScaleInfo; + + unsigned int** qimageCalcYPoints(unsigned int *src, int sw, int sh, + int dh); + int* qimageCalcXPoints(int sw, int dw); + int* qimageCalcApoints(int s, int d, int up); + QImageScaleInfo* qimageFreeScaleInfo(QImageScaleInfo *isi); + QImageScaleInfo *qimageCalcScaleInfo(const QImage &img, int sw, int sh, + int dw, int dh, char aa); +} + +#ifdef USE_MMX_INLINE_ASM +extern "C" { + void __qimageScale_mmx_AARGBA(QImageScale::QImageScaleInfo *isi, + unsigned int *dest, int dxx, int dyy, + int dx, int dy, int dw, int dh, + int dow, int sow); +} +#endif + +using namespace QImageScale; + +QImage Blitz::smoothScale(QImage &src, int w, int h, + Qt::AspectRatioMode aspectRatio) +{ + return(smoothScale(src, QSize(w, h), aspectRatio)); +} + +QImage Blitz::smoothScale(QImage &src, const QSize &sz, + Qt::AspectRatioMode aspectRatio) +{ +#ifdef USE_MMX_INLINE_ASM +#ifdef __GNUC__ +#warning Using MMX smoothscaling +#endif + if(BlitzCPUInfo::haveExtension(BlitzCPUInfo::MMX)){ + QImage buffer; + QSize destSize(src.size()); + destSize.scale(sz, aspectRatio); + if(src.isNull() || !destSize.isValid()) + return(buffer); + if(src.depth() != 32){ + src = src.convertToFormat(src.hasAlphaChannel() ? + QImage::Format_ARGB32 : + QImage::Format_RGB32); + } + else if(src.format() == QImage::Format_ARGB32_Premultiplied) + src = src.convertToFormat(QImage::Format_ARGB32); + + QImageScaleInfo *scaleinfo = + qimageCalcScaleInfo(src, src.width(), src.height(), + destSize.width(), destSize.height(), true); + if(!scaleinfo) + return(buffer); + + buffer = QImage(destSize, src.format()); + __qimageScale_mmx_AARGBA(scaleinfo, (unsigned int *)buffer.scanLine(0), 0, 0, + 0, 0, destSize.width(), destSize.height(), + destSize.width(), src.width()); + qimageFreeScaleInfo(scaleinfo); + return(buffer); + } + else +#endif + { + return(src.scaled(sz, aspectRatio, Qt::SmoothTransformation)); + } +} + +// +// Code ported from Imlib... +// + +// FIXME: replace with qRed, etc... These work on pointers to pixels, not +// pixel values +#define A_VAL(p) ((unsigned char *)(p))[3] +#define R_VAL(p) ((unsigned char *)(p))[2] +#define G_VAL(p) ((unsigned char *)(p))[1] +#define B_VAL(p) ((unsigned char *)(p))[0] + +#define INV_XAP (256 - xapoints[x]) +#define XAP (xapoints[x]) +#define INV_YAP (256 - yapoints[dyy + y]) +#define YAP (yapoints[dyy + y]) + +unsigned int** QImageScale::qimageCalcYPoints(unsigned int *src, + int sw, int sh, int dh) +{ + unsigned int **p; + int i, j = 0; + int val, inc, rv = 0; + + if(dh < 0){ + dh = -dh; + rv = 1; + } + p = new unsigned int* [dh+1]; + + val = 0; + inc = (sh << 16) / dh; + for(i = 0; i < dh; i++){ + p[j++] = src + ((val >> 16) * sw); + val += inc; + } + if(rv){ + for(i = dh / 2; --i >= 0; ){ + unsigned int *tmp = p[i]; + p[i] = p[dh - i - 1]; + p[dh - i - 1] = tmp; + } + } + return(p); +} + +int* QImageScale::qimageCalcXPoints(int sw, int dw) +{ + int *p, i, j = 0; + int val, inc, rv = 0; + + if(dw < 0){ + dw = -dw; + rv = 1; + } + p = new int[dw+1]; + + val = 0; + inc = (sw << 16) / dw; + for(i = 0; i < dw; i++){ + p[j++] = (val >> 16); + val += inc; + } + + if(rv){ + for(i = dw / 2; --i >= 0; ){ + int tmp = p[i]; + p[i] = p[dw - i - 1]; + p[dw - i - 1] = tmp; + } + } + return(p); +} + +int* QImageScale::qimageCalcApoints(int s, int d, int up) +{ + int *p, i, j = 0, rv = 0; + + if(d < 0){ + rv = 1; + d = -d; + } + p = new int[d]; + + /* scaling up */ + if(up){ + int val, inc; + + val = 0; + inc = (s << 16) / d; + for(i = 0; i < d; i++){ + p[j++] = (val >> 8) - ((val >> 8) & 0xffffff00); + if((val >> 16) >= (s - 1)) + p[j - 1] = 0; + val += inc; + } + } + /* scaling down */ + else{ + int val, inc, ap, Cp; + val = 0; + inc = (s << 16) / d; + Cp = ((d << 14) / s) + 1; + for(i = 0; i < d; i++){ + ap = ((0x100 - ((val >> 8) & 0xff)) * Cp) >> 8; + p[j] = ap | (Cp << 16); + j++; + val += inc; + } + } + if(rv){ + int tmp; + for(i = d / 2; --i >= 0; ){ + tmp = p[i]; + p[i] = p[d - i - 1]; + p[d - i - 1] = tmp; + } + } + return(p); +} + +QImageScaleInfo* QImageScale::qimageFreeScaleInfo(QImageScaleInfo *isi) +{ + if(isi){ + delete[] isi->xpoints; + delete[] isi->ypoints; + delete[] isi->xapoints; + delete[] isi->yapoints; + delete isi; + } + return(NULL); +} + +QImageScaleInfo* QImageScale::qimageCalcScaleInfo(const QImage &img, + int sw, int sh, + int dw, int dh, char aa) +{ + QImageScaleInfo *isi; + int scw, sch; + + scw = dw * img.width() / sw; + sch = dh * img.height() / sh; + + isi = new QImageScaleInfo; + if(!isi) + return(NULL); + memset(isi, 0, sizeof(QImageScaleInfo)); + + isi->xup_yup = (qAbs(dw) >= sw) + ((qAbs(dh) >= sh) << 1); + + isi->xpoints = qimageCalcXPoints(img.width(), scw); + if(!isi->xpoints) + return(qimageFreeScaleInfo(isi)); + isi->ypoints = qimageCalcYPoints((unsigned int *)img.scanLine(0), + img.width(), img.height(), sch); + if (!isi->ypoints) + return(qimageFreeScaleInfo(isi)); + if(aa){ + isi->xapoints = qimageCalcApoints(img.width(), scw, isi->xup_yup & 1); + if(!isi->xapoints) + return(qimageFreeScaleInfo(isi)); + isi->yapoints = qimageCalcApoints(img.height(), sch, isi->xup_yup & 2); + if(!isi->yapoints) + return(qimageFreeScaleInfo(isi)); + } + return(isi); +} + diff -Nru syncwall-1.6.0/src/3rdparty/qimageblitz/scalefilter.cpp syncwall-1.7.4/src/3rdparty/qimageblitz/scalefilter.cpp --- syncwall-1.6.0/src/3rdparty/qimageblitz/scalefilter.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qimageblitz/scalefilter.cpp 2012-11-07 11:48:46.000000000 +0000 @@ -0,0 +1,728 @@ +/* + Copyright (C) 2004, 2005, 2007 + Daniel M. Duley + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +/* + Portions of this software are were originally based on ImageMagick's + algorithms. ImageMagick is copyrighted under the following conditions: + +Copyright (C) 2003 ImageMagick Studio, a non-profit organization dedicated to +making software imaging solutions freely available. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files ("ImageMagick"), to deal +in ImageMagick without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of ImageMagick, and to permit persons to whom the ImageMagick is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of ImageMagick. + +The software is provided "as is", without warranty of any kind, express or +implied, including but not limited to the warranties of merchantability, +fitness for a particular purpose and noninfringement. In no event shall +ImageMagick Studio be liable for any claim, damages or other liability, +whether in an action of contract, tort or otherwise, arising from, out of or +in connection with ImageMagick or the use or other dealings in ImageMagick. + +Except as contained in this notice, the name of the ImageMagick Studio shall +not be used in advertising or otherwise to promote the sale, use or other +dealings in ImageMagick without prior written authorization from the +ImageMagick Studio. +*/ + +#include "qimageblitz.h" +#include + +/** + * This is a port of the ImageMagick scaling functions from resize.c. + * + * The most signficant change is ImageMagick uses a function pointer for the + * filter type. This is called usually a couple times in a loop for each + * horizontal and vertical coordinate. I changed this into a switch statement + * that does each type with inline functions. More code but faster. + */ + +#define MagickEpsilon 1.0e-6 +#define MagickPI 3.14159265358979323846264338327950288419716939937510 + +namespace BlitzScaleFilter{ + typedef struct{ + float weight; + unsigned int pixel; + } ContributionInfo; + + bool horizontalFilter(QImage *srcImg, QImage *destImg, + float x_factor, float blur, + ContributionInfo *contribution, + Blitz::ScaleFilterType filter); + bool verticalFilter(QImage *srcImg, QImage *destImg, + float y_factor, float blur, + ContributionInfo *contribution, + Blitz::ScaleFilterType filter); + + // These arrays were moved from their respective functions because they + // are inline + static const float + J1Pone[] = { + 0.581199354001606143928050809e+21f, + -0.6672106568924916298020941484e+20f, + 0.2316433580634002297931815435e+19f, + -0.3588817569910106050743641413e+17f, + 0.2908795263834775409737601689e+15f, + -0.1322983480332126453125473247e+13f, + 0.3413234182301700539091292655e+10f, + -0.4695753530642995859767162166e+7f, + 0.270112271089232341485679099e+4f + }, + J1Qone[] = { + 0.11623987080032122878585294e+22f, + 0.1185770712190320999837113348e+20f, + 0.6092061398917521746105196863e+17f, + 0.2081661221307607351240184229e+15f, + 0.5243710262167649715406728642e+12f, + 0.1013863514358673989967045588e+10f, + 0.1501793594998585505921097578e+7f, + 0.1606931573481487801970916749e+4f, + 0.1e+1 + }; + + static const float + P1Pone[] = { + 0.352246649133679798341724373e+5f, + 0.62758845247161281269005675e+5f, + 0.313539631109159574238669888e+5f, + 0.49854832060594338434500455e+4f, + 0.2111529182853962382105718e+3f, + 0.12571716929145341558495e+1f + }, + P1Qone[] = { + 0.352246649133679798068390431e+5f, + 0.626943469593560511888833731e+5f, + 0.312404063819041039923015703e+5f, + 0.4930396490181088979386097e+4f, + 0.2030775189134759322293574e+3f, + 0.1e+1 + }; + + static const float + Q1Pone[] = { + 0.3511751914303552822533318e+3f, + 0.7210391804904475039280863e+3f, + 0.4259873011654442389886993e+3f, + 0.831898957673850827325226e+2f, + 0.45681716295512267064405e+1f, + 0.3532840052740123642735e-1f + }, + Q1Qone[] = { + 0.74917374171809127714519505e+4f, + 0.154141773392650970499848051e+5f, + 0.91522317015169922705904727e+4f, + 0.18111867005523513506724158e+4f, + 0.1038187585462133728776636e+3f, + 0.1e+1 + }; + + static const float filterSupport[Blitz::SincFilter+1] = { + /*Undefined*/ 0.0f, + /*Point*/ 0.0f, + /*Box*/ 0.5f, + /*Triangle*/ 1.0f, + /*Hermite*/ 1.0f, + /*Hanning*/ 1.0f, + /*Hamming*/ 1.0f, + /*Blackman*/ 1.0f, + /*Gaussian*/ 1.25f, + /*Quadratic*/ 1.5f, + /*Cubic*/ 2.0f, + /*Catrom*/ 2.0f, + /*Mitchell*/ 2.0f, + /*Lanczos*/ 3.0f, + /*BlackmanBessel*/ 3.2383f, + /*BlackmanSinc*/ 4.0f + }; + + inline float J1(float x){ + float p, q; + p=J1Pone[8]; q=J1Qone[8]; + for(int i=7; i >= 0; i--){ + p=p*x*x+J1Pone[i]; + q=q*x*x+J1Qone[i]; + } + return(p/q); + } + + inline float P1(float x){ + float p, q; + p=P1Pone[5]; q=P1Qone[5]; + for(int i=4; i >= 0; i--){ + p=p*(8.0/x)*(8.0/x)+P1Pone[i]; + q=q*(8.0/x)*(8.0/x)+P1Qone[i]; + } + return(p/q); + } + + inline float Q1(float x){ + float p, q; + p=Q1Pone[5]; q=Q1Qone[5]; + for(int i=4; i >= 0; i--){ + p=p*(8.0/x)*(8.0/x)+Q1Pone[i]; + q=q*(8.0/x)*(8.0/x)+Q1Qone[i]; + } + return(p/q); + } + + inline float BesselOrderOne(float x){ + float p, q; + if(x == 0.0) + return(0.0); + p = x; + if(x < 0.0) + x = (-x); + if(x < 8.0) + return(p*J1(x)); + q = std::sqrt((float) (2.0/(MagickPI*x)))*(P1(x)*(1.0/std::sqrt(2.0)*(std::sin(x)- + std::cos(x)))-8.0/x*Q1(x)*(-1.0/std::sqrt(2.0)*(std::sin(x)+ + std::cos(x)))); + if (p < 0.0) + q=(-q); + return(q); + } + + inline float Bessel(const float x, const float /*support*/){ + if(x == 0.0) + return((float)(MagickPI/4.0)); + return(BesselOrderOne(MagickPI*x)/(2.0*x)); + } + + inline float Sinc(const float x, const float /*support*/){ + if(x == 0.0) + return(1.0); + return(std::sin(MagickPI*x)/(MagickPI*x)); + } + + inline float Blackman(const float x, const float /*support*/){ + return(0.42+0.5*std::cos(MagickPI*x)+0.08*std::cos(2*MagickPI*x)); + } + + inline float BlackmanBessel(const float x,const float support){ + return(Blackman(x/support,support)*Bessel(x,support)); + } + + inline float BlackmanSinc(const float x, const float support){ + return(Blackman(x/support,support)*Sinc(x,support)); + } + + inline float Box(const float x, const float /*support*/){ + if(x < -0.5) + return(0.0); + if(x < 0.5) + return(1.0); + return(0.0); + } + + inline float Catrom(const float x, const float /*support*/){ + if(x < -2.0) + return(0.0); + if(x < -1.0) + return(0.5*(4.0+x*(8.0+x*(5.0+x)))); + if(x < 0.0) + return(0.5*(2.0+x*x*(-5.0-3.0*x))); + if(x < 1.0) + return(0.5*(2.0+x*x*(-5.0+3.0*x))); + if(x < 2.0) + return(0.5*(4.0+x*(-8.0+x*(5.0-x)))); + return(0.0); + } + + inline float Cubic(const float x, const float /*support*/){ + if(x < -2.0) + return(0.0); + if(x < -1.0) + return((2.0+x)*(2.0+x)*(2.0+x)/6.0); + if(x < 0.0) + return((4.0+x*x*(-6.0-3.0*x))/6.0); + if(x < 1.0) + return((4.0+x*x*(-6.0+3.0*x))/6.0); + if(x < 2.0) + return((2.0-x)*(2.0-x)*(2.0-x)/6.0); + return(0.0); + } + + inline float Gaussian(const float x, const float /*support*/){ + return(std::exp((float)(-2.0*x*x))*std::sqrt(2.0/MagickPI)); + } + + inline float Hanning(const float x, const float /*support*/){ + return(0.5+0.5*std::cos(MagickPI*(double) x)); + } + + inline float Hamming(const float x, const float /*support*/){ + return(0.54+0.46*std::cos(MagickPI*(double) x)); + } + + inline float Hermite(const float x, const float /*support*/){ + if(x < -1.0) + return(0.0); + if(x < 0.0) + return((2.0*(-x)-3.0)*(-x)*(-x)+1.0); + if(x < 1.0) + return((2.0*x-3.0)*x*x+1.0); + return(0.0); + } + + inline float Lanczos(const float x, const float support){ + if(x < -3.0) + return(0.0); + if(x < 0.0) + return(Sinc(-x,support)*Sinc(-x/3.0,support)); + if(x < 3.0) + return(Sinc(x,support)*Sinc(x/3.0,support)); + return(0.0); + } + + inline float Mitchell(const float x, const float /*support*/){ +#define B (1.0/3.0) +#define C (1.0/3.0) +#define P0 (( 6.0- 2.0*B )/6.0) +#define P2 ((-18.0+12.0*B+ 6.0*C)/6.0) +#define P3 (( 12.0- 9.0*B- 6.0*C)/6.0) +#define Q0 (( 8.0*B+24.0*C)/6.0) +#define Q1 (( -12.0*B-48.0*C)/6.0) +#define Q2 (( 6.0*B+30.0*C)/6.0) +#define Q3 (( - 1.0*B- 6.0*C)/6.0) + if(x < -2.0) + return(0.0); + if(x < -1.0) + return(Q0-x*(Q1-x*(Q2-x*Q3))); + if(x < 0.0) + return(P0+x*x*(P2-x*P3)); + if(x < 1.0) + return(P0+x*x*(P2+x*P3)); + if(x < 2.0) + return(Q0+x*(Q1+x*(Q2+x*Q3))); + return(0.0); + } + + inline float Quadratic(const float x, const float /*support*/){ + if(x < -1.5) + return(0.0); + if(x < -0.5) + return(0.5*(x+1.5)*(x+1.5)); + if(x < 0.5) + return(0.75-x*x); + if(x < 1.5) + return(0.5*(x-1.5)*(x-1.5)); + return(0.0); + } + + inline float Triangle(const float x, const float /*support*/){ + if(x < -1.0) + return(0.0); + if(x < 0.0) + return(1.0+x); + if(x < 1.0) + return(1.0-x); + return(0.0); + } +} + +using namespace BlitzScaleFilter; + + +// +// Horizontal and vertical filters +// + +bool BlitzScaleFilter::horizontalFilter(QImage *srcImg, + QImage *destImg, + float x_factor, float blur, + ContributionInfo *contribution, + Blitz::ScaleFilterType filter) +{ + int n, start, stop, i, x, y; + float center, density, scale, support; + float r, g, b, a; + QRgb *srcData = (QRgb *)srcImg->bits(); + QRgb *destData = (QRgb *)destImg->bits(); + int sw = srcImg->width(); + int dw = destImg->width(); + QRgb pixel; + + scale = blur*qMax(1.0/x_factor, 1.0); + support = scale*filterSupport[filter]; + if(support <= 0.5){ + support = float(0.5+MagickEpsilon); + scale = 1.0; + } + scale = 1.0/scale; + + for(x=0; x < destImg->width(); ++x){ + center = (float) (x+0.5)/x_factor; + start = (int)qMax((double)center-support+0.5, (double)0.0); + stop = (int)qMin((double)center+support+0.5, (double)srcImg->width()); + density=0.0; + + for(n=0; n < (stop-start); ++n){ + contribution[n].pixel = start+n; + switch(filter){ + case Blitz::UndefinedFilter: + default: + contribution[n].weight = + Box(scale*((float)(start+n)-center+0.5), + filterSupport[filter]); + break; + case Blitz::PointFilter: + contribution[n].weight = + Box(scale*((float)(start+n)-center+0.5), + filterSupport[filter]); + break; + case Blitz::BoxFilter: + contribution[n].weight = + Box(scale*((float)(start+n)-center+0.5), + filterSupport[filter]); + break; + case Blitz::TriangleFilter: + contribution[n].weight = + Triangle(scale*((float)(start+n)-center+0.5), + filterSupport[filter]); + break; + case Blitz::HermiteFilter: + contribution[n].weight = + Hermite(scale*((float)(start+n)-center+0.5), + filterSupport[filter]); + break; + case Blitz::HanningFilter: + contribution[n].weight = + Hanning(scale*((float)(start+n)-center+0.5), + filterSupport[filter]); + break; + case Blitz::HammingFilter: + contribution[n].weight = + Hamming(scale*((float)(start+n)-center+0.5), + filterSupport[filter]); + break; + case Blitz::BlackmanFilter: + contribution[n].weight = + Blackman(scale*((float)(start+n)-center+0.5), + filterSupport[filter]); + break; + case Blitz::GaussianFilter: + contribution[n].weight = + Gaussian(scale*((float)(start+n)-center+0.5), + filterSupport[filter]); + break; + case Blitz::QuadraticFilter: + contribution[n].weight = + Quadratic(scale*((float)(start+n)-center+0.5), + filterSupport[filter]); + break; + case Blitz::CubicFilter: + contribution[n].weight = + Cubic(scale*((float)(start+n)-center+0.5), + filterSupport[filter]); + break; + case Blitz::CatromFilter: + contribution[n].weight = + Catrom(scale*((float)(start+n)-center+0.5), + filterSupport[filter]); + break; + case Blitz::MitchellFilter: + contribution[n].weight = + Mitchell(scale*((float)(start+n)-center+0.5), + filterSupport[filter]); + break; + case Blitz::LanczosFilter: + contribution[n].weight = + Lanczos(scale*((float)(start+n)-center+0.5), + filterSupport[filter]); + break; + case Blitz::BesselFilter: + contribution[n].weight = + BlackmanBessel(scale*((float)(start+n)-center+0.5), + filterSupport[filter]); + break; + case Blitz::SincFilter: + contribution[n].weight = + BlackmanSinc(scale*((float)(start+n)-center+0.5), + filterSupport[filter]); + break; + } + density += contribution[n].weight; + } + + if((density != 0.0) && (density != 1.0)){ + // Normalize + density = 1.0/density; + for(i=0; i < n; ++i) + contribution[i].weight *= density; + } + + for(y=0; y < destImg->height(); ++y){ + r = g = b = a = 0; + for(i=0; i < n; ++i){ + pixel = *(srcData+(y*sw)+contribution[i].pixel); + r += qRed(pixel)*contribution[i].weight; + g += qGreen(pixel)*contribution[i].weight; + b += qBlue(pixel)*contribution[i].weight; + a += qAlpha(pixel)*contribution[i].weight; + } + r = r < 0 ? 0 : r > 255 ? 255 : r + 0.5; + g = g < 0 ? 0 : g > 255 ? 255 : g + 0.5; + b = b < 0 ? 0 : b > 255 ? 255 : b + 0.5; + a = a < 0 ? 0 : a > 255 ? 255 : a + 0.5; + *(destData+(y*dw)+x) = qRgba((unsigned char)r, + (unsigned char)g, + (unsigned char)b, + (unsigned char)a); + } + } + return(true); +} + +bool BlitzScaleFilter::verticalFilter(QImage *srcImg, + QImage *destImg, + float y_factor, float blur, + ContributionInfo *contribution, + Blitz::ScaleFilterType filter) +{ + int n, start, stop, i, x, y; + float center, density, scale, support; + float r, g, b, a; + QRgb *srcData = (QRgb *)srcImg->bits(); + QRgb *destData = (QRgb *)destImg->bits(); + int sw = srcImg->width(); + int dw = destImg->width(); + QRgb pixel; + + scale = blur*qMax(1.0/y_factor, 1.0); + support = scale*filterSupport[filter]; + if(support <= 0.5){ + support = float(0.5+MagickEpsilon); + scale = 1.0; + } + scale = 1.0/scale; + + for(y=0; y < destImg->height(); ++y){ + center = (float) (y+0.5)/y_factor; + start = (int)qMax((double)center-support+0.5, (double)0.0); + stop = (int)qMin((double)center+support+0.5, (double)srcImg->height()); + density=0.0; + + for(n=0; n < (stop-start); ++n){ + contribution[n].pixel = start+n; + switch(filter){ + case Blitz::UndefinedFilter: + default: + contribution[n].weight = + Box(scale*((float)(start+n)-center+0.5), + filterSupport[filter]); + break; + case Blitz::PointFilter: + contribution[n].weight = + Box(scale*((float)(start+n)-center+0.5), + filterSupport[filter]); + break; + case Blitz::BoxFilter: + contribution[n].weight = + Box(scale*((float)(start+n)-center+0.5), + filterSupport[filter]); + break; + + case Blitz::TriangleFilter: + contribution[n].weight = + Triangle(scale*((float)(start+n)-center+0.5), + filterSupport[filter]); + break; + case Blitz::HermiteFilter: + contribution[n].weight = + Hermite(scale*((float)(start+n)-center+0.5), + filterSupport[filter]); + break; + case Blitz::HanningFilter: + contribution[n].weight = + Hanning(scale*((float)(start+n)-center+0.5), + filterSupport[filter]); + break; + case Blitz::HammingFilter: + contribution[n].weight = + Hamming(scale*((float)(start+n)-center+0.5), + filterSupport[filter]); + break; + case Blitz::BlackmanFilter: + contribution[n].weight = + Blackman(scale*((float)(start+n)-center+0.5), + filterSupport[filter]); + break; + case Blitz::GaussianFilter: + contribution[n].weight = + Gaussian(scale*((float)(start+n)-center+0.5), + filterSupport[filter]); + break; + case Blitz::QuadraticFilter: + contribution[n].weight = + Quadratic(scale*((float)(start+n)-center+0.5), + filterSupport[filter]); + break; + case Blitz::CubicFilter: + contribution[n].weight = + Cubic(scale*((float)(start+n)-center+0.5), + filterSupport[filter]); + break; + case Blitz::CatromFilter: + contribution[n].weight = + Catrom(scale*((float)(start+n)-center+0.5), + filterSupport[filter]); + break; + case Blitz::MitchellFilter: + contribution[n].weight = + Mitchell(scale*((float)(start+n)-center+0.5), + filterSupport[filter]); + break; + case Blitz::LanczosFilter: + contribution[n].weight = + Lanczos(scale*((float)(start+n)-center+0.5), + filterSupport[filter]); + break; + case Blitz::BesselFilter: + contribution[n].weight = + BlackmanBessel(scale*((float)(start+n)-center+0.5), + filterSupport[filter]); + break; + case Blitz::SincFilter: + contribution[n].weight = + BlackmanSinc(scale*((float)(start+n)-center+0.5), + filterSupport[filter]); + break; + } + density += contribution[n].weight; + } + + if((density != 0.0) && (density != 1.0)){ + // Normalize + density = 1.0/density; + for(i=0; i < n; ++i) + contribution[i].weight *= density; + } + + for(x=0; x < destImg->width(); ++x){ + r = g = b = a = 0; + for(i=0; i < n; ++i){ + pixel = *(srcData+(contribution[i].pixel*sw)+x); + r += qRed(pixel)*contribution[i].weight; + g += qGreen(pixel)*contribution[i].weight; + b += qBlue(pixel)*contribution[i].weight; + a += qAlpha(pixel)*contribution[i].weight; + } + r = r < 0 ? 0 : r > 255 ? 255 : r + 0.5; + g = g < 0 ? 0 : g > 255 ? 255 : g + 0.5; + b = b < 0 ? 0 : b > 255 ? 255 : b + 0.5; + a = a < 0 ? 0 : a > 255 ? 255 : a + 0.5; + *(destData+(y*dw)+x) = qRgba((unsigned char)r, + (unsigned char)g, + (unsigned char)b, + (unsigned char)a); + } + } + return(true); +} + +QImage Blitz::smoothScaleFilter(const QImage &img, int w, int h, + float blur, ScaleFilterType filter, + Qt::AspectRatioMode aspectRatio) +{ + return(smoothScaleFilter(img, QSize(w, h), blur, filter, aspectRatio)); +} + +QImage Blitz::smoothScaleFilter(const QImage &inImage, const QSize &sz, + float blur, ScaleFilterType filter, + Qt::AspectRatioMode aspectRatio) +{ + QImage img(inImage); + QSize destSize(img.size()); + + destSize.scale(sz, aspectRatio); + if(img.isNull() || !destSize.isValid()) + return(img); + int dw = destSize.width(); + int dh = destSize.height(); + + if(img.depth() != 32){ + img = img.convertToFormat(img.hasAlphaChannel() ? + QImage::Format_ARGB32 : + QImage::Format_RGB32); + } + else if(img.format() == QImage::Format_ARGB32_Premultiplied) + img = img.convertToFormat(QImage::Format_ARGB32); + + QImage buffer(destSize, img.hasAlphaChannel() ? + QImage::Format_ARGB32 : QImage::Format_RGB32); + + ContributionInfo *contribution; + float support, x_factor, x_support, y_factor, y_support; + int i; + + // + // Allocate filter contribution info. + // + x_factor= (float)buffer.width()/img.width(); + y_factor= (float)buffer.height()/img.height(); + i = (int)LanczosFilter; + if(filter != UndefinedFilter) + i = (int)filter; + else + if((x_factor == 1.0) && (y_factor == 1.0)) + i = (int)PointFilter; + else + i = (int)MitchellFilter; + x_support = blur*qMax(1.0/x_factor, 1.0)*filterSupport[i]; + y_support = blur*qMax(1.0/y_factor, 1.0)*filterSupport[i]; + support = qMax(x_support, y_support); + if(support < filterSupport[i]) + support = filterSupport[i]; + contribution = + new ContributionInfo[(int)(2.0*qMax((double)support, (double)0.5)+3)]; + + // + // Scale + // + if((dw*(img.height()+dh)) > (dh*(img.width()+dw))){ + QImage tmp(dw, img.height(), buffer.format()); + horizontalFilter(&img, &tmp, x_factor, blur, contribution, filter); + verticalFilter(&tmp, &buffer, y_factor, blur, contribution, filter); + } + else{ + QImage tmp(img.width(), dh, buffer.format()); + verticalFilter(&img, &tmp, y_factor, blur, contribution, filter); + horizontalFilter(&tmp, &buffer, x_factor, blur, contribution, filter); + } + + delete[] contribution; + return(buffer); +} + + diff -Nru syncwall-1.6.0/src/3rdparty/qkeysequencewidget/designer-plugin/qkeysequencewidgetplugin.cpp syncwall-1.7.4/src/3rdparty/qkeysequencewidget/designer-plugin/qkeysequencewidgetplugin.cpp --- syncwall-1.6.0/src/3rdparty/qkeysequencewidget/designer-plugin/qkeysequencewidgetplugin.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qkeysequencewidget/designer-plugin/qkeysequencewidgetplugin.cpp 2010-08-17 11:53:52.000000000 +0000 @@ -0,0 +1,80 @@ +/****************************************************************************** +Copyright (c) 2010, Artem Galichkin +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*******************************************************************************/ + +#include "qkeysequencewidget.h" +#include "qkeysequencewidgetplugin.h" + +#include + +QKeySequenceWidgetPlugin::QKeySequenceWidgetPlugin(QObject *parent) : + QObject(parent) +{ +} + +QString QKeySequenceWidgetPlugin::name() const +{ + return "QKeySequenceWidget"; +} + +QString QKeySequenceWidgetPlugin::includeFile() const +{ + return "qkeysequencewidget.h"; +} + +QString QKeySequenceWidgetPlugin::group() const +{ + return "Custom Widgets"; +} + +QIcon QKeySequenceWidgetPlugin::icon() const +{ + return QIcon(); +} + +QString QKeySequenceWidgetPlugin::toolTip() const +{ + return tr("Tool Tip"); +} + +QString QKeySequenceWidgetPlugin::whatsThis() const +{ + return ""; +} + +bool QKeySequenceWidgetPlugin::isContainer() const +{ + return false; +} + +QWidget* QKeySequenceWidgetPlugin::createWidget(QWidget *parent) +{ + return new QKeySequenceWidget(parent); +} + +Q_EXPORT_PLUGIN2(QKeySequnceWidgetPlugin, QKeySequenceWidgetPlugin) + diff -Nru syncwall-1.6.0/src/3rdparty/qkeysequencewidget/designer-plugin/qkeysequencewidgetplugin.h syncwall-1.7.4/src/3rdparty/qkeysequencewidget/designer-plugin/qkeysequencewidgetplugin.h --- syncwall-1.6.0/src/3rdparty/qkeysequencewidget/designer-plugin/qkeysequencewidgetplugin.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qkeysequencewidget/designer-plugin/qkeysequencewidgetplugin.h 2010-08-17 08:14:24.000000000 +0000 @@ -0,0 +1,55 @@ +/****************************************************************************** +Copyright (c) 2010, Artem Galichkin +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*******************************************************************************/ + +#ifndef QKEYSEQUENCEWIDGETPLUGIN_H +#define QKEYSEQUENCEWIDGETPLUGIN_H + +#include +#include + +class QKeySequenceWidgetPlugin : public QObject, public QDesignerCustomWidgetInterface +{ +Q_OBJECT +Q_INTERFACES(QDesignerCustomWidgetInterface) +public: + explicit QKeySequenceWidgetPlugin(QObject *parent = 0); + + QString name() const; + QString includeFile() const; + QString group() const; + QIcon icon() const; + QString toolTip() const; + QString whatsThis() const; + + bool isContainer() const; + + QWidget* createWidget(QWidget *parent); + +}; + +#endif // QKEYSEQUENCEWIDGETPLUGIN_H diff -Nru syncwall-1.6.0/src/3rdparty/qkeysequencewidget/designer-plugin/qkeysequencewidgetplugin.pro syncwall-1.7.4/src/3rdparty/qkeysequencewidget/designer-plugin/qkeysequencewidgetplugin.pro --- syncwall-1.6.0/src/3rdparty/qkeysequencewidget/designer-plugin/qkeysequencewidgetplugin.pro 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qkeysequencewidget/designer-plugin/qkeysequencewidgetplugin.pro 2010-08-20 13:58:38.000000000 +0000 @@ -0,0 +1,12 @@ +TARGET = QKeySequnceWidgetPlugin +TEMPLATE = lib +CONFIG += designer \ + plugin \ + debug_and_release +include(../qkeysequencewidget/qkeysequencewidget.pri) + +# install +target.path = $$[QT_INSTALL_PLUGINS]/designer +INSTALLS += target +HEADERS += qkeysequencewidgetplugin.h +SOURCES += qkeysequencewidgetplugin.cpp diff -Nru syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/annotated.html syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/annotated.html --- syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/annotated.html 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/annotated.html 2010-08-24 02:25:22.000000000 +0000 @@ -0,0 +1,39 @@ + + + + +QKeySequenceWidget: Class List + + + + + + +
+
+

Class List

+
+
+Here are the classes, structs, unions and interfaces with brief descriptions: + +
QKeySequenceWidgetThe QKeySequenceWidget is a widget to input a QKeySequence
+
+ + + Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/bc_s.png and /tmp/OqecVKC_d5/syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/bc_s.png differ diff -Nru syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/class_q_key_sequence_widget-members.html syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/class_q_key_sequence_widget-members.html --- syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/class_q_key_sequence_widget-members.html 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/class_q_key_sequence_widget-members.html 2010-08-24 02:25:22.000000000 +0000 @@ -0,0 +1,60 @@ + + + + +QKeySequenceWidget: Member List + + + + + + +
+
+

QKeySequenceWidget Member List

+
+
+This is the complete list of members for QKeySequenceWidget, including all inherited members. + + + + + + + + + + + + + + + + + + + + + + + +
ClearButton enum nameQKeySequenceWidget
clearButtonIcon() const QKeySequenceWidget
ClearButtonShow (defined in QKeySequenceWidget)QKeySequenceWidget
clearButtonShow() const QKeySequenceWidget
clearKeySequence()QKeySequenceWidget [slot]
keyNotSupported() (defined in QKeySequenceWidget)QKeySequenceWidget [signal]
keySequence() const QKeySequenceWidget
keySequenceChanged(const QKeySequence &seq) (defined in QKeySequenceWidget)QKeySequenceWidget [signal]
noneText() const QKeySequenceWidget
NoShow enum valueQKeySequenceWidget
QKeySequenceWidget(QWidget *parent=0)QKeySequenceWidget [explicit]
QKeySequenceWidget(QKeySequence seq, QWidget *parent=0)QKeySequenceWidget [explicit]
QKeySequenceWidget(QString noneString, QWidget *parent=0)QKeySequenceWidget [explicit]
QKeySequenceWidget(QKeySequence seq, QString noneString, QWidget *parent=0)QKeySequenceWidget [explicit]
setClearButtonIcon(const QIcon &icon)QKeySequenceWidget [slot]
setClearButtonShow(QKeySequenceWidget::ClearButtonShow show)QKeySequenceWidget [slot]
setKeySequence(const QKeySequence &key)QKeySequenceWidget [slot]
setNoneText(const QString text)QKeySequenceWidget [slot]
setToolTip(const QString &tip) (defined in QKeySequenceWidget)QKeySequenceWidget
ShowLeft enum valueQKeySequenceWidget
ShowRight enum valueQKeySequenceWidget
sizeHint() const (defined in QKeySequenceWidget)QKeySequenceWidget
~QKeySequenceWidget()QKeySequenceWidget [virtual]
+ + + diff -Nru syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/class_q_key_sequence_widget.html syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/class_q_key_sequence_widget.html --- syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/class_q_key_sequence_widget.html 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/class_q_key_sequence_widget.html 2010-08-24 02:25:22.000000000 +0000 @@ -0,0 +1,468 @@ + + + + +QKeySequenceWidget: QKeySequenceWidget Class Reference + + + + + + +
+ +
+

QKeySequenceWidget Class Reference

+
+
+ +

The QKeySequenceWidget is a widget to input a QKeySequence. +More...

+ +

#include <qkeysequencewidget/src/qkeysequencewidget.h>

+ +

List of all members.

+ + + + + + + + + + + + + + + + + + + + + + + + + + +

+Public Types

enum  ClearButton {
+  NoShow = 0x00, +
+  ShowLeft = 0x01, +
+  ShowRight = 0x02 +
+ }

+Public Slots

void setKeySequence (const QKeySequence &key)
void clearKeySequence ()
void setNoneText (const QString text)
void setClearButtonIcon (const QIcon &icon)
void setClearButtonShow (QKeySequenceWidget::ClearButtonShow show)

+Signals

+void keySequenceChanged (const QKeySequence &seq)
+void keyNotSupported ()

+Public Member Functions

 QKeySequenceWidget (QWidget *parent=0)
 QKeySequenceWidget (QKeySequence seq, QWidget *parent=0)
 QKeySequenceWidget (QString noneString, QWidget *parent=0)
 QKeySequenceWidget (QKeySequence seq, QString noneString, QWidget *parent=0)
virtual ~QKeySequenceWidget ()
+QSize sizeHint () const
+void setToolTip (const QString &tip)
QKeySequence keySequence () const
QString noneText () const
QIcon clearButtonIcon () const
QKeySequenceWidget::ClearButtonShow clearButtonShow () const

+Public Attributes

ClearButtonShow
+

Detailed Description

+

The QKeySequenceWidget is a widget to input a QKeySequence.

+

This widget lets the user choose a QKeySequence, which is usually used as a shortcut key. The recording is initiated by calling captureKeySequence() or the user clicking into the widget.

+
    // create new QKeySequenceWidget with empty sequence
+    QKeySequenceWidget *keyWidget = new QKeySequenceWidget;
+    
+    // Set sequence as "Ctrl+Alt+Space"
+    keyWidget->setJeySequence(QKeySequence("Ctrl+Alt+Space"));
+    
+    // set clear button position is left
+    setClearButtonShow(QKeySequenceWidget::ShowLeft);
+    
+    // set cutom clear button icon
+    setClearButtonIcon(QIcon("/path/to/icon.png"));
+    
+    // connecting keySequenceChanged signal to slot
+    connect(keyWidget, SIGNAL(keySequenceChanged(QKeySequence)), this, SLOT(slotKeySequenceChanged(QKeySequence)));
+

Member Enumeration Documentation

+ +
+
+ + + + +
enum ClearButton
+
+
+ +

Modes of sohow ClearButton.

+
Enumerator:
+ + + +
NoShow  +

Hide ClearButton

+
ShowLeft  +

ClearButton isow is left

+
ShowRight  +

ClearButton isow is left

+
+
+
+ +
+
+

Constructor & Destructor Documentation

+ +
+
+ + + + + + + + + +
QKeySequenceWidget (QWidget *  parent = 0 )  [explicit]
+
+
+

Creates a QKeySequenceWidget object wuth parent and empty keySequence

+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + +
QKeySequenceWidget (QKeySequence  seq,
QWidget *  parent = 0 
) [explicit]
+
+
+

Creates a QKeySequenceWidget object wuth parent and keysequence keySequence

+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + +
QKeySequenceWidget (QString  noneString,
QWidget *  parent = 0 
) [explicit]
+
+
+

Creates a QKeySequenceWidget object wuth parent and string for noneString

+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
QKeySequenceWidget (QKeySequence  seq,
QString  noneString,
QWidget *  parent = 0 
) [explicit]
+
+
+

Creates a QKeySequenceWidget object wuth parent and keysequence keySequence and string for noneString

+ +
+
+ +
+
+ + + + + + + + +
~QKeySequenceWidget ( )  [virtual]
+
+
+

Destroy a QKeySequenceWidget object

+ +
+
+

Member Function Documentation

+ +
+
+ + + + + + + + +
QIcon clearButtonIcon ( )  const
+
+
+

Get clear buttom icon.

+
Returns:
QIcon object
+ +
+
+ +
+
+ + + + + + + + +
QKeySequenceWidget::ClearButtonShow clearButtonShow ( )  const
+
+
+

Return mode of clear button dosplay.

+
Parameters:
+ + +
show Dysplay mode of clear button (NoShow, ShowLeft or ShorRight)
+
+
+ +
+
+ +
+
+ + + + + + + + +
void clearKeySequence ( )  [slot]
+
+
+

Clear key sequence.

+ +
+
+ +
+
+ + + + + + + + +
QKeySequence keySequence ( )  const
+
+
+

Get current key sequence.

+
Returns:
Current key sequenc
+ +
+
+ +
+
+ + + + + + + + +
QString noneText ( )  const
+
+
+

Get string for display when key sequence is undefined.

+
Returns:
Text string
+ +
+
+ +
+
+ + + + + + + + + +
void setClearButtonIcon (const QIcon &  icon )  [slot]
+
+
+

Set custom icon for clear buttom.

+
Parameters:
+ + +
icon QIcon object
+
+
+ +
+
+ +
+
+ + + + + + + + + +
void setClearButtonShow (QKeySequenceWidget::ClearButtonShow  show )  [slot]
+
+
+

Setting mode of Clear Buttorn display.

+
Parameters:
+ + +
show Position of clear button ClearButtornShow
+
+
+ +
+
+ +
+
+ + + + + + + + + +
void setKeySequence (const QKeySequence &  key )  [slot]
+
+
+

Set the key sequence.

+
Parameters:
+ + +
key Key sequence
+
+
+
See also:
clearKeySequence
+ +
+
+ +
+
+ + + + + + + + + +
void setNoneText (const QString  text )  [slot]
+
+
+

Set string for display when key sequence is undefined.

+
Parameters:
+ + +
text Text string
+
+
+ +
+
+
+ + + diff -Nru syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/classes.html syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/classes.html --- syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/classes.html 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/classes.html 2010-08-24 02:25:22.000000000 +0000 @@ -0,0 +1,40 @@ + + + + +QKeySequenceWidget: Alphabetical List + + + + + + +
+
+

Class Index

+
+
+ + +
  Q  
+
QKeySequenceWidget   
+
+ + + Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/closed.png and /tmp/OqecVKC_d5/syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/closed.png differ diff -Nru syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/doxygen.css syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/doxygen.css --- syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/doxygen.css 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/doxygen.css 2010-08-24 02:25:22.000000000 +0000 @@ -0,0 +1,656 @@ +/* The standard CSS for doxygen */ + +body, table, div, p, dl { + font-family: Lucida Grande, Verdana, Geneva, Arial, sans-serif; + font-size: 12px; +} + +/* @group Heading Levels */ + +h1 { + font-size: 150%; +} + +h2 { + font-size: 120%; +} + +h3 { + font-size: 100%; +} + +dt { + font-weight: bold; +} + +div.multicol { + -moz-column-gap: 1em; + -webkit-column-gap: 1em; + -moz-column-count: 3; + -webkit-column-count: 3; +} + +p.startli, p.startdd, p.starttd { + margin-top: 2px; +} + +p.endli { + margin-bottom: 0px; +} + +p.enddd { + margin-bottom: 4px; +} + +p.endtd { + margin-bottom: 2px; +} + +/* @end */ + +caption { + font-weight: bold; +} + +span.legend { + font-size: 70%; + text-align: center; +} + +h3.version { + font-size: 90%; + text-align: center; +} + +div.qindex, div.navtab{ + background-color: #EBEFF6; + border: 1px solid #A3B4D7; + text-align: center; + margin: 2px; + padding: 2px; +} + +div.qindex, div.navpath { + width: 100%; + line-height: 140%; +} + +div.navtab { + margin-right: 15px; +} + +/* @group Link Styling */ + +a { + color: #3D578C; + font-weight: normal; + text-decoration: none; +} + +.contents a:visited { + color: #4665A2; +} + +a:hover { + text-decoration: underline; +} + +a.qindex { + font-weight: bold; +} + +a.qindexHL { + font-weight: bold; + background-color: #9CAFD4; + color: #ffffff; + border: 1px double #869DCA; +} + +.contents a.qindexHL:visited { + color: #ffffff; +} + +a.el { + font-weight: bold; +} + +a.elRef { +} + +a.code { + color: #4665A2; +} + +a.codeRef { + color: #4665A2; +} + +/* @end */ + +dl.el { + margin-left: -1cm; +} + +.fragment { + font-family: monospace, fixed; + font-size: 105%; +} + +pre.fragment { + border: 1px solid #C4CFE5; + background-color: #FBFCFD; + padding: 4px 6px; + margin: 4px 8px 4px 2px; + overflow: auto; + word-wrap: break-word; + font-size: 9pt; + line-height: 125%; +} + +div.ah { + background-color: black; + font-weight: bold; + color: #ffffff; + margin-bottom: 3px; + margin-top: 3px; + padding: 0.2em; + border: solid thin #333; + border-radius: 0.5em; + -webkit-border-radius: .5em; + -moz-border-radius: .5em; + -webkit-box-shadow: 2px 2px 3px #999; + -moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px; + background-image: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#000),color-stop(0.3, #444)); + background-image: -moz-linear-gradient(center top, #eee 0%, #444 40%, #000); +} + +div.groupHeader { + margin-left: 16px; + margin-top: 12px; + margin-bottom: 6px; + font-weight: bold; +} + +div.groupText { + margin-left: 16px; + font-style: italic; +} + +body { + background: white; + color: black; + margin: 0; +} + +div.contents { + margin-top: 10px; + margin-left: 10px; + margin-right: 10px; +} + +td.indexkey { + background-color: #EBEFF6; + font-weight: bold; + border: 1px solid #C4CFE5; + margin: 2px 0px 2px 0; + padding: 2px 10px; +} + +td.indexvalue { + background-color: #EBEFF6; + border: 1px solid #C4CFE5; + padding: 2px 10px; + margin: 2px 0px; +} + +tr.memlist { + background-color: #EEF1F7; +} + +p.formulaDsp { + text-align: center; +} + +img.formulaDsp { + +} + +img.formulaInl { + vertical-align: middle; +} + +div.center { + text-align: center; + margin-top: 0px; + margin-bottom: 0px; + padding: 0px; +} + +div.center img { + border: 0px; +} + +address.footer { + text-align: right; + padding-right: 12px; +} + +img.footer { + border: 0px; + vertical-align: middle; +} + +/* @group Code Colorization */ + +span.keyword { + color: #008000 +} + +span.keywordtype { + color: #604020 +} + +span.keywordflow { + color: #e08000 +} + +span.comment { + color: #800000 +} + +span.preprocessor { + color: #806020 +} + +span.stringliteral { + color: #002080 +} + +span.charliteral { + color: #008080 +} + +span.vhdldigit { + color: #ff00ff +} + +span.vhdlchar { + color: #000000 +} + +span.vhdlkeyword { + color: #700070 +} + +span.vhdllogic { + color: #ff0000 +} + +/* @end */ + +/* +.search { + color: #003399; + font-weight: bold; +} + +form.search { + margin-bottom: 0px; + margin-top: 0px; +} + +input.search { + font-size: 75%; + color: #000080; + font-weight: normal; + background-color: #e8eef2; +} +*/ + +td.tiny { + font-size: 75%; +} + +.dirtab { + padding: 4px; + border-collapse: collapse; + border: 1px solid #A3B4D7; +} + +th.dirtab { + background: #EBEFF6; + font-weight: bold; +} + +hr { + height: 0px; + border: none; + border-top: 1px solid #4A6AAA; +} + +hr.footer { + height: 1px; +} + +/* @group Member Descriptions */ + +table.memberdecls { + border-spacing: 0px; + padding: 0px; +} + +.mdescLeft, .mdescRight, +.memItemLeft, .memItemRight, +.memTemplItemLeft, .memTemplItemRight, .memTemplParams { + background-color: #F9FAFC; + border: none; + margin: 4px; + padding: 1px 0 0 8px; +} + +.mdescLeft, .mdescRight { + padding: 0px 8px 4px 8px; + color: #555; +} + +.memItemLeft, .memItemRight, .memTemplParams { + border-top: 1px solid #C4CFE5; +} + +.memItemLeft, .memTemplItemLeft { + white-space: nowrap; +} + +.memTemplParams { + color: #4665A2; + white-space: nowrap; +} + +/* @end */ + +/* @group Member Details */ + +/* Styles for detailed member documentation */ + +.memtemplate { + font-size: 80%; + color: #4665A2; + font-weight: normal; + margin-left: 3px; +} + +.memnav { + background-color: #EBEFF6; + border: 1px solid #A3B4D7; + text-align: center; + margin: 2px; + margin-right: 15px; + padding: 2px; +} + +.memitem { + padding: 0; + margin-bottom: 10px; +} + +.memname { + white-space: nowrap; + font-weight: bold; + margin-left: 6px; +} + +.memproto { + border-top: 1px solid #A8B8D9; + border-left: 1px solid #A8B8D9; + border-right: 1px solid #A8B8D9; + padding: 6px 0px 6px 0px; + color: #253555; + font-weight: bold; + text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); + /* firefox specific markup */ + -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; + -moz-border-radius-topright: 8px; + -moz-border-radius-topleft: 8px; + /* webkit specific markup */ + -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + -webkit-border-top-right-radius: 8px; + -webkit-border-top-left-radius: 8px; + background-image:url('nav_f.png'); + background-repeat:repeat-x; + background-color: #E2E8F2; + +} + +.memdoc { + border-bottom: 1px solid #A8B8D9; + border-left: 1px solid #A8B8D9; + border-right: 1px solid #A8B8D9; + padding: 2px 5px; + background-color: #FBFCFD; + border-top-width: 0; + /* firefox specific markup */ + -moz-border-radius-bottomleft: 8px; + -moz-border-radius-bottomright: 8px; + -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; + background-image: -moz-linear-gradient(center top, #FFFFFF 0%, #FFFFFF 60%, #F7F8FB 95%, #EEF1F7); + /* webkit specific markup */ + -webkit-border-bottom-left-radius: 8px; + -webkit-border-bottom-right-radius: 8px; + -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + background-image: -webkit-gradient(linear,center top,center bottom,from(#FFFFFF), color-stop(0.6,#FFFFFF), color-stop(0.60,#FFFFFF), color-stop(0.95,#F7F8FB), to(#EEF1F7)); +} + +.paramkey { + text-align: right; +} + +.paramtype { + white-space: nowrap; +} + +.paramname { + color: #602020; + white-space: nowrap; +} +.paramname em { + font-style: normal; +} + +/* @end */ + +/* @group Directory (tree) */ + +/* for the tree view */ + +.ftvtree { + font-family: sans-serif; + margin: 0px; +} + +/* these are for tree view when used as main index */ + +.directory { + font-size: 9pt; + font-weight: bold; + margin: 5px; +} + +.directory h3 { + margin: 0px; + margin-top: 1em; + font-size: 11pt; +} + +/* +The following two styles can be used to replace the root node title +with an image of your choice. Simply uncomment the next two styles, +specify the name of your image and be sure to set 'height' to the +proper pixel height of your image. +*/ + +/* +.directory h3.swap { + height: 61px; + background-repeat: no-repeat; + background-image: url("yourimage.gif"); +} +.directory h3.swap span { + display: none; +} +*/ + +.directory > h3 { + margin-top: 0; +} + +.directory p { + margin: 0px; + white-space: nowrap; +} + +.directory div { + display: none; + margin: 0px; +} + +.directory img { + vertical-align: -30%; +} + +/* these are for tree view when not used as main index */ + +.directory-alt { + font-size: 100%; + font-weight: bold; +} + +.directory-alt h3 { + margin: 0px; + margin-top: 1em; + font-size: 11pt; +} + +.directory-alt > h3 { + margin-top: 0; +} + +.directory-alt p { + margin: 0px; + white-space: nowrap; +} + +.directory-alt div { + display: none; + margin: 0px; +} + +.directory-alt img { + vertical-align: -30%; +} + +/* @end */ + +div.dynheader { + margin-top: 8px; +} + +address { + font-style: normal; + color: #2A3D61; +} + +table.doxtable { + border-collapse:collapse; +} + +table.doxtable td, table.doxtable th { + border: 1px solid #2D4068; + padding: 3px 7px 2px; +} + +table.doxtable th { + background-color: #374F7F; + color: #FFFFFF; + font-size: 110%; + padding-bottom: 4px; + padding-top: 5px; + text-align:left; +} + +.tabsearch { + top: 0px; + left: 10px; + height: 36px; + background-image: url('tab_b.png'); + z-index: 101; + overflow: hidden; + font-size: 13px; +} + +.navpath ul +{ + font-size: 11px; + background-image:url('tab_b.png'); + background-repeat:repeat-x; + height:30px; + line-height:30px; + color:#8AA0CC; + border:solid 1px #C2CDE4; + overflow:hidden; + margin:0px; + padding:0px; +} + +.navpath li +{ + list-style-type:none; + float:left; + padding-left:10px; + padding-right: 15px; + background-image:url('bc_s.png'); + background-repeat:no-repeat; + background-position:right; + color:#364D7C; +} + +.navpath a +{ + height:32px; + display:block; + text-decoration: none; + outline: none; +} + +.navpath a:hover +{ + color:#6884BD; +} + +div.summary +{ + float: right; + font-size: 8pt; + padding-right: 5px; + width: 50%; + text-align: right; +} + +div.summary a +{ + white-space: nowrap; +} + +div.header +{ + background-image:url('nav_h.png'); + background-repeat:repeat-x; + background-color: #F9FAFC; + margin: 0px; + border-bottom: 1px solid #C4CFE5; +} + +div.headertitle +{ + padding: 5px 5px 5px 10px; +} + Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/doxygen.png and /tmp/OqecVKC_d5/syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/doxygen.png differ diff -Nru syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/functions.html syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/functions.html --- syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/functions.html 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/functions.html 2010-08-24 02:25:22.000000000 +0000 @@ -0,0 +1,87 @@ + + + + +QKeySequenceWidget: Class Members + + + + + + +
+Here is a list of all documented class members with links to the class documentation for each member: +
+ + + diff -Nru syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/functions_enum.html syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/functions_enum.html --- syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/functions_enum.html 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/functions_enum.html 2010-08-24 02:25:22.000000000 +0000 @@ -0,0 +1,45 @@ + + + + +QKeySequenceWidget: Class Members - Enumerations + + + + + + +
+
+ + + diff -Nru syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/functions_eval.html syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/functions_eval.html --- syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/functions_eval.html 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/functions_eval.html 2010-08-24 02:25:22.000000000 +0000 @@ -0,0 +1,51 @@ + + + + +QKeySequenceWidget: Class Members - Enumerator + + + + + + +
+
+ + + diff -Nru syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/functions_func.html syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/functions_func.html --- syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/functions_func.html 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/functions_func.html 2010-08-24 02:25:22.000000000 +0000 @@ -0,0 +1,75 @@ + + + + +QKeySequenceWidget: Class Members - Functions + + + + + + +
+
+ + + diff -Nru syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/index.hhc syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/index.hhc --- syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/index.hhc 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/index.hhc 2010-08-24 02:25:22.000000000 +0000 @@ -0,0 +1,21 @@ + + + + + +
    +
  • +
  • +
      +
    +
  • +
      +
    +
  • +
      +
    • +
    +
  • +
+ + diff -Nru syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/index.hhk syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/index.hhk --- syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/index.hhk 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/index.hhk 2010-08-24 02:25:22.000000000 +0000 @@ -0,0 +1,51 @@ + + + + + +
    +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
      +
    • +
    • +
    • +
    • +
    • +
    • +
    • +
    • +
    • +
    • +
    • +
    • +
    • +
    • +
    • +
    • +
    • +
    • +
    • +
    +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
+ + diff -Nru syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/index.hhp syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/index.hhp --- syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/index.hhp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/index.hhp 2010-08-24 02:25:22.000000000 +0000 @@ -0,0 +1,33 @@ +[OPTIONS] +Compatibility=1.1 +Full-text search=Yes +Contents file=index.hhc +Default Window=main +Default topic=index.html +Index file=index.hhk +Language=0x409 English (United States) +Title=QKeySequenceWidget + +[WINDOWS] +main="QKeySequenceWidget","index.hhc","index.hhk","index.html","index.html",,,,,0x23520,,0x10387e,,,,,,,,0 + +[FILES] +index.html +pages.html +license.html +using.html +annotated.html +classes.html +functions.html +functions_func.html +functions_enum.html +functions_eval.html +class_q_key_sequence_widget.html +class_q_key_sequence_widget-members.html +tabs.css +tab_a.png +tab_b.png +tab_h.png +tab_s.png +nav_h.png +nav_f.png diff -Nru syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/index.html syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/index.html --- syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/index.html 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/index.html 2010-08-24 02:25:22.000000000 +0000 @@ -0,0 +1,52 @@ + + + + +QKeySequenceWidget: QKeySequenceWidget + + + + + + + +
+

1.0

+Overview

+

The QKeySequenceWidget is a widget to input a QKeySequence.

+

This widget lets the user choose a QKeySequence, which i s usually used as a shortcut key. The recording is initiated by calling captureKeySequence() or the user clicking into the widget.

+

The QKeySequenceWidget is based on code KKeySequenceWidget from KDE project. But it not needs kde libraries for building and working.

+

+Platforms

+

QKeySequenceWidget might be usable in all environments where you find Qt.
+ QKeySequenceWidget requires Qt 4.5.x or newer.

+

+How to use the QKeySequenceWidget

+

Read the page Using the QKeySequenceWidget to obtain how to integrate SingleApplication with your project.

+

+License

+

QKeySequenceWidget is distributed under the terms of the BSD License.

+

+Author contacts

+

Author: Artem Galichkin

+ +
+ + + diff -Nru syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/license.html syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/license.html --- syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/license.html 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/license.html 2010-08-24 02:25:22.000000000 +0000 @@ -0,0 +1,37 @@ + + + + +QKeySequenceWidget: License + + + + + + +
+
+

License

+
+
+

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

+
    +
  • * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • +
  • * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • +
  • * Neither the name of the <organization> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
  • +
+

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT holder>=""> BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+
+ + + Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/nav_f.png and /tmp/OqecVKC_d5/syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/nav_f.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/nav_h.png and /tmp/OqecVKC_d5/syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/nav_h.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/open.png and /tmp/OqecVKC_d5/syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/open.png differ diff -Nru syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/pages.html syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/pages.html --- syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/pages.html 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/pages.html 2010-08-24 02:25:22.000000000 +0000 @@ -0,0 +1,36 @@ + + + + +QKeySequenceWidget: Page Index + + + + + + +
+
+

Related Pages

+
+
+Here is a list of all related documentation pages: +
+ + + Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/tab_a.png and /tmp/OqecVKC_d5/syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/tab_a.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/tab_b.png and /tmp/OqecVKC_d5/syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/tab_b.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/tab_h.png and /tmp/OqecVKC_d5/syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/tab_h.png differ Binary files /tmp/z4QGu3aKN3/syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/tab_s.png and /tmp/OqecVKC_d5/syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/tab_s.png differ diff -Nru syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/tabs.css syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/tabs.css --- syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/tabs.css 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/tabs.css 2010-08-24 02:25:22.000000000 +0000 @@ -0,0 +1,59 @@ +.tabs, .tabs2, .tabs3 { + background-image: url('tab_b.png'); + width: 100%; + z-index: 101; + font-size: 13px; +} + +.tabs2 { + font-size: 10px; +} +.tabs3 { + font-size: 9px; +} + +.tablist { + margin: 0; + padding: 0; + display: table; +} + +.tablist li { + float: left; + display: table-cell; + background-image: url('tab_b.png'); + line-height: 36px; + list-style: none; +} + +.tablist a { + display: block; + padding: 0 20px; + font-weight: bold; + background-image:url('tab_s.png'); + background-repeat:no-repeat; + background-position:right; + color: #283A5D; + text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); + text-decoration: none; + outline: none; +} + +.tabs3 .tablist a { + padding: 0 10px; +} + +.tablist a:hover { + background-image: url('tab_h.png'); + background-repeat:repeat-x; + color: #fff; + text-shadow: 0px 1px 1px rgba(0, 0, 0, 1.0); + text-decoration: none; +} + +.tablist li.current a { + background-image: url('tab_a.png'); + background-repeat:repeat-x; + color: #fff; + text-shadow: 0px 1px 1px rgba(0, 0, 0, 1.0); +} diff -Nru syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/using.html syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/using.html --- syncwall-1.6.0/src/3rdparty/qkeysequencewidget/doc/html/using.html 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qkeysequencewidget/doc/html/using.html 2010-08-24 02:25:22.000000000 +0000 @@ -0,0 +1,74 @@ + + + + +QKeySequenceWidget: Using the QKeySequenceWidget + + + + + + +
+
+

Using the QKeySequenceWidget

+
+
+

How to use the QKeySequenceWidget

+

+In qmake-based projects

+

For using QKeySequenceWidget in your qmake-based project you must copy "qkeysequencewidget" directory to your source tree. And include qkeysequencewidget.pri into your *.pro file.

+

For example see projects in "demos" directoy .

+

+In qmake-based projects

+

For using QKeySequenceWidget in your CMake-based project you must coy "qkeysequencewidget" directory to your source tree. And include into main CMakeLists.txt this strings:

+
    +
  • add_subdirectory("path/to/qkeysequencewidget/")
  • +
  • include_directories("path/to/qkeysequencewidget/src")
  • +
+

Then add "qkeysequencewidget" into target_link_libraries section for your project.

+

For example, see CmakeLists.txt in root directoy.

+

+Sample code

+

This sample is shows a simple use of the widget in run-time.

+
    // create new QKeySequenceWidget with empty sequence
+    QKeySequenceWidget *keyWidget = new QKeySequenceWidget;
+    
+    // Set sequence as "Ctrl+Alt+Space"
+    keyWidget->setJeySequence(QKeySequence("Ctrl+Alt+Space"));
+    
+    // set clear button position is left
+    setClearButtonShow(QKeySequenceWidget::ShowLeft);
+    
+    // set cutom clear button icon
+    setClearButtonIcon(QIcon("/path/to/icon.png"));
+    
+    // connecting keySequenceChanged signal to slot
+    connect(keyWidget, SIGNAL(keySequenceChanged(QKeySequence)), this, SLOT(slotKeySequenceChanged(QKeySequence)));
+

+Plugin for QtDesigner

+

For using QKeySequenceWidget in QtDesigner you needs build designer-plugin. This located in "designer-plugin" directory.

+
    +
  • qmake
  • +
  • make
  • +
+

Installing QKeySeqenceWidgetPlughin^

+

In Linux:

+

make install (as root)

+

In Windows:

+

Copy QKeySequnceWidgetPlugin.dll to ${QT_DIR}/plugins/designer

+

It builded only qmake, CMake not supported.

+
+ + + diff -Nru syncwall-1.6.0/src/3rdparty/qkeysequencewidget/qkeysequencewidget.cpp syncwall-1.7.4/src/3rdparty/qkeysequencewidget/qkeysequencewidget.cpp --- syncwall-1.6.0/src/3rdparty/qkeysequencewidget/qkeysequencewidget.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qkeysequencewidget/qkeysequencewidget.cpp 2013-04-28 06:30:48.000000000 +0000 @@ -0,0 +1,575 @@ +/****************************************************************************** +Copyright (c) 2010, Artem Galichkin +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*******************************************************************************/ + +#include +#include +#include +#include + +#include "qkeysequencewidget_p.h" +#include "qkeysequencewidget.h" + +/*! + Creates a QKeySequenceWidget object wuth \a parent and empty \a keySequence +*/ +QKeySequenceWidget::QKeySequenceWidget(QWidget *parent) : + QWidget(parent), d_ptr(new QKeySequenceWidgetPrivate()) +{ + Q_D(QKeySequenceWidget); + d->q_ptr = this; + d->init(QKeySequence(), QString()); + + _connectingSlots(); +} + +/*! + Creates a QKeySequenceWidget object wuth \a parent and keysequence \a keySequence + and string for \a noneString +*/ +QKeySequenceWidget::QKeySequenceWidget(QKeySequence seq, QString noneString, QWidget *parent) : + QWidget(parent), d_ptr(new QKeySequenceWidgetPrivate()) +{ + Q_D(QKeySequenceWidget); + d->q_ptr = this; +// qDebug() << "q_prt " << this; + d->init(seq, noneString); + _connectingSlots(); +} + +/*! + Creates a QKeySequenceWidget object wuth \a parent and keysequence \a keySequence +*/ +QKeySequenceWidget::QKeySequenceWidget(QKeySequence seq, QWidget *parent) : + QWidget(parent), d_ptr(new QKeySequenceWidgetPrivate()) +{ +// qDebug() << "widget constructor"; + Q_D(QKeySequenceWidget); + d->q_ptr = this; +// qDebug() << "q_prt " << this; + d->init(seq, QString()); + _connectingSlots(); + +} + +/*! + Creates a QKeySequenceWidget object wuth \a parent and string for \a noneString +*/ +QKeySequenceWidget::QKeySequenceWidget(QString noneString, QWidget *parent) : + QWidget(parent), d_ptr(new QKeySequenceWidgetPrivate()) +{ +// qDebug() << "widget constructor"; + Q_D(QKeySequenceWidget); + d->q_ptr = this; +// qDebug() << "q_prt " << this; + d->init(QKeySequence(), noneString); + + _connectingSlots(); +} + +/*! + Destroy a QKeySequenceWidget object +*/ +QKeySequenceWidget::~QKeySequenceWidget() +{ + delete d_ptr; +} + +QSize QKeySequenceWidget::sizeHint() const +{ + return d_ptr->shortcutButton->sizeHint(); +} + +/*! + Setting tooltip text to sequence button + \param tip Text string +*/ +void QKeySequenceWidget::setToolTip(const QString &tip) +{ + d_ptr->setToolTip(tip); +} + +/*! + Setting mode of Clear Buttorn display. + \param show Position of clear button \a ClearButtornShow + \sa clearButtonShow +*/ +void QKeySequenceWidget::setClearButtonShow(QKeySequenceWidget::ClearButtonShow show) +{ + d_ptr->showClearButton = show; + d_ptr->updateView(); +} + +/*! + Return mode of clear button dosplay. + \param show Display mode of clear button (NoShow, ShowLeft or ShorRight) + \sa setClearButtonShow +*/ +QKeySequenceWidget::ClearButtonShow QKeySequenceWidget::clearButtonShow() const +{ + return static_cast(d_ptr->showClearButton); +} + + +/*! + Set the key sequence. + \param key Key sequence + \sa clearKeySequence + */ +void QKeySequenceWidget::setKeySequence(const QKeySequence& key) +{ + if (d_ptr->isRecording == false) + { + d_ptr->oldSequence = d_ptr->currentSequence; + } + + d_ptr->doneRecording(); + + d_ptr->currentSequence = key; + d_ptr->doneRecording(); +} + +/*! + Get current key sequence. + \return Current key sequence + \sa setKeySequence + \sa clearKeySequence + */ +QKeySequence QKeySequenceWidget::keySequence() const +{ + return d_ptr->currentSequence; +} + +/*! + Clear key sequence. + \sa setKeySequence + */ +void QKeySequenceWidget::clearKeySequence() +{ + setKeySequence(QKeySequence()); +} + +// slot for capture key sequence starting (private) +void QKeySequenceWidget::captureKeySequence() +{ + d_ptr->startRecording(); +} + +/*! + Set string for display when key sequence is undefined. + \param text Text string + \sa noneText + */ +void QKeySequenceWidget::setNoneText(const QString text) +{ + d_ptr->noneSequenceText = text; + d_ptr->updateDisplayShortcut(); +} + +/*! + Get string for display when key sequence is undefined. + \return Text string + \sa setNoneText + */ +QString QKeySequenceWidget::noneText() const +{ + return d_ptr->noneSequenceText; +} + +/*! + Set custom icon for clear buttom. + \param icon QIcon object + \sa clearButtonIcon + */ +void QKeySequenceWidget::setClearButtonIcon(const QIcon &icon) +{ + d_ptr->clearButton->setIcon(icon); +} + +/*! + Get clear buttom icon. + \return QIcon object + \sa setClearButtonIcon + */ +QIcon QKeySequenceWidget::clearButtonIcon() const +{ + return d_ptr->clearButton->icon(); +} + +// connection internal signals & slots +void QKeySequenceWidget::_connectingSlots() +{ + // connect signals to slots + connect(d_ptr->clearButton, SIGNAL(clicked()), this, +SLOT(clearKeySequence())); + connect(&d_ptr->modifierlessTimeout, SIGNAL(timeout()), this, SLOT(doneRecording())); + connect(d_func()->shortcutButton, SIGNAL(clicked()), this, SLOT(captureKeySequence())); + +} + +// Private class implementation + +QKeySequenceWidgetPrivate::QKeySequenceWidgetPrivate() + : layout(NULL), clearButton(NULL), shortcutButton(NULL) +{ + Q_Q(QKeySequenceWidget); + Q_UNUSED(q); +} + +QKeySequenceWidgetPrivate::~QKeySequenceWidgetPrivate() +{ + +} + +void QKeySequenceWidgetPrivate::init(const QKeySequence &keySeq, const QString &noneStr) +{ + Q_Q(QKeySequenceWidget); + Q_UNUSED(q); + layout = new QHBoxLayout(q_func()); + layout->setMargin(0); + layout->setSpacing(1); + + clearButton = new QToolButton(q_func()); + clearButton->setText("x"); + + layout->addWidget(clearButton); + + shortcutButton = new QShortcutButton(this, q_func()); + + if (noneStr.isNull() == true) + { + noneSequenceText = "..."; + } + else + { + noneSequenceText = noneStr; + } + + q_ptr->clearKeySequence(); + currentSequence = keySeq; + + shortcutButton->setFocusPolicy(Qt::StrongFocus); + + layout->addWidget(shortcutButton); + + showClearButton = QKeySequenceWidget::ShowRight; + + clearButton->setIcon(QIcon(":/img/delete_32.png")); + + // unfocused clear button afyer created (small hack) + clearButton->setFocusPolicy(Qt::NoFocus); + + // update ui + updateDisplayShortcut(); + updateView(); +} + +// set tooltip only for seqyence button +void QKeySequenceWidgetPrivate::setToolTip(const QString &tip) +{ + shortcutButton->setToolTip(tip); + clearButton->setToolTip(""); +} + +// update the location of widgets +void QKeySequenceWidgetPrivate::updateView() +{ +// qDebug() << "update view "; + switch(showClearButton) + { + case QKeySequenceWidget::ShowLeft: + clearButton->setVisible(true); + layout->setDirection(QBoxLayout::LeftToRight); + break; + case QKeySequenceWidget::ShowRight: + clearButton->setVisible(true); + layout->setDirection(QBoxLayout::RightToLeft); + break; + case QKeySequenceWidget::NoShow: + clearButton->setVisible(false); + break; + default: + layout->setDirection(QBoxLayout::LeftToRight); + } +} + +void QKeySequenceWidgetPrivate::startRecording() +{ + numKey = 0; + modifierKeys = 0; + oldSequence = currentSequence; + currentSequence = QKeySequence(); + isRecording = true; + shortcutButton->setDown(true); + + shortcutButton->grabKeyboard(); + + if (!QWidget::keyboardGrabber()) + { + qWarning() << "Failed to grab the keyboard! Most likely qt's nograb option is active"; + } + + // update Shortcut display + updateDisplayShortcut(); +} + +void QKeySequenceWidgetPrivate::doneRecording() +{ + modifierlessTimeout.stop(); + + isRecording = false; + shortcutButton->releaseKeyboard(); + shortcutButton->setDown(false); + + // if sequence is not changed + if (currentSequence == oldSequence) + { + // update Shortcut display + updateDisplayShortcut(); + + return; + } + + // key sequnce is changed + emit q_ptr->keySequenceChanged(currentSequence); + + // update Shortcut display + updateDisplayShortcut(); +} + +inline void QKeySequenceWidgetPrivate::cancelRecording() +{ + currentSequence = oldSequence; + doneRecording(); +} + +inline void QKeySequenceWidgetPrivate::controlModifierlessTimout() +{ + if (numKey != 0 && !modifierKeys) + { + // No modifier key pressed currently. Start the timout + modifierlessTimeout.start(600); + } + else + { + // A modifier is pressed. Stop the timeout + modifierlessTimeout.stop(); + } +} + + +inline void QKeySequenceWidgetPrivate::keyNotSupported() +{ + Q_EMIT q_ptr->keyNotSupported(); +} + +void QKeySequenceWidgetPrivate::updateDisplayShortcut() +{ + // empty string if no non-modifier was pressed + QString str = currentSequence.toString(QKeySequence::NativeText); + str.replace('&', QLatin1String("&&")); // TODO -- check it + + if (isRecording == true) + { + if (modifierKeys) + { + if (str.isEmpty() == false) + str.append(","); + + if ((modifierKeys & Qt::META) ) + str += "Meta + "; + + if ((modifierKeys & Qt::CTRL) ) + str += "Ctrl + "; + + if ((modifierKeys & Qt::ALT) ) + str += "Alt + "; + + if ((modifierKeys & Qt::SHIFT) ) + str += "Shift + "; + } + + // make it clear that input is still going on + str.append("..."); + } + + // if is noting + if (str.isEmpty() == true) + { + str = noneSequenceText; + } + + shortcutButton->setText(str); +} + + +// QKeySequenceButton implementation +QSize QShortcutButton::sizeHint() const +{ + return QPushButton::sizeHint(); +} + +bool QShortcutButton::event(QEvent *e) +{ + if (d->isRecording == true && e->type() == QEvent::KeyPress) + { + keyPressEvent(static_cast(e)); + return true; + } + + if (d->isRecording && e->type() == QEvent::ShortcutOverride) + { + e->accept(); + return true; + } + + if (d->isRecording == true && e->type() == QEvent::FocusOut) + { + d->cancelRecording(); + return true; + } + + return QPushButton::event(e); +} + +void QShortcutButton::keyPressEvent(QKeyEvent *keyEvent) +{ + // qDebug() << "key pressed"; + int keyQt = keyEvent->key(); + +// Qt sometimes returns garbage keycodes, I observed -1, +// if it doesn't know a key. +// We cannot do anything useful with those (several keys have -1, +// indistinguishable) +// and QKeySequence.toString() will also yield a garbage string. + if (keyQt == -1) + { + // keu moy supported in Qt + d->cancelRecording(); + d->keyNotSupported(); + + } + + //get modifiers key + uint newModifiers = keyEvent->modifiers() & (Qt::SHIFT | Qt::CTRL | Qt::ALT +| Qt::META); + + // block autostart capturing on key_return or key space press + if (d->isRecording == false && (keyQt == Qt::Key_Return || keyQt == Qt::Key_Space)) + { + return; + } + + // We get events even if recording isn't active. + if (d->isRecording == false) + { + return QPushButton::keyPressEvent(keyEvent); + } + + keyEvent->accept(); + d->modifierKeys = newModifiers; + + // switching key type + switch(keyQt) + { + case Qt::Key_AltGr: //or else we get unicode salad + return; + case Qt::Key_Shift: + case Qt::Key_Control: + case Qt::Key_Alt: + case Qt::Key_Meta: + case Qt::Key_Menu: //unused (yes, but why?) + // TODO - check it key + d->controlModifierlessTimout(); + d->updateDisplayShortcut(); + break; + default: + { + + } + + // We now have a valid key press. + if (keyQt) + { + if ((keyQt == Qt::Key_Backtab) && (d->modifierKeys & Qt::SHIFT)) + { + keyQt = Qt::Key_Tab | d->modifierKeys; + } + else //if (d->isShiftAsModifierAllowed(keyQt)) + { + keyQt |= d->modifierKeys; + } + + if (d->numKey == 0) + { + d->currentSequence = QKeySequence(keyQt); + } + + d->numKey++; // increment nuber of pressed keys + + if (d->numKey >= 4) + { + d->doneRecording(); + return; + } + + d->controlModifierlessTimout(); + d->updateDisplayShortcut(); + } + } +} + +void QShortcutButton::keyReleaseEvent(QKeyEvent *keyEvent) +{ +// qDebug() << "key released"; + if (keyEvent->key() == -1) + { + // ignore garbage, see keyPressEvent() + return; + } + + // if not recording mode + if (d->isRecording == false) + { + return QPushButton::keyReleaseEvent(keyEvent); + } + + keyEvent->accept(); + + uint newModifiers = keyEvent->modifiers() & (Qt::SHIFT | Qt::CTRL | Qt::ALT | Qt::META); + + // if a modifier that belongs to the shortcut was released... + if ((newModifiers & d->modifierKeys) < d->modifierKeys) + { + d->modifierKeys = newModifiers; + d->controlModifierlessTimout(); + d->updateDisplayShortcut(); + } +} + + + diff -Nru syncwall-1.6.0/src/3rdparty/qkeysequencewidget/qkeysequencewidget.h syncwall-1.7.4/src/3rdparty/qkeysequencewidget/qkeysequencewidget.h --- syncwall-1.6.0/src/3rdparty/qkeysequencewidget/qkeysequencewidget.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qkeysequencewidget/qkeysequencewidget.h 2013-04-28 06:22:40.000000000 +0000 @@ -0,0 +1,121 @@ +/****************************************************************************** +Copyright (c) 2010, Artem Galichkin +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*******************************************************************************/ + +#ifndef QKEYSEQUENCEWIDGET_H +#define QKEYSEQUENCEWIDGET_H + +#include "qkeysequencewidget_p.h" + +#include +#include + +class QKeySequenceWidgetPrivate; + +/*! + \class QKeySequenceWidget + + \brief The QKeySequenceWidget is a widget to input a QKeySequence. + + This widget lets the user choose a QKeySequence, which is usually used as a + shortcut key. The recording is initiated by calling captureKeySequence() or + the user clicking into the widget. + + \code + // create new QKeySequenceWidget with empty sequence + QKeySequenceWidget *keyWidget = new QKeySequenceWidget; + + // Set sequence as "Ctrl+Alt+Space" + keyWidget->setJeySequence(QKeySequence("Ctrl+Alt+Space")); + + // set clear button position is left + setClearButtonShow(QKeySequenceWidget::ShowLeft); + + // set cutom clear button icon + setClearButtonIcon(QIcon("/path/to/icon.png")); + + // connecting keySequenceChanged signal to slot + connect(keyWidget, SIGNAL(keySequenceChanged(QKeySequence)), this, SLOT(slotKeySequenceChanged(QKeySequence))); + \endcode +*/ +class QKeySequenceWidget : public QWidget +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QKeySequenceWidget); + Q_PRIVATE_SLOT(d_func(), void doneRecording()) + + Q_PROPERTY(QKeySequence keySequence READ keySequence WRITE setKeySequence) + Q_PROPERTY(QKeySequenceWidget::ClearButtonShow clearButton READ clearButtonShow WRITE setClearButtonShow) + Q_PROPERTY(QString noneText READ noneText WRITE setNoneText) + Q_PROPERTY(QIcon clearButtonIcon READ clearButtonIcon WRITE setClearButtonIcon) + +private: + QKeySequenceWidgetPrivate * const d_ptr; + void _connectingSlots(); + +private Q_SLOTS: + void captureKeySequence(); + +public: + explicit QKeySequenceWidget(QWidget *parent = 0); + explicit QKeySequenceWidget(QKeySequence seq, QWidget *parent = 0); + explicit QKeySequenceWidget(QString noneString, QWidget *parent = 0); + explicit QKeySequenceWidget(QKeySequence seq, QString noneString, QWidget *parent = 0); + virtual ~QKeySequenceWidget(); + QSize sizeHint() const; + void setToolTip(const QString &tip); + QKeySequence keySequence() const; + QString noneText() const; + QIcon clearButtonIcon() const; + + /*! + \brief Modes of sohow ClearButton + */ + enum ClearButton { + NoShow = 0x00, /**< Hide ClearButton */ + ShowLeft = 0x01, /**< ClearButton isow is left */ + ShowRight = 0x02 /**< ClearButton isow is left */ + }; + + Q_DECLARE_FLAGS(ClearButtonShow, ClearButton); + Q_FLAGS(ClearButtonShow) + + QKeySequenceWidget::ClearButtonShow clearButtonShow() const; + +Q_SIGNALS: + void keySequenceChanged(const QKeySequence &seq); + void keyNotSupported(); + +public Q_SLOTS: + void setKeySequence(const QKeySequence &key); + void clearKeySequence(); + void setNoneText(const QString text); + void setClearButtonIcon(const QIcon& icon); + void setClearButtonShow(QKeySequenceWidget::ClearButtonShow show); +}; + +#endif // QKEYSEQUENCEWIDGET_H diff -Nru syncwall-1.6.0/src/3rdparty/qkeysequencewidget/qkeysequencewidget_p.h syncwall-1.7.4/src/3rdparty/qkeysequencewidget/qkeysequencewidget_p.h --- syncwall-1.6.0/src/3rdparty/qkeysequencewidget/qkeysequencewidget_p.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qkeysequencewidget/qkeysequencewidget_p.h 2013-04-28 06:30:48.000000000 +0000 @@ -0,0 +1,123 @@ +/****************************************************************************** +Copyright (c) 2010, Artem Galichkin +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*******************************************************************************/ + +#ifndef QKEYSEQUENCEWIDGET_P_H +#define QKEYSEQUENCEWIDGET_P_H + +#include +#include +#include +#include +#include +#include +#include + +//#include "qkeysequencewidget.h" + +class QShortcutButton; +class QKeySequenceWidget; + +class QKeySequenceWidgetPrivate // : public QObject +{ + //Q_OBJECT + Q_DECLARE_PUBLIC(QKeySequenceWidget); + +public: + QKeySequenceWidget * q_ptr; + + QKeySequenceWidgetPrivate(); + virtual ~QKeySequenceWidgetPrivate(); + + void init(const QKeySequence &keySeq, const QString &noneStr); + void updateView(); + + void startRecording(); + void doneRecording(); + inline void cancelRecording(); + inline void controlModifierlessTimout(); + inline void keyNotSupported(); + + void updateDisplayShortcut(); + + // members + QKeySequence currentSequence; + QKeySequence oldSequence; + QString noneSequenceText; + + QTimer modifierlessTimeout; + + quint32 numKey; + quint32 modifierKeys; + + void setToolTip(const QString& tip); + + QHBoxLayout *layout; + QToolButton *clearButton; + QShortcutButton *shortcutButton; + + int showClearButton; + + bool isRecording; + +}; + +class QShortcutButton : public QPushButton +{ + Q_OBJECT + +public: + explicit QShortcutButton(QKeySequenceWidgetPrivate *p, QWidget *parent = 0) + : QPushButton(parent) + , d(p) + { +// qDebug() << "qShortcut button Create"; + // qDebug() << "parent----" << parent; + + // qDebug() << "visible " << isVisible(); + setMinimumWidth(QPushButton::minimumWidth()); + QPushButton::setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); + } + + virtual ~QShortcutButton() + { + // qDebug() << "qShortcut button delete"; + } + + virtual QSize sizeHint() const; + +protected: + // Reimplemented for internal reasons. + virtual bool event(QEvent *e); + virtual void keyPressEvent(QKeyEvent *keyEvent); + virtual void keyReleaseEvent(QKeyEvent *keyEvent); + +private: + QKeySequenceWidgetPrivate * const d; +}; + +#endif // QKEYSEQUENCEWIDGET_P_H diff -Nru syncwall-1.6.0/src/3rdparty/qt-extended/qexifimageheader.cpp syncwall-1.7.4/src/3rdparty/qt-extended/qexifimageheader.cpp --- syncwall-1.6.0/src/3rdparty/qt-extended/qexifimageheader.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qt-extended/qexifimageheader.cpp 2012-05-15 11:58:34.000000000 +0000 @@ -0,0 +1,1970 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt scene graph research project. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This file was copied from Qt Extended 4.5 + +#include "qexifimageheader.h" + +#include +#include +#include +#include +#include +#include +#include + +/*! + \typedef QExifSRational + + A synonym for \c QPair representing a signed rational number as stored in EXIF + headers. The first integer in the pair is the numerator and the second the denominator. +*/ + +/*! + \typedef QExifURational + + A synonym for \c QPair representing an unsigned rational number as stored in + EXIF headers. The first integer in the pair is the numerator and the second the denominator. +*/ + +struct ExifIfdHeader +{ + quint16 tag; + quint16 type; + quint32 count; + union + { + quint32 offset; + quint8 offsetBytes[ 4 ]; + char offsetAscii[ 4 ]; + quint16 offsetShorts[ 2 ]; + }; +}; + +QDataStream &operator >>( QDataStream &stream, ExifIfdHeader &header ) +{ + stream >> header.tag; + stream >> header.type; + stream >> header.count; + + if( header.type == QExifValue::Byte && header.count <= 4 ) + { + stream.readRawData( header.offsetAscii, 4 ); + } + else if( header.type == QExifValue::Ascii && header.count <= 4 ) + { + stream.readRawData( header.offsetAscii, 4 ); + } + else if( header.type == QExifValue::Short && header.count <= 2 ) + { + stream >> header.offsetShorts[ 0 ]; + stream >> header.offsetShorts[ 1 ]; + } + else + { + stream >> header.offset; + } + + return stream; +} + + +class QExifValuePrivate : public QSharedData +{ +public: + QExifValuePrivate( quint16 t, int c ) + : type( t ), count( c ) + {} + virtual ~QExifValuePrivate(){} + + quint16 type; + int count; +}; + +class QExifByteValuePrivate : public QExifValuePrivate +{ +public: + QExifByteValuePrivate() + : QExifValuePrivate(QExifValue::Byte, 0) + { ref.ref(); } + QExifByteValuePrivate( const QVector< quint8 > &v ) + : QExifValuePrivate( QExifValue::Byte, v.size() ), value( v ) + {} + + QVector< quint8 > value; +}; + +class QExifUndefinedValuePrivate : public QExifValuePrivate +{ +public: + QExifUndefinedValuePrivate( const QByteArray &v ) + : QExifValuePrivate( QExifValue::Undefined, v.size() ), value( v ) + {} + + QByteArray value; +}; + +class QExifAsciiValuePrivate : public QExifValuePrivate +{ +public: + QExifAsciiValuePrivate( const QString &v ) + : QExifValuePrivate( QExifValue::Ascii, v.size() + 1 ), value( v ) + {} + + QString value; +}; + +class QExifShortValuePrivate : public QExifValuePrivate +{ +public: + QExifShortValuePrivate( const QVector< quint16 > &v ) + : QExifValuePrivate( QExifValue::Short, v.size() ), value( v ) + {} + + QVector< quint16 > value; +}; + +class QExifLongValuePrivate : public QExifValuePrivate +{ +public: + QExifLongValuePrivate( const QVector< quint32 > &v ) + : QExifValuePrivate( QExifValue::Long, v.size() ), value( v ) + {} + + QVector< quint32 > value; +}; + +class QExifSignedLongValuePrivate : public QExifValuePrivate +{ +public: + QExifSignedLongValuePrivate( const QVector< qint32 > &v ) + : QExifValuePrivate( QExifValue::SignedLong, v.size() ), value( v ) + {} + + QVector< qint32 > value; +}; + +class QExifRationalValuePrivate : public QExifValuePrivate +{ +public: + QExifRationalValuePrivate( const QVector< QExifURational > &v ) + : QExifValuePrivate( QExifValue::Rational, v.size() ), value( v ) + {} + + QVector< QExifURational > value; +}; + +class QExifSignedRationalValuePrivate : public QExifValuePrivate +{ +public: + QExifSignedRationalValuePrivate( const QVector< QExifSRational > &v ) + : QExifValuePrivate( QExifValue::SignedRational, v.size() ), value( v ) + {} + + QVector< QExifSRational > value; +}; + +Q_GLOBAL_STATIC(QExifByteValuePrivate,qExifValuePrivateSharedNull) + +/*! + \class QExifValue + \inpublicgroup QtBaseModule + \brief The QExifValue class represents data types found in EXIF image headers. + + Tag values in EXIF headers are stored as arrays of a limited number of data types. QExifValue + encapsulates a union of these types and provides conversions to and from appropriate Qt types. + + \section1 String encoding + + Most tags with string values in EXIF headers are ASCII encoded and have the Ascii value type, + but some tags allow other encodings. In this case the value type is Undefined and the encoding + of the text is given by the encoding function(). + + \section1 Date-time values + + Date-time values in EXIF headers are stored in ASCII encoded strings of the form + \c {yyyy:MM:dd HH:mm:ss}. Constructing a QExifValue from a QDateTime will perform this + conversion and likewise an appropriately formed QExifValue can be converted to a QDateTime + using the toDateTime() function. + + \sa QExifImageHeader + + \preliminary +*/ + +/*! + \enum QExifValue::Type + + Enumerates the possible types of EXIF values. + + \value Byte An unsigned 8 bit integer. + \value Ascii A null terminated ascii string. + \value Short An unsigned 16 bit integer. + \value Long An unsigned 32 bit integer. + \value Rational Two unsigned 32 bit integers, representing a the numerator and denominator of an unsigned rational number. + \value Undefined An array of 8 bit integers. + \value SignedLong A signed 32 bit integer. + \value SignedRational Two signed 32 bit integers representing the numerator and denominator of a signed rational number. +*/ + +/*! + \enum QExifValue::TextEncoding + + Enumerates the encodings of text strings in EXIF values of Undefined type. + + \value NoEncoding An ASCII string of Ascii type. + \value AsciiEncoding An ASCII string of Undefined type. + \value JisEncoding A JIS X208-1990 string of Undefined type. + \value UnicodeEncoding A Unicode string of Undefined type. + \value UndefinedEncoding An unspecified string encoding of Undefined type. Assumed to be the local 8-bit encoding. +*/ + +/*! + Constructs a null QExifValue. +*/ +QExifValue::QExifValue() + : d( qExifValuePrivateSharedNull() ) +{ +} + +/*! + Constructs a QExifValue with a \a value of type Byte. +*/ +QExifValue::QExifValue( quint8 value ) + : d( new QExifByteValuePrivate( QVector< quint8 >( 1, value ) ) ) +{ +} + +/*! + Constructs a QExifValue with an array of \a values of type Byte. +*/ +QExifValue::QExifValue( const QVector< quint8 > &values ) + : d( new QExifByteValuePrivate( values ) ) +{ +} + +/*! + Constructs a QExifValue with a \a value of type Ascii or Undefined. + + If the \a encoding is NoEncoding the value will be of type Ascii, otherwise it will be Undefined and the string + encoded using the given \a encoding. +*/ +QExifValue::QExifValue( const QString &value, TextEncoding encoding ) + : d( qExifValuePrivateSharedNull() ) +{ + switch( encoding ) + { + case AsciiEncoding: + d = new QExifUndefinedValuePrivate( QByteArray::fromRawData( "ASCII\0\0\0", 8 ) + value.toAscii() ); + break; + case JisEncoding: + { + QTextCodec *codec = QTextCodec::codecForName( "JIS X 0208" ); + if( codec ) + d = new QExifUndefinedValuePrivate( QByteArray::fromRawData( "JIS\0\0\0\0\0", 8 ) + codec->fromUnicode( value ) ); + } + break; + case UnicodeEncoding: + { + QTextCodec *codec = QTextCodec::codecForName( "UTF-16" ); + if( codec ) + d = new QExifUndefinedValuePrivate( QByteArray::fromRawData( "UNICODE\0", 8 ) + codec->fromUnicode( value ) ); + } + break; + case UndefinedEncoding: + d = new QExifUndefinedValuePrivate( QByteArray::fromRawData( "\0\0\0\0\0\0\0\\0", 8 ) + value.toLocal8Bit() ); + break; + default: + d = new QExifAsciiValuePrivate( value ); + } +} + +/*! + Constructs a QExifValue with a \a value of type Short. +*/ +QExifValue::QExifValue( quint16 value ) + : d( new QExifShortValuePrivate( QVector< quint16 >( 1, value ) ) ) +{ +} + +/*! + Constructs a QExifValue with an array of \a values of type Short. +*/ +QExifValue::QExifValue( const QVector< quint16 > &values ) + : d( new QExifShortValuePrivate( values ) ) +{ +} + +/*! + Constructs a QExifValue with a \a value of type Long. +*/ +QExifValue::QExifValue( quint32 value ) + : d( new QExifLongValuePrivate( QVector< quint32 >( 1, value ) ) ) +{ +} + +/*! + Constructs a QExifValue with an array of \a values of type Long. +*/ +QExifValue::QExifValue( const QVector< quint32 > &values ) + : d( new QExifLongValuePrivate( values ) ) +{ +} + +/*! + Constructs a QExifValue with a \a value of type Rational. +*/ +QExifValue::QExifValue( const QExifURational &value ) + : d( new QExifRationalValuePrivate( QVector< QExifURational >( 1, value ) ) ) +{ +} + +/*! + Constructs a QExifValue with an array of \a values of type Rational. +*/ +QExifValue::QExifValue( const QVector< QExifURational > &values ) + : d( new QExifRationalValuePrivate( values ) ) +{ +} + +/*! + Constructs a QExifValue with a \a value of type Undefined. +*/ +QExifValue::QExifValue( const QByteArray &value ) + : d( new QExifUndefinedValuePrivate( value ) ) +{ +} + +/*! + Constructs a QExifValue with a \a value of type SignedLong. +*/ +QExifValue::QExifValue( qint32 value ) + : d( new QExifSignedLongValuePrivate( QVector< qint32 >( 1, value ) ) ) +{ +} + +/*! + Constructs a QExifValue with an array of \a values of type SignedLong. +*/ +QExifValue::QExifValue( const QVector< qint32 > &values ) + : d( new QExifSignedLongValuePrivate( values ) ) +{ +} + +/*! + Constructs a QExifValue with a \a value of type SignedRational. +*/ +QExifValue::QExifValue( const QExifSRational &value ) + : d( new QExifSignedRationalValuePrivate( QVector< QExifSRational >( 1, value ) ) ) +{ +} + +/*! + Constructs a QExifValue with an array of \a values of type SignedRational. +*/ +QExifValue::QExifValue( const QVector< QExifSRational > &values ) + : d( new QExifSignedRationalValuePrivate( values ) ) +{ +} + +/*! + Constructs a QExifValue of type Ascii with an ascii string formatted from a date-time \a value. + + Date-times are stored as strings in the format \c {yyyy:MM:dd HH:mm:ss}. +*/ +QExifValue::QExifValue( const QDateTime &value ) + : d( new QExifAsciiValuePrivate( value.toString( QLatin1String( "yyyy:MM:dd HH:mm:ss" ) ) ) ) +{ +} + +/*! + Constructs a copy of the QExifValue \a other. +*/ +QExifValue::QExifValue( const QExifValue &other ) + : d( other.d ) +{ +} + +/*! + Assigns the value of \a other to a QExifValue. +*/ +QExifValue &QExifValue::operator =( const QExifValue &other ) +{ + d = other.d; + + return *this; +} + +/*! + Destroys a QExifValue. +*/ +QExifValue::~QExifValue() +{ +} + +/*! + Compares a QExifValue to \a other. Returns true if they are the same value and false otherwise. +*/ +bool QExifValue::operator ==( const QExifValue &other ) const +{ + return d == other.d; +} + +/*! + Returns true if a QExifValue has a null value and false otherwise. +*/ +bool QExifValue::isNull() const +{ + return d == qExifValuePrivateSharedNull(); +} + +/*! + Returns the type of a QExifValue. +*/ +int QExifValue::type() const +{ + return d->type; +} + +/*! + Returns the number of elements in a QExifValue. For ascii strings this is the length of the string + including the terminating null. +*/ +int QExifValue::count() const +{ + return d->count; +} + +/*! + Returns the encoding of strings stored in Undefined values. +*/ +QExifValue::TextEncoding QExifValue::encoding() const +{ + if( d->type == Undefined && d->count > 8 ) + { + QByteArray value = static_cast< const QExifUndefinedValuePrivate * >( d.constData() )->value; + + if( value.startsWith( QByteArray::fromRawData( "ASCII\0\0\0", 8 ) ) ) + return AsciiEncoding; + else if( value.startsWith( QByteArray::fromRawData( "JIS\0\0\0\0\0", 8 ) ) ) + return JisEncoding; + else if( value.startsWith( QByteArray::fromRawData( "UNICODE\0", 8 ) ) ) + return UnicodeEncoding; + else if( value.startsWith( QByteArray::fromRawData( "\0\0\0\0\0\0\0\0", 8 ) ) ) + return UndefinedEncoding; + } + return NoEncoding; +} + +/*! + Returns the value of a single element QExifValue of type Byte. +*/ +quint8 QExifValue::toByte() const +{ + return d->type == Byte && d->count == 1 + ? static_cast< const QExifByteValuePrivate * >( d.constData() )->value.at( 0 ) + : 0; +} + +/*! + Returns the value of a multiple element QExifValue of type Byte. +*/ +QVector< quint8 > QExifValue::toByteVector() const +{ + return d->type == Byte + ? static_cast< const QExifByteValuePrivate * >( d.constData() )->value + : QVector< quint8 >(); +} + +/*! + Returns the value of a QExifValue of type Ascii. +*/ +QString QExifValue::toString() const +{ + switch( d->type ) + { + case Ascii: + return static_cast< const QExifAsciiValuePrivate * >( d.constData() )->value; + case Undefined: + { + QByteArray string = static_cast< const QExifUndefinedValuePrivate * >( d.constData() )->value.mid( 8 ); + + switch( encoding() ) + { + case AsciiEncoding: + return QString::fromAscii( string.constData(), string.length() ); + case JisEncoding: + { + QTextCodec *codec = QTextCodec::codecForName( "JIS X 0208" ); + if( codec ) + return codec->toUnicode( string ); + } + break; + case UnicodeEncoding: + { + QTextCodec *codec = QTextCodec::codecForName( "UTF-16" ); + if( codec ) + return codec->toUnicode( string ); + } + case UndefinedEncoding: + return QString::fromLocal8Bit( string.constData(), string.length() ); + default: + break; + } + } + default: + return QString(); + } +} + +/*! + Returns the value of a single element QExifValue of type Byte or Short. +*/ +quint16 QExifValue::toShort() const +{ + if( d->count == 1 ) + { + switch( d->type ) + { + case Byte: + return static_cast< const QExifByteValuePrivate * >( d.constData() )->value.at( 0 ); + case Short: + return static_cast< const QExifShortValuePrivate * >( d.constData() )->value.at( 0 ); + } + } + return 0; +} + +/*! + Returns the value of a single element QExifValue of type Short. +*/ +QVector< quint16 > QExifValue::toShortVector() const +{ + return d->type == Short + ? static_cast< const QExifShortValuePrivate * >( d.constData() )->value + : QVector< quint16 >(); +} + +/*! + Returns the value of a single element QExifValue of type Byte, Short, Long, or SignedLong. +*/ +quint32 QExifValue::toLong() const +{ + if( d->count == 1 ) + { + switch( d->type ) + { + case Byte: + return static_cast< const QExifByteValuePrivate * >( d.constData() )->value.at( 0 ); + case Short: + return static_cast< const QExifShortValuePrivate * >( d.constData() )->value.at( 0 ); + case Long: + return static_cast< const QExifLongValuePrivate * >( d.constData() )->value.at( 0 ); + case SignedLong: + return static_cast< const QExifSignedLongValuePrivate * >( d.constData() )->value.at( 0 ); + } + } + return 0; +} + +/*! + Returns the value of a multiple element QExifValue of type Long. +*/ +QVector< quint32 > QExifValue::toLongVector() const +{ + return d->type == Long + ? static_cast< const QExifLongValuePrivate * >( d.constData() )->value + : QVector< quint32 >(); +} + +/*! + Returns the value of a multiple element QExifValue of type Rational. +*/ +QExifURational QExifValue::toRational() const +{ + return d->type == Rational && d->count == 1 + ? static_cast< const QExifRationalValuePrivate * >( d.constData() )->value.at( 0 ) + : QExifURational(); +} + +/*! + Returns the value of a multiple element QExifValue of type Rational. +*/ +QVector< QExifURational > QExifValue::toRationalVector() const +{ + return d->type == Rational + ? static_cast< const QExifRationalValuePrivate * >( d.constData() )->value + : QVector< QExifURational >(); +} + +/*! + Returns the value of a QExifValue of type Undefined. +*/ +QByteArray QExifValue::toByteArray() const +{ + switch( d->type ) + { + case Ascii: + return static_cast< const QExifAsciiValuePrivate * >( d.constData() )->value.toAscii(); + case Undefined: + return static_cast< const QExifUndefinedValuePrivate * >( d.constData() )->value; + default: + return QByteArray(); + } +} + +/*! + Returns the value of a single element QExifValue of type Byte, Short, Long, or SignedLong. +*/ +qint32 QExifValue::toSignedLong() const +{ + if( d->count == 1 ) + { + switch( d->type ) + { + case Byte: + return static_cast< const QExifByteValuePrivate * >( d.constData() )->value.at( 0 ); + case Short: + return static_cast< const QExifShortValuePrivate * >( d.constData() )->value.at( 0 ); + case Long: + return static_cast< const QExifLongValuePrivate * >( d.constData() )->value.at( 0 ); + case SignedLong: + return static_cast< const QExifSignedLongValuePrivate * >( d.constData() )->value.at( 0 ); + } + } + return 0; +} + +/*! + Returns the value of a multiple element QExifValue of type SignedLong. +*/ +QVector< qint32 > QExifValue::toSignedLongVector() const +{ + return d->type == SignedLong + ? static_cast< const QExifSignedLongValuePrivate * >( d.constData() )->value + : QVector< qint32 >(); +} + +/*! + Returns the value of a single element QExifValue of type SignedRational. +*/ +QExifSRational QExifValue::toSignedRational() const +{ + return d->type == SignedRational && d->count == 1 + ? static_cast< const QExifSignedRationalValuePrivate * >( d.constData() )->value.at( 0 ) + : QExifSRational(); +} + +/*! + Returns the value of a multiple element QExifValue of type SignedRational. +*/ +QVector< QExifSRational > QExifValue::toSignedRationalVector() const +{ + return d->type == SignedRational + ? static_cast< const QExifSignedRationalValuePrivate * >( d.constData() )->value + : QVector< QExifSRational >(); +} + +/*! + Returns the value of QExifValue storing a date-time. + + Date-times are stored as ascii strings in the format \c {yyyy:MM:dd HH:mm:ss}. +*/ +QDateTime QExifValue::toDateTime() const +{ + return d->type == Ascii && d->count == 20 + ? QDateTime::fromString( static_cast< const QExifAsciiValuePrivate * >( d.constData() )->value, QLatin1String( "yyyy:MM:dd HH:mm:ss" ) ) + : QDateTime(); +} + +class QExifImageHeaderPrivate +{ +public: + QSysInfo::Endian byteOrder; + mutable qint64 size; + QMap imageIfdValues; + QMap exifIfdValues; + QMap gpsIfdValues; + + QSize thumbnailSize; + QByteArray thumbnailData; + QExifValue thumbnailXResolution; + QExifValue thumbnailYResolution; + QExifValue thumbnailResolutionUnit; + QExifValue thumbnailOrientation; +}; + +/*! + \class QExifImageHeader + \inpublicgroup QtBaseModule + \brief The QExifImageHeader class provides functionality for reading and writing EXIF image headers. + + EXIF headers are a collection of properties that describe the image they're embedded in. + Each property is identified by a tag of which there are three kinds. \l {ImageTag}{Image tags} + which mostly describe the format (dimensions, resolution, orientation) but also include some + descriptive information (description, camera make and model, artist). \l {ExifExtendedTag} + {EXIF extended tags} which elaborate on some of the image tags and record the camera settings at + time of capture among other things. Finally there are \l {GpsTag}{GPS tags} which record the + location the image was captured. + + EXIF tags are typically found in JPEG images but may be found in other image formats. To read + headers from a JPEG image QExifImageHeader provides the loadFromJpeg() function, and the + complementary saveToJpeg() function for writing. To allow reading and writing arbitrary + formats QExifImageHeader provides the read() and write() functions which work with just the + EXIF header data itself. + + \preliminary +*/ + +/*! + \enum QExifImageHeader::ImageTag + Enumerates the TIFF image tag IDs defined in the EXIF specification. + + \value ImageWidth + \value ImageLength + \value BitsPerSample + \value Compression + \value PhotometricInterpretation + \value Orientation + \value SamplesPerPixel + \value PlanarConfiguration + \value YCbCrSubSampling + \value XResolution + \value YResolution + \value ResolutionUnit + \value StripOffsets + \value RowsPerStrip + \value StripByteCounts + \value TransferFunction + \value WhitePoint + \value PrimaryChromaciticies + \value YCbCrCoefficients + \value ReferenceBlackWhite + \value DateTime + \value ImageDescription + \value Make + \value Model + \value Software + \value Artist + \value Copyright +*/ + +/*! + \enum QExifImageHeader::ExifExtendedTag + Enumerates the extended EXIF tag IDs defined in the EXIF specification. + + \value ExifVersion + \value FlashPixVersion + \value ColorSpace + \value ComponentsConfiguration + \value CompressedBitsPerPixel + \value PixelXDimension + \value PixelYDimension + \value MakerNote + \value UserComment + \value RelatedSoundFile + \value DateTimeOriginal + \value DateTimeDigitized + \value SubSecTime + \value SubSecTimeOriginal + \value SubSecTimeDigitized + \value ImageUniqueId + \value ExposureTime + \value FNumber + \value ExposureProgram + \value SpectralSensitivity + \value ISOSpeedRatings + \value Oecf + \value ShutterSpeedValue + \value ApertureValue + \value BrightnessValue + \value ExposureBiasValue + \value MaxApertureValue + \value SubjectDistance + \value MeteringMode + \value LightSource + \value Flash + \value FocalLength + \value SubjectArea + \value FlashEnergy + \value SpatialFrequencyResponse + \value FocalPlaneXResolution + \value FocalPlaneYResolution + \value FocalPlaneResolutionUnit + \value SubjectLocation + \value ExposureIndex + \value SensingMethod + \value FileSource + \value SceneType + \value CfaPattern + \value CustomRendered + \value ExposureMode + \value WhiteBalance + \value DigitalZoomRatio + \value FocalLengthIn35mmFilm + \value SceneCaptureType + \value GainControl + \value Contrast + \value Saturation + \value Sharpness + \value DeviceSettingDescription + \value SubjectDistanceRange +*/ + +/*! + \enum QExifImageHeader::GpsTag + Enumerates the GPS tag IDs from the EXIF specification. + + \value GpsVersionId + \value GpsLatitudeRef + \value GpsLatitude + \value GpsLongitudeRef + \value GpsLongitude + \value GpsAltitudeRef + \value GpsAltitude + \value GpsTimeStamp + \value GpsSatellites + \value GpsStatus + \value GpsMeasureMode + \value GpsDop + \value GpsSpeedRef + \value GpsSpeed + \value GpsTrackRef + \value GpsTrack + \value GpsImageDirectionRef + \value GpsImageDirection + \value GpsMapDatum + \value GpsDestLatitudeRef + \value GpsDestLatitude + \value GpsDestLongitudeRef + \value GpsDestLongitude + \value GpsDestBearingRef + \value GpsDestBearing + \value GpsDestDistanceRef + \value GpsDestDistance + \value GpsProcessingMethod + \value GpsAreaInformation + \value GpsDateStamp + \value GpsDifferential +*/ + +/*! + Constructs a new EXIF image data editor. +*/ +QExifImageHeader::QExifImageHeader() + : d( new QExifImageHeaderPrivate ) +{ + d->byteOrder = QSysInfo::ByteOrder; + d->size = -1; +} + +/*! + Constructs a new EXIF image data editor and reads the meta-data from a JPEG image with the given \a fileName. +*/ +QExifImageHeader::QExifImageHeader(const QString &fileName) + : d(new QExifImageHeaderPrivate) +{ + d->byteOrder = QSysInfo::ByteOrder; + d->size = -1; + + loadFromJpeg(fileName); +} + +/*! + Destroys an EXIF image data editor. +*/ +QExifImageHeader::~QExifImageHeader() +{ + clear(); + + delete d; +} + +/*! + Reads meta-data from a JPEG image with the given \a fileName. + + Returns true if the data was successfully parsed and false otherwise. +*/ +bool QExifImageHeader::loadFromJpeg(const QString &fileName) +{ + QFile file(fileName); + + if(file.open(QIODevice::ReadOnly)) + return loadFromJpeg(&file); + else + return false; +} + +/*! + Reads meta-data from an I/O \a device containing a JPEG image. + + Returns true if the data was successfully parsed and false otherwise. +*/ +bool QExifImageHeader::loadFromJpeg(QIODevice *device) +{ + clear(); + + QByteArray exifData = extractExif(device); + + if (!exifData.isEmpty()) { + QBuffer buffer(&exifData); + + return buffer.open(QIODevice::ReadOnly) && read(&buffer); + } + + return false; +} + +/*! + Saves meta-data to a JPEG image with the given \a fileName. + + Returns true if the data was successfully written. +*/ +bool QExifImageHeader::saveToJpeg(const QString &fileName) const +{ + QFile file(fileName); + + if (file.open(QIODevice::ReadWrite)) + return saveToJpeg(&file); + else + return false; +} + +/*! + Save meta-data to the given I/O \a device. + + The device must be non-sequential and already contain a valid JPEG image. + + Returns true if the data was successfully written. +*/ +bool QExifImageHeader::saveToJpeg(QIODevice *device) const +{ + if( device->isSequential() ) + return false; + + QByteArray exif; + + { + QBuffer buffer( &exif ); + + if( !buffer.open( QIODevice::WriteOnly ) ) + return false; + + write( &buffer ); + + buffer.close(); + + exif = QByteArray::fromRawData( "Exif\0\0", 6 ) + exif; + } + + QDataStream stream( device ); + + stream.setByteOrder( QDataStream::BigEndian ); + + if( device->read( 2 ) != "\xFF\xD8" ) // Not a valid JPEG image. + return false; + + quint16 segmentId; + quint16 segmentLength; + + stream >> segmentId; + stream >> segmentLength; + + if( segmentId == 0xFFE0 ) + { + QByteArray jfif = device->read( segmentLength - 2 ); + + if( !jfif.startsWith( "JFIF" ) ) + return false; + + stream >> segmentId; + stream >> segmentLength; + + if( segmentId == 0xFFE1 ) + { + QByteArray oldExif = device->read( segmentLength - 2 ); + + if( !oldExif.startsWith( "Exif" ) ) + return false; + + int dSize = oldExif.size() - exif.size(); + + if( dSize > 0 ) + exif += QByteArray( dSize, '\0' ); + + QByteArray remainder = device->readAll(); + + device->seek( 0 ); + + stream << quint16( 0xFFD8 ); // SOI + stream << quint16( 0xFFE0 ); // APP0 + stream << quint16( jfif.size() + 2 ); + device->write( jfif ); + stream << quint16( 0xFFE1 ); //APP1 + stream << quint16( exif.size() + 2 ); + device->write( exif ); + device->write( remainder ); + } + else + { + QByteArray remainder = device->readAll(); + + device->seek( 0 ); + + stream << quint16( 0xFFD8 ); // SOI + stream << quint16( 0xFFE0 ); // APP0 + stream << quint16( jfif.size() + 2 ); + device->write( jfif ); + stream << quint16( 0xFFE1 ); //APP1 + stream << quint16( exif.size() + 2 ); + device->write( exif ); + stream << quint16( 0xFFE0 ); // APP0 + stream << segmentId; + stream << segmentLength; + device->write( remainder ); + } + } + else if( segmentId == 0xFFE1 ) + { + QByteArray oldExif = device->read( segmentLength - 2 ); + + if( !oldExif.startsWith( "Exif" ) ) + return false; + + int dSize = oldExif.size() - exif.size(); + + if( dSize > 0 ) + exif += QByteArray( dSize, '\0' ); + + QByteArray remainder = device->readAll(); + + device->seek( 0 ); + + stream << quint16( 0xFFD8 ); // SOI + stream << quint16( 0xFFE1 ); //APP1 + stream << quint16( exif.size() + 2 ); + device->write( exif ); + device->write( remainder ); + } + else + { + QByteArray remainder = device->readAll(); + + device->seek( 0 ); + + stream << quint16( 0xFFD8 ); // SOI + stream << quint16( 0xFFE1 ); //APP1 + stream << quint16( exif.size() + 2 ); + device->write( exif ); + stream << segmentId; + stream << segmentLength; + device->write( remainder ); + } + + return true; +} + +/*! + Returns the byte order of EXIF file. +*/ +QSysInfo::Endian QExifImageHeader::byteOrder() const +{ + return d->byteOrder; +} + + +quint32 QExifImageHeader::sizeOf(const QExifValue &value) const +{ + switch (value.type()) { + case QExifValue::Byte: + case QExifValue::Undefined: + return value.count() > 4 + ? 12 + value.count() + : 12; + case QExifValue::Ascii: + return value.count() > 4 + ? 12 + value.count() + : 12; + case QExifValue::Short: + return value.count() > 2 + ? 12 + value.count() * sizeof(quint16) + : 12; + case QExifValue::Long: + case QExifValue::SignedLong: + return value.count() > 1 + ? 12 + value.count() * sizeof(quint32) + : 12; + case QExifValue::Rational: + case QExifValue::SignedRational: + return value.count() > 0 + ? 12 + value.count() * sizeof(quint32) * 2 + : 12; + default: + return 0; + } +} + +template +quint32 QExifImageHeader::calculateSize(const QMap &values) const +{ + quint32 size = sizeof(quint16); + + foreach (const QExifValue &value, values) + size += sizeOf(value); + + return size; +} + +/*! + Returns the size of EXIF data in bytes. +*/ +qint64 QExifImageHeader::size() const +{ + if (d->size == -1) { + d->size + = 2 // Byte Order + + 2 // Marker + + 4 // Image Ifd offset + + 12 // ExifIfdPointer Ifd + + 4 // Thumbnail Ifd offset + + calculateSize(d->imageIfdValues) // Image headers and values. + + calculateSize(d->exifIfdValues); // Exif headers and values. + + if (!d->gpsIfdValues.isEmpty()) { + d->size + += 12 // GpsInfoIfdPointer Ifd + + calculateSize(d->gpsIfdValues); // Gps headers and values. + } + + if (!d->thumbnailData.isEmpty()) { + d->size + += 2 // Thumbnail Ifd count + + 12 // Compression Ifd + + 20 // XResolution Ifd + + 20 // YResolution Ifd + + 12 // ResolutionUnit Ifd + + 12 // JpegInterchangeFormat Ifd + + 12 // JpegInterchangeFormatLength Ifd + + d->thumbnailData.size(); // Thumbnail data size. + } + } + + return d->size; +} + +/*! + Clears all image meta-data. +*/ +void QExifImageHeader::clear() +{ + d->imageIfdValues.clear(); + d->exifIfdValues.clear(); + d->gpsIfdValues.clear(); + d->thumbnailData.clear(); + + d->size = -1; +} + +/*! + Returns a list of all image tags in an EXIF header. +*/ +QList QExifImageHeader::imageTags() const +{ + return d->imageIfdValues.keys(); +} + +/*! + Returns a list of all extended EXIF tags in a header. +*/ +QList QExifImageHeader::extendedTags() const +{ + return d->exifIfdValues.keys(); +} + +/*! + Returns a list of all GPS tags in an EXIF header. +*/ +QList QExifImageHeader::gpsTags() const +{ + return d->gpsIfdValues.keys(); +} + +/*! + Returns true if an EXIf header contains a value for an image \a tag and false otherwise. +*/ +bool QExifImageHeader::contains(ImageTag tag) const +{ + return d->imageIfdValues.contains(tag); +} + +/*! + Returns true if a header contains a a value for an extended EXIF \a tag and false otherwise. +*/ +bool QExifImageHeader::contains(ExifExtendedTag tag) const +{ + return d->exifIfdValues.contains(tag); +} + +/*! + Returns true if an EXIf header contains a value for a GPS \a tag and false otherwise. +*/ +bool QExifImageHeader::contains(GpsTag tag) const +{ + return d->gpsIfdValues.contains(tag); +} + +/*! + Removes the value for an image \a tag. +*/ +void QExifImageHeader::remove(ImageTag tag) +{ + d->imageIfdValues.remove(tag); + + d->size = -1; +} + +/*! + Removes the value for an extended EXIF \a tag. +*/ +void QExifImageHeader::remove(ExifExtendedTag tag) +{ + d->exifIfdValues.remove(tag); + + d->size = -1; +} + +/*! + Removes the value for a GPS \a tag. +*/ +void QExifImageHeader::remove(GpsTag tag) +{ + d->gpsIfdValues.remove(tag); + + d->size = -1; +} + +/*! + Returns the value for an image \a tag. +*/ +QExifValue QExifImageHeader::value(ImageTag tag) const +{ + return d->imageIfdValues.value(tag); +} + +/*! + Returns the value for an extended EXIF \a tag. +*/ +QExifValue QExifImageHeader::value(ExifExtendedTag tag) const +{ + return d->exifIfdValues.value(tag); +} + +/*! + Returns the value for a GPS tag. +*/ +QExifValue QExifImageHeader::value(GpsTag tag) const +{ + return d->gpsIfdValues.value(tag); +} + +/*! + Sets the \a value for an image \a tag. +*/ +void QExifImageHeader::setValue(ImageTag tag, const QExifValue &value) +{ + d->imageIfdValues[tag] = value; + + d->size = -1; +} + +/*! + Sets the \a value for an extended EXIF \a tag. +*/ +void QExifImageHeader::setValue(ExifExtendedTag tag, const QExifValue &value) +{ + d->exifIfdValues[tag] = value; + + d->size = -1; +} + +/*! + Sets the \a value for an GPS \a tag. +*/ +void QExifImageHeader::setValue(GpsTag tag, const QExifValue &value) +{ + d->gpsIfdValues[tag] = value; + + d->size = -1; +} + +/*! + Returns the image thumbnail. +*/ +QImage QExifImageHeader::thumbnail() const +{ + QImage image; + + image.loadFromData(d->thumbnailData, "JPG"); + + if (!d->thumbnailOrientation.isNull()) { + switch (d->thumbnailOrientation.toShort()) { + case 1: + return image; + case 2: + return image.transformed(QTransform().rotate(180, Qt::YAxis)); + case 3: + return image.transformed(QTransform().rotate(180, Qt::ZAxis)); + case 4: + return image.transformed(QTransform().rotate(180, Qt::XAxis)); + case 5: + return image.transformed(QTransform().rotate(180, Qt::YAxis).rotate(90, Qt::ZAxis)); + case 6: + return image.transformed(QTransform().rotate(90, Qt::ZAxis)); + case 7: + return image.transformed(QTransform().rotate(180, Qt::XAxis).rotate(90, Qt::ZAxis)); + case 8: + return image.transformed(QTransform().rotate(270, Qt::ZAxis)); + } + } + + return image; +} + +/*! + Sets the image \a thumbnail. +*/ +void QExifImageHeader::setThumbnail( const QImage &thumbnail ) +{ + if (!thumbnail.isNull()) { + QBuffer buffer; + + if (buffer.open(QIODevice::WriteOnly) && thumbnail.save(&buffer, "JPG")) { + buffer.close(); + + d->thumbnailSize = thumbnail.size(); + d->thumbnailData = buffer.data(); + d->thumbnailOrientation = QExifValue(); + } + } else { + d->thumbnailSize = QSize(); + d->thumbnailData = QByteArray(); + } + + d->size = -1; +} + +QByteArray QExifImageHeader::extractExif( QIODevice *device ) const +{ + QDataStream stream( device ); + + stream.setByteOrder( QDataStream::BigEndian ); + + if( device->read( 2 ) != "\xFF\xD8" ) + return QByteArray(); + + while( device->read( 2 ) != "\xFF\xE1" ) + { + if( device->atEnd() ) + return QByteArray(); + + quint16 length; + + stream >> length; + + device->seek( device->pos() + length - 2 ); + } + + quint16 length; + + stream >> length; + + if( device->read( 4 ) != "Exif" ) + return QByteArray(); + + device->read( 2 ); + + return device->read( length - 8 ); +} + + +QList QExifImageHeader::readIfdHeaders(QDataStream &stream) const +{ + QList headers; + + quint16 count; + + stream >> count; + + for (quint16 i = 0; i < count; i++) { + ExifIfdHeader header; + + stream >> header; + + headers.append(header); + } + + return headers; +} + +QExifValue QExifImageHeader::readIfdValue(QDataStream &stream, int startPos, const ExifIfdHeader &header) const +{ + switch (header.type) { + case QExifValue::Byte: + { + QVector value( header.count ); + + if (header.count > 4) { + stream.device()->seek(startPos + header.offset); + + for (quint32 i = 0; i < header.count; i++) + stream >> value[i]; + } else { + for( quint32 i = 0; i < header.count; i++ ) + value[ i ] = header.offsetBytes[ i ]; + + } + return QExifValue(value); + } + case QExifValue::Undefined: + if (header.count > 4) { + stream.device()->seek(startPos + header.offset); + + return QExifValue(stream.device()->read(header.count)); + } else { + return QExifValue(QByteArray::fromRawData(header.offsetAscii, header.count)); + } + case QExifValue::Ascii: + if (header.count > 4) { + stream.device()->seek(startPos + header.offset); + + QByteArray ascii = stream.device()->read(header.count); + + return QExifValue(QString::fromAscii(ascii.constData(), ascii.size() - 1)); + } else { + return QExifValue(QString::fromAscii(header.offsetAscii, header.count - 1)); + } + case QExifValue::Short: + { + QVector value(header.count); + + if (header.count > 2) { + stream.device()->seek(startPos + header.offset); + + for (quint32 i = 0; i < header.count; i++) + stream >> value[i]; + } else { + for (quint32 i = 0; i < header.count; i++) + value[i] = header.offsetShorts[i]; + + } + return QExifValue(value); + } + case QExifValue::Long: + { + QVector value(header.count); + + if (header.count > 1) { + stream.device()->seek(startPos + header.offset); + + for (quint32 i = 0; i < header.count; i++) + stream >> value[i]; + } else if(header.count == 1) { + value[0] = header.offset; + } + return QExifValue(value); + } + case QExifValue::SignedLong: + { + QVector value(header.count); + + if (header.count > 1) { + stream.device()->seek(startPos + header.offset); + + for (quint32 i = 0; i < header.count; i++) + stream >> value[i]; + } else if (header.count == 1) { + value[0] = header.offset; + } + return QExifValue(value); + } + break; + case QExifValue::Rational: + { + QVector value(header.count); + + stream.device()->seek(startPos + header.offset); + + for (quint32 i = 0; i < header.count; i++) + stream >> value[i]; + + return QExifValue(value); + } + case QExifValue::SignedRational: + { + QVector value(header.count); + + stream.device()->seek(startPos + header.offset); + + for(quint32 i = 0; i < header.count; i++) + stream >> value[i]; + + return QExifValue(value); + } + default: + qWarning() << "Invalid Ifd Type" << header.type; + + return QExifValue(); + } +} + +template QMap QExifImageHeader::readIfdValues( + QDataStream &stream, int startPos, const QList &headers) const +{ + QMap values; + + // This needs to be non-const so it works with gcc3 + QList headers_ = headers; + foreach (const ExifIfdHeader &header, headers_) + values[T(header.tag)] = readIfdValue(stream, startPos, header); + + return values; +} + +template +QMap QExifImageHeader::readIfdValues( + QDataStream &stream, int startPos, const QExifValue &pointer) const +{ + if (pointer.type() == QExifValue::Long && pointer.count() == 1) { + stream.device()->seek(startPos + pointer.toLong()); + + QList headers = readIfdHeaders(stream); + + return readIfdValues(stream, startPos, headers); + } else { + return QMap(); + } +} + + +/*! + Reads the contents of an EXIF header from an I/O \a device. + + Returns true if the header was read and false otherwise. + + \sa loadFromJpeg(), write() +*/ +bool QExifImageHeader::read(QIODevice *device) +{ + clear(); + + int startPos = device->pos(); + + QDataStream stream(device); + + QByteArray byteOrder = device->read(2); + + if (byteOrder == "II") { + d->byteOrder = QSysInfo::LittleEndian; + + stream.setByteOrder( QDataStream::LittleEndian ); + } else if (byteOrder == "MM") { + d->byteOrder = QSysInfo::BigEndian; + + stream.setByteOrder( QDataStream::BigEndian ); + } else { + return false; + } + + quint16 id; + quint32 offset; + + stream >> id; + stream >> offset; + + if (id != 0x002A) + return false; + + device->seek(startPos + offset); + + QList headers = readIfdHeaders(stream); + + stream >> offset; + + d->imageIfdValues = readIfdValues(stream, startPos, headers); + + QExifValue exifIfdPointer = d->imageIfdValues.take(ImageTag(ExifIfdPointer)); + QExifValue gpsIfdPointer = d->imageIfdValues.take(ImageTag(GpsInfoIfdPointer)); + + d->exifIfdValues = readIfdValues(stream, startPos, exifIfdPointer); + d->gpsIfdValues = readIfdValues(stream, startPos, gpsIfdPointer); + + d->exifIfdValues.remove(ExifExtendedTag(InteroperabilityIfdPointer)); + + if (offset) { + device->seek(startPos + offset); + + QMap thumbnailIfdValues = readIfdValues( + stream, startPos, readIfdHeaders( stream)); + + QExifValue jpegOffset = thumbnailIfdValues.value(JpegInterchangeFormat); + QExifValue jpegLength = thumbnailIfdValues.value(JpegInterchangeFormatLength); + + if (jpegOffset.type() == QExifValue::Long && jpegOffset.count() == 1 + && jpegLength.type() == QExifValue::Long && jpegLength.count() == 1) + { + device->seek(startPos + jpegOffset.toLong()); + + d->thumbnailData = device->read( jpegLength.toLong() ); + + d->thumbnailXResolution = thumbnailIfdValues.value(XResolution); + d->thumbnailYResolution = thumbnailIfdValues.value(YResolution); + d->thumbnailResolutionUnit = thumbnailIfdValues.value(ResolutionUnit); + d->thumbnailOrientation = thumbnailIfdValues.value(Orientation); + } + } + return true; +} + +quint32 QExifImageHeader::writeExifHeader(QDataStream &stream, quint16 tag, const QExifValue &value, quint32 offset) const +{ + stream << tag; + stream << quint16(value.type()); + stream << quint32(value.count()); + + switch (value.type()) { + case QExifValue::Byte: + if (value.count() <= 4) { + foreach (quint8 byte, value.toByteVector()) + stream << byte; + for (int j = value.count(); j < 4; j++) + stream << quint8(0); + } else { + stream << offset; + + offset += value.count(); + } + break; + case QExifValue::Undefined: + if (value.count() <= 4) { + stream.device()->write(value.toByteArray()); + + if ( value.count() < 4) + stream.writeRawData("\0\0\0\0", 4 - value.count()); + } else { + stream << offset; + + offset += value.count(); + } + break; + case QExifValue::Ascii: + if (value.count() <= 4) { + QByteArray bytes = value.toByteArray(); + + stream.writeRawData(bytes.constData(), value.count()); + if (value.count() < 4) + stream.writeRawData("\0\0\0\0", 4 - value.count()); + } else { + stream << offset; + + offset += value.count(); + } + break; + case QExifValue::Short: + if (value.count() <= 2) { + foreach (quint16 shrt, value.toShortVector()) + stream << shrt; + for (int j = value.count(); j < 2; j++) + stream << quint16(0); + } else { + stream << offset; + + offset += value.count() * sizeof(quint16); + } + break; + case QExifValue::Long: + if(value.count() == 0) { + stream << quint32(0); + } else if(value.count() == 1) { + stream << value.toLong(); + } else { + stream << offset; + + offset += value.count() * sizeof(quint32); + } + break; + case QExifValue::SignedLong: + if (value.count() == 0) { + stream << quint32( 0 ); + } else if (value.count() == 1) { + stream << value.toSignedLong(); + } else { + stream << offset; + + offset += value.count() * sizeof(qint32); + } + break; + case QExifValue::Rational: + if(value.count() == 0) { + stream << quint32(0); + } else { + stream << offset; + + offset += value.count() * sizeof(quint32) * 2; + } + break; + case QExifValue::SignedRational: + if (value.count() == 0) { + stream << quint32(0); + } else { + stream << offset; + + offset += value.count() * sizeof(qint32) * 2; + } + break; + default: + qWarning() << "Invalid Ifd Type" << value.type(); + stream << quint32(0); + } + + return offset; +} + +void QExifImageHeader::writeExifValue(QDataStream &stream, const QExifValue &value) const +{ + switch (value.type()) { + case QExifValue::Byte: + if (value.count() > 4) + foreach (quint8 byte, value.toByteVector()) + stream << byte; + break; + case QExifValue::Undefined: + if (value.count() > 4) + stream.device()->write(value.toByteArray()); + break; + case QExifValue::Ascii: + if (value.count() > 4) { + QByteArray bytes = value.toByteArray(); + + stream.writeRawData(bytes.constData(), bytes.size() + 1); + } + break; + case QExifValue::Short: + if (value.count() > 2) + foreach(quint16 shrt, value.toShortVector()) + stream << shrt; + break; + case QExifValue::Long: + if(value.count() > 1) + foreach (quint32 lng, value.toLongVector()) + stream << lng; + break; + case QExifValue::SignedLong: + if (value.count() > 1) + foreach(qint32 lng, value.toSignedLongVector()) + stream << lng; + break; + case QExifValue::Rational: + if (value.count() > 0) + foreach (QExifURational rational, value.toRationalVector()) + stream << rational; + break; + case QExifValue::SignedRational: + if (value.count() > 0) + foreach (QExifSRational rational, value.toSignedRationalVector()) + stream << rational; + break; + default: + qWarning() << "Invalid Ifd Type" << value.type(); + break; + } +} + +template quint32 QExifImageHeader::writeExifHeaders( + QDataStream &stream, const QMap &values, quint32 offset) const +{ + offset += values.count() * 12; + + for (typename QMap::const_iterator i = values.constBegin(); i != values.constEnd(); i++) + offset = writeExifHeader(stream, i.key(), i.value(), offset); + + return offset; +} + +template void QExifImageHeader::writeExifValues( + QDataStream &stream, const QMap &values) const +{ + for (typename QMap::const_iterator i = values.constBegin(); i != values.constEnd(); i++) + writeExifValue(stream, i.value()); +} + +/*! + Writes an EXIF header to an I/O \a device. + + Returns the total number of bytes written. +*/ +qint64 QExifImageHeader::write(QIODevice *device) const +{ +#ifndef QT_NO_DEBUG + qint64 startPos = device->pos(); +#endif + + QDataStream stream( device ); + + if (d->byteOrder == QSysInfo::LittleEndian) { + stream.setByteOrder( QDataStream::LittleEndian ); + + device->write("II", 2); + device->write("\x2A\x00", 2); + device->write("\x08\x00\x00\x00", 4); + } else if (d->byteOrder == QSysInfo::BigEndian) { + stream.setByteOrder(QDataStream::BigEndian); + + device->write("MM", 2); + device->write("\x00\x2A", 2); + device->write("\x00\x00\x00\x08", 4); + } + + quint16 count = d->imageIfdValues.count() + 1; + quint32 offset = 26; + + if (!d->gpsIfdValues.isEmpty()) { + count++; + offset += 12; + } + + stream << count; + + offset = writeExifHeaders(stream, d->imageIfdValues, offset); + + quint32 exifIfdOffset = offset; + + stream << quint16( ExifIfdPointer ); + stream << quint16( QExifValue::Long ); + stream << quint32( 1 ); + stream << exifIfdOffset; + offset += calculateSize(d->exifIfdValues); + + quint32 gpsIfdOffset = offset; + + if (!d->gpsIfdValues.isEmpty()) { + stream << quint16(GpsInfoIfdPointer); + stream << quint16(QExifValue::Long); + stream << quint32(1); + stream << gpsIfdOffset; + + d->imageIfdValues.insert(ImageTag(GpsInfoIfdPointer), QExifValue(offset)); + + offset += calculateSize(d->gpsIfdValues); + } + + if (!d->thumbnailData.isEmpty()) + stream << offset; // Write offset to thumbnail Ifd. + else + stream << quint32(0); + + writeExifValues( stream, d->imageIfdValues ); + + Q_ASSERT(startPos + exifIfdOffset == device->pos()); + + stream << quint16(d->exifIfdValues.count()); + + writeExifHeaders(stream, d->exifIfdValues, exifIfdOffset); + writeExifValues(stream, d->exifIfdValues); + + Q_ASSERT(startPos + gpsIfdOffset == device->pos()); + + if (!d->gpsIfdValues.isEmpty()) { + stream << quint16(d->gpsIfdValues.count()); + + writeExifHeaders(stream, d->gpsIfdValues, gpsIfdOffset); + writeExifValues(stream, d->gpsIfdValues); + } + + Q_ASSERT(startPos + offset == device->pos()); + + if (!d->thumbnailData.isEmpty()) { + offset += 86; + + stream << quint16(7); + + QExifValue xResolution = d->thumbnailXResolution.isNull() + ? QExifValue(QExifURational(72, 1)) + : d->thumbnailXResolution; + + QExifValue yResolution = d->thumbnailYResolution.isNull() + ? QExifValue(QExifURational(72, 1)) + : d->thumbnailYResolution; + + QExifValue resolutionUnit = d->thumbnailResolutionUnit.isNull() + ? QExifValue(quint16(2)) + : d->thumbnailResolutionUnit; + + QExifValue orientation = d->thumbnailOrientation.isNull() + ? QExifValue(quint16(0)) + : d->thumbnailOrientation; + + writeExifHeader(stream, Compression, QExifValue(quint16(6)), offset); + + offset = writeExifHeader(stream, XResolution, xResolution, offset); + offset = writeExifHeader(stream, YResolution, yResolution, offset); + + writeExifHeader(stream, ResolutionUnit, resolutionUnit, offset); + writeExifHeader(stream, Orientation, orientation, offset); + writeExifHeader(stream, JpegInterchangeFormat, QExifValue(offset), offset); + writeExifHeader(stream, JpegInterchangeFormatLength, + QExifValue(quint32(d->thumbnailData.size())), offset); + + writeExifValue(stream, xResolution); + writeExifValue(stream, yResolution); + + Q_ASSERT(startPos + offset == device->pos()); + + device->write(d->thumbnailData); + + offset += d->thumbnailData.size(); + } + + Q_ASSERT(startPos + offset == device->pos()); + + d->size = offset; + + return offset; +} diff -Nru syncwall-1.6.0/src/3rdparty/qt-extended/qexifimageheader.h syncwall-1.7.4/src/3rdparty/qt-extended/qexifimageheader.h --- syncwall-1.6.0/src/3rdparty/qt-extended/qexifimageheader.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qt-extended/qexifimageheader.h 2012-05-15 11:58:08.000000000 +0000 @@ -0,0 +1,347 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt scene graph research project. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This file was copied from Qt Extended 4.5 + +#ifndef QEXIFIMAGEHEADER_H +#define QEXIFIMAGEHEADER_H + +#include +#include +#include +#include +#include + +typedef QPair< quint32, quint32 > QExifURational; +typedef QPair< qint32, qint32 > QExifSRational; + +Q_DECLARE_METATYPE(QExifURational) +Q_DECLARE_METATYPE(QExifSRational) + +class QExifValuePrivate; + +class QExifValue +{ +public: + enum Type + { + Byte = 1, + Ascii = 2, + Short = 3, + Long = 4, + Rational = 5, + Undefined = 7, + SignedLong = 9, + SignedRational = 10 + }; + + enum TextEncoding + { + NoEncoding, + AsciiEncoding, + JisEncoding, + UnicodeEncoding, + UndefinedEncoding + }; + + QExifValue(); + QExifValue( quint8 value ); + QExifValue( const QVector< quint8 > &value ); + QExifValue( const QString &value, TextEncoding encoding = NoEncoding ); + QExifValue( quint16 value ); + QExifValue( const QVector< quint16 > &value ); + QExifValue( quint32 value ); + QExifValue( const QVector< quint32 > &value ); + QExifValue( const QExifURational &value ); + QExifValue( const QVector< QExifURational > &value ); + QExifValue( const QByteArray &value ); + QExifValue( qint32 value ); + QExifValue( const QVector< qint32 > &value ); + QExifValue( const QExifSRational &value ); + QExifValue( const QVector< QExifSRational > &value ); + QExifValue( const QDateTime &value ); + QExifValue( const QExifValue &other ); + QExifValue &operator =( const QExifValue &other ); + ~QExifValue(); + + bool operator ==( const QExifValue &other ) const; + + bool isNull() const; + + int type() const; + int count() const; + + TextEncoding encoding() const; + + quint8 toByte() const; + QVector< quint8 > toByteVector() const; + QString toString() const; + quint16 toShort() const; + QVector< quint16 > toShortVector() const; + quint32 toLong() const; + QVector< quint32 > toLongVector() const; + QExifURational toRational() const; + QVector< QExifURational > toRationalVector() const; + QByteArray toByteArray() const; + qint32 toSignedLong() const; + QVector< qint32 > toSignedLongVector() const; + QExifSRational toSignedRational() const; + QVector< QExifSRational > toSignedRationalVector() const; + QDateTime toDateTime() const; + +private: + QExplicitlySharedDataPointer< QExifValuePrivate > d; +}; + +struct ExifIfdHeader; + +class QExifImageHeaderPrivate; + +class QExifImageHeader +{ + Q_DISABLE_COPY(QExifImageHeader) +public: + enum ImageTag + { + + ImageWidth = 0x0100, + ImageLength = 0x0101, + BitsPerSample = 0x0102, + Compression = 0x0103, + PhotometricInterpretation = 0x0106, + Orientation = 0x0112, + SamplesPerPixel = 0x0115, + PlanarConfiguration = 0x011C, + YCbCrSubSampling = 0x0212, + XResolution = 0x011A, + YResolution = 0x011B, + ResolutionUnit = 0x0128, + StripOffsets = 0x0111, + RowsPerStrip = 0x0116, + StripByteCounts = 0x0117, + TransferFunction = 0x012D, + WhitePoint = 0x013E, + PrimaryChromaciticies = 0x013F, + YCbCrCoefficients = 0x0211, + ReferenceBlackWhite = 0x0214, + DateTime = 0x0132, + ImageDescription = 0x010E, + Make = 0x010F, + Model = 0x0110, + Software = 0x0131, + Artist = 0x013B, + Copyright = 0x8298 + }; + + enum ExifExtendedTag + { + ExifVersion = 0x9000, + FlashPixVersion = 0xA000, + ColorSpace = 0xA001, + ComponentsConfiguration = 0x9101, + CompressedBitsPerPixel = 0x9102, + PixelXDimension = 0xA002, + PixelYDimension = 0xA003, + MakerNote = 0x927C, + UserComment = 0x9286, + RelatedSoundFile = 0xA004, + DateTimeOriginal = 0x9003, + DateTimeDigitized = 0x9004, + SubSecTime = 0x9290, + SubSecTimeOriginal = 0x9291, + SubSecTimeDigitized = 0x9292, + ImageUniqueId = 0xA420, + + ExposureTime = 0x829A, + FNumber = 0x829D, + ExposureProgram = 0x8822, + SpectralSensitivity = 0x8824, + ISOSpeedRatings = 0x8827, + Oecf = 0x8828, + ShutterSpeedValue = 0x9201, + ApertureValue = 0x9202, + BrightnessValue = 0x9203, + ExposureBiasValue = 0x9204, + MaxApertureValue = 0x9205, + SubjectDistance = 0x9206, + MeteringMode = 0x9207, + LightSource = 0x9208, + Flash = 0x9209, + FocalLength = 0x920A, + SubjectArea = 0x9214, + FlashEnergy = 0xA20B, + SpatialFrequencyResponse = 0xA20C, + FocalPlaneXResolution = 0xA20E, + FocalPlaneYResolution = 0xA20F, + FocalPlaneResolutionUnit = 0xA210, + SubjectLocation = 0xA214, + ExposureIndex = 0xA215, + SensingMethod = 0xA217, + FileSource = 0xA300, + SceneType = 0xA301, + CfaPattern = 0xA302, + CustomRendered = 0xA401, + ExposureMode = 0xA402, + WhiteBalance = 0xA403, + DigitalZoomRatio = 0xA404, + FocalLengthIn35mmFilm = 0xA405, + SceneCaptureType = 0xA406, + GainControl = 0xA407, + Contrast = 0xA408, + Saturation = 0xA409, + Sharpness = 0xA40A, + DeviceSettingDescription = 0xA40B, + SubjectDistanceRange = 0x40C + }; + + enum GpsTag + { + GpsVersionId = 0x0000, + GpsLatitudeRef = 0x0001, + GpsLatitude = 0x0002, + GpsLongitudeRef = 0x0003, + GpsLongitude = 0x0004, + GpsAltitudeRef = 0x0005, + GpsAltitude = 0x0006, + GpsTimeStamp = 0x0007, + GpsSatellites = 0x0008, + GpsStatus = 0x0009, + GpsMeasureMode = 0x000A, + GpsDop = 0x000B, + GpsSpeedRef = 0x000C, + GpsSpeed = 0x000D, + GpsTrackRef = 0x000E, + GpsTrack = 0x000F, + GpsImageDirectionRef = 0x0010, + GpsImageDirection = 0x0011, + GpsMapDatum = 0x0012, + GpsDestLatitudeRef = 0x0013, + GpsDestLatitude = 0x0014, + GpsDestLongitudeRef = 0x0015, + GpsDestLongitude = 0x0016, + GpsDestBearingRef = 0x0017, + GpsDestBearing = 0x0018, + GpsDestDistanceRef = 0x0019, + GpsDestDistance = 0x001A, + GpsProcessingMethod = 0x001B, + GpsAreaInformation = 0x001C, + GpsDateStamp = 0x001D, + GpsDifferential = 0x001E + }; + + QExifImageHeader(); + explicit QExifImageHeader(const QString &fileName); + ~QExifImageHeader(); + + bool loadFromJpeg(const QString &fileName); + bool loadFromJpeg(QIODevice *device); + bool saveToJpeg(const QString &fileName) const; + bool saveToJpeg(QIODevice *device) const; + + bool read(QIODevice *device); + qint64 write(QIODevice *device) const; + + qint64 size() const; + + QSysInfo::Endian byteOrder() const; + + void clear(); + + QList imageTags() const; + QList extendedTags() const; + QList gpsTags() const; + + bool contains(ImageTag tag) const; + bool contains(ExifExtendedTag tag) const; + bool contains(GpsTag tag) const; + + void remove(ImageTag tag); + void remove(ExifExtendedTag tag); + void remove(GpsTag tag); + + QExifValue value(ImageTag tag) const; + QExifValue value(ExifExtendedTag tag) const; + QExifValue value(GpsTag tag) const; + + void setValue(ImageTag tag, const QExifValue &value); + void setValue(ExifExtendedTag tag, const QExifValue &value); + void setValue(GpsTag tag, const QExifValue &value); + + QImage thumbnail() const; + void setThumbnail( const QImage &thumbnail ); + +private: + enum PrivateTag + { + ExifIfdPointer = 0x8769, + GpsInfoIfdPointer = 0x8825, + InteroperabilityIfdPointer = 0xA005, + JpegInterchangeFormat = 0x0201, + JpegInterchangeFormatLength = 0x0202 + }; + + QByteArray extractExif( QIODevice *device ) const; + + QList< ExifIfdHeader > readIfdHeaders( QDataStream &stream ) const; + + QExifValue readIfdValue(QDataStream &stream, int startPos, const ExifIfdHeader &header) const; + template QMap readIfdValues( + QDataStream &stream, int startPos, const QList &headers) const; + template QMap readIfdValues( + QDataStream &stream, int startPos, const QExifValue &pointer) const; + + quint32 writeExifHeader(QDataStream &stream, quint16 tag, const QExifValue &value, quint32 offset) const; + void writeExifValue(QDataStream &stream, const QExifValue &value) const; + + template quint32 writeExifHeaders( + QDataStream &stream, const QMap &values, quint32 offset) const; + template void writeExifValues( + QDataStream &target, const QMap &values) const; + + quint32 sizeOf(const QExifValue &value) const; + + template quint32 calculateSize( + const QMap &values) const; + + QExifImageHeaderPrivate *d; +}; + +#endif diff -Nru syncwall-1.6.0/src/3rdparty/qtwin/CMakeLists.txt syncwall-1.7.4/src/3rdparty/qtwin/CMakeLists.txt --- syncwall-1.6.0/src/3rdparty/qtwin/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qtwin/CMakeLists.txt 2010-07-07 16:03:36.000000000 +0000 @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 2.6) + +set(QTWIN-SOURCES + qtwin.cpp +) + +ADD_LIBRARY(qtwin STATIC + ${QTWIN-SOURCES} +) diff -Nru syncwall-1.6.0/src/3rdparty/qtwin/qtwin.cpp syncwall-1.7.4/src/3rdparty/qtwin/qtwin.cpp --- syncwall-1.6.0/src/3rdparty/qtwin/qtwin.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qtwin/qtwin.cpp 2011-12-13 02:23:56.000000000 +0000 @@ -0,0 +1,266 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Use, modification and distribution is allowed without limitation, +** warranty, liability or support of any kind. +** +****************************************************************************/ + +#include "qtwin.h" +#include +#include +#include +#include +#include + +#ifdef Q_WS_WIN + +#include + +// Blur behind data structures +#define DWM_BB_ENABLE 0x00000001 // fEnable has been specified +#define DWM_BB_BLURREGION 0x00000002 // hRgnBlur has been specified +#define DWM_BB_TRANSITIONONMAXIMIZED 0x00000004 // fTransitionOnMaximized has been specified +#define WM_DWMCOMPOSITIONCHANGED 0x031E // Composition changed window message + +typedef struct _DWM_BLURBEHIND +{ + DWORD dwFlags; + BOOL fEnable; + HRGN hRgnBlur; + BOOL fTransitionOnMaximized; +} DWM_BLURBEHIND, *PDWM_BLURBEHIND; + +typedef struct _MARGINS +{ + int cxLeftWidth; + int cxRightWidth; + int cyTopHeight; + int cyBottomHeight; +} MARGINS, *PMARGINS; + +typedef HRESULT (WINAPI *PtrDwmIsCompositionEnabled)(BOOL* pfEnabled); +typedef HRESULT (WINAPI *PtrDwmExtendFrameIntoClientArea)(HWND hWnd, const MARGINS* pMarInset); +typedef HRESULT (WINAPI *PtrDwmEnableBlurBehindWindow)(HWND hWnd, const DWM_BLURBEHIND* pBlurBehind); +typedef HRESULT (WINAPI *PtrDwmGetColorizationColor)(DWORD *pcrColorization, BOOL *pfOpaqueBlend); + +static PtrDwmIsCompositionEnabled pDwmIsCompositionEnabled= 0; +static PtrDwmEnableBlurBehindWindow pDwmEnableBlurBehindWindow = 0; +static PtrDwmExtendFrameIntoClientArea pDwmExtendFrameIntoClientArea = 0; +static PtrDwmGetColorizationColor pDwmGetColorizationColor = 0; + + +/* + * Internal helper class that notifies windows if the + * DWM compositing state changes and updates the widget + * flags correspondingly. + */ +class WindowNotifier : public QWidget +{ +public: + WindowNotifier() + { + winId(); + } + void addWidget(QWidget *widget) + { + widgets.append(widget); + } + void removeWidget(QWidget *widget) + { + widgets.removeAll(widget); + } + bool winEvent(MSG *message, long *result); + +private: + QWidgetList widgets; +}; + +static bool resolveLibs() +{ + if (!pDwmIsCompositionEnabled) + { + QLibrary dwmLib(QString::fromAscii("dwmapi")); + pDwmIsCompositionEnabled =(PtrDwmIsCompositionEnabled)dwmLib.resolve("DwmIsCompositionEnabled"); + pDwmExtendFrameIntoClientArea = (PtrDwmExtendFrameIntoClientArea)dwmLib.resolve("DwmExtendFrameIntoClientArea"); + pDwmEnableBlurBehindWindow = (PtrDwmEnableBlurBehindWindow)dwmLib.resolve("DwmEnableBlurBehindWindow"); + pDwmGetColorizationColor = (PtrDwmGetColorizationColor)dwmLib.resolve("DwmGetColorizationColor"); + } + + return pDwmIsCompositionEnabled != 0; +} + +#endif + +/*! + * Chekcs and returns true if Windows DWM composition + * is currently enabled on the system. + * + * To get live notification on the availability of + * this feature, you will currently have to + * reimplement winEvent() on your widget and listen + * for the WM_DWMCOMPOSITIONCHANGED event to occur. + * + */ +bool QtWin::isCompositionEnabled() +{ +#ifdef Q_WS_WIN + + if (resolveLibs()) + { + HRESULT hr = S_OK; + BOOL isEnabled = false; + hr = pDwmIsCompositionEnabled(&isEnabled); + + if (SUCCEEDED(hr)) + return isEnabled; + } + +#endif + return false; +} + +/*! + * Enables Blur behind on a Widget. + * + * \a enable tells if the blur should be enabled or not + */ +bool QtWin::enableBlurBehindWindow(QWidget *widget, bool enable, + const QRegion ®ion) +{ + Q_ASSERT(widget); + bool result = false; +#ifdef Q_WS_WIN + + if (resolveLibs()) + { + DWM_BLURBEHIND bb = {0}; + HRESULT hr = S_OK; + bb.fEnable = enable; + bb.dwFlags = DWM_BB_ENABLE; + bb.hRgnBlur = NULL; + + if (!region.isEmpty()) + { + bb.dwFlags |= DWM_BB_BLURREGION; + bb.hRgnBlur = region.handle(); + } + + widget->setAttribute(Qt::WA_TranslucentBackground, enable); + widget->setAttribute(Qt::WA_NoSystemBackground, enable); + hr = pDwmEnableBlurBehindWindow(widget->winId(), &bb); + + if (SUCCEEDED(hr)) + { + result = true; + windowNotifier()->addWidget(widget); + } + } + +#endif + return result; +} + +/*! + * ExtendFrameIntoClientArea. + * + * This controls the rendering of the frame inside the window. + * Note that passing margins of -1 (the default value) will completely + * remove the frame from the window. + * + * \note you should not call enableBlurBehindWindow before calling + * this functions + * + * \a enable tells if the blur should be enabled or not + */ +bool QtWin::extendFrameIntoClientArea(QWidget *widget, int left, int top, int right, int bottom) +{ + + Q_ASSERT(widget); + Q_UNUSED(left); + Q_UNUSED(top); + Q_UNUSED(right); + Q_UNUSED(bottom); + + bool result = false; +#ifdef Q_WS_WIN + + if (resolveLibs()) + { + QLibrary dwmLib(QString::fromAscii("dwmapi")); + HRESULT hr = S_OK; + MARGINS m = {left, top, right, bottom}; + hr = pDwmExtendFrameIntoClientArea(widget->winId(), &m); + + if (SUCCEEDED(hr)) + { + result = true; + windowNotifier()->addWidget(widget); + } + + widget->setAttribute(Qt::WA_TranslucentBackground, result); + } + +#endif + return result; +} + +/*! + * Returns the current colorizationColor for the window. + * + * \a enable tells if the blur should be enabled or not + */ +QColor QtWin::colorizatinColor() +{ + QColor resultColor = QApplication::palette().window().color(); + +#ifdef Q_WS_WIN + + if (resolveLibs()) + { + DWORD color = 0; + BOOL opaque = FALSE; + QLibrary dwmLib(QString::fromAscii("dwmapi")); + HRESULT hr = S_OK; + hr = pDwmGetColorizationColor(&color, &opaque); + + if (SUCCEEDED(hr)) + resultColor = QColor(color); + } + +#endif + return resultColor; +} + +#ifdef Q_WS_WIN +WindowNotifier *QtWin::windowNotifier() +{ + static WindowNotifier *windowNotifierInstance = 0; + + if (!windowNotifierInstance) + windowNotifierInstance = new WindowNotifier; + + return windowNotifierInstance; +} + + +/* Notify all enabled windows that the DWM state changed */ +bool WindowNotifier::winEvent(MSG *message, long *result) +{ + if (message && message->message == WM_DWMCOMPOSITIONCHANGED) + { + bool compositionEnabled = QtWin::isCompositionEnabled(); + foreach(QWidget * widget, widgets) + { + if (widget) + { + widget->setAttribute(Qt::WA_NoSystemBackground, compositionEnabled); + widget->update(); + } + } + } + + return QWidget::winEvent(message, result); +} +#endif diff -Nru syncwall-1.6.0/src/3rdparty/qtwin/qtwin.cpp.orig syncwall-1.7.4/src/3rdparty/qtwin/qtwin.cpp.orig --- syncwall-1.6.0/src/3rdparty/qtwin/qtwin.cpp.orig 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qtwin/qtwin.cpp.orig 2010-07-07 16:03:36.000000000 +0000 @@ -0,0 +1,229 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Use, modification and distribution is allowed without limitation, +** warranty, liability or support of any kind. +** +****************************************************************************/ + +#include "qtwin.h" +#include +#include +#include +#include +#include + +#ifdef Q_WS_WIN + +#include + +// Blur behind data structures +#define DWM_BB_ENABLE 0x00000001 // fEnable has been specified +#define DWM_BB_BLURREGION 0x00000002 // hRgnBlur has been specified +#define DWM_BB_TRANSITIONONMAXIMIZED 0x00000004 // fTransitionOnMaximized has been specified +#define WM_DWMCOMPOSITIONCHANGED 0x031E // Composition changed window message + +typedef struct _DWM_BLURBEHIND +{ + DWORD dwFlags; + BOOL fEnable; + HRGN hRgnBlur; + BOOL fTransitionOnMaximized; +} DWM_BLURBEHIND, *PDWM_BLURBEHIND; + +typedef struct _MARGINS +{ + int cxLeftWidth; + int cxRightWidth; + int cyTopHeight; + int cyBottomHeight; +} MARGINS, *PMARGINS; + +typedef HRESULT (WINAPI *PtrDwmIsCompositionEnabled)(BOOL* pfEnabled); +typedef HRESULT (WINAPI *PtrDwmExtendFrameIntoClientArea)(HWND hWnd, const MARGINS* pMarInset); +typedef HRESULT (WINAPI *PtrDwmEnableBlurBehindWindow)(HWND hWnd, const DWM_BLURBEHIND* pBlurBehind); +typedef HRESULT (WINAPI *PtrDwmGetColorizationColor)(DWORD *pcrColorization, BOOL *pfOpaqueBlend); + +static PtrDwmIsCompositionEnabled pDwmIsCompositionEnabled= 0; +static PtrDwmEnableBlurBehindWindow pDwmEnableBlurBehindWindow = 0; +static PtrDwmExtendFrameIntoClientArea pDwmExtendFrameIntoClientArea = 0; +static PtrDwmGetColorizationColor pDwmGetColorizationColor = 0; + + +/* + * Internal helper class that notifies windows if the + * DWM compositing state changes and updates the widget + * flags correspondingly. + */ +class WindowNotifier : public QWidget +{ +public: + WindowNotifier() { winId(); } + void addWidget(QWidget *widget) { widgets.append(widget); } + void removeWidget(QWidget *widget) { widgets.removeAll(widget); } + bool winEvent(MSG *message, long *result); + +private: + QWidgetList widgets; +}; + +static bool resolveLibs() +{ + if (!pDwmIsCompositionEnabled) { + QLibrary dwmLib(QString::fromAscii("dwmapi")); + pDwmIsCompositionEnabled =(PtrDwmIsCompositionEnabled)dwmLib.resolve("DwmIsCompositionEnabled"); + pDwmExtendFrameIntoClientArea = (PtrDwmExtendFrameIntoClientArea)dwmLib.resolve("DwmExtendFrameIntoClientArea"); + pDwmEnableBlurBehindWindow = (PtrDwmEnableBlurBehindWindow)dwmLib.resolve("DwmEnableBlurBehindWindow"); + pDwmGetColorizationColor = (PtrDwmGetColorizationColor)dwmLib.resolve("DwmGetColorizationColor"); + } + return pDwmIsCompositionEnabled != 0; +} + +#endif + +/*! + * Chekcs and returns true if Windows DWM composition + * is currently enabled on the system. + * + * To get live notification on the availability of + * this feature, you will currently have to + * reimplement winEvent() on your widget and listen + * for the WM_DWMCOMPOSITIONCHANGED event to occur. + * + */ +bool QtWin::isCompositionEnabled() +{ +#ifdef Q_WS_WIN + if (resolveLibs()) { + HRESULT hr = S_OK; + BOOL isEnabled = false; + hr = pDwmIsCompositionEnabled(&isEnabled); + if (SUCCEEDED(hr)) + return isEnabled; + } +#endif + return false; +} + +/*! + * Enables Blur behind on a Widget. + * + * \a enable tells if the blur should be enabled or not + */ +bool QtWin::enableBlurBehindWindow(QWidget *widget, bool enable, + const QRegion ®ion) +{ + Q_ASSERT(widget); + bool result = false; +#ifdef Q_WS_WIN + if (resolveLibs()) { + DWM_BLURBEHIND bb = {0}; + HRESULT hr = S_OK; + bb.fEnable = enable; + bb.dwFlags = DWM_BB_ENABLE; + bb.hRgnBlur = NULL; + + if (!region.isEmpty()) { + bb.dwFlags |= DWM_BB_BLURREGION; + bb.hRgnBlur = region.handle(); + } + + widget->setAttribute(Qt::WA_TranslucentBackground, enable); + widget->setAttribute(Qt::WA_NoSystemBackground, enable); + hr = pDwmEnableBlurBehindWindow(widget->winId(), &bb); + if (SUCCEEDED(hr)) { + result = true; + windowNotifier()->addWidget(widget); + } + } +#endif + return result; +} + +/*! + * ExtendFrameIntoClientArea. + * + * This controls the rendering of the frame inside the window. + * Note that passing margins of -1 (the default value) will completely + * remove the frame from the window. + * + * \note you should not call enableBlurBehindWindow before calling + * this functions + * + * \a enable tells if the blur should be enabled or not + */ +bool QtWin::extendFrameIntoClientArea(QWidget *widget, int left, int top, int right, int bottom) +{ + + Q_ASSERT(widget); + Q_UNUSED(left); + Q_UNUSED(top); + Q_UNUSED(right); + Q_UNUSED(bottom); + + bool result = false; +#ifdef Q_WS_WIN + if (resolveLibs()) { + QLibrary dwmLib(QString::fromAscii("dwmapi")); + HRESULT hr = S_OK; + MARGINS m = {left, top, right, bottom}; + hr = pDwmExtendFrameIntoClientArea(widget->winId(), &m); + if (SUCCEEDED(hr)) { + result = true; + windowNotifier()->addWidget(widget); + } + widget->setAttribute(Qt::WA_TranslucentBackground, result); + } +#endif + return result; +} + +/*! + * Returns the current colorizationColor for the window. + * + * \a enable tells if the blur should be enabled or not + */ +QColor QtWin::colorizatinColor() +{ + QColor resultColor = QApplication::palette().window().color(); + +#ifdef Q_WS_WIN + if (resolveLibs()) { + DWORD color = 0; + BOOL opaque = FALSE; + QLibrary dwmLib(QString::fromAscii("dwmapi")); + HRESULT hr = S_OK; + hr = pDwmGetColorizationColor(&color, &opaque); + if (SUCCEEDED(hr)) + resultColor = QColor(color); + } +#endif + return resultColor; +} + +#ifdef Q_WS_WIN +WindowNotifier *QtWin::windowNotifier() +{ + static WindowNotifier *windowNotifierInstance = 0; + if (!windowNotifierInstance) + windowNotifierInstance = new WindowNotifier; + return windowNotifierInstance; +} + + +/* Notify all enabled windows that the DWM state changed */ +bool WindowNotifier::winEvent(MSG *message, long *result) +{ + if (message && message->message == WM_DWMCOMPOSITIONCHANGED) { + bool compositionEnabled = QtWin::isCompositionEnabled(); + foreach(QWidget * widget, widgets) { + if (widget) { + widget->setAttribute(Qt::WA_NoSystemBackground, compositionEnabled); + } + widget->update(); + } + } + return QWidget::winEvent(message, result); +} +#endif diff -Nru syncwall-1.6.0/src/3rdparty/qtwin/qtwin.h syncwall-1.7.4/src/3rdparty/qtwin/qtwin.h --- syncwall-1.6.0/src/3rdparty/qtwin/qtwin.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qtwin/qtwin.h 2010-07-07 16:03:36.000000000 +0000 @@ -0,0 +1,38 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Use, modification and distribution is allowed without limitation, +** warranty, liability or support of any kind. +** +****************************************************************************/ + +#ifndef QTWIN_H +#define QTWIN_H + +#include +#include +/** + * This is a helper class for using the Desktop Window Manager + * functionality on Windows 7 and Windows Vista. On other platforms + * these functions will simply not do anything. + */ + +class WindowNotifier; + +class QtWin +{ +public: + static bool enableBlurBehindWindow(QWidget *widget, bool enable = true, + const QRegion& region = QRegion()); + static bool extendFrameIntoClientArea(QWidget *widget, + int left = -1, int top = -1, + int right = -1, int bottom = -1); + static bool isCompositionEnabled(); + static QColor colorizatinColor(); + +private: + static WindowNotifier *windowNotifier(); +}; + +#endif // QTWIN_H diff -Nru syncwall-1.6.0/src/3rdparty/qxt/CMakeLists.txt syncwall-1.7.4/src/3rdparty/qxt/CMakeLists.txt --- syncwall-1.6.0/src/3rdparty/qxt/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qxt/CMakeLists.txt 2013-03-21 08:10:08.000000000 +0000 @@ -0,0 +1,34 @@ +cmake_minimum_required(VERSION 2.6) + +PROJECT(qxt) + +find_package(Qt4 REQUIRED) + +INCLUDE(${QT_USE_FILE}) + +set(QXT-SOURCES + qxtglobal.cpp + qxtglobalshortcut.cpp +) + +set(QXT-MOC-HEADERS + qxtglobalshortcut.h +) + +if(WIN32) + set(QXT-SOURCES ${QXT-SOURCES} qxtglobalshortcut_win.cpp) +elseif(APPLE) + set(QXT-SOURCES ${QXT-SOURCES} qxtglobalshortcut_mac.cpp) +else(WIN32) + set(QXT-SOURCES ${QXT-SOURCES} qxtglobalshortcut_x11.cpp) +endif(WIN32) + +QT4_WRAP_CPP(QXT-SOURCES-MOC ${QXT-MOC-HEADERS}) + +# add special flags for compilation +ADD_DEFINITIONS( -DQXT_STATIC ) + +ADD_LIBRARY(qxt STATIC + ${QXT-SOURCES} + ${QXT-SOURCES-MOC} +) diff -Nru syncwall-1.6.0/src/3rdparty/qxt/LICENSE syncwall-1.7.4/src/3rdparty/qxt/LICENSE --- syncwall-1.6.0/src/3rdparty/qxt/LICENSE 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qxt/LICENSE 2011-03-29 12:16:32.000000000 +0000 @@ -0,0 +1,89 @@ +Qt Extension Library +Copyright (C) 2007 Qxt Foundation + +------------------- Disclaimer ------------------------------------------------ + +Until the Qxt Foundation is legally established, copyright for the +source code falls back to the original contributor. For information about the +status of the Qxt Foundation, or about the copyright status of any part of Qxt, +contact the Qxt project maintainers at + +Once the Qxt Foundation has been legally established, all contributors must +transfer all copyright interest to the Qxt Foundation before their submissions +will be added to the project. + +------------------- License --------------------------------------------------- + +This library is free software; you can redistribute it and/or modify it +under the terms of the Common Public License, version 1.0, as published by IBM +or under the terms of the GNU Lesser General Public License, version 2.1, +as published by the Free Software Foundation + +This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY +WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR +FITNESS FOR A PARTICULAR PURPOSE. + +You should have received a copy of the CPL along with this file. +See the LICENSE file and the cpl1.0.txt file included with the source +distribution for more information. If you did not receive a copy of the +license, contact the Qxt Foundation. + +You should have received a copy of the LGPL along with this file. +See the LICENSE file and the lgpl-2.1.txt file included with the source +distribution for more information. If you did not receive a copy of the +license, contact the Qxt Foundation. + +Parts of Qxt depend on Qt 4 and/or other libraries that have their own +licenses. Qxt is independent of these licenses; however, use of these other +libraries is subject to their respective license agreements. + +------------------- Intent ---------------------------------------------------- + +The following section describes the opinions and intent of the Qxt Foundation +with regards to the licensing and use of the Qxt source code and library. In +the event that the CPL is found to be illegal or invalid, or if any application +or clause of the license is subjected to question or abuse, this section is a +general statement of the desired interpretation. + +This section has no legal standing and the statements made here are strictly +subject to the text of the CPL; that is, if this section and the CPL are in +disagreement, the text of the CPL takes precedence. In no way does this +intent grant you any additional rights or impose any additional restrictions. + +If you have questions about licensing, contact the maintainers. + +Qxt is built and supported by open-source enthusiasts. +- Please respect the open-source background of the contributors. The code is + provided for everyone's use; you may not restrict the rights of anyone to + use it. + - No individual may claim ownership of any part of the code. It belongs + to the community. + - You may modify the source code to suit your needs, but these changes + must be made free. If you distribute a modified form of Qxt, you must + also distribute the entire source code of the modified form. + - Digital Rights Management (DRM) puts unfair, unfree restrictions on + users and developers. It is the opposite of Free Software. We can't + stop you from using it, but please don't use the Qxt name for software + restricted by DRM. +- Please respect the time and effort put into the project by the developers. + - If you find Qxt useful, it would be appreciated if you would include + text in your application (for instance, in the About dialog) giving + acknowledgement to Qxt. + - If you make modifications to the source code, you must not call the + modified version "Qxt." It's okay to include "Qxt" in the name, but + anyone who receives the modified version needs to know that it's not + the same as the version distributed by the Qxt Foundation. +- We want everyone to be able to use Qxt without restrictions. + - If you distribute Qxt in compiled binary form, please ensure that + everyone who receives it can get the source code used to create it. + - You are free to use Qxt in closed-source applications as long as you + distribute Qxt in an open-source fashion. This does not require you + to make your entire application open-source. +- The Qxt Foundation is a non-profit, non-political organization. + - Please don't use the Qxt name in any political or semi-political + propaganda or publication. We don't like it. +- Qxt is distributed "as-is," with no warranty. + - If it makes your program crash, your computer blow up, or tiny demons + fly out of your nose, please don't sue us. + diff -Nru syncwall-1.6.0/src/3rdparty/qxt/QxtGlobalShortcut syncwall-1.7.4/src/3rdparty/qxt/QxtGlobalShortcut --- syncwall-1.6.0/src/3rdparty/qxt/QxtGlobalShortcut 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qxt/QxtGlobalShortcut 2011-11-24 15:10:32.000000000 +0000 @@ -0,0 +1,2 @@ +#include "qxtglobalshortcut.h" + diff -Nru syncwall-1.6.0/src/3rdparty/qxt/qxtglobal.cpp syncwall-1.7.4/src/3rdparty/qxt/qxtglobal.cpp --- syncwall-1.6.0/src/3rdparty/qxt/qxtglobal.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qxt/qxtglobal.cpp 2011-11-24 15:10:32.000000000 +0000 @@ -0,0 +1,241 @@ +/**************************************************************************** + ** + ** Copyright (C) Qxt Foundation. Some rights reserved. + ** + ** This file is part of the QxtCore module of the Qxt library. + ** + ** This library is free software; you can redistribute it and/or modify it + ** under the terms of the Common Public License, version 1.0, as published + ** by IBM, and/or under the terms of the GNU Lesser General Public License, + ** version 2.1, as published by the Free Software Foundation. + ** + ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY + ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY + ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR + ** FITNESS FOR A PARTICULAR PURPOSE. + ** + ** You should have received a copy of the CPL and the LGPL along with this + ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files + ** included with the source distribution for more information. + ** If you did not receive a copy of the licenses, contact the Qxt Foundation. + ** + ** + ** + ****************************************************************************/ + +#include "qxtglobal.h" + +/*! + \headerfile + \title Global Qxt Declarations + \inmodule QxtCore + + \brief The header provides basic declarations and + is included by all other Qxt headers. + */ + +/*! + \macro QXT_VERSION + \relates + + This macro expands a numeric value of the form 0xMMNNPP (MM = + major, NN = minor, PP = patch) that specifies Qxt's version + number. For example, if you compile your application against Qxt + 0.4.0, the QXT_VERSION macro will expand to 0x000400. + + You can use QXT_VERSION to use the latest Qt features where + available. For example: + \code + #if QXT_VERSION >= 0x000400 + qxtTabWidget->setTabMovementMode(QxtTabWidget::InPlaceMovement); + #endif + \endcode + + \sa QXT_VERSION_STR, qxtVersion() + */ + +/*! + \macro QXT_VERSION_STR + \relates + + This macro expands to a string that specifies Qxt's version number + (for example, "0.4.0"). This is the version against which the + application is compiled. + + \sa qxtVersion(), QXT_VERSION + */ + +/*! + \relates + + Returns the version number of Qxt at run-time as a string (for + example, "0.4.0"). This may be a different version than the + version the application was compiled against. + + \sa QXT_VERSION_STR + */ +const char* qxtVersion() +{ + return QXT_VERSION_STR; +} + +/*! +\headerfile +\title The Qxt private implementation +\inmodule QxtCore + +\brief The header provides tools for hiding +details of a class. + +Application code generally doesn't have to be concerned about hiding its +implementation details, but when writing library code it is important to +maintain a constant interface, both source and binary. Maintaining a constant +source interface is easy enough, but keeping the binary interface constant +means moving implementation details into a private class. The PIMPL, or +d-pointer, idiom is a common method of implementing this separation. QxtPimpl +offers a convenient way to connect the public and private sides of your class. + +\section1 Getting Started +Before you declare the public class, you need to make a forward declaration +of the private class. The private class must have the same name as the public +class, followed by the word Private. For example, a class named MyTest would +declare the private class with: +\code +class MyTestPrivate; +\endcode + +\section1 The Public Class +Generally, you shouldn't keep any data members in the public class without a +good reason. Functions that are part of the public interface should be declared +in the public class, and functions that need to be available to subclasses (for +calling or overriding) should be in the protected section of the public class. +To connect the private class to the public class, include the +QXT_DECLARE_PRIVATE macro in the private section of the public class. In the +example above, the private class is connected as follows: +\code +private: + QXT_DECLARE_PRIVATE(MyTest) +\endcode + +Additionally, you must include the QXT_INIT_PRIVATE macro in the public class's +constructor. Continuing with the MyTest example, your constructor might look +like this: +\code +MyTest::MyTest() { + // initialization + QXT_INIT_PRIVATE(MyTest); +} +\endcode + +\section1 The Private Class +As mentioned above, data members should usually be kept in the private class. +This allows the memory layout of the private class to change without breaking +binary compatibility for the public class. Functions that exist only as +implementation details, or functions that need access to private data members, +should be implemented here. + +To define the private class, inherit from the template QxtPrivate class, and +include the QXT_DECLARE_PUBLIC macro in its public section. The template +parameter should be the name of the public class. For example: +\code +class MyTestPrivate : public QxtPrivate { +public: + MyTestPrivate(); + QXT_DECLARE_PUBLIC(MyTest) +}; +\endcode + +\section1 Accessing Private Members +Use the qxt_d() function (actually a function-like object) from functions in +the public class to access the private class. Similarly, functions in the +private class can invoke functions in the public class by using the qxt_p() +function (this one's actually a function). + +For example, assume that MyTest has methods named getFoobar and doBaz(), +and MyTestPrivate has a member named foobar and a method named doQuux(). +The code might resemble this example: +\code +int MyTest::getFoobar() { + return qxt_d().foobar; +} + +void MyTestPrivate::doQuux() { + qxt_p().doBaz(foobar); +} +\endcode +*/ + +/*! + * \macro QXT_DECLARE_PRIVATE(PUB) + * \relates + * Declares that a public class has a related private class. + * + * This shuold be put in the private section of the public class. The parameter is the name of the public class. + */ + +/*! + * \macro QXT_DECLARE_PUBLIC(PUB) + * \relates + * Declares that a private class has a related public class. + * + * This may be put anywhere in the declaration of the private class. The parameter is the name of the public class. + */ + +/*! + * \macro QXT_INIT_PRIVATE(PUB) + * \relates + * Initializes resources owned by the private class. + * + * This should be called from the public class's constructor, + * before qxt_d() is used for the first time. The parameter is the name of the public class. + */ + +/*! + * \macro QXT_D(PUB) + * \relates + * Returns a reference in the current scope named "d" to the private class. + * + * This function is only available in a class using \a QXT_DECLARE_PRIVATE. + */ + +/*! + * \macro QXT_P(PUB) + * \relates + * Creates a reference in the current scope named "q" to the public class. + * + * This macro only works in a class using \a QXT_DECLARE_PUBLIC. + */ + +/*! + * \fn QxtPrivate& PUB::qxt_d() + * \relates + * Returns a reference to the private class. + * + * This function is only available in a class using \a QXT_DECLARE_PRIVATE. + */ + +/*! + * \fn const QxtPrivate& PUB::qxt_d() const + * \relates + * Returns a const reference to the private class. + * + * This function is only available in a class using \a QXT_DECLARE_PRIVATE. + * This overload will be automatically used in const functions. + */ + +/*! + * \fn PUB& QxtPrivate::qxt_p() + * \relates + * Returns a reference to the public class. + * + * This function is only available in a class using \a QXT_DECLARE_PUBLIC. + */ + +/*! + * \fn const PUB& QxtPrivate::qxt_p() const + * \relates + * Returns a const reference to the public class. + * + * This function is only available in a class using \a QXT_DECLARE_PUBLIC. + * This overload will be automatically used in const functions. + */ diff -Nru syncwall-1.6.0/src/3rdparty/qxt/qxtglobal.h syncwall-1.7.4/src/3rdparty/qxt/qxtglobal.h --- syncwall-1.6.0/src/3rdparty/qxt/qxtglobal.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qxt/qxtglobal.h 2011-11-24 15:10:32.000000000 +0000 @@ -0,0 +1,207 @@ +/**************************************************************************** + ** + ** Copyright (C) Qxt Foundation. Some rights reserved. + ** + ** This file is part of the QxtCore module of the Qxt library. + ** + ** This library is free software; you can redistribute it and/or modify it + ** under the terms of the Common Public License, version 1.0, as published + ** by IBM, and/or under the terms of the GNU Lesser General Public License, + ** version 2.1, as published by the Free Software Foundation. + ** + ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY + ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY + ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR + ** FITNESS FOR A PARTICULAR PURPOSE. + ** + ** You should have received a copy of the CPL and the LGPL along with this + ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files + ** included with the source distribution for more information. + ** If you did not receive a copy of the licenses, contact the Qxt Foundation. + ** + ** + ** + ****************************************************************************/ + +#ifndef QXTGLOBAL_H +#define QXTGLOBAL_H + +#include + +#define QXT_VERSION 0x000602 +#define QXT_VERSION_STR "0.6.2" + +//--------------------------global macros------------------------------ + +#ifndef QXT_NO_MACROS + +#endif // QXT_NO_MACROS + +//--------------------------export macros------------------------------ + +#define QXT_DLLEXPORT DO_NOT_USE_THIS_ANYMORE + +#if !defined(QXT_STATIC) +# if defined(BUILD_QXT_CORE) +# define QXT_CORE_EXPORT Q_DECL_EXPORT +# else +# define QXT_CORE_EXPORT Q_DECL_IMPORT +# endif +#else +# define QXT_CORE_EXPORT +#endif // BUILD_QXT_CORE + +#if !defined(QXT_STATIC) +# if defined(BUILD_QXT_GUI) +# define QXT_GUI_EXPORT Q_DECL_EXPORT +# else +# define QXT_GUI_EXPORT Q_DECL_IMPORT +# endif +#else +# define QXT_GUI_EXPORT +#endif // BUILD_QXT_GUI + +#if !defined(QXT_STATIC) +# if defined(BUILD_QXT_NETWORK) +# define QXT_NETWORK_EXPORT Q_DECL_EXPORT +# else +# define QXT_NETWORK_EXPORT Q_DECL_IMPORT +# endif +#else +# define QXT_NETWORK_EXPORT +#endif // BUILD_QXT_NETWORK + +#if !defined(QXT_STATIC) +# if defined(BUILD_QXT_SQL) +# define QXT_SQL_EXPORT Q_DECL_EXPORT +# else +# define QXT_SQL_EXPORT Q_DECL_IMPORT +# endif +#else +# define QXT_SQL_EXPORT +#endif // BUILD_QXT_SQL + +#if !defined(QXT_STATIC) +# if defined(BUILD_QXT_WEB) +# define QXT_WEB_EXPORT Q_DECL_EXPORT +# else +# define QXT_WEB_EXPORT Q_DECL_IMPORT +# endif +#else +# define QXT_WEB_EXPORT +#endif // BUILD_QXT_WEB + +#if !defined(QXT_STATIC) +# if defined(BUILD_QXT_BERKELEY) +# define QXT_BERKELEY_EXPORT Q_DECL_EXPORT +# else +# define QXT_BERKELEY_EXPORT Q_DECL_IMPORT +# endif +#else +# define QXT_BERKELEY_EXPORT +#endif // BUILD_QXT_BERKELEY + +#if !defined(QXT_STATIC) +# if defined(BUILD_QXT_ZEROCONF) +# define QXT_ZEROCONF_EXPORT Q_DECL_EXPORT +# else +# define QXT_ZEROCONF_EXPORT Q_DECL_IMPORT +# endif +#else +# define QXT_ZEROCONF_EXPORT +#endif // QXT_ZEROCONF_EXPORT + +#if defined BUILD_QXT_CORE || defined BUILD_QXT_GUI || defined BUILD_QXT_SQL || defined BUILD_QXT_NETWORK || defined BUILD_QXT_WEB || defined BUILD_QXT_BERKELEY || defined BUILD_QXT_ZEROCONF +# define BUILD_QXT +#endif + +QXT_CORE_EXPORT const char* qxtVersion(); + +#ifndef QT_BEGIN_NAMESPACE +#define QT_BEGIN_NAMESPACE +#endif + +#ifndef QT_END_NAMESPACE +#define QT_END_NAMESPACE +#endif + +#ifndef QT_FORWARD_DECLARE_CLASS +#define QT_FORWARD_DECLARE_CLASS(Class) class Class; +#endif + +/**************************************************************************** +** This file is derived from code bearing the following notice: +** The sole author of this file, Adam Higerd, has explicitly disclaimed all +** copyright interest and protection for the content within. This file has +** been placed in the public domain according to United States copyright +** statute and case law. In jurisdictions where this public domain dedication +** is not legally recognized, anyone who receives a copy of this file is +** permitted to use, modify, duplicate, and redistribute this file, in whole +** or in part, with no restrictions or conditions. In these jurisdictions, +** this file shall be copyright (C) 2006-2008 by Adam Higerd. +****************************************************************************/ + +#define QXT_DECLARE_PRIVATE(PUB) friend class PUB##Private; QxtPrivateInterface qxt_d; +#define QXT_DECLARE_PUBLIC(PUB) friend class PUB; +#define QXT_INIT_PRIVATE(PUB) qxt_d.setPublic(this); +#define QXT_D(PUB) PUB##Private& d = qxt_d() +#define QXT_P(PUB) PUB& p = qxt_p() + +template +class QxtPrivate +{ +public: + virtual ~QxtPrivate() + {} + inline void QXT_setPublic(PUB* pub) + { + qxt_p_ptr = pub; + } + +protected: + inline PUB& qxt_p() + { + return *qxt_p_ptr; + } + inline const PUB& qxt_p() const + { + return *qxt_p_ptr; + } + +private: + PUB* qxt_p_ptr; +}; + +template +class QxtPrivateInterface +{ + friend class QxtPrivate; +public: + QxtPrivateInterface() + { + pvt = new PVT; + } + ~QxtPrivateInterface() + { + delete pvt; + } + + inline void setPublic(PUB* pub) + { + pvt->QXT_setPublic(pub); + } + inline PVT& operator()() + { + return *static_cast(pvt); + } + inline const PVT& operator()() const + { + return *static_cast(pvt); + } +private: + QxtPrivateInterface(const QxtPrivateInterface&) { } + QxtPrivateInterface& operator=(const QxtPrivateInterface&) { } + QxtPrivate* pvt; +}; + +#endif // QXT_GLOBAL diff -Nru syncwall-1.6.0/src/3rdparty/qxt/qxtglobalshortcut.cpp syncwall-1.7.4/src/3rdparty/qxt/qxtglobalshortcut.cpp --- syncwall-1.6.0/src/3rdparty/qxt/qxtglobalshortcut.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qxt/qxtglobalshortcut.cpp 2011-11-24 15:10:32.000000000 +0000 @@ -0,0 +1,201 @@ +/**************************************************************************** + ** + ** Copyright (C) Qxt Foundation. Some rights reserved. + ** + ** This file is part of the QxtGui module of the Qxt library. + ** + ** This library is free software; you can redistribute it and/or modify it + ** under the terms of the Common Public License, version 1.0, as published + ** by IBM, and/or under the terms of the GNU Lesser General Public License, + ** version 2.1, as published by the Free Software Foundation. + ** + ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY + ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY + ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR + ** FITNESS FOR A PARTICULAR PURPOSE. + ** + ** You should have received a copy of the CPL and the LGPL along with this + ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files + ** included with the source distribution for more information. + ** If you did not receive a copy of the licenses, contact the Qxt Foundation. + ** + ** + ** + ****************************************************************************/ +#include "qxtglobalshortcut.h" +#include "qxtglobalshortcut_p.h" +#include +#include + +bool QxtGlobalShortcutPrivate::error = false; +#ifndef Q_WS_MAC +int QxtGlobalShortcutPrivate::ref = 0; +QAbstractEventDispatcher::EventFilter QxtGlobalShortcutPrivate::prevEventFilter = 0; +#endif // Q_WS_MAC +QHash, QxtGlobalShortcut*> QxtGlobalShortcutPrivate::shortcuts; + +QxtGlobalShortcutPrivate::QxtGlobalShortcutPrivate() : enabled(true), key(Qt::Key(0)), mods(Qt::NoModifier) +{ +#ifndef Q_WS_MAC + if (!ref++) + prevEventFilter = QAbstractEventDispatcher::instance()->setEventFilter(eventFilter); +#endif // Q_WS_MAC +} + +QxtGlobalShortcutPrivate::~QxtGlobalShortcutPrivate() +{ +#ifndef Q_WS_MAC + if (!--ref) + QAbstractEventDispatcher::instance()->setEventFilter(prevEventFilter); +#endif // Q_WS_MAC +} + +bool QxtGlobalShortcutPrivate::setShortcut(const QKeySequence& shortcut) +{ + Qt::KeyboardModifiers allMods = Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier; + key = shortcut.isEmpty() ? Qt::Key(0) : Qt::Key((shortcut[0] ^ allMods) & shortcut[0]); + mods = shortcut.isEmpty() ? Qt::KeyboardModifiers(0) : Qt::KeyboardModifiers(shortcut[0] & allMods); + const quint32 nativeKey = nativeKeycode(key); + const quint32 nativeMods = nativeModifiers(mods); + const bool res = registerShortcut(nativeKey, nativeMods); + if (res) + shortcuts.insert(qMakePair(nativeKey, nativeMods), &qxt_p()); + else + qWarning() << "QxtGlobalShortcut failed to register:" << QKeySequence(key + mods).toString(); + return res; +} + +bool QxtGlobalShortcutPrivate::unsetShortcut() +{ + bool res = false; + const quint32 nativeKey = nativeKeycode(key); + const quint32 nativeMods = nativeModifiers(mods); + if (shortcuts.value(qMakePair(nativeKey, nativeMods)) == &qxt_p()) + res = unregisterShortcut(nativeKey, nativeMods); + if (res) + shortcuts.remove(qMakePair(nativeKey, nativeMods)); + else + qWarning() << "QxtGlobalShortcut failed to unregister:" << QKeySequence(key + mods).toString(); + key = Qt::Key(0); + mods = Qt::KeyboardModifiers(0); + return res; +} + +void QxtGlobalShortcutPrivate::activateShortcut(quint32 nativeKey, quint32 nativeMods) +{ + QxtGlobalShortcut* shortcut = shortcuts.value(qMakePair(nativeKey, nativeMods)); + if (shortcut && shortcut->isEnabled()) + emit shortcut->activated(); +} + +/*! + \class QxtGlobalShortcut + \inmodule QxtGui + \brief The QxtGlobalShortcut class provides a global shortcut aka "hotkey". + + A global shortcut triggers even if the application is not active. This + makes it easy to implement applications that react to certain shortcuts + still if some other application is active or if the application is for + example minimized to the system tray. + + Example usage: + \code + QxtGlobalShortcut* shortcut = new QxtGlobalShortcut(window); + connect(shortcut, SIGNAL(activated()), window, SLOT(toggleVisibility())); + shortcut->setShortcut(QKeySequence("Ctrl+Shift+F12")); + \endcode + + \bold {Note:} Since Qxt 0.6 QxtGlobalShortcut no more requires QxtApplication. + */ + +/*! + \fn QxtGlobalShortcut::activated() + + This signal is emitted when the user types the shortcut's key sequence. + + \sa shortcut + */ + +/*! + Constructs a new QxtGlobalShortcut with \a parent. + */ +QxtGlobalShortcut::QxtGlobalShortcut(QObject* parent) + : QObject(parent) +{ + QXT_INIT_PRIVATE(QxtGlobalShortcut); +} + +/*! + Constructs a new QxtGlobalShortcut with \a shortcut and \a parent. + */ +QxtGlobalShortcut::QxtGlobalShortcut(const QKeySequence& shortcut, QObject* parent) + : QObject(parent) +{ + QXT_INIT_PRIVATE(QxtGlobalShortcut); + setShortcut(shortcut); +} + +/*! + Destructs the QxtGlobalShortcut. + */ +QxtGlobalShortcut::~QxtGlobalShortcut() +{ + if (qxt_d().key != 0) + qxt_d().unsetShortcut(); +} + +/*! + \property QxtGlobalShortcut::shortcut + \brief the shortcut key sequence + + \bold {Note:} Notice that corresponding key press and release events are not + delivered for registered global shortcuts even if they are disabled. + Also, comma separated key sequences are not supported. + Only the first part is used: + + \code + qxtShortcut->setShortcut(QKeySequence("Ctrl+Alt+A,Ctrl+Alt+B")); + Q_ASSERT(qxtShortcut->shortcut() == QKeySequence("Ctrl+Alt+A")); + \endcode + */ +QKeySequence QxtGlobalShortcut::shortcut() const +{ + return QKeySequence(qxt_d().key | qxt_d().mods); +} + +bool QxtGlobalShortcut::setShortcut(const QKeySequence& shortcut) +{ + if (qxt_d().key != 0) + qxt_d().unsetShortcut(); + return qxt_d().setShortcut(shortcut); +} + +/*! + \property QxtGlobalShortcut::enabled + \brief whether the shortcut is enabled + + A disabled shortcut does not get activated. + + The default value is \c true. + + \sa setDisabled() + */ +bool QxtGlobalShortcut::isEnabled() const +{ + return qxt_d().enabled; +} + +void QxtGlobalShortcut::setEnabled(bool enabled) +{ + qxt_d().enabled = enabled; +} + +/*! + Sets the shortcut \a disabled. + + \sa enabled + */ +void QxtGlobalShortcut::setDisabled(bool disabled) +{ + qxt_d().enabled = !disabled; +} diff -Nru syncwall-1.6.0/src/3rdparty/qxt/qxtglobalshortcut.h syncwall-1.7.4/src/3rdparty/qxt/qxtglobalshortcut.h --- syncwall-1.6.0/src/3rdparty/qxt/qxtglobalshortcut.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qxt/qxtglobalshortcut.h 2011-11-24 15:10:32.000000000 +0000 @@ -0,0 +1,58 @@ +/**************************************************************************** + ** + ** Copyright (C) Qxt Foundation. Some rights reserved. + ** + ** This file is part of the QxtGui module of the Qxt library. + ** + ** This library is free software; you can redistribute it and/or modify it + ** under the terms of the Common Public License, version 1.0, as published + ** by IBM, and/or under the terms of the GNU Lesser General Public License, + ** version 2.1, as published by the Free Software Foundation. + ** + ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY + ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY + ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR + ** FITNESS FOR A PARTICULAR PURPOSE. + ** + ** You should have received a copy of the CPL and the LGPL along with this + ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files + ** included with the source distribution for more information. + ** If you did not receive a copy of the licenses, contact the Qxt Foundation. + ** + ** + ** + ****************************************************************************/ +#ifndef QXTGLOBALSHORTCUT_H +#define QXTGLOBALSHORTCUT_H + +#include "qxtglobal.h" +#include +#include +class QxtGlobalShortcutPrivate; + +class QXT_GUI_EXPORT QxtGlobalShortcut : public QObject +{ + Q_OBJECT + QXT_DECLARE_PRIVATE(QxtGlobalShortcut) + Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled) + Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut) + +public: + explicit QxtGlobalShortcut(QObject* parent = 0); + explicit QxtGlobalShortcut(const QKeySequence& shortcut, QObject* parent = 0); + virtual ~QxtGlobalShortcut(); + + QKeySequence shortcut() const; + bool setShortcut(const QKeySequence& shortcut); + + bool isEnabled() const; + +public Q_SLOTS: + void setEnabled(bool enabled = true); + void setDisabled(bool disabled = true); + +Q_SIGNALS: + void activated(); +}; + +#endif // QXTGLOBALSHORTCUT_H diff -Nru syncwall-1.6.0/src/3rdparty/qxt/qxtglobalshortcut_mac.cpp syncwall-1.7.4/src/3rdparty/qxt/qxtglobalshortcut_mac.cpp --- syncwall-1.6.0/src/3rdparty/qxt/qxtglobalshortcut_mac.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qxt/qxtglobalshortcut_mac.cpp 2011-11-24 15:10:32.000000000 +0000 @@ -0,0 +1,198 @@ +/**************************************************************************** + ** + ** Copyright (C) Qxt Foundation. Some rights reserved. + ** + ** This file is part of the QxtGui module of the Qxt library. + ** + ** This library is free software; you can redistribute it and/or modify it + ** under the terms of the Common Public License, version 1.0, as published + ** by IBM, and/or under the terms of the GNU Lesser General Public License, + ** version 2.1, as published by the Free Software Foundation. + ** + ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY + ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY + ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR + ** FITNESS FOR A PARTICULAR PURPOSE. + ** + ** You should have received a copy of the CPL and the LGPL along with this + ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files + ** included with the source distribution for more information. + ** If you did not receive a copy of the licenses, contact the Qxt Foundation. + ** + ** + ** + ****************************************************************************/ +#include +#include "qxtglobalshortcut_p.h" +#include +#include +#include +#include + +typedef QPair Identifier; +static QMap keyRefs; +static QHash keyIDs; +static quint32 hotKeySerial = 0; +static bool qxt_mac_handler_installed = false; + +OSStatus qxt_mac_handle_hot_key(EventHandlerCallRef nextHandler, EventRef event, void* data) +{ + Q_UNUSED(nextHandler); + Q_UNUSED(data); + if (GetEventClass(event) == kEventClassKeyboard && GetEventKind(event) == kEventHotKeyPressed) + { + EventHotKeyID keyID; + GetEventParameter(event, kEventParamDirectObject, typeEventHotKeyID, NULL, sizeof(keyID), NULL, &keyID); + Identifier id = keyIDs.key(keyID.id); + QxtGlobalShortcutPrivate::activateShortcut(id.second, id.first); + } + return noErr; +} + +quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers) +{ + quint32 native = 0; + if (modifiers & Qt::ShiftModifier) + native |= shiftKey; + if (modifiers & Qt::ControlModifier) + native |= cmdKey; + if (modifiers & Qt::AltModifier) + native |= optionKey; + if (modifiers & Qt::MetaModifier) + native |= controlKey; + if (modifiers & Qt::KeypadModifier) + native |= kEventKeyModifierNumLockMask; + return native; +} + +quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key) +{ + UTF16Char ch; + // Constants found in NSEvent.h from AppKit.framework + if (key == Qt::Key_Up) ch = 0xF700; + else if (key == Qt::Key_Down) ch = 0xF701; + else if (key == Qt::Key_Left) ch = 0xF702; + else if (key == Qt::Key_Right) ch = 0xF703; + else if (key >= Qt::Key_F1 && key <= Qt::Key_F35) + ch = key - Qt::Key_F1 + 0xF704; + else if (key == Qt::Key_Insert) ch = 0xF727; + else if (key == Qt::Key_Delete) ch = 0xF728; + else if (key == Qt::Key_Home) ch = 0xF729; + else if (key == Qt::Key_End) ch = 0xF72B; + else if (key == Qt::Key_PageUp) ch = 0xF72C; + else if (key == Qt::Key_PageDown) ch = 0xF72D; + else if (key == Qt::Key_Print) ch = 0xF72E; + else if (key == Qt::Key_ScrollLock) ch = 0xF72F; + else if (key == Qt::Key_Pause) ch = 0xF730; + else if (key == Qt::Key_SysReq) ch = 0xF731; + else if (key == Qt::Key_Stop) ch = 0xF734; + else if (key == Qt::Key_Menu) ch = 0xF735; + else if (key == Qt::Key_Select) ch = 0xF741; + else if (key == Qt::Key_Execute) ch = 0xF742; + else if (key == Qt::Key_Help) ch = 0xF746; + else if (key == Qt::Key_Mode_switch) ch = 0xF747; + else if (key == Qt::Key_Escape) ch = 27; + else if (key == Qt::Key_Return) ch = 13; + else if (key == Qt::Key_Enter) ch = 3; + else if (key == Qt::Key_Tab) ch = 9; + else ch = key; + + KeyboardLayoutRef layout; + KeyboardLayoutKind layoutKind; + KLGetCurrentKeyboardLayout(&layout); + KLGetKeyboardLayoutProperty(layout, kKLKind, const_cast(reinterpret_cast(&layoutKind))); + + if (layoutKind == kKLKCHRKind) + { // no Unicode available + if (ch > 255) return 0; + + char* data; + KLGetKeyboardLayoutProperty(layout, kKLKCHRData, const_cast(reinterpret_cast(&data))); + int ct = *reinterpret_cast(data + 258); + for (int i = 0; i < ct; i++) + { + char* keyTable = data + 260 + 128 * i; + for (int j = 0; j < 128; j++) + { + if (keyTable[j] == ch) return j; + } + } + + return 0; + } + + char* data; + KLGetKeyboardLayoutProperty(layout, kKLuchrData, const_cast(reinterpret_cast(&data))); + UCKeyboardLayout* header = reinterpret_cast(data); + UCKeyboardTypeHeader* table = header->keyboardTypeList; + + for (quint32 i=0; i < header->keyboardTypeCount; i++) + { + UCKeyStateRecordsIndex* stateRec = 0; + if (table[i].keyStateRecordsIndexOffset != 0) + { + stateRec = reinterpret_cast(data + table[i].keyStateRecordsIndexOffset); + if (stateRec->keyStateRecordsIndexFormat != kUCKeyStateRecordsIndexFormat) stateRec = 0; + } + + UCKeyToCharTableIndex* charTable = reinterpret_cast(data + table[i].keyToCharTableIndexOffset); + if (charTable->keyToCharTableIndexFormat != kUCKeyToCharTableIndexFormat) continue; + + for (quint32 j=0; j < charTable->keyToCharTableCount; j++) + { + UCKeyOutput* keyToChar = reinterpret_cast(data + charTable->keyToCharTableOffsets[j]); + for (quint32 k=0; k < charTable->keyToCharTableSize; k++) + { + if (keyToChar[k] & kUCKeyOutputTestForIndexMask) + { + long idx = keyToChar[k] & kUCKeyOutputGetIndexMask; + if (stateRec && idx < stateRec->keyStateRecordCount) + { + UCKeyStateRecord* rec = reinterpret_cast(data + stateRec->keyStateRecordOffsets[idx]); + if (rec->stateZeroCharData == ch) return k; + } + } + else if (!(keyToChar[k] & kUCKeyOutputSequenceIndexMask) && keyToChar[k] < 0xFFFE) + { + if (keyToChar[k] == ch) return k; + } + } // for k + } // for j + } // for i + + return 0; +} + +bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativeMods) +{ + if (!qxt_mac_handler_installed) + { + EventTypeSpec t; + t.eventClass = kEventClassKeyboard; + t.eventKind = kEventHotKeyPressed; + InstallApplicationEventHandler(&qxt_mac_handle_hot_key, 1, &t, NULL, NULL); + } + + EventHotKeyID keyID; + keyID.signature = 'cute'; + keyID.id = ++hotKeySerial; + + EventHotKeyRef ref = 0; + bool rv = !RegisterEventHotKey(nativeKey, nativeMods, keyID, GetApplicationEventTarget(), 0, &ref); + if (rv) + { + keyIDs.insert(Identifier(nativeMods, nativeKey), keyID.id); + keyRefs.insert(keyID.id, ref); + } + return rv; +} + +bool QxtGlobalShortcutPrivate::unregisterShortcut(quint32 nativeKey, quint32 nativeMods) +{ + Identifier id(nativeMods, nativeKey); + if (!keyIDs.contains(id)) return false; + + EventHotKeyRef ref = keyRefs.take(keyIDs[id]); + keyIDs.remove(id); + return !UnregisterEventHotKey(ref); +} diff -Nru syncwall-1.6.0/src/3rdparty/qxt/qxtglobalshortcut_p.h syncwall-1.7.4/src/3rdparty/qxt/qxtglobalshortcut_p.h --- syncwall-1.6.0/src/3rdparty/qxt/qxtglobalshortcut_p.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qxt/qxtglobalshortcut_p.h 2011-11-24 15:10:32.000000000 +0000 @@ -0,0 +1,66 @@ +/**************************************************************************** + ** + ** Copyright (C) Qxt Foundation. Some rights reserved. + ** + ** This file is part of the QxtGui module of the Qxt library. + ** + ** This library is free software; you can redistribute it and/or modify it + ** under the terms of the Common Public License, version 1.0, as published + ** by IBM, and/or under the terms of the GNU Lesser General Public License, + ** version 2.1, as published by the Free Software Foundation. + ** + ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY + ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY + ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR + ** FITNESS FOR A PARTICULAR PURPOSE. + ** + ** You should have received a copy of the CPL and the LGPL along with this + ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files + ** included with the source distribution for more information. + ** If you did not receive a copy of the licenses, contact the Qxt Foundation. + ** + ** + ** + ****************************************************************************/ +#ifndef QXTGLOBALSHORTCUT_P_H +#define QXTGLOBALSHORTCUT_P_H + +#include "qxtglobalshortcut.h" +#include +#include +#include + +class QxtGlobalShortcutPrivate : public QxtPrivate +{ +public: + QXT_DECLARE_PUBLIC(QxtGlobalShortcut) + QxtGlobalShortcutPrivate(); + ~QxtGlobalShortcutPrivate(); + + bool enabled; + Qt::Key key; + Qt::KeyboardModifiers mods; + + bool setShortcut(const QKeySequence& shortcut); + bool unsetShortcut(); + + static bool error; +#ifndef Q_WS_MAC + static int ref; + static QAbstractEventDispatcher::EventFilter prevEventFilter; + static bool eventFilter(void* message); +#endif // Q_WS_MAC + + static void activateShortcut(quint32 nativeKey, quint32 nativeMods); + +private: + static quint32 nativeKeycode(Qt::Key keycode); + static quint32 nativeModifiers(Qt::KeyboardModifiers modifiers); + + static bool registerShortcut(quint32 nativeKey, quint32 nativeMods); + static bool unregisterShortcut(quint32 nativeKey, quint32 nativeMods); + + static QHash, QxtGlobalShortcut*> shortcuts; +}; + +#endif // QXTGLOBALSHORTCUT_P_H diff -Nru syncwall-1.6.0/src/3rdparty/qxt/qxtglobalshortcut_win.cpp syncwall-1.7.4/src/3rdparty/qxt/qxtglobalshortcut_win.cpp --- syncwall-1.6.0/src/3rdparty/qxt/qxtglobalshortcut_win.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qxt/qxtglobalshortcut_win.cpp 2011-12-05 08:10:54.000000000 +0000 @@ -0,0 +1,292 @@ +/**************************************************************************** + ** + ** Copyright (C) Qxt Foundation. Some rights reserved. + ** + ** This file is part of the QxtGui module of the Qxt library. + ** + ** This library is free software; you can redistribute it and/or modify it + ** under the terms of the Common Public License, version 1.0, as published + ** by IBM, and/or under the terms of the GNU Lesser General Public License, + ** version 2.1, as published by the Free Software Foundation. + ** + ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY + ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY + ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR + ** FITNESS FOR A PARTICULAR PURPOSE. + ** + ** You should have received a copy of the CPL and the LGPL along with this + ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files + ** included with the source distribution for more information. + ** If you did not receive a copy of the licenses, contact the Qxt Foundation. + ** + ** + ** + ****************************************************************************/ +#include "qxtglobalshortcut_p.h" +#include + +// Key code values not found in winuser.h +#ifndef VK_MINUS +#define VK_MINUS 0xBD +#endif // VK_MINUS +#ifndef VK_SEMICOLON +#define VK_SEMICOLON 0xBA +#endif // VK_SEMICOLON +#ifndef VK_PERIOD +#define VK_PERIOD 0xBE +#endif // VK_PERIOD +#ifndef VK_COMMA +#define VK_COMMA 0xBC +#endif // VK_COMMA +#ifndef VK_QUOTE +#define VK_QUOTE 0xDE +#endif // VK_QUOTE +#ifndef VK_BACK_QUOTE +#define VK_BACK_QUOTE 0xC0 +#endif // VK_BACK_QUOTE +#ifndef VK_SLASH +#define VK_SLASH 0xBF +#endif // VK_SLASH +#ifndef VK_BACK_SLASH +#define VK_BACK_SLASH 0xDC +#endif // VK_BACK_SLASH +#ifndef VK_EQUALS +#define VK_EQUALS 0xBB +#endif // VK_EQUALS +#ifndef VK_OPEN_BRACKET +#define VK_OPEN_BRACKET 0xDB +#endif // VK_OPEN_BRACKET +#ifndef VK_CLOSE_BRACKET +#define VK_CLOSE_BRACKET 0xDD +#endif // VK_CLOSE_BRACKET +#ifndef VK_GR_LESS +#define VK_GR_LESS 0xE2 +#endif // VK_GR_LESS + +#ifndef VK_MEDIA_NEXT_TRACK +#define VK_MEDIA_NEXT_TRACK 0xB0 +#endif // VK_MEDIA_NEXT_TRACK +#ifndef VK_MEDIA_PREV_TRACK +#define VK_MEDIA_PREV_TRACK 0xB1 +#endif // VK_MEDIA_PREV_TRACK +#ifndef VK_MEDIA_STOP +#define VK_MEDIA_STOP 0xB2 +#endif // VK_MEDIA_STOP +#ifndef VK_MEDIA_PLAY_PAUSE +#define VK_MEDIA_PLAY_PAUSE 0xB3 +#endif // VK_MEDIA_PLAY_PAUSE + +#ifndef VK_VOLUME_MUTE +#define VK_VOLUME_MUTE 0xAD +#endif // VK_VOLUME_MUTE +#ifndef VK_VOLUME_DOWN +#define VK_VOLUME_DOWN 0xAE +#endif // VK_VOLUME_DOWN +#ifndef VK_VOLUME_UP +#define VK_VOLUME_UP 0xAF +#endif // VK_VOLUME_UP + +bool QxtGlobalShortcutPrivate::eventFilter(void* message) +{ + MSG* msg = static_cast(message); + if (msg->message == WM_HOTKEY) + { + const quint32 keycode = HIWORD(msg->lParam); + const quint32 modifiers = LOWORD(msg->lParam); + activateShortcut(keycode, modifiers); + } + return false; +} + +quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers) +{ + // MOD_ALT, MOD_CONTROL, (MOD_KEYUP), MOD_SHIFT, MOD_WIN + quint32 native = 0; + if (modifiers & Qt::ShiftModifier) + native |= MOD_SHIFT; + if (modifiers & Qt::ControlModifier) + native |= MOD_CONTROL; + if (modifiers & Qt::AltModifier) + native |= MOD_ALT; + if (modifiers & Qt::MetaModifier) + native |= MOD_WIN; + // TODO: resolve these? + //if (modifiers & Qt::KeypadModifier) + //if (modifiers & Qt::GroupSwitchModifier) + return native; +} + +quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key) +{ + switch (key) + { + case Qt::Key_Escape: + return VK_ESCAPE; + case Qt::Key_Tab: + case Qt::Key_Backtab: + return VK_TAB; + case Qt::Key_Backspace: + return VK_BACK; + case Qt::Key_Return: + case Qt::Key_Enter: + return VK_RETURN; + case Qt::Key_Insert: + return VK_INSERT; + case Qt::Key_Delete: + return VK_DELETE; + case Qt::Key_Pause: + return VK_PAUSE; + case Qt::Key_Print: + return VK_PRINT; + case Qt::Key_Clear: + return VK_CLEAR; + case Qt::Key_Home: + return VK_HOME; + case Qt::Key_End: + return VK_END; + case Qt::Key_Left: + return VK_LEFT; + case Qt::Key_Up: + return VK_UP; + case Qt::Key_Right: + return VK_RIGHT; + case Qt::Key_Down: + return VK_DOWN; + case Qt::Key_PageUp: + return VK_PRIOR; + case Qt::Key_PageDown: + return VK_NEXT; + case Qt::Key_F1: + return VK_F1; + case Qt::Key_F2: + return VK_F2; + case Qt::Key_F3: + return VK_F3; + case Qt::Key_F4: + return VK_F4; + case Qt::Key_F5: + return VK_F5; + case Qt::Key_F6: + return VK_F6; + case Qt::Key_F7: + return VK_F7; + case Qt::Key_F8: + return VK_F8; + case Qt::Key_F9: + return VK_F9; + case Qt::Key_F10: + return VK_F10; + case Qt::Key_F11: + return VK_F11; + case Qt::Key_F12: + return VK_F12; + case Qt::Key_F13: + return VK_F13; + case Qt::Key_F14: + return VK_F14; + case Qt::Key_F15: + return VK_F15; + case Qt::Key_F16: + return VK_F16; + case Qt::Key_F17: + return VK_F17; + case Qt::Key_F18: + return VK_F18; + case Qt::Key_F19: + return VK_F19; + case Qt::Key_F20: + return VK_F20; + case Qt::Key_F21: + return VK_F21; + case Qt::Key_F22: + return VK_F22; + case Qt::Key_F23: + return VK_F23; + case Qt::Key_F24: + return VK_F24; + case Qt::Key_Space: + return VK_SPACE; + case Qt::Key_Asterisk: + return VK_MULTIPLY; + case Qt::Key_Plus: + return VK_ADD; + case Qt::Key_Comma: + return VK_SEPARATOR; + case Qt::Key_Minus: + return VK_SUBTRACT; + case Qt::Key_Slash: + return VK_DIVIDE; + case Qt::Key_MediaNext: + return VK_MEDIA_NEXT_TRACK; + case Qt::Key_MediaPrevious: + return VK_MEDIA_PREV_TRACK; + case Qt::Key_MediaPlay: + return VK_MEDIA_PLAY_PAUSE; + case Qt::Key_MediaStop: + return VK_MEDIA_STOP; + // couldn't find those in VK_* + //case Qt::Key_MediaLast: + //case Qt::Key_MediaRecord: + case Qt::Key_VolumeDown: + return VK_VOLUME_DOWN; + case Qt::Key_VolumeUp: + return VK_VOLUME_UP; + case Qt::Key_VolumeMute: + return VK_VOLUME_MUTE; + + // numbers + case Qt::Key_0: + case Qt::Key_1: + case Qt::Key_2: + case Qt::Key_3: + case Qt::Key_4: + case Qt::Key_5: + case Qt::Key_6: + case Qt::Key_7: + case Qt::Key_8: + case Qt::Key_9: + return key; + + // letters + case Qt::Key_A: + case Qt::Key_B: + case Qt::Key_C: + case Qt::Key_D: + case Qt::Key_E: + case Qt::Key_F: + case Qt::Key_G: + case Qt::Key_H: + case Qt::Key_I: + case Qt::Key_J: + case Qt::Key_K: + case Qt::Key_L: + case Qt::Key_M: + case Qt::Key_N: + case Qt::Key_O: + case Qt::Key_P: + case Qt::Key_Q: + case Qt::Key_R: + case Qt::Key_S: + case Qt::Key_T: + case Qt::Key_U: + case Qt::Key_V: + case Qt::Key_W: + case Qt::Key_X: + case Qt::Key_Y: + case Qt::Key_Z: + return key; + + default: + return 0; + } +} + +bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativeMods) +{ + return RegisterHotKey(0, nativeMods ^ nativeKey, nativeMods, nativeKey); +} + +bool QxtGlobalShortcutPrivate::unregisterShortcut(quint32 nativeKey, quint32 nativeMods) +{ + return UnregisterHotKey(0, nativeMods ^ nativeKey); +} diff -Nru syncwall-1.6.0/src/3rdparty/qxt/qxtglobalshortcut_x11.cpp syncwall-1.7.4/src/3rdparty/qxt/qxtglobalshortcut_x11.cpp --- syncwall-1.6.0/src/3rdparty/qxt/qxtglobalshortcut_x11.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/3rdparty/qxt/qxtglobalshortcut_x11.cpp 2011-11-24 15:10:32.000000000 +0000 @@ -0,0 +1,118 @@ +/**************************************************************************** + ** + ** Copyright (C) Qxt Foundation. Some rights reserved. + ** + ** This file is part of the QxtGui module of the Qxt library. + ** + ** This library is free software; you can redistribute it and/or modify it + ** under the terms of the Common Public License, version 1.0, as published + ** by IBM, and/or under the terms of the GNU Lesser General Public License, + ** version 2.1, as published by the Free Software Foundation. + ** + ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY + ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY + ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR + ** FITNESS FOR A PARTICULAR PURPOSE. + ** + ** You should have received a copy of the CPL and the LGPL along with this + ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files + ** included with the source distribution for more information. + ** If you did not receive a copy of the licenses, contact the Qxt Foundation. + ** + ** + ** + ****************************************************************************/ +#include "qxtglobalshortcut_p.h" +#include +#include + +static int (*original_x_errhandler)(Display* display, XErrorEvent* event); + +static int qxt_x_errhandler(Display* display, XErrorEvent *event) +{ + Q_UNUSED(display); + switch (event->error_code) + { + case BadAccess: + case BadValue: + case BadWindow: + if (event->request_code == 33 /* X_GrabKey */ || + event->request_code == 34 /* X_UngrabKey */) + { + QxtGlobalShortcutPrivate::error = true; + //TODO: + //char errstr[256]; + //XGetErrorText(dpy, err->error_code, errstr, 256); + } + default: + return 0; + } +} + +bool QxtGlobalShortcutPrivate::eventFilter(void* message) +{ + XEvent* event = static_cast(message); + if (event->type == KeyPress) + { + XKeyEvent* key = (XKeyEvent*) event; + activateShortcut(key->keycode, + // Mod1Mask == Alt, Mod4Mask == Meta + key->state & (ShiftMask | ControlMask | Mod1Mask | Mod4Mask)); + } + return false; +} + +quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers) +{ + // ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask, and Mod5Mask + quint32 native = 0; + if (modifiers & Qt::ShiftModifier) + native |= ShiftMask; + if (modifiers & Qt::ControlModifier) + native |= ControlMask; + if (modifiers & Qt::AltModifier) + native |= Mod1Mask; + if (modifiers & Qt::MetaModifier) + native |= Mod4Mask; + + // TODO: resolve these? + //if (modifiers & Qt::MetaModifier) + //if (modifiers & Qt::KeypadModifier) + //if (modifiers & Qt::GroupSwitchModifier) + return native; +} + +quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key) +{ + Display* display = QX11Info::display(); + return XKeysymToKeycode(display, XStringToKeysym(QKeySequence(key).toString().toLatin1().data())); +} + +bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativeMods) +{ + Display* display = QX11Info::display(); + Window window = QX11Info::appRootWindow(); + Bool owner = True; + int pointer = GrabModeAsync; + int keyboard = GrabModeAsync; + error = false; + original_x_errhandler = XSetErrorHandler(qxt_x_errhandler); + XGrabKey(display, nativeKey, nativeMods, window, owner, pointer, keyboard); + XGrabKey(display, nativeKey, nativeMods | Mod2Mask, window, owner, pointer, keyboard); // allow numlock + XSync(display, False); + XSetErrorHandler(original_x_errhandler); + return !error; +} + +bool QxtGlobalShortcutPrivate::unregisterShortcut(quint32 nativeKey, quint32 nativeMods) +{ + Display* display = QX11Info::display(); + Window window = QX11Info::appRootWindow(); + error = false; + original_x_errhandler = XSetErrorHandler(qxt_x_errhandler); + XUngrabKey(display, nativeKey, nativeMods, window); + XUngrabKey(display, nativeKey, nativeMods | Mod2Mask, window); // allow numlock + XSync(display, False); + XSetErrorHandler(original_x_errhandler); + return !error; +} diff -Nru syncwall-1.6.0/src/AppSettings.cpp syncwall-1.7.4/src/AppSettings.cpp --- syncwall-1.6.0/src/AppSettings.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/AppSettings.cpp 2013-05-05 23:37:32.000000000 +0000 @@ -0,0 +1,26 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#include "AppSettings.h" + +AppSettings::AppSettings( ) + : QSettings (PACKAGE_ORGANIZATION, PACKAGE_NAME) +{ +} diff -Nru syncwall-1.6.0/src/AppSettings.h syncwall-1.7.4/src/AppSettings.h --- syncwall-1.6.0/src/AppSettings.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/AppSettings.h 2013-07-13 06:06:28.000000000 +0000 @@ -0,0 +1,45 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#ifndef _APPETTINGS_H_ +#define _APPETTINGS_H_ + +#include + +#define PACKAGE_ORGANIZATION "TheHive" +#define PACKAGE_NAME "SyncWall" +#define PACKAGE_VERSION "1.7.4" +#define PACKAGE_DB_VERSION "1" +#define PACKAGE_ONLINE_HELP_URL "http://thehive.xbee.net/index.php?module=pages&func=display&pageid=1" +#define PACKAGE_CHECK_RELEASE_URL "http://sourceforge.net/projects/syncwall/files" + +class AppSettings : + public QSettings +{ + Q_OBJECT + +public: + + AppSettings( ); + +protected: +}; + +#endif // _APPETTINGS_H_ diff -Nru syncwall-1.6.0/src/BackgroundItem.cpp syncwall-1.7.4/src/BackgroundItem.cpp --- syncwall-1.6.0/src/BackgroundItem.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/BackgroundItem.cpp 2013-05-05 23:37:32.000000000 +0000 @@ -0,0 +1,196 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#include +#include +#include +#include + +#include "BackgroundItem.h" + +const int decoMargin = 2; // default pen width + supplementary contour if selected (so 1 + 1) +const int penWidth = 1; +const int cornerSize = 2; + +BackgroundItem::BackgroundItem ( QGraphicsItem * parent ) : QGraphicsItem(parent), + m_freezeXAxis(false), + m_freezeYAxis(false) +{ + setFlag(QGraphicsItem::ItemIsMovable, true); + setFlag(QGraphicsItem::ItemIsSelectable, true); + setFlag(QGraphicsItem::ItemIsFocusable, true); + setFlag(QGraphicsItem::ItemSendsScenePositionChanges,true); +} + +QRectF BackgroundItem::boundingRect() const +{ + QRectF res; + res = QRectF( + -( m_size.width() ) / 2, + -( m_size.height() ) / 2 - decoMargin, + m_size.width() + 2 * decoMargin, + m_size.height() + 2 * decoMargin + ); + + return res; +} + +void BackgroundItem::setImage(const QImage &image, const QSize &size, const QSize &desktopSize) +{ + m_image = image; + m_size = size; + m_desktopSize = desktopSize; + + QRectF itemBoundinRect = boundingRect(); + qreal ih = itemBoundinRect.height() / 2; + qreal iw = itemBoundinRect.width() / 2; + + setPos(QPointF(iw + 1,ih + 1) - m_offset); + + update(); +} + +void BackgroundItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget * /* widget */) +{ + QPen pen(Qt::black); + pen.setWidth(1); + pen.setCosmetic(true); + + //draw out box + pen.setBrush(Qt::black); + painter->setPen(pen); + + QRectF itemRect = boundingRect().translated(decoMargin - penWidth,decoMargin - penWidth); + + painter->drawRoundedRect(itemRect,cornerSize,cornerSize); + + // draw image + drawDesktop(painter); + + // draw highlight if needed + if (option->state & QStyle::State_Selected) + { + pen.setBrush(Qt::red); + painter->setPen(pen); + painter->drawRoundedRect(itemRect, cornerSize, cornerSize); + } +} + +void BackgroundItem::drawDesktop(QPainter *painter) +{ + if ( m_image.isNull() ) + { + painter->fillRect ( + -m_size.width() / 2, + -m_size.height() / 2, + m_size.width(), + m_size.height(), + Qt::white ); + } + else + { + QRectF target( + -m_size.width() / 2, + -m_size.height() / 2, + m_size.width(), + m_size.height() + ); + painter->drawImage( target,m_image,m_image.rect() ); + } +} + +void BackgroundItem::mousePressEvent1 ( QGraphicsSceneMouseEvent * event ) +{ + QGraphicsItem::mousePressEvent(event); +} + +void BackgroundItem::mouseMoveEvent1 ( QGraphicsSceneMouseEvent * event ) +{ + QGraphicsItem::mouseMoveEvent(event); +} + +void BackgroundItem::mouseReleaseEvent1 ( QGraphicsSceneMouseEvent * event ) +{ + QGraphicsItem::mouseReleaseEvent(event); +} + +void BackgroundItem::setFreezeXAxis(bool val) +{ + m_freezeXAxis = val; +} + +void BackgroundItem::setFreezeYAxis(bool val) +{ + m_freezeYAxis = val; +} + +QVariant BackgroundItem::itemChange(GraphicsItemChange change, const QVariant &value) +{ + //qDebug() << " BackgroundItem::itemChange = " << change; + if (change == QGraphicsItem::ItemPositionChange) + { + if (m_freezeXAxis) + { + return QPointF( pos().x(), value.toPointF().y() ); + } + else if (m_freezeYAxis) + { + return QPointF( value.toPointF().x(), pos().y() ); + } + else // limit to the scene rect + { + // value is the new position. + QPointF newPos = value.toPointF(); + if ( scene() ) + { + QRectF itemBoundinRect = boundingRect(); + + qreal ih = itemBoundinRect.height() / 2; + qreal iw = itemBoundinRect.width() / 2; + QRectF rect = scene()->sceneRect(); + + rect.adjust(iw - 1,ih - 1,-iw + 1,-ih + 1); + + if ( rect.isValid() && !rect.contains(newPos) ) + { + // Keep the item inside the scene rect. + newPos.setX( qMin( rect.right(), qMax( newPos.x(), rect.left() ) ) ); + newPos.setY( qMin( rect.bottom(), qMax( newPos.y(), rect.top() ) ) ); + return newPos; + } + } + } + } + return QGraphicsItem::itemChange(change, value); +} + +void BackgroundItem::setOffset(const QPointF &offset) +{ + m_offset = offset; +} + +QPointF BackgroundItem::getOffset() const +{ + QPointF p = scenePos(); + QRectF itemBoundinRect = boundingRect(); + qreal ih = itemBoundinRect.height() / 2; + qreal iw = itemBoundinRect.width() / 2; + return p + QPointF(-iw - 1,-ih - 1); +} diff -Nru syncwall-1.6.0/src/BackgroundItem.h syncwall-1.7.4/src/BackgroundItem.h --- syncwall-1.6.0/src/BackgroundItem.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/BackgroundItem.h 2013-05-05 23:37:34.000000000 +0000 @@ -0,0 +1,69 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#ifndef _BACKGROUNDITEM_H_ +#define _BACKGROUNDITEM_H_ + +#include +#include +#include + +class BackgroundItem : public QGraphicsItem +{ +public: + + BackgroundItem ( QGraphicsItem * parent = 0 ); + + virtual QRectF boundingRect() const; + virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget * /* widget */); + + void setImage(const QImage &,const QSize &size, const QSize &desktopSize); + + void setSize(const QSize &size); + QSize getSize() const {return m_size; } + + QPointF getOffset() const; + void setOffset(const QPointF &); + + void setFreezeXAxis(bool); + void setFreezeYAxis(bool); + +protected: + + QVariant itemChange(GraphicsItemChange change, const QVariant &value); + + virtual void mousePressEvent1 ( QGraphicsSceneMouseEvent * event ); + virtual void mouseMoveEvent1 ( QGraphicsSceneMouseEvent * event ); + virtual void mouseReleaseEvent1 ( QGraphicsSceneMouseEvent * event ); + +private: + + void drawDesktop(QPainter *painter); + + QSize m_size; + QSize m_desktopSize; + bool m_freezeXAxis; + bool m_freezeYAxis; + QPointF m_offset; + + QImage m_image; +}; + +#endif // _BACKGROUNDITEM_H_ diff -Nru syncwall-1.6.0/src/BackgroundPainter.cpp syncwall-1.7.4/src/BackgroundPainter.cpp --- syncwall-1.6.0/src/BackgroundPainter.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/BackgroundPainter.cpp 2013-05-05 23:37:32.000000000 +0000 @@ -0,0 +1,1064 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "BackgroundPainter.h" + +#include "AppSettings.h" +#include "LogHandler.h" +#include "qimageblitz.h" + +#include +#ifdef Q_OS_WIN +#define M_PI 3.14159265358979323846 // VC++ does not recognise those (standard) constants +#endif + +#ifndef MIN +#define MIN(a,b) ( (a) < (b) ? (a) : (b) ) +#endif +#ifndef MAX +#define MAX(a,b) ( (a) > (b) ? (a) : (b) ) +#endif +#ifndef ABS +#define ABS(x) ( ( (int)(x) ^ ( (int)(x) >> 31 ) ) - ( (int)(x) >> 31 ) ) +#endif + +const int previewFactor = 10; + +bool operator>(const QSize &s1, const QSize &s2) +{ + return s1.width() > s2.width() || s1.height() > s2.height(); +} + +// Exponential blur, Jani Huhtanen, 2006 +#include + +template +static inline void blurinner(unsigned char *bptr, int &zR, int &zG, int &zB, int &zA, int alpha) +{ + int R,G,B,A; + R = *bptr; + G = *(bptr + 1); + B = *(bptr + 2); + A = *(bptr + 3); + zR += ( alpha * ( (R << zprec) - zR ) ) >> aprec; + zG += ( alpha * ( (G << zprec) - zG ) ) >> aprec; + zB += ( alpha * ( (B << zprec) - zB ) ) >> aprec; + zA += ( alpha * ( (A << zprec) - zA ) ) >> aprec; + *bptr = zR >> zprec; + *(bptr + 1) = zG >> zprec; + *(bptr + 2) = zB >> zprec; + *(bptr + 3) = zA >> zprec; +} + +template +static inline void blurrow( QImage & im, int line, int alpha) +{ + int zR,zG,zB,zA; + QRgb *ptr = (QRgb *)im.scanLine(line); + zR = *( (unsigned char *)ptr ) << zprec; + zG = *( (unsigned char *)ptr + 1 ) << zprec; + zB = *( (unsigned char *)ptr + 2 ) << zprec; + zA = *( (unsigned char *)ptr + 3 ) << zprec; + + for(int index = 1; index( (unsigned char *)&ptr[index],zR,zG,zB,zA,alpha ); + + for(int index = im.width() - 2; index>=0; index--) + blurinner( (unsigned char *)&ptr[index],zR,zG,zB,zA,alpha ); +} + +template +static inline void blurcol( QImage & im, int col, int alpha) +{ + int zR,zG,zB,zA; + QRgb *ptr = (QRgb *)im.bits(); + ptr += col; + zR = *( (unsigned char *)ptr ) << zprec; + zG = *( (unsigned char *)ptr + 1 ) << zprec; + zB = *( (unsigned char *)ptr + 2 ) << zprec; + zA = *( (unsigned char *)ptr + 3 ) << zprec; + + for( int index = im.width(); index<(im.height() - 1) * im.width(); index += im.width() ) + blurinner( (unsigned char *)&ptr[index],zR,zG,zB,zA,alpha ); + + for( int index = (im.height() - 2) * im.width(); index>=0; index -= im.width() ) + blurinner( (unsigned char *)&ptr[index],zR,zG,zB,zA,alpha ); +} + +/* + * expblur(QImage &img, int radius) + * + * In-place blur of image 'img' with kernel + * of approximate radius 'radius'. + * + * Blurs with two sided exponential impulse + * response. + * + * aprec = precision of alpha parameter + * in fixed-point format 0.aprec + * + * zprec = precision of state parameters + * zR,zG,zB and zA in fp format 8.zprec + */ +template +void expblur( QImage &img, int radius ) +{ + if (radius < 1) + return; + + // Calculate the alpha such that 90% of the kernel is within the radius. Kernel extends to infinity. + int alpha = (int)( (1 << aprec) * ( 1.0f - expf( -2.3f / (radius + 1.f) ) ) ); + + for(int row = 0; row(img,row,alpha); + + for(int col = 0; col(img,col,alpha); +} + +BackgroundPainter::BackgroundPainter(QObject *parent) + : QObject(parent), + m_shareImageBetweenScreen(false), + m_multiMonitorType(MULTIMONITOR_NO_MULTIMONITOR), + m_resizingType(SCALE_KEEP_EXPANDED_ASPECT), + m_verticalAlignmentType(ALIGN_V_CENTER), + m_horizontalAlignmentType(ALIGN_H_CENTER), + m_fillingType(FILL_BY_SMART_COLOR), + m_specialEffectType(EFFECT_NONE), + m_lastSpecialEffectType(EFFECT_NONE), + m_specialEffectParam(5.0f), + m_fillingColor1(Qt::red), + m_fillingColor2(Qt::blue), + m_inverseGradient(false), + m_smoothAlgorithm(SMOOTH_DEFAULT), + m_sharpenSmoothScale(false) +{ + loadSettings(); + + // update + m_hasParameter << EFFECT_BLUR; + m_hasParameter << EFFECT_GAUSSIAN_BLUR; + m_hasParameter << EFFECT_SHARPEN; + m_hasParameter << EFFECT_GAUSSIAN_SHARPEN; + m_hasParameter << EFFECT_EMBOSS; + m_hasParameter << EFFECT_DESATURATE; + m_hasParameter << EFFECT_SWIRL; + m_hasParameter << EFFECT_OILPAINT; + m_hasParameter << EFFECT_GLOW; + m_hasParameter << EFFECT_PROGRESSIVEBLUR; +} + +BackgroundPainter::~BackgroundPainter() +{ + //saveSettings(); +} + +QColor m_fillingColor; + +void BackgroundPainter::loadSettings() +{ + AppSettings settings; + + settings.beginGroup("BackgroundPainter"); + + m_shareImageBetweenScreen = settings.value("shareImageBetweenScreen",false).toBool(); + + m_multiMonitorType = settings.value("multiMonitorType",MULTIMONITOR_NO_MULTIMONITOR).toInt(); + m_resizingType = settings.value("resizingType",SCALE_KEEP_EXPANDED_ASPECT).toInt(); + m_verticalAlignmentType = settings.value("verticalAlignmentType",ALIGN_V_CENTER).toInt(); + m_horizontalAlignmentType = settings.value("horizontalAlignmentType",ALIGN_H_CENTER).toInt(); + m_fillingType = settings.value("fillingType",FILL_BY_SMART_COLOR).toInt(); + m_fillingColor1 = settings.value( "fillingColor1",QColor(5,150,200) ).value(); + m_fillingColor2 = settings.value( "fillingColor2",QColor(5,250,200) ).value(); + m_specialEffectType = settings.value("specialEffectType",EFFECT_NONE).toInt(); + m_specialEffectParam = settings.value("specialEffectParam",5.0f).toFloat(); + m_inverseGradient = settings.value("inverseGradient",false).toBool(); + m_smoothAlgorithm = settings.value("smoothAlgorithm",SMOOTH_DEFAULT).toInt(); + + settings.endGroup(); +} + +void BackgroundPainter::saveSettings() +{ + AppSettings settings; + + settings.beginGroup("BackgroundPainter"); + + settings.setValue("shareImageBetweenScreen", m_shareImageBetweenScreen); + settings.setValue("multiMonitorType", m_multiMonitorType); + settings.setValue("resizingType", m_resizingType); + if (m_verticalAlignmentType != ALIGN_V_USER) + settings.setValue("verticalAlignmentType", m_verticalAlignmentType); + if (m_verticalAlignmentType != ALIGN_H_USER) + settings.setValue("horizontalAlignmentType", m_horizontalAlignmentType); + settings.setValue("fillingType", m_fillingType); + settings.setValue("fillingColor1", m_fillingColor1); + settings.setValue("fillingColor2", m_fillingColor2); + settings.setValue("specialEffectType", m_specialEffectType); + settings.setValue("specialEffectParam", m_specialEffectParam); + settings.setValue("inverseGradient", m_inverseGradient); + settings.setValue("smoothAlgorithm", m_smoothAlgorithm); + + settings.endGroup(); +} + +void BackgroundPainter::setMultiMonitorSupportType(int val) +{ + m_multiMonitorType = val; +} + +void BackgroundPainter::setResizingType(int method) +{ + m_resizingType = method; +} + +void BackgroundPainter::setVerticalAlignmentType(int val) +{ + m_verticalAlignmentType = val; +} + +void BackgroundPainter::setHorizontalAlignmentType(int val) +{ + m_horizontalAlignmentType = val; +} + +void BackgroundPainter::setFillingType(int val) +{ + m_fillingType = val; +} + +void BackgroundPainter::setSmoothAlgorithm(int val) +{ + m_smoothAlgorithm = val; +} + +void BackgroundPainter::setSpecialEffectType(int val) +{ + m_specialEffectType = val; +} + +void BackgroundPainter::setSpecialEffectParameter(float val) +{ + m_specialEffectParam = val; +} + +void BackgroundPainter::setShareImageBetweenScreen(bool val) +{ + m_shareImageBetweenScreen = val; +} + +void BackgroundPainter::setInverseGradient(bool val) +{ + m_inverseGradient = val; +} + +void BackgroundPainter::setFillingColor1(const QColor &color) +{ + m_fillingColor1 = color; +} + +void BackgroundPainter::setFillingColor2(const QColor &color) +{ + m_fillingColor2 = color; +} + +QImage BackgroundPainter::processImage(const QImage &srcImage, bool previewMode) +{ + QSize resampledSrcImgSize = getSizeAccordingToConfig(srcImage.size(),previewMode); + QSize resampledTargetImgSize = getSizeAccordingToConfig(m_targetSizeWithMargins,previewMode); + + QSize goodSize = resampledSrcImgSize.expandedTo(resampledTargetImgSize); + + QImage wallp(goodSize,QImage::Format_ARGB32); + + fillImage(srcImage,wallp); + + QImage img = smoothScale(srcImage,resampledSrcImgSize,m_smoothAlgorithm); + + postProcess(img, m_specialEffectType,previewMode); + + embedImage(img,wallp); + + return wallp; +} + +QImage BackgroundPainter::smoothScale(const QImage &image,const QSize &newSize,int mode) const +{ + QImage img; + float factor = 1.0f; + if (m_sharpenSmoothScale) + factor = 0.5f; + switch(mode) + { + case SMOOTH_BLITZ_BLACKMANFILTER: + { + img = Blitz::smoothScaleFilter(image, newSize, + factor, + Blitz::BlackmanFilter, + Qt::IgnoreAspectRatio); + break; + } + case SMOOTH_BLITZ_CUBICFILTER: + { + img = Blitz::smoothScaleFilter(image, newSize, + factor, + Blitz::CubicFilter, + Qt::IgnoreAspectRatio); + break; + } + case SMOOTH_BLITZ_MITCHELLFILTER: + { + img = Blitz::smoothScaleFilter(image, newSize, + factor, + Blitz::MitchellFilter, + Qt::IgnoreAspectRatio); + break; + } + case SMOOTH_BLITZ_LANCZOSFILTER: + { + img = Blitz::smoothScaleFilter(image, newSize, + factor, + Blitz::LanczosFilter, + Qt::IgnoreAspectRatio); + break; + } + default: + case SMOOTH_DEFAULT: + { + img = image.scaled( newSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + break; + } + } + + return img; +} + +void BackgroundPainter::embedImage(const QImage&src, QImage & dest) +{ + QPainter painter(&dest); + + int offsetDestX = MAX(0,( dest.width() - src.width() ) / 2); + int offsetDestY = MAX(0,( dest.height() - src.height() ) / 2); + int offsetSrcX = ABS( MIN(0,( dest.width() - src.width() ) / 2) ); + int offsetSrcY = ABS( MIN(0,( dest.height() - src.height() ) / 2) ); + int width = MIN( dest.width(),src.width() ); + int height = MIN( dest.height(),src.height() ); + + QRect source (offsetSrcX, offsetSrcY,width, height); + QRect target (offsetDestX, offsetDestY,width,height); + painter.drawImage(target, src, source); +} + +QColor BackgroundPainter::computeSmartColor(const QImage &img) +{ + int red = 0; + int green = 0; + int blue = 0; + + for (int y = 0; y < img.height(); y++) + { + const QRgb *lineSrc = reinterpret_cast( img.scanLine(y) ); + + for (int x = 0; x < img.width(); x++) + { + red += qRed(lineSrc[x]); + green += qGreen(lineSrc[x]); + blue += qBlue(lineSrc[x]); + } + } + + //Calculate average + red /= img.height() * img.width(); + green /= img.height() * img.width(); + blue /= img.height() * img.width(); + + return QColor(red,green,blue); +} + +void BackgroundPainter::postProcess(QImage &img, int effect, bool preview) +{ + float sizeFactor = 1.0f; + + if (preview) + sizeFactor = previewFactor; + + switch (effect) + { + case EFFECT_RANDOM: + if (!preview) + m_lastSpecialEffectType = qrand() % EFFECT_RANDOM; + qDebug() << "m_lastSpecialEffectType = " << m_lastSpecialEffectType; + postProcess(img,m_lastSpecialEffectType,preview); + break; + + case EFFECT_GRAYSCALE: + Blitz::grayscale(img); + break; + + case EFFECT_BLUR: + img = Blitz::blur(img,(int) m_specialEffectParam / sizeFactor); + break; + + case EFFECT_GAUSSIAN_BLUR: + img = Blitz::gaussianBlur(img,(int) m_specialEffectParam / sizeFactor); + break; + + case EFFECT_EDGE: + img = Blitz::edge(img); + break; + + case EFFECT_SHARPEN: + img = Blitz::sharpen(img, (int) m_specialEffectParam / sizeFactor); + break; + + case EFFECT_GAUSSIAN_SHARPEN: + img = Blitz::gaussianSharpen(img, (int) m_specialEffectParam / sizeFactor); + break; + + case EFFECT_EMBOSS: + img = Blitz::emboss(img, (int) m_specialEffectParam / sizeFactor); + break; + + case EFFECT_DESATURATE: + img = Blitz::desaturate(img, m_specialEffectParam); + break; + + case EFFECT_FLATTEN: + img = Blitz::flatten(img, m_fillingColor1, m_fillingColor2); + break; + + case EFFECT_SWIRL: + img = Blitz::swirl(img, m_specialEffectParam); + break; + + case EFFECT_OILPAINT: + img = Blitz::oilPaint(img, m_specialEffectParam / sizeFactor); + break; + + case EFFECT_CHARCOAL: + img = Blitz::charcoal(img); + break; + + case EFFECT_SEPIA: + img = toSepia(img); + break; + + case EFFECT_INVERTCOLOR: + img = invertColors(img); + break; + + case EFFECT_GLOW: + img = glow(img,m_specialEffectParam); + break; + + case EFFECT_PROGRESSIVEBLUR: + img = progressiveBlur(img,m_specialEffectParam); + break; + + case EFFECT_NONE: + default: + break; + } +} + +void BackgroundPainter::fillImage(const QImage &src, QImage &target) +{ + // fill the image with the default values if needed + if (m_resizingType == SCALE_IGNORE_ASPECT || + m_resizingType == SCALE_KEEP_EXPANDED_ASPECT) + return; + + QPainter painter(&target); + + switch (m_fillingType) + { + case FILL_BY_COLOR: + { + LogHandler::getInstance()->reportDebug("BackgroundPainter: Fill by color ..."); + painter.fillRect(target.rect(),m_fillingColor1); + break; + } + + case FILL_BY_SMART_COLOR: + { + LogHandler::getInstance()->reportDebug("BackgroundPainter: Fill by smart color ..."); + painter.fillRect( target.rect(),computeSmartColor(src) ); + break; + } + + case FILL_BY_BLUR: + { + LogHandler::getInstance()->reportDebug("BackgroundPainter: Fill by blurred image ..."); + QImage blurred(src); + blurred = Blitz::blur(blurred,30); + + //blurred.save("d:/tmp/blurred.png","PNG"); + + painter.drawImage( target.rect(), blurred.scaled( target.width(),target.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation) ); + break; + } + + case FILL_BY_VERTICAL_GRADIENT: + { + LogHandler::getInstance()->reportDebug("BackgroundPainter: Fill by vertical gradient ..."); + QLinearGradient linearGrad( 0, 0, 0, target.height() ); + + if (m_inverseGradient) + { + linearGrad.setColorAt( 0.0, m_fillingColor2); + linearGrad.setColorAt( 1.0, m_fillingColor1); + } + else + { + linearGrad.setColorAt( 0.0, m_fillingColor1); + linearGrad.setColorAt( 1.0, m_fillingColor2); + } + + painter.setBrush( linearGrad ); + painter.fillRect( 0, 0, target.width(),target.height(), QBrush(linearGrad) ); + break; + } + + case FILL_BY_HORIZONTAL_GRADIENT: + { + LogHandler::getInstance()->reportDebug("BackgroundPainter: Fill by horizontal gradient ..."); + QLinearGradient linearGrad( 0, 0, target.width(), 0 ); + + if (m_inverseGradient) + { + linearGrad.setColorAt( 0.0, m_fillingColor2); + linearGrad.setColorAt( 1.0, m_fillingColor1); + } + else + { + linearGrad.setColorAt( 0.0, m_fillingColor1); + linearGrad.setColorAt( 1.0, m_fillingColor2); + } + + painter.setBrush( linearGrad ); + painter.fillRect( 0, 0, target.width(),target.height(), QBrush(linearGrad) ); + break; + } + + case FILL_BY_RADIAL_GRADIENT: + { + LogHandler::getInstance()->reportDebug("BackgroundPainter: Fill by radial gradient ..."); + float w = target.width() / 2.0f; + float h = target.height() / 2.0f; + QRadialGradient radialGrad( w,h, sqrtf(w * w + h * h) ); + + if (m_inverseGradient) + { + radialGrad.setColorAt( 0.0, m_fillingColor2); + radialGrad.setColorAt( 1.0, m_fillingColor1); + } + else + { + radialGrad.setColorAt( 0.0, m_fillingColor1); + radialGrad.setColorAt( 1.0, m_fillingColor2); + } + + painter.setBrush( radialGrad ); + painter.fillRect( 0, 0, target.width(),target.height(), QBrush(radialGrad) ); + break; + } + + default: + { + break; + } + } +} + +QSize BackgroundPainter::getSizeAccordingToConfig(const QSize &baseSize, bool preview) +{ + QSize finalSize(baseSize); + + // nothing to do !! + if (baseSize == m_targetSizeWithMargins) + { + if (preview) + finalSize /= previewFactor; + + return finalSize; + } + + float baseAspectRatio = (float) baseSize.width() / (float) ( baseSize.height() ); + float targetAspectRatio = (float) m_targetSizeWithMargins.width() / (float) ( m_targetSizeWithMargins.height() ); + + switch (m_resizingType) + { + case SCALE_NO_RESIZE: + { + finalSize = baseSize; + break; + } + + case SCALE_IGNORE_ASPECT: + { + finalSize = m_targetSizeWithMargins; + break; + } + + case SCALE_KEEP_ASPECT: + { + if ( (baseAspectRatio >= targetAspectRatio) ) + finalSize = QSize( m_targetSizeWithMargins.width(), (int) (m_targetSizeWithMargins.width() / baseAspectRatio + 0.5) ); + else + finalSize = QSize( (int) (m_targetSizeWithMargins.height() * baseAspectRatio + 0.5), m_targetSizeWithMargins.height() ); + + break; + } + + case SCALE_KEEP_EXPANDED_ASPECT: + { + if (baseAspectRatio >= targetAspectRatio ) + finalSize = QSize( (int)(baseSize.width() / ( (float)baseSize.height() / m_targetSizeWithMargins.height() ) + 0.5),m_targetSizeWithMargins.height() ); + else + finalSize = QSize( m_targetSizeWithMargins.width(), (int)(baseSize.height() / ( (float)baseSize.width() / m_targetSizeWithMargins.width() ) + 0.5) ); + + break; + } + } + + if (preview) + finalSize /= previewFactor; + + return finalSize; +} + +QList BackgroundPainter::cropAndSplit(const QImage & background,const QList &listGamingArea) +{ + QSize finalSize(m_targetSize); + float sizeFactor = 1.0f; + QList results; + + finalSize /= sizeFactor; + + QRectF total; + QSize bgSize = background.size(); + + foreach (const QRectF &rectf, listGamingArea) + total |= rectf; + + int marginsWidth = bgSize.width() - total.width() - total.x(); + + int alignOffsetX = 0; + int alignOffsetY = 0; + + if ( !m_userOffset.isNull() ) + { + alignOffsetY = m_userOffset.y() / sizeFactor; + alignOffsetX = m_userOffset.x() / sizeFactor; + } + else + { + // compute the offset according to the alignment requirement + switch(m_verticalAlignmentType) + { + case ALIGN_V_CENTER: + alignOffsetY = ( bgSize.height() - finalSize.height() ) / 2; + break; + + case ALIGN_V_BOTTOM: + alignOffsetY = bgSize.height() - finalSize.height(); + break; + + case ALIGN_V_TOP: // top align by default + default: + break; + } + + switch(m_horizontalAlignmentType) + { + case ALIGN_H_CENTER: + alignOffsetX = ( bgSize.width() - finalSize.width() ) / 2; + break; + + case ALIGN_H_RIGHT: + alignOffsetX = marginsWidth; + break; + + case ALIGN_H_LEFT: // top align by default + default: + break; + } + } + + // Fill the image with the gaming area list + foreach (const QRectF &zone, listGamingArea) + { + QRectF source( + zone.x() / sizeFactor + alignOffsetX, + zone.y() / sizeFactor + alignOffsetY, + zone.width() / sizeFactor, + zone.height() / sizeFactor + ); + + results << background.copy( source.toRect() ); + } + return results; +} + +QImage BackgroundPainter::cropAndMerge(const QImage & background,const QList &listGamingArea) +{ + QSize finalSize(m_targetSize); + float sizeFactor = 1.0f; + + finalSize /= sizeFactor; + + QRectF total; + QSize bgSize = background.size(); + + foreach (const QRectF &rectf, listGamingArea) + total |= rectf; + + int marginsWidth = bgSize.width() - total.width() - total.x(); + + QImage wallp(finalSize,QImage::Format_ARGB32); + + int alignOffsetX = 0; + int alignOffsetY = 0; + + if ( !m_userOffset.isNull() ) + { + alignOffsetY = m_userOffset.y() / sizeFactor; + alignOffsetX = m_userOffset.x() / sizeFactor; + } + else + { + // compute the offset according to the alignment requirement + switch(m_verticalAlignmentType) + { + case ALIGN_V_CENTER: + alignOffsetY = ( bgSize.height() - finalSize.height() ) / 2; + break; + + case ALIGN_V_BOTTOM: + alignOffsetY = bgSize.height() - finalSize.height(); + break; + + case ALIGN_V_TOP: // top align by default + default: + break; + } + + switch(m_horizontalAlignmentType) + { + case ALIGN_H_CENTER: + alignOffsetX = ( bgSize.width() - finalSize.width() ) / 2; + break; + + case ALIGN_H_RIGHT: + alignOffsetX = marginsWidth; //bgSize.width() - finalSize.width(); + break; + + case ALIGN_H_LEFT: // left align by default + default: + break; + } + } + + QPainter painter(&wallp); + int offsetX = MAX(0,( finalSize.width() - bgSize.width() ) / 2); + int offsetY = 0; + + // Fill the image with the gaming area list + foreach (const QRectF &zone, listGamingArea) + { + QRectF target(offsetX,offsetY + zone.y(),zone.width() / sizeFactor,zone.height() / sizeFactor); + QRectF source( + zone.x() / sizeFactor + alignOffsetX, + zone.y() / sizeFactor + alignOffsetY, + zone.width() / sizeFactor, + zone.height() / sizeFactor + ); + + painter.drawImage(target,background,source); + offsetX += zone.width() / sizeFactor; + } + return wallp; +} + +QImage BackgroundPainter::crop(const QImage & background, const QSize &size, bool preview) +{ + QSize finalSize(size); + float sizeFactor = 1.0f; + + if (preview) + sizeFactor = previewFactor; + + finalSize /= sizeFactor; + + QImage wallp(finalSize,QImage::Format_ARGB32); + QSize bgSize = background.size(); + int marginsWidth = bgSize.width() - finalSize.width(); + + int alignOffsetX = 0; + int alignOffsetY = 0; + + if ( !m_userOffset.isNull() ) + { + alignOffsetY = m_userOffset.y() / sizeFactor; + alignOffsetX = m_userOffset.x() / sizeFactor; + } + else + { + // compute the offset according to the alignment requirement + switch(m_verticalAlignmentType) + { + case ALIGN_V_CENTER: + alignOffsetY = ( bgSize.height() - finalSize.height() ) / 2; + break; + + case ALIGN_V_BOTTOM: + alignOffsetY = bgSize.height() - finalSize.height(); + break; + + case ALIGN_V_TOP: // top align by default + default: + break; + } + + switch(m_horizontalAlignmentType) + { + case ALIGN_H_CENTER: + alignOffsetX = ( bgSize.width() - finalSize.width() ) / 2; + break; + + case ALIGN_H_RIGHT: + alignOffsetX = marginsWidth; //bgSize.width() - finalSize.width(); + break; + + case ALIGN_H_LEFT: // left align by default + default: + break; + } + } + + QPainter painter(&wallp); + + QRectF target( 0.0f,0.0f,finalSize.width(),finalSize.height() ); + QRectF source( + alignOffsetX, + alignOffsetY, + finalSize.width(), + finalSize.height() + ); + + painter.drawImage(target,background,source); + + return wallp; +} + +bool BackgroundPainter::hasSpecialEffectParameter(int specialEffect) const +{ + if ( m_hasParameter.contains(specialEffect) ) + return true; + + return false; +} + +QImage BackgroundPainter::toSepia(const QImage &img) +{ + QImage dest(img.size(), QImage::Format_ARGB32); + const int w = img.width(); + const int h = img.height(); + + for (int y = 0; y(blurred, radius); + + // replace alpha value in blurred image + int width = blurred.width(); + int height = blurred.height(); + + for (int y = 0; y < height; y++) + { + QRgb *lineSrc = reinterpret_cast( blurredImage.scanLine(y) ); + QRgb *lineBlur = reinterpret_cast( blurred.scanLine(y) ); + QRgb *lineMask = reinterpret_cast( mask.scanLine(y) ); + + for (int x = 0; x < width; x++) + { + QRgb valueDest = qRgba( qRed(*lineBlur),qGreen(*lineBlur),qBlue(*lineBlur),qRed(*lineMask) ); + + blurred.setPixel(x,y,valueDest); + + lineMask++; + lineSrc++; + lineBlur++; + } + } + + QPainter imagePainter(&blurredImage); + + imagePainter.save(); + imagePainter.setCompositionMode(QPainter::CompositionMode_SourceOver); + imagePainter.drawImage(0,0, blurred); + imagePainter.restore(); + imagePainter.end(); + + return blurredImage; +} + +QImage BackgroundPainter::glow(const QImage &image, int radius) +{ + QImage glownImage(image.size(), QImage::Format_ARGB32_Premultiplied); + glownImage.fill(0x00); + QPainter imagePainter(&glownImage); + + imagePainter.drawImage(0,0, image); + + //ExpBlur with 0.16 fp for alpha and + //8.7 fp for state parameters zR,zG,zB and zA + QImage blurred = image; + expblur<16,7>(blurred, radius); + + imagePainter.save(); + imagePainter.setCompositionMode(QPainter::CompositionMode_Plus); + imagePainter.drawImage(0,0, blurred); + imagePainter.restore(); + imagePainter.end(); + + return glownImage; +} + +QImage BackgroundPainter::invertColors(const QImage &img) +{ + QImage inverted(img.size(), QImage::Format_ARGB32); + const int w = img.width(); + const int h = img.height(); + + for (int y = 0; y +#include +#include + +class BackgroundPainter : + public QObject +{ + Q_OBJECT + +public: + + enum MultiMonitorSupportType + { + MULTIMONITOR_NO_MULTIMONITOR = 0, + MULTIMONITOR_ONE_IMAGE_MULTIPLEMONITOR, + MULTIMONITOR_ONE_IMAGE_BY_MONITOR, + MULTIMONITOR_END + }; + + enum ResizingType + { + SCALE_NO_RESIZE = 0, + SCALE_IGNORE_ASPECT, + SCALE_KEEP_ASPECT, + SCALE_KEEP_EXPANDED_ASPECT, + SCALE_END + }; + + enum VerticalAlignmentType + { + ALIGN_V_TOP = 0, + ALIGN_V_CENTER, + ALIGN_V_BOTTOM, + ALIGN_V_USER, + ALIGN_V_END + }; + + enum HorizontalAlignmentType + { + ALIGN_H_LEFT = 0, + ALIGN_H_CENTER, + ALIGN_H_RIGHT, + ALIGN_H_USER, + ALIGN_H_END + }; + + enum FillingType + { + FILL_BY_COLOR = 0, + FILL_BY_SMART_COLOR, + FILL_BY_BLUR, + FILL_BY_VERTICAL_GRADIENT, + FILL_BY_HORIZONTAL_GRADIENT, + FILL_BY_RADIAL_GRADIENT, + FILL_END + }; + + enum SpecialEffectType + { + EFFECT_NONE = 0, + EFFECT_GRAYSCALE, + EFFECT_BLUR, + EFFECT_GAUSSIAN_BLUR, + EFFECT_EDGE, + EFFECT_SHARPEN, + EFFECT_GAUSSIAN_SHARPEN, + EFFECT_EMBOSS, + EFFECT_DESATURATE, + EFFECT_FLATTEN, + EFFECT_SWIRL, + EFFECT_OILPAINT, + EFFECT_CHARCOAL, + EFFECT_SEPIA, + EFFECT_INVERTCOLOR, + EFFECT_GLOW, + EFFECT_PROGRESSIVEBLUR, + EFFECT_RANDOM, + EFFECT_END + }; + + enum RotationModeType + { + ROTATION_UNLNOWN = 0, + ROTATION_NONE, + ROTATION_FLIP_HORIZ, + ROTATION_180, + ROTATION_FLIP_VERTICAL, + ROTATION_TRANSPOSE, + ROTATION_90, + ROTATION_TRANSVERSE, + ROTATION_270, + ROTATION_END + }; + + enum SmoothScaleType + { + SMOOTH_DEFAULT = 0, + SMOOTH_BLITZ_BLACKMANFILTER, + SMOOTH_BLITZ_CUBICFILTER, + SMOOTH_BLITZ_MITCHELLFILTER, + SMOOTH_BLITZ_LANCZOSFILTER + }; + + BackgroundPainter(QObject *parent = NULL); + virtual ~BackgroundPainter(); + + void setMultiMonitorSupportType(int); + int getMultiMonitorSupportType() const + { + return m_multiMonitorType; + } + + void setResizingType(int); + int getResizingType() const + { + return m_resizingType; + } + + void setVerticalAlignmentType(int); + int getVerticalAlignmentType() const + { + return m_verticalAlignmentType; + } + + void setHorizontalAlignmentType(int); + int getHorizontalAlignmentType() const + { + return m_horizontalAlignmentType; + } + + void setFillingType(int); + int getFillingType() const + { + return m_fillingType; + } + + void setSpecialEffectType(int); + int getSpecialEffectType() const + { + return m_specialEffectType; + } + + int getLastSpecialEffectType() const + { + return m_lastSpecialEffectType; + } + + void setSmoothAlgorithm(int); + int getSmoothAlgorithm() const + { + return m_smoothAlgorithm; + } + + void setSpecialEffectParameter(float val); + float getSpecialEffectParameter() const { return m_specialEffectParam; } + + void setShareImageBetweenScreen(bool); + bool getShareImageBetweenScreen() const + { + return m_shareImageBetweenScreen; + } + + void setFillingColor1(const QColor &color); + const QColor &getFillingColor1() const {return m_fillingColor1; } + + void setFillingColor2(const QColor &color); + const QColor &getFillingColor2() const {return m_fillingColor2; } + + void setInverseGradient(bool); + bool getInverseGradient() const + { + return m_inverseGradient; + } + + QImage processImage(const QImage &srcImage, bool previewMode = false); + + void setTargetSizeWithMargins(const QSize &size){m_targetSizeWithMargins = size; } + QSize getTargetSizeWithMargins() const { return m_targetSizeWithMargins; } + + void setTargetSize(const QSize &size){m_targetSize = size; } + QSize getTargetSize() const { return m_targetSize; } + + QSize getSizeAccordingToConfig(const QSize &baseSize, bool preview = false); + + void fillImage(const QImage &src, QImage &target); + void postProcess(QImage &, int effect, bool preview = false); + + QImage cropAndMerge(const QImage & background,const QList &listGamingArea); + QList cropAndSplit(const QImage & background,const QList &listGamingArea); + QImage crop(const QImage & background,const QSize &size, bool previewMode = false); + void embedImage(const QImage&src, QImage & desc); + + bool hasSpecialEffectParameter(int) const; + QImage transform(const QImage &image, int mode) const; + QImage smoothScale(const QImage &image,const QSize &newSize,int mode) const; + + void setUserOffset(const QPointF &); + const QPointF & getUserOffset() const + { + return m_userOffset; + } + +public slots: + + void saveSettings(); + +signals: + +private: + + void loadSettings(); + + QColor computeSmartColor(const QImage &img); + QImage toSepia(const QImage &img); + QImage invertColors(const QImage &img); + QImage glow(const QImage &image, int radius); + QImage progressiveBlur(const QImage &image, int radius); + + bool m_shareImageBetweenScreen; + int m_multiMonitorType; + int m_resizingType; + int m_verticalAlignmentType; + int m_horizontalAlignmentType; + int m_fillingType; + int m_specialEffectType; + int m_lastSpecialEffectType; + float m_specialEffectParam; + + QColor m_fillingColor1; + QColor m_fillingColor2; + bool m_inverseGradient; + + QSize m_targetSize; + QSize m_targetSizeWithMargins; + + QList m_hasParameter; + int m_smoothAlgorithm; + bool m_sharpenSmoothScale; + + QPointF m_userOffset; +}; + +#endif // _BACKGROUNDPAINTER_H_ diff -Nru syncwall-1.6.0/src/BackgroundPainterConfigWidget.cpp syncwall-1.7.4/src/BackgroundPainterConfigWidget.cpp --- syncwall-1.6.0/src/BackgroundPainterConfigWidget.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/BackgroundPainterConfigWidget.cpp 2013-05-05 23:37:32.000000000 +0000 @@ -0,0 +1,841 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#include +#include +#include +#include + +#include "qexifimageheader.h" + +#include "BackgroundPainterConfigWidget.h" + +#include "ui_BackgroundPainterConfigWidget.h" + +#include "ScreenItem.h" +#include "DesktopScene.h" +#include "AppSettings.h" +#include "MiscFunctions.h" +#include "LogHandler.h" + +BackgroundPainterConfigWidget::BackgroundPainterConfigWidget(QWidget *parent) + : QWidget(parent), + ui(new Ui::BackgroundPainterConfigWidget), + m_exportParameters(true), + m_ignoreParameters(false), + m_skipTooSmallImage(false), + m_rotateFromMetadata(false) +{ + ui->setupUi(this); + createDesktop(); + loadSettings(); + updateUI(); + updateDesktop(); +} + +BackgroundPainterConfigWidget::~BackgroundPainterConfigWidget() +{ + //saveSettings(); + delete ui; +} + +void BackgroundPainterConfigWidget::createDesktop() +{ + QDesktopWidget *desktop = QApplication::desktop(); + + qDeleteAll(m_screens); + m_screens.clear(); + + for (int screen = 0; screen < desktop->screenCount(); screen++) + { + QRect avail = desktop->screenGeometry(screen); + m_screens << new ScreenItem(avail.size(),screen + 1); + } +} + +void BackgroundPainterConfigWidget::updateDesktop() +{ + if ( m_screens.isEmpty() ) + return; + + //qDebug() << "scene nb items = " << m_desktopScene->items().size(); + + foreach ( QGraphicsItem * item, m_desktopScene->items() ) + { + ScreenItem *screen = dynamic_cast(item); + if (screen) + m_desktopScene->removeItem(item); + } + + QDesktopWidget *desktop = QApplication::desktop(); + int mainScreen = desktop->primaryScreen(); + + QList screens; + + if ( m_screens.size() > 1 && m_painter.getShareImageBetweenScreen() && m_painter.getMultiMonitorSupportType() != BackgroundPainter::MULTIMONITOR_NO_MULTIMONITOR ) + { + for (int screen = 0; screen < m_screens.size(); screen++) + { + screens << m_screens.at(screen); + screens.at(screen)->setUseMargins(true); + screens.at(screen)->setDrawText(true); + } + } + else + { + screens << m_screens.at(mainScreen); + screens.at(0)->setUseMargins(false); // single screen => no margin + screens.at(0)->setDrawText(false); // single screen => no text + } + + m_desktopScene->addScreens(screens); + ui->graphicsViewDesktop->zoomToFit(); +} + +void BackgroundPainterConfigWidget::updateUI() +{ + m_desktopScene = new DesktopScene(this); + m_desktopScene->setSceneState(DesktopScene::STATE_MOVING_SCREEN); + ui->graphicsViewDesktop->setScene(m_desktopScene); + + connect( m_desktopScene, SIGNAL( reordering() ), this, SLOT( previewImage() ) ); + + // setup UI + initMultiMonitorSupportType(); + initResizingType(); + initAlignmentType(); + initFillingType(); + initSpecialEffectType(); + initSamplingMethod(); + + // apply parameters + applyConfig(); + + // connect signals if screens configuration change + connect( QApplication::desktop(),SIGNAL( screenCountChanged(int) ),this,SLOT( updateScreenConfig(int) ) ); + connect( QApplication::desktop(),SIGNAL( resized(int) ),this,SLOT( updateScreenConfig(int) ) ); + + // force first tab (basic parameters) + ui->tabWidgetParameters->setCurrentIndex(0); +} + +void BackgroundPainterConfigWidget::updateScreenConfig(int) +{ + QDesktopWidget *desktop = QApplication::desktop(); + + // ? new screen + if ( desktop->screenCount() > m_screens.size() ) + { + for (int screen = m_screens.size(); screen < desktop->screenCount(); screen++) + { + QRect avail = desktop->screenGeometry(screen); + m_screens << new ScreenItem(avail.size(),screen + 1); + } + } + else if ( desktop->screenCount() < m_screens.size() ) + { + int nb = m_screens.size(); + for (int screen = desktop->screenCount(); screen < nb; screen++) + delete m_screens.takeLast(); + } + + // update geometry and screen number + for (int screen = 0; screen < m_screens.size(); screen++) + { + QRect avail = desktop->screenGeometry(screen); + m_screens[screen]->setSize( avail.size() ); + m_screens[screen]->setNumber(screen + 1); + } + + updateDesktop(); + + processImage(m_lastFile); +} + +void BackgroundPainterConfigWidget::applyConfig() +{ + // enable only if several screens detected ... + ui->checkBoxShareScreen->setChecked( m_painter.getShareImageBetweenScreen() ); + ui->checkBoxShareScreen->setEnabled(QApplication::desktop()->screenCount() > 1); + + ui->comboBoxMultiMonitor->setCurrentIndex( m_painter.getMultiMonitorSupportType() ); + + // enable only if several screens detected ... + ui->comboBoxMultiMonitor->setEnabled( QApplication::desktop()->screenCount() > 1 && m_painter.getShareImageBetweenScreen() ); + + // display tips only if several screens + ui->labelTips->setVisible(QApplication::desktop()->screenCount() > 1); + + ui->comboBoxResizingType->setCurrentIndex( m_painter.getResizingType() ); + ui->comboBoxAlignmentTypeVertical->setCurrentIndex( m_painter.getVerticalAlignmentType() ); + ui->comboBoxAlignmentTypeVertical->setEnabled(m_painter.getResizingType() != BackgroundPainter::SCALE_IGNORE_ASPECT && + m_painter.getResizingType() != BackgroundPainter::SCALE_KEEP_ASPECT + ); + ui->comboBoxAlignmentTypeHorizontal->setCurrentIndex( m_painter.getHorizontalAlignmentType() ); + ui->comboBoxAlignmentTypeHorizontal->setEnabled(m_painter.getResizingType() != BackgroundPainter::SCALE_IGNORE_ASPECT && + m_painter.getResizingType() != BackgroundPainter::SCALE_KEEP_ASPECT + ); + ui->comboBoxFillingType->setCurrentIndex( m_painter.getFillingType() ); + ui->comboBoxFillingType->setEnabled(m_painter.getResizingType() != BackgroundPainter::SCALE_IGNORE_ASPECT && + m_painter.getResizingType() != BackgroundPainter::SCALE_KEEP_EXPANDED_ASPECT + ); + + setButtonColor(m_painter.getFillingColor1(),ui->pushButtonPreviewColor1); + setButtonColor(m_painter.getFillingColor2(),ui->pushButtonPreviewColor2); + ui->pushButtonPreviewColor1->setEnabled(m_painter.getFillingType() == BackgroundPainter::FILL_BY_COLOR || + m_painter.getFillingType() == BackgroundPainter::FILL_BY_VERTICAL_GRADIENT || + m_painter.getFillingType() == BackgroundPainter::FILL_BY_HORIZONTAL_GRADIENT || + m_painter.getFillingType() == BackgroundPainter::FILL_BY_RADIAL_GRADIENT + ); + ui->pushButtonPreviewColor2->setEnabled(m_painter.getFillingType() == BackgroundPainter::FILL_BY_VERTICAL_GRADIENT || + m_painter.getFillingType() == BackgroundPainter::FILL_BY_HORIZONTAL_GRADIENT || + m_painter.getFillingType() == BackgroundPainter::FILL_BY_RADIAL_GRADIENT + ); + + ui->checkBoxInverseGradient->setEnabled( + m_painter.getFillingType() == BackgroundPainter::FILL_BY_VERTICAL_GRADIENT || + m_painter.getFillingType() == BackgroundPainter::FILL_BY_HORIZONTAL_GRADIENT || + m_painter.getFillingType() == BackgroundPainter::FILL_BY_RADIAL_GRADIENT + ); + ui->checkBoxInverseGradient->setChecked( m_painter.getInverseGradient() ); + + ui->comboBoxSpecialEffect->setCurrentIndex( m_painter.getSpecialEffectType() ); + ui->doubleSpinBoxSpecialEffectParam->setValue( m_painter.getSpecialEffectParameter() ); + ui->doubleSpinBoxSpecialEffectParam->setEnabled( m_painter.hasSpecialEffectParameter( m_painter.getSpecialEffectType() ) ); + + ui->checkBoxExportParameters->setChecked(m_exportParameters); + ui->checkBoxIgnoreParameters->setChecked(m_ignoreParameters); + ui->checkBoxSkipTooSmallImage->setChecked(m_skipTooSmallImage); + ui->checkBoxSkipTooSmallImage->setChecked(m_rotateFromMetadata); + + ui->checkBoxSkipTooSmallImage->setEnabled(m_painter.getResizingType() == BackgroundPainter::SCALE_IGNORE_ASPECT || + m_painter.getResizingType() == BackgroundPainter::SCALE_KEEP_EXPANDED_ASPECT + ); + + ui->comboBoxSamplingMethod->setCurrentIndex( m_painter.getSmoothAlgorithm() ); +} + +void BackgroundPainterConfigWidget::initResizingType() +{ + // user data are set just to help (not used) + ui->comboBoxResizingType->addItem(tr("no resize"),BackgroundPainter::SCALE_NO_RESIZE); + ui->comboBoxResizingType->addItem(tr("Stretch to fill (Ignore aspect ratio)"),BackgroundPainter::SCALE_IGNORE_ASPECT); + ui->comboBoxResizingType->addItem(tr("Proportionally stretch to fit"),BackgroundPainter::SCALE_KEEP_ASPECT); + ui->comboBoxResizingType->addItem(tr("Fill proportionally"),BackgroundPainter::SCALE_KEEP_EXPANDED_ASPECT); +} + +void BackgroundPainterConfigWidget::initMultiMonitorSupportType() +{ + // user data are set just to help (not used) + ui->comboBoxMultiMonitor->addItem(tr("No multi monitor support (wallpaper duplicated)"),BackgroundPainter::MULTIMONITOR_NO_MULTIMONITOR); + ui->comboBoxMultiMonitor->addItem(tr("Extend image (one file for all monitors)"),BackgroundPainter::MULTIMONITOR_ONE_IMAGE_MULTIPLEMONITOR); + ui->comboBoxMultiMonitor->addItem(tr("Extend image then crop (one file per monitor)"),BackgroundPainter::MULTIMONITOR_ONE_IMAGE_BY_MONITOR); +} + +void BackgroundPainterConfigWidget::initAlignmentType() +{ + // user data are set just to help (not used) + ui->comboBoxAlignmentTypeVertical->addItem(tr("Top alignment"),BackgroundPainter::ALIGN_V_TOP); + ui->comboBoxAlignmentTypeVertical->addItem(tr("Center alignment"),BackgroundPainter::ALIGN_V_CENTER); + ui->comboBoxAlignmentTypeVertical->addItem(tr("Bottom alignment"),BackgroundPainter::ALIGN_V_BOTTOM); + + // user data are set just to help (not used) + ui->comboBoxAlignmentTypeHorizontal->addItem(tr("Left alignment"),BackgroundPainter::ALIGN_H_LEFT); + ui->comboBoxAlignmentTypeHorizontal->addItem(tr("Center alignment"),BackgroundPainter::ALIGN_H_CENTER); + ui->comboBoxAlignmentTypeHorizontal->addItem(tr("Right alignment"),BackgroundPainter::ALIGN_H_RIGHT); +} + +void BackgroundPainterConfigWidget::initFillingType() +{ + // user data are set just to help (not used) + ui->comboBoxFillingType->addItem(tr("Fixed color"),BackgroundPainter::FILL_BY_COLOR); + ui->comboBoxFillingType->addItem(tr("Smart color (extract from image)"),BackgroundPainter::FILL_BY_SMART_COLOR); + ui->comboBoxFillingType->addItem(tr("Blurred image"),BackgroundPainter::FILL_BY_BLUR); + ui->comboBoxFillingType->addItem(tr("Vertical gradient"),BackgroundPainter::FILL_BY_VERTICAL_GRADIENT); + ui->comboBoxFillingType->addItem(tr("Horizontal gradient"),BackgroundPainter::FILL_BY_HORIZONTAL_GRADIENT); + ui->comboBoxFillingType->addItem(tr("Radial gradient"),BackgroundPainter::FILL_BY_RADIAL_GRADIENT); +} + +void BackgroundPainterConfigWidget::initSamplingMethod() +{ + // user data are set just to help (not used) + ui->comboBoxSamplingMethod->addItem(tr("Qt default algorithm"),BackgroundPainter::SMOOTH_DEFAULT); + ui->comboBoxSamplingMethod->addItem(tr("Blackman smooth filter"),BackgroundPainter::SMOOTH_BLITZ_BLACKMANFILTER); + ui->comboBoxSamplingMethod->addItem(tr("Cubic filter"),BackgroundPainter::SMOOTH_BLITZ_CUBICFILTER); + ui->comboBoxSamplingMethod->addItem(tr("Mitchell filter"),BackgroundPainter::SMOOTH_BLITZ_MITCHELLFILTER); + ui->comboBoxSamplingMethod->addItem(tr("Lanczos filter"),BackgroundPainter::SMOOTH_BLITZ_LANCZOSFILTER); +} + +void BackgroundPainterConfigWidget::initSpecialEffectType() +{ + ui->comboBoxSpecialEffect->addItem(tr("No effect"),BackgroundPainter::EFFECT_NONE); + ui->comboBoxSpecialEffect->addItem(tr("Grayscale"),BackgroundPainter::EFFECT_GRAYSCALE); + ui->comboBoxSpecialEffect->addItem(tr("Blur"),BackgroundPainter::EFFECT_BLUR); + ui->comboBoxSpecialEffect->addItem(tr("Gaussian blur"),BackgroundPainter::EFFECT_GAUSSIAN_BLUR); + ui->comboBoxSpecialEffect->addItem(tr("Edge"),BackgroundPainter::EFFECT_EDGE); + ui->comboBoxSpecialEffect->addItem(tr("Sharpen"),BackgroundPainter::EFFECT_SHARPEN); + ui->comboBoxSpecialEffect->addItem(tr("Gaussian sharpen"),BackgroundPainter::EFFECT_GAUSSIAN_SHARPEN); + ui->comboBoxSpecialEffect->addItem(tr("Emboss"),BackgroundPainter::EFFECT_EMBOSS); + ui->comboBoxSpecialEffect->addItem(tr("Desaturate"),BackgroundPainter::EFFECT_DESATURATE); + ui->comboBoxSpecialEffect->addItem(tr("Flatten"),BackgroundPainter::EFFECT_FLATTEN); + ui->comboBoxSpecialEffect->addItem(tr("Swirl"),BackgroundPainter::EFFECT_SWIRL); + ui->comboBoxSpecialEffect->addItem(tr("Oilpaint"),BackgroundPainter::EFFECT_OILPAINT); + ui->comboBoxSpecialEffect->addItem(tr("Charcoal"),BackgroundPainter::EFFECT_CHARCOAL); + ui->comboBoxSpecialEffect->addItem(tr("Sepia"),BackgroundPainter::EFFECT_SEPIA); + ui->comboBoxSpecialEffect->addItem(tr("Invert colors"),BackgroundPainter::EFFECT_INVERTCOLOR); + ui->comboBoxSpecialEffect->addItem(tr("Glow"),BackgroundPainter::EFFECT_GLOW); + ui->comboBoxSpecialEffect->addItem(tr("Progressive blur"),BackgroundPainter::EFFECT_PROGRESSIVEBLUR); + ui->comboBoxSpecialEffect->addItem(tr("Random Effect"),BackgroundPainter::EFFECT_RANDOM); +} + +void BackgroundPainterConfigWidget::previewImage(const QString &file) +{ + if ( !file.isEmpty() && m_previewFile != file ) + { + m_previewImage = QImage(file); + ui->labelPreviewImage->setText( QString("%1 - %2x%3").arg( QFileInfo(file).baseName() ).arg( m_previewImage.width() ).arg( m_previewImage.height() ) ); + if (m_rotateFromMetadata) + { + QExifImageHeader qexif(file); + m_previewImage = m_painter.transform( m_previewImage,qexif.value(QExifImageHeader::Orientation).toShort() ); + } + } + + m_previewFile = file; + + if ( m_previewImage.isNull() ) + { + m_previewImage = QImage(":/syncwall/flower.png"); + ui->labelPreviewImage->setText(""); + } + + // refresh final size just in case ... + m_painter.setTargetSize( m_desktopScene->getSize() ); + m_painter.setTargetSizeWithMargins( m_desktopScene->getSizeWithMargins() ); + + QSize minDesktopSize = m_desktopScene->getSizeWithMargins(); + + //qDebug() << "minDesktopSize = " << minDesktopSize; + + //QSize totalSizeWithConfig = m_painter.getSizeAccordingToConfig(minDesktopSize); + QSize resampledSrcImgSize = m_painter.getSizeAccordingToConfig( m_previewImage.size() ); + + //qDebug() << "resampledSrcImgSize = " << resampledSrcImgSize; + + QImage background = m_painter.processImage(m_previewImage,true); + + //background.save("d:/tmp/background.png","PNG"); + + QImage res = m_painter.crop(background,minDesktopSize,true); + + //res.save("d:/tmp/res.png","PNG"); + + m_desktopScene->applyImage(res,background,minDesktopSize, resampledSrcImgSize); +} + +void BackgroundPainterConfigWidget::processImage(const QString &file, bool manual) +{ + m_lastFile = file; + + if (m_previewFile != m_lastFile) + { + m_previewImage = QImage(file); + if (m_rotateFromMetadata) + { + QExifImageHeader qexif(file); + m_previewImage = m_painter.transform( m_previewImage,qexif.value(QExifImageHeader::Orientation).toShort() ); + } + m_previewFile = file; + } + + static int rejectNum = 0; + if (manual && m_skipTooSmallImage) + { + // check a + QSize s = m_desktopScene->getSize(); + if (m_previewImage.size().width() < s.width() / 2 || m_previewImage.size().height() < s.height() / 2) + { + LogHandler::getInstance()->reportInfo( QObject::tr("BackgroundPainterConfigWidget: image %1 is reject because its size is too small (%2x%3/%4x%5))").arg( m_lastFile).arg( m_previewImage.size().width() ).arg( m_previewImage.size().height() ).arg( s.width() ).arg( s.height() ) ); + rejectNum++; + + // watchdog + if (rejectNum < 50) + emit requestNewImage(); + else + LogHandler::getInstance()->reportError( QObject::tr("BackgroundPainterConfigWidget: too many reject files => please change settings of add more hi-resolution images !!") ); + return; + } + } + rejectNum = 0; // reset the reject counter + + QImage wallp = m_painter.processImage(m_previewImage); + + //wallp.save("C:\\Users\\xbee\\AppData\\Local\\TheHive\\SyncWall\\ori.png"); + QList listGamingArea = m_desktopScene->getGamingAreaList(); + + //qDebug() << "BackgroundPainterConfigWidget::processImage = " << listGamingArea; + + if (m_painter.getMultiMonitorSupportType() != BackgroundPainter::MULTIMONITOR_ONE_IMAGE_BY_MONITOR) + { + QImage res = m_painter.cropAndMerge(wallp,listGamingArea); + emit newImage(res); + } + else + { + QList res = m_painter.cropAndSplit(wallp,listGamingArea); + emit newImages(res); + } + + previewImage(file); // load m_previewImage + + // encode configuration and send it to client + emit newConfiguration( encodeConfiguration(file) ); +} + +void BackgroundPainterConfigWidget::on_checkBoxShareScreen_stateChanged ( int state ) +{ + m_painter.setShareImageBetweenScreen(state); + + ui->checkBoxShareScreen->setChecked( m_painter.getShareImageBetweenScreen() ); + + // enable only if several screens detected ... + ui->comboBoxMultiMonitor->setEnabled( QApplication::desktop()->screenCount() > 1 && m_painter.getShareImageBetweenScreen() ); + + // enable tips label if needed + ui->labelTips->setEnabled(state == Qt::Checked); + + emit parametersChange(); + + updateDesktop(); +} + +void BackgroundPainterConfigWidget::on_checkBoxInverseGradient_stateChanged ( int state ) +{ + if ( (bool)state == m_painter.getInverseGradient() ) + return; + + m_painter.setInverseGradient(state); + previewImage(); +} + +void BackgroundPainterConfigWidget::on_checkBoxIgnoreParameters_stateChanged ( int state ) +{ + m_ignoreParameters = state; +} + +void BackgroundPainterConfigWidget::on_checkBoxExportParameters_stateChanged ( int state ) +{ + m_exportParameters = state; +} + +void BackgroundPainterConfigWidget::on_checkBoxSkipTooSmallImage_stateChanged ( int state ) +{ + m_skipTooSmallImage = state; +} + +void BackgroundPainterConfigWidget::on_checkBoxRotateWithMetadata_stateChanged ( int state ) +{ + m_rotateFromMetadata = state; +} + +void BackgroundPainterConfigWidget::on_comboBoxResizingType_activated(int index) +{ + if ( index == m_painter.getResizingType() ) + return; + + m_painter.setResizingType(index); + ui->comboBoxAlignmentTypeVertical->setEnabled( + index != BackgroundPainter::SCALE_IGNORE_ASPECT && + index != BackgroundPainter::SCALE_KEEP_ASPECT + ); + ui->comboBoxAlignmentTypeHorizontal->setEnabled( + index != BackgroundPainter::SCALE_IGNORE_ASPECT && + index != BackgroundPainter::SCALE_KEEP_ASPECT + ); + + ui->comboBoxFillingType->setEnabled( + index != BackgroundPainter::SCALE_IGNORE_ASPECT && + index != BackgroundPainter::SCALE_KEEP_EXPANDED_ASPECT + ); + + ui->checkBoxSkipTooSmallImage->setEnabled(index == BackgroundPainter::SCALE_IGNORE_ASPECT || + index == BackgroundPainter::SCALE_KEEP_EXPANDED_ASPECT + ); + + emit parametersChange(); + + previewImage(); +} + +void BackgroundPainterConfigWidget::on_comboBoxMultiMonitor_activated(int index) +{ + if ( index == m_painter.getMultiMonitorSupportType() ) + return; + + m_painter.setMultiMonitorSupportType(index); + + emit parametersChange(); + + updateDesktop(); +} + +void BackgroundPainterConfigWidget::on_comboBoxAlignmentTypeVertical_activated(int index) +{ + if ( index == m_painter.getVerticalAlignmentType() ) + return; + + m_painter.setVerticalAlignmentType(index); + + emit parametersChange(); + + previewImage(); +} + +void BackgroundPainterConfigWidget::on_comboBoxAlignmentTypeHorizontal_activated(int index) +{ + if ( index == m_painter.getHorizontalAlignmentType() ) + return; + + m_painter.setHorizontalAlignmentType(index); + + emit parametersChange(); + + previewImage(); +} + +void BackgroundPainterConfigWidget::on_comboBoxSpecialEffect_activated(int index) +{ + if ( index == m_painter.getSpecialEffectType() ) + return; + + m_painter.setSpecialEffectType(index); + ui->doubleSpinBoxSpecialEffectParam->setEnabled( m_painter.hasSpecialEffectParameter(index) ); + previewImage(); +} + +void BackgroundPainterConfigWidget::on_doubleSpinBoxSpecialEffectParam_valueChanged(double val) +{ + if ( val == m_painter.getSpecialEffectParameter() ) + return; + + m_painter.setSpecialEffectParameter(val); + previewImage(); +} + +void BackgroundPainterConfigWidget::on_comboBoxSamplingMethod_activated(int index) +{ + if ( index == m_painter.getSmoothAlgorithm() ) + return; + + m_painter.setSmoothAlgorithm(index); + + previewImage(); +} + +void BackgroundPainterConfigWidget::on_comboBoxFillingType_activated(int index) +{ + if ( index == m_painter.getFillingType() ) + return; + + m_painter.setFillingType(index); + ui->pushButtonPreviewColor1->setEnabled(index == BackgroundPainter::FILL_BY_COLOR || + index == BackgroundPainter::FILL_BY_VERTICAL_GRADIENT || + index == BackgroundPainter::FILL_BY_HORIZONTAL_GRADIENT || + index == BackgroundPainter::FILL_BY_RADIAL_GRADIENT + ); + ui->pushButtonPreviewColor2->setEnabled(index == BackgroundPainter::FILL_BY_VERTICAL_GRADIENT || + index == BackgroundPainter::FILL_BY_HORIZONTAL_GRADIENT || + index == BackgroundPainter::FILL_BY_RADIAL_GRADIENT + ); + ui->checkBoxInverseGradient->setEnabled(index == BackgroundPainter::FILL_BY_VERTICAL_GRADIENT || + index == BackgroundPainter::FILL_BY_HORIZONTAL_GRADIENT || + index == BackgroundPainter::FILL_BY_RADIAL_GRADIENT + ); + previewImage(); +} + +void BackgroundPainterConfigWidget::on_pushButtonPreviewColor1_pressed() +{ + QColor prevColor = ui->pushButtonPreviewColor1->palette().color(QPalette::Button); + QColor c = QColorDialog::getColor(prevColor); + + if (c == prevColor) + return; + + setButtonColor(c,ui->pushButtonPreviewColor1); + m_painter.setFillingColor1(c); + previewImage(); +} + +void BackgroundPainterConfigWidget::on_pushButtonPreviewColor2_pressed() +{ + QColor prevColor = ui->pushButtonPreviewColor2->palette().color(QPalette::Button); + QColor c = QColorDialog::getColor(prevColor); + + if (c == prevColor) + return; + + setButtonColor(c,ui->pushButtonPreviewColor2); + m_painter.setFillingColor2(c); + previewImage(); +} + +void BackgroundPainterConfigWidget::setButtonColor(const QColor &c, QPushButton *b) +{ + if ( c.isValid() && b) + { + QPalette palette = b->palette(); + palette.setColor(QPalette::Button, c); + b->setPalette(palette); // to easily save the color + } +} + +void BackgroundPainterConfigWidget::loadSettings() +{ + AppSettings settings; + + settings.beginGroup("ScreensConfig"); + + // screens + int size = settings.beginReadArray("screens"); + + for (int i = 0; i < size; ++i) + { + settings.setArrayIndex(i); + int num = settings.value("num").toInt(); + int marginTop = settings.value("marginTop").toInt(); + int marginBottom = settings.value("marginBottom").toInt(); + int marginLeft = settings.value("marginLeft").toInt(); + int marginRight = settings.value("marginRight").toInt(); + QPointF pos = settings.value("pos").toPointF(); + + if ( num <= m_screens.size() && num > 0 ) + { + m_screens.at(num - 1)->setMargings(marginTop,marginBottom,marginLeft,marginRight); + m_screens.at(num - 1)->setPos(pos); // to restore good placement + } + } + + settings.endArray(); + + settings.endGroup(); + + settings.beginGroup("ClientServerConnection"); + m_exportParameters = settings.value("exportParameters",true).toBool(); + m_ignoreParameters = settings.value("ignoreParameters",false).toBool(); + settings.endGroup(); + + settings.beginGroup("BackgroundPainter"); + m_skipTooSmallImage = settings.value("skipTooSmallImage",false).toBool(); + m_rotateFromMetadata = settings.value("rotateFromMetadata",false).toBool(); + + settings.endGroup(); +} + +void BackgroundPainterConfigWidget::saveSettings() +{ + AppSettings settings; + + settings.beginGroup("ScreensConfig"); + + // screens + settings.beginWriteArray( "screens", m_screens.count() ); + + for (int i = 0; i < m_screens.size(); ++i) + { + settings.setArrayIndex(i); + settings.setValue( "num", m_screens.at(i)->getNumber() ); + settings.setValue( "marginTop", m_screens.at(i)->getMarginTop() ); + settings.setValue( "marginBottom", m_screens.at(i)->getMarginBottom() ); + settings.setValue( "marginLeft", m_screens.at(i)->getMarginLeft() ); + settings.setValue( "marginRight", m_screens.at(i)->getMarginRight() ); + settings.setValue( "pos", m_screens.at(i)->pos() ); + } + + settings.endArray(); + + settings.endGroup(); + + settings.beginGroup("ClientServerConnection"); + + settings.setValue("exportParameters",m_exportParameters); + settings.setValue("ignoreParameters",m_ignoreParameters); + + settings.endGroup(); + + settings.beginGroup("BackgroundPainter"); + settings.setValue("skipTooSmallImage",m_skipTooSmallImage); + settings.setValue("rotateFromMetadata",m_rotateFromMetadata); + + //settings.setValue("lastFile",m_lastFile); + + settings.endGroup(); + + m_painter.saveSettings(); +} + +void BackgroundPainterConfigWidget::decodeAndApplyMessage(const QString &mess) +{ + QStringList list = mess.split('|'); + QString version = list[0]; + if (version == "1.1") + { + bool hasParameters = (list.size() == 10) ? true : false; + bool hasJustHeader = (list.size() == 2) ? true : false; + if (!hasParameters && !hasJustHeader) + { + LogHandler::getInstance()->reportError( QObject::tr("BackgroundPainterConfigWidget: Message with invalid nb of parameters (%1 instead of %2)").arg( list.size() ).arg( 10 ) ); + return; + } + + int index = 1; + QString file = list[index++]; + bool somethingDiffer = ( file != MiscFunctions::getSignificantPart(m_lastFile) ); // check if new request is different from previous + if (hasParameters && !m_ignoreParameters) + { + // m_painter.setResizingType() + somethingDiffer |= ( m_painter.getResizingType() != list[index].toInt() ); + m_painter.setResizingType( list[index++].toInt() ); + + // m_painter.setVerticalAlignmentType() + somethingDiffer |= ( m_painter.getVerticalAlignmentType() != list[index].toInt() ); + m_painter.setVerticalAlignmentType( list[index++].toInt() ); + + // m_painter.setHorizontalAlignmentType() + somethingDiffer |= ( m_painter.getHorizontalAlignmentType() != list[index].toInt() ); + m_painter.setHorizontalAlignmentType( list[index++].toInt() ); + + // m_painter.setFillingType() + somethingDiffer |= ( m_painter.getFillingType() != list[index].toInt() ); + m_painter.setFillingType( list[index++].toInt() ); + + // m_painter.getFillingColor1 + somethingDiffer |= ( m_painter.getFillingColor1() != QColor(list[index]) ); + m_painter.setFillingColor1( QColor(list[index++]) ); + + // m_painter.getFillingColor2 + somethingDiffer |= ( m_painter.getFillingColor2() != QColor(list[index]) ); + m_painter.setFillingColor2( QColor(list[index++]) ); + + // m_painter.setInverseGradient + somethingDiffer |= ( m_painter.getInverseGradient() != (bool)list[index].toInt() ); + m_painter.setInverseGradient( (bool)list[index++].toInt() ); + + // m_painter.setSpecialEffectType() + somethingDiffer |= ( m_painter.getSpecialEffectType() != list[index].toInt() ); + m_painter.setSpecialEffectType( list[index++].toInt() ); + + // m_painter.setSpecialEffectParameter(); + somethingDiffer |= ( m_painter.getSpecialEffectParameter() != list[index].toFloat() ); + m_painter.setSpecialEffectParameter( list[index++].toFloat() ); + + // m_painter.setSmoothAlgorithm(); + somethingDiffer |= ( m_painter.getSmoothAlgorithm() != list[index].toInt() ); + m_painter.setSmoothAlgorithm( list[index++].toInt() ); + } + + if (somethingDiffer) + { + applyConfig(); + emit decodedImage(file); + } + } + else + { + LogHandler::getInstance()->reportError( QObject::tr("BackgroundPainterConfigWidget: Message with unknown version received (%1)").arg( version ) ); + } +} + +QString BackgroundPainterConfigWidget::encodeConfiguration(const QString &file) +{ + // version string + QString mess = "1.1"; + + // file + mess += "|" + MiscFunctions::getSignificantPart(file); + + // export image parameters to client ? + if (!m_exportParameters) + return mess; + + // m_painter.getResizingType() + mess += QString("|%1").arg( m_painter.getResizingType() ); + + // m_painter.getVerticalType() + mess += QString("|%1").arg( m_painter.getVerticalAlignmentType() ); + + // m_painter.getHorizontalAlignmentType() + mess += QString("|%1").arg( m_painter.getHorizontalAlignmentType() ); + + // m_painter.getFillingType() + mess += QString("|%1").arg( m_painter.getFillingType() ); + + // m_painter.getFillingColor1 + mess += QString("|%1").arg( m_painter.getFillingColor1().name() ); + + // m_painter.getFillingColor1 + mess += QString("|%1").arg( m_painter.getFillingColor2().name() ); + + // m_painter.getInverseGradient + mess += QString("|%1").arg( m_painter.getInverseGradient() ); + + // m_painter.getSpecialEffectType() + // special RANDOM_EFFECT + if (m_painter.getSpecialEffectType() != BackgroundPainter::EFFECT_RANDOM) + mess += QString("|%1").arg( m_painter.getSpecialEffectType() ); + else // send computed effect + mess += QString("|%1").arg( m_painter.getLastSpecialEffectType() ); + + // m_painter.getSpecialEffectParameter(); + mess += QString("|%1").arg( m_painter.getSpecialEffectParameter() ); + + // m_painter.getSmoothAlgorithm(); + mess += QString("|%1").arg( m_painter.getSmoothAlgorithm() ); + + return mess; +} + +bool BackgroundPainterConfigWidget::isUserMoveAllowed() const +{ + return m_painter.getResizingType() == BackgroundPainter::SCALE_KEEP_EXPANDED_ASPECT && m_painter.getShareImageBetweenScreen(); +} + +void BackgroundPainterConfigWidget::setUserOffset(const QPoint &offset) +{ + m_desktopScene->setUserOffset(offset); + m_painter.setUserOffset(offset); +} + +QPointF BackgroundPainterConfigWidget::validCurrentUserPositioning() +{ + QPointF offset( -m_desktopScene->getUserOffset() ); + m_painter.setUserOffset(offset); + + previewImage(); + return offset; +} + +int BackgroundPainterConfigWidget::getScreenNumberByConfig() const +{ + if ( m_painter.getShareImageBetweenScreen() && (m_painter.getMultiMonitorSupportType() != BackgroundPainter::MULTIMONITOR_NO_MULTIMONITOR) ) + return QApplication::desktop()->screenCount(); + else + return 1; +} diff -Nru syncwall-1.6.0/src/BackgroundPainterConfigWidget.h syncwall-1.7.4/src/BackgroundPainterConfigWidget.h --- syncwall-1.6.0/src/BackgroundPainterConfigWidget.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/BackgroundPainterConfigWidget.h 2013-05-05 23:37:34.000000000 +0000 @@ -0,0 +1,139 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ +#ifndef _BACKGROUNDPAINTERCONFIGWIDGET_H_ +#define _BACKGROUNDPAINTERCONFIGWIDGET_H_ + +#include + +#include "BackgroundPainter.h" + +// forward declarations +class DesktopScene; +class ScreenItem; + +class QPushButton; + +namespace Ui +{ +class BackgroundPainterConfigWidget; +} + +class BackgroundPainterConfigWidget : public QWidget +{ + Q_OBJECT + +public: + + explicit BackgroundPainterConfigWidget(QWidget *parent = 0); + ~BackgroundPainterConfigWidget(); + + DesktopScene *getScenePreview() const { return m_desktopScene; } + bool isUserMoveAllowed() const; + + void processImage(const QString &,bool manual = false); + + //! valid the current position of the image (user defined) + QPointF validCurrentUserPositioning(); + + //! get the number of screen take into account by current configuration + int getScreenNumberByConfig() const; + + void setUserOffset(const QPoint &); + +public slots: + + void decodeAndApplyMessage(const QString &); + + void saveSettings(); + + void updateScreenConfig(int); + + void previewImage( const QString &file = QString() ); + +signals: + + //! request a new image to display according to user parameter (current one don't match) + void requestNewImage(); + + //! send computed image(s) to display + void newImage(const QImage &); + void newImages(const QList &); + + //! send new configuration string to client + void newConfiguration(const QString &); + + //! send decoded image from server string to display + void decodedImage(const QString &); + + //! send that user change parameters + void parametersChange(); + +private slots: + + void on_checkBoxShareScreen_stateChanged ( int state ); + void on_checkBoxInverseGradient_stateChanged ( int state ); + void on_checkBoxIgnoreParameters_stateChanged ( int state ); + void on_checkBoxExportParameters_stateChanged ( int state ); + void on_comboBoxResizingType_activated(int index); + void on_comboBoxAlignmentTypeVertical_activated(int index); + void on_comboBoxAlignmentTypeHorizontal_activated(int index); + void on_comboBoxFillingType_activated(int index); + void on_comboBoxSpecialEffect_activated(int index); + void on_pushButtonPreviewColor1_pressed(); + void on_pushButtonPreviewColor2_pressed(); + void on_doubleSpinBoxSpecialEffectParam_valueChanged(double); + void on_comboBoxMultiMonitor_activated(int); + void on_checkBoxSkipTooSmallImage_stateChanged ( int state ); + void on_checkBoxRotateWithMetadata_stateChanged ( int state ); + void on_comboBoxSamplingMethod_activated(int index); + +private: + + void loadSettings(); + + void updateUI(); + void applyConfig(); + void createDesktop(); + void updateDesktop(); + void initResizingType(); + void initAlignmentType(); + void initMultiMonitorSupportType(); + void initFillingType(); + void initSamplingMethod(); + void initSpecialEffectType(); + void setButtonColor(const QColor &c, QPushButton *b); + QString encodeConfiguration(const QString &); + + Ui::BackgroundPainterConfigWidget *ui; + + BackgroundPainter m_painter; + DesktopScene *m_desktopScene; + QImage m_previewImage; + QString m_previewFile; + + QList m_screens; + bool m_exportParameters; + bool m_ignoreParameters; + bool m_skipTooSmallImage; + bool m_rotateFromMetadata; + QString m_lastFile; +}; + +#endif // _BACKGROUNDPAINTERCONFIGWIDGET_H_ diff -Nru syncwall-1.6.0/src/DatabaseManager.cpp syncwall-1.7.4/src/DatabaseManager.cpp --- syncwall-1.6.0/src/DatabaseManager.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/DatabaseManager.cpp 2013-05-05 23:37:32.000000000 +0000 @@ -0,0 +1,260 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#include +#include +#include +#include + +#include +#include + +#include "DatabaseManager.h" + +#include "AppSettings.h" +#include "LogHandler.h" +#include "MiscFunctions.h" +#include "ImageInfos.h" + +#if !defined(WIN32) +#include // for unlink +#endif + +DatabaseManager::DatabaseManager(QObject *parent) : + QObject(parent), + m_valid(false), + m_driverName("") +{ + init(); +} + +DatabaseManager::~DatabaseManager() +{ + m_valid = false; + m_db.close(); +} + +bool DatabaseManager::isValid() const +{ + return m_valid; +} + +void DatabaseManager::init() +{ + QStringList neededDrivers(QStringList() << "QSQLITE" << "QSQLITE3"); + + foreach (const QString &driverName, neededDrivers) + { + if ( QSqlDatabase::isDriverAvailable(driverName) ) + { + m_driverName = driverName; + break; + } + } + + if (m_driverName.isEmpty()) + { + LogHandler::getInstance()->reportError( tr("No SQLITE driver available") ); + return; + } + + m_database = MiscFunctions::getValidStorage() + QString("/%1.sqlite").arg(PACKAGE_NAME).toLower(); + + LogHandler::getInstance()->reportInfo( tr("DatabaseManager::init: open db %1 ...").arg(m_database) ); + if ( !QFileInfo(m_database).exists() && !createDB() ) + return; + + m_valid = openDB(); +} + +bool DatabaseManager::initDB() +{ + m_db = QSqlDatabase::addDatabase(m_driverName); + m_db.setDatabaseName(m_database); + if ( !m_db.open() ) + { + LogHandler::getInstance()->reportError( tr("DatabaseManager::createDB: db connection failed ... (%1)").arg( m_db.lastError().text() ) ); + return false; + } + + QSqlQuery query(m_db); + + // init db + query.exec("PRAGMA journal_mode = OFF"); + + return true; +} + +void DatabaseManager::clearDB() +{ + if (m_valid) + m_db.close(); + unlink( m_database.toStdString().c_str() ); + init(); +} + +bool DatabaseManager::createDB() +{ + if ( !initDB() ) + return false; + + QSqlQuery query(m_db); + + // set default version + query.exec( QString("pragma user_version = %1").arg(PACKAGE_DB_VERSION) ); + + QString request = QString("create table ImageInfos (") + + " url text primary key, " + + " size integer, " + + " width integer, " + + " height integer, " + + " rate integer, " + + " offsetmap text, " + + " lastModification text, " + + " timestamp integer, " + + " thumb blob default null)"; + + // create table + if ( !query.exec(request) ) + { + m_db.close(); + LogHandler::getInstance()->reportError( tr("DatabaseManager::createDB: cannot create table ... (%1)").arg( query.lastError().text() ) ); + return false; + } + m_db.close(); + return true; +} + +bool DatabaseManager::openDB() +{ + if ( !initDB() ) + return false; + + QSqlQuery query(m_db); + + if ( query.exec("pragma user_version") ) + { + query.next(); + + int user_version = query.value(0).toInt(); + + if ( user_version != QString("%1").arg(PACKAGE_DB_VERSION).toInt() ) + { + m_db.close(); + LogHandler::getInstance()->reportError( tr("DatabaseManager::openDB: database version don't match current one !") ); + return false; + } + } + return true; +} + +void DatabaseManager::retrieveInfos(ImageInfos *infos) +{ + if (!infos || !m_valid) + return; + + QSqlQuery query; + + if ( query.exec( QString("select url, size, width, height, rate, offsetmap, lastModification, thumb from ImageInfos where url = '%1'").arg( infos->getFilename() ) ) ) + { + if ( query.next() ) + { + QString file = query.value(0).toString(); + int size = query.value(1).toInt(); + int width = query.value(2).toInt(); + int height = query.value(3).toInt(); + int rate = query.value(4).toInt(); + QString offsetmap = query.value(5).toString(); + QString lastModification = query.value(6).toString(); + QByteArray ba = query.value(7).toByteArray(); + + QImage img; + img.loadFromData(ba); + + infos->setHeight(height); + infos->setWidth(width); + infos->setRate(rate); + infos->setOffsetMap(offsetmap); + infos->setLastModificationTime(lastModification); + infos->setFileSize(size); + infos->setThumbnail(img); + } + } +} + +void DatabaseManager::removeInfos(const QString &url) +{ + if (!m_valid) + return; + + QSqlQuery query; + + if ( !query.exec( QString("DELETE FROM ImageInfos WHERE url = '%1'").arg(url) ) ) + { + LogHandler::getInstance()->reportError( tr("DatabaseManager::removeInfos: Error when removing data for %2 (%1) ").arg(url).arg( query.lastError().text() ) ); + return; + } +} + +void DatabaseManager::storeInfos(ImageInfos *infos) +{ + if (!infos || !m_valid) + return; + + QSqlQuery query; + + /* + " url text primary key, " + + " size integer, " + + " width integer, " + + " height integer, " + + " lastModification text, " + " timestamp integer, " + + */ + + int now = QDateTime::currentDateTime().toTime_t(); + + if ( !query.prepare( QString("REPLACE INTO ImageInfos (url, size, width, height, rate, offsetmap, lastModification, timestamp, thumb ) VALUES (:url, :size, :width, :height, :rate, :offsetmap, :lastModification, :timestamp, :thumb)") ) ) + { + LogHandler::getInstance()->reportError( tr("DatabaseManager::storeInfos: Error in query preparation ... (%1) ").arg( query.lastError().text() ) ); + return; + } + + query.bindValue( ":url", infos->getFilename() ); + query.bindValue( ":size", infos->getFileSize() ); + query.bindValue( ":width", infos->getWidth() ); + query.bindValue( ":height", infos->getHeight() ); + query.bindValue( ":rate", infos->getRate() ); + query.bindValue( ":offsetmap", infos->getOffsetMap() ); + query.bindValue( ":lastModification", infos->getLastModificationAsString() ); + query.bindValue(":timestamp", now); + + QImage thumb( infos->getThumbnail() ); + QByteArray bytes; + QBuffer buffer(&bytes); + buffer.open(QIODevice::WriteOnly); + thumb.save(&buffer, "PNG"); + + query.bindValue(":thumb", bytes); + + if ( !query.exec() ) + LogHandler::getInstance()->reportError( tr("DatabaseManager::storeInfos: Error in query execution ... (%1)").arg( query.lastError().text() ) ); + +} diff -Nru syncwall-1.6.0/src/DatabaseManager.h syncwall-1.7.4/src/DatabaseManager.h --- syncwall-1.6.0/src/DatabaseManager.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/DatabaseManager.h 2013-05-05 23:37:34.000000000 +0000 @@ -0,0 +1,61 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#ifndef _DATABASE_MANAGER_H_ +#define _DATABASE_MANAGER_H_ + +#include + +#include + +class ImageInfos; + +class DatabaseManager : public QObject +{ + Q_OBJECT + +public: + + DatabaseManager(QObject *parent = 0); + virtual ~DatabaseManager(); + + bool isValid() const; + + void retrieveInfos(ImageInfos *infos); + void storeInfos(ImageInfos *infos); + void removeInfos(const QString &); + + //! Delete and reinit current database + void clearDB(); + +private: + + void init(); + bool initDB(); + bool createDB(); + bool openDB(); + + QString m_database; + QSqlDatabase m_db; + bool m_valid; + QString m_driverName; +}; + +#endif // _DATABASE_MANAGER_H_ diff -Nru syncwall-1.6.0/src/DesktopScene.cpp syncwall-1.7.4/src/DesktopScene.cpp --- syncwall-1.6.0/src/DesktopScene.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/DesktopScene.cpp 2013-05-05 23:37:32.000000000 +0000 @@ -0,0 +1,312 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#include "DesktopScene.h" +#include "ScreenItem.h" +#include "BackgroundItem.h" + +#include +#include +#include + +const int displayedMargin = 2; + +bool lessThanCenter(const QGraphicsItem *s1, const QGraphicsItem *s2) +{ + QPointF p1 = s1->pos(); + QPointF p2 = s2->pos(); + return p1.x() < p2.x(); +} + +DesktopScene::DesktopScene(QObject * parent) + : QGraphicsScene(parent), + m_hasMove(false), + m_state(STATE_IDLE) +{ + setSceneRect(0,0,200, 200); + + // add a background item by default + BackgroundItem *item = new BackgroundItem; + addItem(item); +} + +DesktopScene::~DesktopScene() +{ +} + +void DesktopScene::addScreens(const QList &screens) +{ + int offset = 0; + foreach (ScreenItem * screen, screens) + { + addItem(screen); + + // decal for auto placement + if (screen->x() == 0) + screen->setX(offset); + offset += screen->boundingRect().width(); + } + reorder(); +} + +void DesktopScene::addScreen(ScreenItem *screen) +{ + addItem(screen); + + // decal for auto placement + screen->setX( screen->boundingRect().width() ); + reorder(); +} + +void DesktopScene::reorder() +{ + // search for cumulated width & height + QList list = items (); + + // sort list with x value => get the correct order for screen to be displayed + qSort(list.begin(),list.end(),lessThanCenter); + + // Get the higher screen for vertical alignment + int highest = 0; + foreach( QGraphicsItem * item, list ) + { + ScreenItem *screen = dynamic_cast(item); + if (screen) + highest = qMax( highest,screen->getSizeWithMargins ().height() ); + } + + // place all item now + int offsetX = 0; + int offsetY = 0; + + foreach( QGraphicsItem * item, list ) + { + ScreenItem *screen = dynamic_cast(item); + if (!screen) + continue; + + QSize size = screen->getSizeWithMargins (); + QPointF oldScenePos = screen->scenePos(); + QPointF oldPos = screen->pos(); + QRectF oldSceneRect = screen->sceneBoundingRect(); + + int posx = offsetX; + posx += size.width() / 2; // because center on (0,0) + int posy = offsetY; + posy += size.height() / 2; // because center on (0,0) + posy -= screen->getMarginBottom(); + + if (oldPos.y() > highest / 2) // bottom alignment + { + posy += ( highest - size.height() ); + } + + screen->setPos(posx,posy); + + offsetX += screen->getSizeWithMargins().width(); // + displayedMargin; + } + + emit reordering(); +} + +void DesktopScene::applyImage(const QImage &cropped,const QImage &full, const QSize &desktopSize, const QSize &realSize) +{ + foreach( QGraphicsItem * item, items () ) + { + ScreenItem *screen = dynamic_cast(item); + if (screen) + { + screen->setImage(cropped); + } + else + { + BackgroundItem *bg = dynamic_cast(item); + if (bg) + bg->setImage(full,realSize,desktopSize); + } + } +} + +void DesktopScene::setUserOffset(const QPoint &offset) +{ + foreach( QGraphicsItem * item, items () ) + { + BackgroundItem *bg = dynamic_cast(item); + if (bg) + bg->setOffset(offset); + } +} + +QPointF DesktopScene::getUserOffset() const +{ + QPointF offset(0,0); + + foreach( QGraphicsItem * item, items () ) + { + BackgroundItem *bg = dynamic_cast(item); + if ( bg && bg->isVisible() ) + offset = bg->getOffset(); + } + return offset; +} + +QList DesktopScene::getGamingAreaList() const +{ + QList gamingArea; + + QList list = items (); + + // search if background item is visible => get user offset + + // sort list with x value => get the correct order for screen to be displayed + qSort(list.begin(),list.end(),lessThanCenter); + + foreach( QGraphicsItem * item, list ) + { + ScreenItem *screen = dynamic_cast(item); + if (screen) + { + gamingArea << screen->getValidSceneBoundingRect(); + } + } + return gamingArea; +} + +QSize DesktopScene::getSize() const +{ + QSize size(0,0); + foreach( QGraphicsItem * item, items() ) + { + ScreenItem *screen = dynamic_cast(item); + if (screen) + { + size.rwidth() += screen->getSize().width(); + size.rheight() = qMax( size.height(), screen->getSize().height() ); + } + } + return size; +} + +QSize DesktopScene::getSizeWithMargins() const +{ + QSize size(0,0); + foreach( QGraphicsItem * item, items() ) + { + ScreenItem *screen = dynamic_cast(item); + if (screen) + { + size.rwidth() += screen->getRealSizeWithMargins().width(); + size.rheight() = qMax( size.height(), screen->getRealSizeWithMargins().height() ); + } + } + return size; +} + +void DesktopScene::mouseMoveEvent ( QGraphicsSceneMouseEvent * mouseEvent ) +{ + m_hasMove = true; + QGraphicsScene::mouseMoveEvent(mouseEvent); +} + +void DesktopScene::mouseReleaseEvent ( QGraphicsSceneMouseEvent * mouseEvent ) +{ + if (m_hasMove && m_state == STATE_MOVING_SCREEN) + reorder(); + QGraphicsScene::mouseReleaseEvent(mouseEvent); + m_hasMove = false; +} + +void DesktopScene::setSceneState(int state) +{ + m_state = state; + + foreach( QGraphicsItem * item, items () ) + { + ScreenItem *screen = dynamic_cast(item); + if (screen) + { + screen->setFlag(QGraphicsItem::ItemIsMovable,m_state == STATE_MOVING_SCREEN); + screen->setFlag(QGraphicsItem::ItemIsSelectable,m_state == STATE_MOVING_SCREEN); + screen->setFlag(QGraphicsItem::ItemIsFocusable,m_state == STATE_MOVING_SCREEN); + screen->setOpaque(m_state != STATE_MOVING_BACKGROUND); + } + else + { + BackgroundItem *bg = dynamic_cast(item); + if (bg) + { + bg->setVisible(m_state == STATE_MOVING_BACKGROUND); + bg->setFlag(QGraphicsItem::ItemIsMovable,m_state == STATE_MOVING_BACKGROUND); + bg->setFlag(QGraphicsItem::ItemIsSelectable,m_state == STATE_MOVING_BACKGROUND); + bg->setFlag(QGraphicsItem::ItemIsFocusable,m_state == STATE_MOVING_BACKGROUND); + } + } + } +} + +int DesktopScene::getSceneState() const +{ + return m_state; +} + +QRectF DesktopScene::getSceneRect () const +{ + if (m_state == STATE_MOVING_BACKGROUND) + { + foreach( QGraphicsItem * item, items () ) + { + BackgroundItem *bg = dynamic_cast(item); + if (bg) + { + // compute the enlarge scene bounding box + QRectF bgr = bg->boundingRect(); + QRectF sum( getScreensRect () ); + qreal diffWidth = bgr.width() - sum.width(); + qreal diffHeight = bgr.height() - sum.height(); + sum.setLeft(sum.left() - diffWidth); + sum.setTop(sum.top() - diffHeight); + sum.setBottom(sum.bottom() + diffHeight); + sum.setRight(sum.right() + diffWidth); + + return sum; + } + } + return QRectF (); + } + else + { + return getScreensRect (); + } +} + +QRectF DesktopScene::getScreensRect () const +{ + QRectF sum; + foreach( QGraphicsItem * item, items () ) + { + ScreenItem *screen = dynamic_cast(item); + if (screen) + { + QRectF rect = screen->sceneBoundingRect(); + sum |= rect; + } + } + return sum; +} diff -Nru syncwall-1.6.0/src/DesktopScene.h syncwall-1.7.4/src/DesktopScene.h --- syncwall-1.6.0/src/DesktopScene.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/DesktopScene.h 2013-05-05 23:37:34.000000000 +0000 @@ -0,0 +1,83 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#ifndef _DESKTOPSCENE_H_ +#define _DESKTOPSCENE_H_ + +#include +#include + +class ScreenItem; + +class DesktopScene : + public QGraphicsScene +{ + Q_OBJECT + +public: + + enum typeSceneState + { + STATE_IDLE = 0, + STATE_MOVING_SCREEN, + STATE_MOVING_BACKGROUND + }; + + DesktopScene(QObject * parent = 0); + ~DesktopScene(); + + QRectF getSceneRect () const; + QRectF getScreensRect () const; + + void addScreens(const QList &); + void addScreen(ScreenItem *); + void reorder(); + + QSize getSizeWithMargins() const; + QSize getSize() const; + + QList getGamingAreaList() const; + + void applyImage(const QImage &cropped, const QImage &full, const QSize &desktopSize, const QSize &realSize); + + void setSceneState(int); + int getSceneState() const; + + QPointF getUserOffset() const; + void setUserOffset(const QPoint &); + +signals: + + void reordering(); + +protected: + + virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * mouseEvent ); + virtual void mouseMoveEvent ( QGraphicsSceneMouseEvent * mouseEvent ); + +private: + + QSize m_size; + QRectF m_rect; + bool m_hasMove; + int m_state; +}; + +#endif // _DESKTOPSCENE_H_ diff -Nru syncwall-1.6.0/src/DesktopView.cpp syncwall-1.7.4/src/DesktopView.cpp --- syncwall-1.6.0/src/DesktopView.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/DesktopView.cpp 2013-05-05 23:37:32.000000000 +0000 @@ -0,0 +1,86 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#include "DesktopView.h" +#include "DesktopScene.h" + +//#include "ScreenItem.h" + +#include +#include +#include + +//#include + +DesktopView::DesktopView(QWidget * parent) + : QGraphicsView(parent) +{ + // a gradient background + //QLinearGradient lgradient(0, 0,1000,1000); // here 1000x1000 pixel !! + QRadialGradient lgradient(0.0,0.0,2000); + lgradient.setSpread(QGradient::PadSpread); + lgradient.setColorAt( 1, QColor("#4a4a4a") ); + lgradient.setColorAt( 0, QColor("#797979") ); + setBackgroundBrush(lgradient); + + setCacheMode( QGraphicsView::CacheBackground ); + + setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); + setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform); + + setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); + setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); + setFrameStyle( QFrame::NoFrame ); +} + +DesktopView::~DesktopView() +{ +} + +void DesktopView::resizeEvent(QResizeEvent* event) +{ + zoomToFit(); + QGraphicsView::resizeEvent(event); +} + +void DesktopView::zoomToFit() +{ + DesktopScene *scn = qobject_cast( scene() ); + + if (scn) + { + scn->setSceneRect( scn->getSceneRect() ); + fitInView(scene()->sceneRect(), Qt::KeepAspectRatio); + scene()->update( scene()->sceneRect() ); + scale(1 / 1.1, 1 / 1.1); + } +} + +void DesktopView::zoomIn() +{ + scale(1.1, 1.1); + emit zoomChanged(); +} + +void DesktopView::zoomOut() +{ + scale(1 / 1.1, 1 / 1.1); + emit zoomChanged(); +} diff -Nru syncwall-1.6.0/src/DesktopView.h syncwall-1.7.4/src/DesktopView.h --- syncwall-1.6.0/src/DesktopView.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/DesktopView.h 2013-05-05 23:37:34.000000000 +0000 @@ -0,0 +1,52 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#ifndef _DESKTOPVIEW_H_ +#define _DESKTOPVIEW_H_ + +#include +#include + +class DesktopView : + public QGraphicsView +{ + Q_OBJECT + +public: + + DesktopView(QWidget * parent = 0); + ~DesktopView(); + + void zoomOut(); + void zoomIn(); + void zoomToFit(); + +signals: + + void zoomChanged(); + +protected: + + void resizeEvent(QResizeEvent* event); + +private: +}; + +#endif // _DESKTOPVIEW_H_ diff -Nru syncwall-1.6.0/src/IMessageHandler.h syncwall-1.7.4/src/IMessageHandler.h --- syncwall-1.6.0/src/IMessageHandler.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/IMessageHandler.h 2013-05-05 23:37:34.000000000 +0000 @@ -0,0 +1,70 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#ifndef _IMESSAGEHANDLER_H_ +#define _IMESSAGEHANDLER_H_ + +#include + +//! The Message handler, which can be implemented by the client + +class IMessageHandler +{ +public: + + enum MessageLevel + { + MSG_DEBUG = 0, /*!< Message only for debugging purpose. */ + MSG_INFO, /*!< Information message. */ + MSG_WARNING, /*!< Warning, abnormal event. */ + MSG_ERROR /*!< Error, invalid file. */ + }; + + //! Virtual destructor + virtual ~IMessageHandler() {} + + //! This method is called when a message is to be reported to the client + virtual void reportMessage( MessageLevel level, const QString & message ) = 0; + + //! Report only a debug message + virtual void reportDebug(const QString & message ) = 0; + + //! Report only a debug message + virtual void reportInfo(const QString & message ) = 0; + + //! Report only a debug message + virtual void reportWarning(const QString & message ) = 0; + + //! Report only a debug message + virtual void reportError(const QString & message ) = 0; +}; + +//! Sets the error handler to be used for error and warning reporting + +/*! + * This allows the user to set the current Message handler. If the + * parameter is NULL, API reverts back to the default error handler, + * which redirects all warnings and errors to std::cerr. + * + * \sa IMessageHandler + */ +void setMessageHandler( IMessageHandler* Hdl ); + +#endif // _IMESSAGEHANDLER_H_ diff -Nru syncwall-1.6.0/src/IconViewDelegate.cpp syncwall-1.7.4/src/IconViewDelegate.cpp --- syncwall-1.6.0/src/IconViewDelegate.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/IconViewDelegate.cpp 2013-05-05 23:37:32.000000000 +0000 @@ -0,0 +1,46 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#include +#include + +#include "IconViewDelegate.h" + +IconViewDelegate::IconViewDelegate(QObject * parent) : QStyledItemDelegate(parent) +{ +} + +IconViewDelegate::~IconViewDelegate() +{ +} + +// Define item size in listview. +QSize IconViewDelegate::sizeHint(const QStyleOptionViewItem & /*option*/, + const QModelIndex & index) const +{ + QPixmap pix = qvariant_cast( index.data(Qt::DecorationRole) ); + QSize iconsize = pix.size(); + + //QSize iconsize = option.decorationSize; + QFont font = QApplication::font(); + QFontMetrics fm(font); + + return( QSize(iconsize.width(),iconsize.height() + 2 * fm.height() + 8 ) ); +} diff -Nru syncwall-1.6.0/src/IconViewDelegate.h syncwall-1.7.4/src/IconViewDelegate.h --- syncwall-1.6.0/src/IconViewDelegate.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/IconViewDelegate.h 2013-05-05 23:37:34.000000000 +0000 @@ -0,0 +1,36 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#ifndef IconViewDelegate_H_ +#define IconViewDelegate_H_ +#include + +class IconViewDelegate : public QStyledItemDelegate +{ +public: + + IconViewDelegate(QObject * parent = 0); + virtual ~IconViewDelegate(); + + QSize sizeHint(const QStyleOptionViewItem &option, + const QModelIndex & index ) const; +}; + +#endif /* IconViewDelegate_H_ */ diff -Nru syncwall-1.6.0/src/ImageInfos.cpp syncwall-1.7.4/src/ImageInfos.cpp --- syncwall-1.6.0/src/ImageInfos.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/ImageInfos.cpp 2013-05-05 23:37:32.000000000 +0000 @@ -0,0 +1,223 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#include +#include +#include + +#include +#include + +#include "ImageInfos.h" +#include "LogHandler.h" + +const int thumbnailSize = 100; +const int ImageInfos::maxRating = 5; + +ImageInfos::ImageInfos(const QString &file) : + m_filename(file) +{ + reset(); +} + +ImageInfos::~ImageInfos() +{ +} + +void ImageInfos::reset() +{ + m_changed = true; + m_key = m_filename; + QFileInfo infos(m_filename); + m_name = infos.baseName(); + m_completeName = infos.completeBaseName(); + m_fileSize = 0; + m_width = 0; + m_height = 0; + m_rate = 1; + m_mapOffset.clear(); + m_lastModification = QDateTime::fromString("0-0-0"); + m_thumbnail = computeSubImage(); +} + +bool ImageInfos::update() +{ + QFileInfo infos(m_filename); + + // file don't change so exit (must do approximative compare for date rounding effect !!) + if ( infos.lastModified() <= m_lastModification.addSecs(1) ) + return false; + + m_lastModification = infos.lastModified(); + m_thumbnail = computeSubImage( QImage(m_filename) ); + computeLabel(); + + m_fileSize = infos.size(); + m_txtFileSize = sizeToString(m_fileSize); + + return true; +} + +QString ImageInfos::sizeToString(quint64 size) const +{ + QString bytesStr; + if ( !(size >> 10) ) + bytesStr = QString::number(size) + ' ' + QObject::tr("Bytes"); + else if ( !(size >> 20) ) + bytesStr = QString::number(size / 1024.0, 'f', 3) + ' ' + QObject::tr("KB"); + else if ( !(size >> 30) ) + bytesStr = QString::number( (size >> 10) / 1024.0, 'f', 3 ) + ' ' + QObject::tr("MB"); + else if ( !(size >> 40) ) + bytesStr = QString::number( (size >> 20) / 1024.0, 'f', 3 ) + ' ' + QObject::tr("GB"); + else + bytesStr = QString::number( (size >> 30) / 1024.0, 'f', 3 ) + ' ' + QObject::tr("TB"); + + return bytesStr; +} + +QImage ImageInfos::computeSubImage(const QImage &image) +{ + // compute thumbnail if needed + QImage img(image); + if ( img.isNull() ) + { + img = QImage(":/syncwall/default.png"); + } + else + { + m_width = img.width(); + m_height = img.height(); + + // compute the file size if available + QString valx = QString::number( img.width() ); + QString valy = QString::number( img.height() ); + m_imageSize = QString("%1x%2").arg(valx).arg(valy); + } + + return img.scaled(thumbnailSize, thumbnailSize, Qt::KeepAspectRatio); +} + +void ImageInfos::setLastModificationTime(const QString &t) +{ + m_lastModification = QDateTime::fromString(t); +} + +void ImageInfos::setHeight(int h) +{ + m_height = h; + m_imageSize = QString("%1x%2").arg(m_width).arg(m_height); + computeLabel(); +} + +void ImageInfos::setWidth(int w) +{ + m_width = w; + m_imageSize = QString("%1x%2").arg(m_width).arg(m_height); + computeLabel(); +} + +void ImageInfos::setFileSize(int s) +{ + m_fileSize = s; + m_txtFileSize = sizeToString(m_fileSize); +} + +void ImageInfos::setThumbnail(const QImage &img) +{ + m_thumbnail = img; +} + +void ImageInfos::computeLabel() +{ + QString elidedName = QApplication::fontMetrics().elidedText( m_completeName, Qt::ElideLeft, thumbnailSize - 20); + m_label = QString("%1\n(%2)").arg(elidedName).arg(m_imageSize); + if (m_rate > 1) + { + m_label += " "; + for (int i = 0; i < m_rate; i++) + m_label += "*"; + } +} + +void ImageInfos::setRate(int rate) +{ + if (rate < 1) + m_rate = 1; + else if (rate > maxRating) + m_rate = maxRating; + else + m_rate = rate; + computeLabel(); +} + +QString ImageInfos::getOffsetMap() const +{ + QString str; + QList screens = m_mapOffset.keys(); + + for (int i = 0; i < screens.size(); ++i) + str += QString("%1;%2,%3|").arg(screens[i]).arg( m_mapOffset[screens[i]].x() ).arg( m_mapOffset[screens[i]].y() ); + + return str; +} + +void ImageInfos::setOffsetMap(const QString &map) +{ + m_mapOffset.clear(); + + if ( map.isEmpty() ) + return; + + QRegExp rx("(\\d+);(\\d+),(\\d+)|"); + + int pos = 0; + while ( ( pos = rx.indexIn(map, pos) ) != -1 ) + { + int nbScr = rx.cap(1).toInt(); + int offx = rx.cap(2).toInt(); + int offy = rx.cap(3).toInt(); + m_mapOffset[nbScr] = QPoint(offx,offy); + pos += rx.matchedLength() + 1; + } +} + +bool ImageInfos::isOffsetDefined(int nbScr) const +{ + return m_mapOffset.contains(nbScr); +} + +QString ImageInfos::getOffsetAsString(int nbScr) const +{ + QString res; + if ( m_mapOffset.contains(nbScr) ) + res = QString("%1;%2").arg( m_mapOffset[nbScr].x() ).arg( m_mapOffset[nbScr].y() ); + return res; +} + +QPoint ImageInfos::getOffset(int nbScr) const +{ + return m_mapOffset[nbScr]; +} + +void ImageInfos::setOffset(const QPoint &p, int nbScr) +{ + if (nbScr > 0) + m_mapOffset[nbScr] = p; +} diff -Nru syncwall-1.6.0/src/ImageInfos.h syncwall-1.7.4/src/ImageInfos.h --- syncwall-1.6.0/src/ImageInfos.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/ImageInfos.h 2013-05-05 23:37:34.000000000 +0000 @@ -0,0 +1,101 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#ifndef _IMAGEINFOS_H_ +#define _IMAGEINFOS_H_ + +#include +#include +#include + +#include +#include + +class DatabaseManager; + +class ImageInfos +{ +public: + + ImageInfos(const QString &file); + virtual ~ImageInfos(); + + const QImage& getThumbnail() const { return m_thumbnail; } + const QString& getImageSize() const { return m_imageSize; } + const QString& getLabel() const { return m_label; } + const QString& getKey() const { return m_key; } + const QString& getFilename() const { return m_filename; } + const QString& getName() const { return m_name; } + const QString& getFileSizeAsString() const { return m_txtFileSize; } + quint64 getFileSize() const { return m_fileSize; } + int getRate() const { return m_rate; } + + int getWidth() const {return m_width; } + int getHeight() const {return m_height; } + QString getLastModificationAsString() const {return m_lastModification.toString(); } + + void setThumbnail(const QImage &); + void setLastModificationTime(const QString &); + void setHeight(int h); + void setWidth(int w); + void setRate(int rate); + void setFileSize(int); + + bool update(); + void reset(); + + bool isOffsetDefined(int nbScr) const; + QString getOffsetAsString(int nbScr) const; + QPoint getOffset(int nbScr) const; + + void setOffset(const QPoint &, int nbScr); + + // database functions + QString getOffsetMap() const; + void setOffsetMap(const QString &); + + static const int maxRating; + +private: + + QImage computeSubImage( const QImage & = QImage() ); + void computeLabel(); + QString sizeToString(quint64 size) const; + + QImage m_thumbnail; + bool m_changed; + QString m_imageSize; + QString m_label; + QString m_key; + QString m_filename; + QString m_name; + QString m_completeName; + quint64 m_fileSize; + QString m_txtFileSize; + QDateTime m_lastModification; + int m_width; + int m_height; + int m_rate; + + // map screen [number][offsetx, offsety] + QMap m_mapOffset; +}; + +#endif // _IMAGEINFOS_H_ diff -Nru syncwall-1.6.0/src/ImageView.cpp syncwall-1.7.4/src/ImageView.cpp --- syncwall-1.6.0/src/ImageView.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/ImageView.cpp 2013-05-05 23:37:32.000000000 +0000 @@ -0,0 +1,664 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#include +#include +#include +#include + +#include "ImageView.h" + +//----------------------------------------------------------------------------------------- +// Image View + +ImageView::ImageView(QWidget *parent, Qt::WFlags flags) : QGraphicsView(parent), + m_displayInfos(false), + m_navigatorWindow(NULL), + m_navigatorSize(0.15f), + m_navigatorMargin(10), + m_showNavigator(true) + +{ + m_viewportRect = QRect( 0, 0, width(), height() ); + m_worldMatrix.reset(); + + m_navigatorWindow = new ImageNavigator(this, flags); + m_navigatorWindow->setTransforms(&m_worldMatrix, &m_imgMatrix); + + initBackground(); + + setStyleSheet( "QGraphicsView { border-style: none; }" ); + setMouseTracking (true); //receive mouse event everytime + + connect( m_navigatorWindow, SIGNAL( moveViewSignal(const QPointF &) ), this, SLOT( moveView(const QPointF &) ) ); +} + +ImageView::~ImageView() +{ +} + +void ImageView::initBackground() +{ + // precreate background tile + m_tileBg = QPixmap(16, 16); + m_tileBg.fill(Qt::white); + QPainter pt(&m_tileBg); + QColor color(202, 202, 202); + pt.fillRect(0, 0, 8, 8, color); + pt.fillRect(8, 8, 8, 8, color); + pt.end(); +} + +void ImageView::setImage(const QImage &newImg) +{ + m_navigatorWindow->setImage( QImage() ); // clear overview + + m_image = newImg; + m_imgRect = QRectF( 0, 0, newImg.width(), newImg.height() ); + + m_worldMatrix.reset(); + updateImageMatrix(); + + m_navigatorWindow->setImage(m_image); + + update(); +} + +bool ImageView::isImageInside() +{ + return m_viewportRect.contains( m_worldMatrix.mapRect(m_imgViewRect) ); +} + +// displacement functions -------------------------------------------------------------------- + +// Move Left +void ImageView::moveLeft() +{ + float delta = 2 * width() / ( 100.0 * m_worldMatrix.m11() ); + moveView( QPointF(delta,0) ); +} + +// Move Right +void ImageView::moveRight() +{ + float delta = -2 * width() / ( 100.0 * m_worldMatrix.m11() ); + moveView( QPointF(delta,0) ); +} + +// Move Up +void ImageView::moveUp() +{ + float delta = 2 * height() / ( 100.0 * m_worldMatrix.m11() ); + moveView( QPointF(0,delta) ); +} + +// Move Down +void ImageView::moveDown() +{ + float delta = -2 * height() / ( 100.0 * m_worldMatrix.m11() ); + moveView( QPointF(0,delta) ); +} + +void ImageView::setShowOverview(bool val) +{ + m_showNavigator = val; + update(); +} + +void ImageView::zoomIn() +{ + zoom(1.1f); +} + +void ImageView::zoomOut() +{ + zoom(0.9f); +} + +void ImageView::zoom(float factor, const QPointF &c) +{ + if ( m_image.isNull() ) + return; + + QPointF center(c); + + //limit zoom out --- + if (m_worldMatrix.m11() == 1 && factor < 1) + return; + + if (m_worldMatrix.m11() * factor < 1) + { + resetView(); + return; + } + + //limit zoom in --- + if (m_worldMatrix.m11() * m_imgMatrix.m11() > 50 && factor > 1) + return; + + bool blackBorder = false; + + // if no center assigned: zoom in at the image center + if (center.x() == -1 || center.y() == -1) + { + center = QPointF( (float)width() / 2.0f, (float)height() / 2.0f ); + } + else + { + // if black border - do not zoom to the mouse coordinate + if ( (float)m_imgViewRect.width() * (m_worldMatrix.m11() * factor) < (float)width() ) + { + center.setX( (float)width() / 2.0f ); + blackBorder = true; + } + + if ( ( (float)m_imgViewRect.height() * m_worldMatrix.m11() * factor ) < (float)height() ) + { + center.setY( (float)height() / 2.0f ); + blackBorder = true; + } + } + + //inverse the transform + int a, b; + m_worldMatrix.inverted().map(center.x(), center.y(), &a, &b); + + m_worldMatrix.translate(a - factor * a, b - factor * b); + m_worldMatrix.scale(factor, factor); + + controlImagePosition(); + + if (blackBorder && factor < 1) + centerImage(); + + emit newZoomFactor( getZoom() ); + + update(); +} + +void ImageView::resetView() +{ + m_worldMatrix.reset(); + update(); +} + +float ImageView::getZoom() +{ + return m_imgMatrix.m11() * m_worldMatrix.m11() * 100.0f; +} + +void ImageView::moveView(const QPointF &d) +{ + QPointF delta(d); + QRectF imgWorldRect = m_worldMatrix.mapRect(m_imgViewRect); + + if ( imgWorldRect.width() < width() ) + delta.setX(0); + + if ( imgWorldRect.height() < height() ) + delta.setY(0); + + m_worldMatrix.translate( delta.x(), delta.y() ); + controlImagePosition(); + update(); +} + +void ImageView::controlImagePosition(float lb, float ub) +{ + QRectF imgRectWorld = m_worldMatrix.mapRect(m_imgViewRect); + + if (lb == -1) + lb = m_viewportRect.width() / 2; + + if (ub == -1) + ub = m_viewportRect.height() / 2; + + if ( imgRectWorld.left() > lb && imgRectWorld.width() > width() ) + m_worldMatrix.translate( ( lb - imgRectWorld.left() ) / m_worldMatrix.m11(), 0 ); + + if ( imgRectWorld.top() > ub && imgRectWorld.height() > height() ) + m_worldMatrix.translate( 0, ( ub - imgRectWorld.top() ) / m_worldMatrix.m11() ); + + if ( imgRectWorld.right() < lb && imgRectWorld.width() > width() ) + m_worldMatrix.translate( ( lb - imgRectWorld.right() ) / m_worldMatrix.m11(), 0 ); + + if ( imgRectWorld.bottom() < ub && imgRectWorld.height() > height() ) + m_worldMatrix.translate( 0, ( ub - imgRectWorld.bottom() ) / m_worldMatrix.m11() ); +} + +void ImageView::centerImage() +{ + QRectF imgWorldRect = m_worldMatrix.mapRect(m_imgViewRect); + + // if black border - center the image + if ( imgWorldRect.width() < (float)width() ) + { + float dx = ( (float)width() - imgWorldRect.width() ) * 0.5f - m_imgViewRect.x() * m_worldMatrix.m11(); + dx = ( dx - m_worldMatrix.dx() ) / m_worldMatrix.m11(); + m_worldMatrix.translate(dx, 0); + } + else if (imgWorldRect.left() > 0) + m_worldMatrix.translate(-imgWorldRect.left() / m_worldMatrix.m11(), 0); + else if ( imgWorldRect.right() < width() ) + m_worldMatrix.translate( ( width() - imgWorldRect.right() ) / m_worldMatrix.m11(), 0 ); + + if ( imgWorldRect.height() < height() ) + { + float dy = ( height() - imgWorldRect.height() ) * 0.5f - m_imgViewRect.y() * m_worldMatrix.m22(); + dy = ( dy - m_worldMatrix.dy() ) / m_worldMatrix.m22(); + m_worldMatrix.translate(0, dy); + } + else if (imgWorldRect.top() > 0) + { + m_worldMatrix.translate( 0, -imgWorldRect.top() / m_worldMatrix.m22() ); + } + else if ( imgWorldRect.bottom() < height() ) + { + m_worldMatrix.translate( 0, ( height() - imgWorldRect.bottom() ) / m_worldMatrix.m22() ); + } +} + +void ImageView::updateImageMatrix() +{ + if ( m_image.isNull() ) + return; + + QRectF oldImgRect = m_imgViewRect; + QTransform oldImgMatrix = m_imgMatrix; + + m_imgMatrix.reset(); + + // if the image is smaller or zoom is active: paint the image as is + if ( !m_viewportRect.contains(m_imgRect) ) + { + m_imgMatrix = getScaledImageMatrix(); + } + else + { + m_imgMatrix.translate( (float)( width() - m_image.width() ) * 0.5f, (float)( height() - m_image.height() ) * 0.5f ); + m_imgMatrix.scale(1.0f, 1.0f); + } + + m_imgViewRect = m_imgMatrix.mapRect(m_imgRect); + + // update world matrix + if (m_worldMatrix.m11() != 1) + { + float scaleFactor = oldImgMatrix.m11() / m_imgMatrix.m11(); + double dx = oldImgRect.x() / scaleFactor - m_imgViewRect.x(); + double dy = oldImgRect.y() / scaleFactor - m_imgViewRect.y(); + + m_worldMatrix.scale(scaleFactor, scaleFactor); + m_worldMatrix.translate(dx, dy); + } +} + +QTransform ImageView::getScaledImageMatrix() +{ + // the image resizes as we zoom + float ratioImg = m_imgRect.width() / m_imgRect.height(); + float ratioWin = (float)width() / (float)height(); + + QTransform imgMatrix; + float s; + + if (m_imgRect.width() == 0 || m_imgRect.height() == 0) + s = 1.0f; + else + s = (ratioImg > ratioWin) ? (float)width() / m_imgRect.width() : (float)height() / m_imgRect.height(); + + imgMatrix.scale(s, s); + + QRectF imgViewRect = imgMatrix.mapRect(m_imgRect); + imgMatrix.translate( ( width() - imgViewRect.width() ) * 0.5f / s, ( height() - imgViewRect.height() ) * 0.5f / s ); + + return imgMatrix; +} + +void ImageView::paintEvent(QPaintEvent* event) +{ + QPainter painter( viewport() ); + + // draw background + painter.drawTiledPixmap(rect(), m_tileBg); + + if ( !m_image.isNull() ) + { + painter.setWorldTransform(m_worldMatrix); + + if (m_imgMatrix.m11() * m_worldMatrix.m11() <= (float)2.0f) + painter.setRenderHint(QPainter::SmoothPixmapTransform); + + draw(&painter); + + //Now disable matrixWorld for overlay display + painter.setWorldMatrixEnabled (false); + } + + //in mode zoom/panning + if (m_worldMatrix.m11() > 1 && !isImageInside() && m_showNavigator) + { + if ( m_navigatorWindow->isVisible() ) + { + // top right placement + m_navigatorWindow->move(width() - m_navigatorMargin - m_navigatorWindow->width(), m_navigatorMargin); + } + else + { + m_navigatorWindow->show(); + m_navigatorWindow->update(); + } + } + else + { + m_navigatorWindow->hide(); + } + + QGraphicsView::paintEvent(event); +} + +// drawing functions -------------------------------------------------------------------- + +void ImageView::draw(QPainter *painter) +{ + painter->setRenderHint(QPainter::SmoothPixmapTransform); //-> uncomment for smooth aliasing + painter->drawImage(m_imgViewRect, m_image, m_imgRect); +} + +// event -------------------------------------------------------------------- + +void ImageView::resizeEvent(QResizeEvent *event) +{ + m_viewportRect = QRect( 0, 0, width(), height() ); + + updateImageMatrix(); + centerImage(); + + emit newZoomFactor( getZoom() ); + + m_navigatorWindow->resize(size() * m_navigatorSize); + m_navigatorWindow->setViewPortRect( geometry() ); + + QGraphicsView::resizeEvent(event); +} + +// key events -------------------------------------------------------------------- + +void ImageView::keyPressEvent(QKeyEvent* event) +{ + if (event->key() == Qt::Key_Up) + { + moveUp(); + } + else if (event->key() == Qt::Key_Down) + { + moveDown(); + } + else if (event->key() == Qt::Key_Left) + { + moveLeft(); + } + else if (event->key() == Qt::Key_Right) + { + moveRight(); + } + else if (event->key() == Qt::Key_Plus) + { + zoomIn(); + } + else if (event->key() == Qt::Key_Minus) + { + zoomOut(); + } + QGraphicsView::keyPressEvent(event); +} + +// mouse events -------------------------------------------------------------------- + +void ImageView::mousePressEvent(QMouseEvent *event) +{ + m_enterPos = event->pos(); + setCursor(Qt::ClosedHandCursor); + + if (m_worldMatrix.m11() > 1 && !isImageInside() && event->buttons() == Qt::LeftButton) + m_lastPos = event->pos(); + + QWidget::mousePressEvent(event); +} + +void ImageView::mouseReleaseEvent(QMouseEvent *event) +{ + setCursor(Qt::ArrowCursor); + QWidget::mouseReleaseEvent(event); +} + +void ImageView::mouseMoveEvent(QMouseEvent *event) +{ + if (m_displayInfos) + getPixelInfo( event->pos() ); + + if (m_worldMatrix.m11() > 1 && event->buttons() == Qt::LeftButton) + { + QPointF cPos = event->pos(); + QPointF dxy = (cPos - m_lastPos); + m_lastPos = cPos; + moveView( dxy / m_worldMatrix.m11() ); + } + + QWidget::mouseMoveEvent(event); +} + +void ImageView::wheelEvent(QWheelEvent *event) +{ + float factor = event->delta(); + + factor /= -1200.0f; + factor += 1.0f; + + zoom( factor, event->pos() ); +} + +void ImageView::getPixelInfo(const QPoint& pos) +{ + if ( m_image.isNull() ) + return; + + QPointF imgPos = m_worldMatrix.inverted().map( QPointF(pos) ); + imgPos = m_imgMatrix.inverted().map(imgPos); + + QPoint xy = imgPos.toPoint(); + + if ( xy.x() < 0 || xy.y() < 0 || xy.x() >= m_image.width() || xy.y() >= m_image.height() ) + return; + + QColor col = m_image.pixel(xy); + + QString msg = QString( tr("x: %1 y: %2 | r: %3 g: %4 b: %5") ).arg( QString::number( xy.x() ) ).arg( QString::number( xy.y() ) ).arg( QString::number( col.red() ) ).arg( QString::number( col.green() ) ).arg( QString::number( col.blue() ) ); + + if ( m_image.hasAlphaChannel() ) + msg = msg + QString( tr(" a: %1") ).arg( QString::number( col.alpha() ) ); + + emit infos(msg); +} + +// file handling -------------------------------------------------------------------- + +void ImageView::load(const QString & file) +{ + m_image.load(file); + setImage(m_image); +} + +QImage& ImageView::getImage() +{ + return m_image; +} + +// ImageOverview -------------------------------------------------------------------- + +ImageNavigator::ImageNavigator(QWidget* parent, Qt::WindowFlags flags) : QWidget(parent, flags), + m_worldMatrix(NULL), + m_imgMatrix(NULL), + m_backgroundColor( QColor(0, 0, 0, 150) ) +{ +} + +void ImageNavigator::paintEvent(QPaintEvent * /*event */) +{ + if (m_img.isNull() || !m_imgMatrix || !m_worldMatrix) + return; + + QPainter painter(this); + + QRectF imgRect = QRectF( QPoint(), m_img.size() ); + QRectF overviewRect = QRectF( QPoint(), QSize(geometry().width() - 1, geometry().height() - 1) ); // get the overview rect + + QTransform overviewImgMatrix = getScaledImageMatrix(); // matrix that always resizes the image to the current viewport + QRectF overviewImgRect = overviewImgMatrix.mapRect(imgRect); + overviewImgRect.setTop(overviewImgRect.top() + 1); + overviewImgRect.setLeft(overviewImgRect.left() + 1); + overviewImgRect.setWidth(overviewImgRect.width() - 1); // we have a border... correct that... + overviewImgRect.setHeight(overviewImgRect.height() - 1); + + // now render the current view + QRectF viewRect = m_viewPortRect; + viewRect = m_worldMatrix->inverted().mapRect(viewRect); + viewRect = m_imgMatrix->inverted().mapRect(viewRect); + viewRect = overviewImgMatrix.mapRect(viewRect); + + //draw the image's location + painter.setBrush(m_backgroundColor); + painter.setPen( QColor(200, 200, 200) ); + painter.drawRect(overviewRect); + painter.setOpacity(0.8f); + painter.drawImage( overviewImgRect, m_imgT, QRect( 0, 0, m_imgT.width(), m_imgT.height() ) ); + + painter.setPen( QColor(100, 0, 0) ); + painter.setBrush( QColor(100, 0, 0, 50) ); + painter.drawRect(viewRect); +} + +void ImageNavigator::mousePressEvent(QMouseEvent *event) +{ + m_enterPos = event->pos(); + m_lastPos = event->pos(); +} + +void ImageNavigator::mouseReleaseEvent(QMouseEvent *event) +{ + QPointF dxy = m_enterPos - QPointF( event->pos() ); + + if (dxy.manhattanLength() < 4) + { + // move to the current position + // now render the current view + QRectF viewRect = m_viewPortRect; + viewRect = m_worldMatrix->inverted().mapRect(viewRect); + viewRect = m_imgMatrix->inverted().mapRect(viewRect); + viewRect = getScaledImageMatrix().mapRect(viewRect); + QPointF currentViewPoint = viewRect.center(); + + float panningSpeed = -( m_worldMatrix->m11() / ( getScaledImageMatrix().m11() / m_imgMatrix->m11() ) ); + + QPointF cPos = event->pos(); + QPointF dxy = (cPos - currentViewPoint) / m_worldMatrix->m11() * panningSpeed; + emit moveViewSignal(dxy); + } +} + +void ImageNavigator::mouseMoveEvent(QMouseEvent *event) +{ + if (event->buttons() != Qt::LeftButton) + return; + + float panningSpeed = -( m_worldMatrix->m11() / ( getScaledImageMatrix().m11() / m_imgMatrix->m11() ) ); + + QPointF cPos = event->pos(); + QPointF dxy = (cPos - m_lastPos) / m_worldMatrix->m11() * panningSpeed; + m_lastPos = cPos; + emit moveViewSignal(dxy); +} + +void ImageNavigator::resizeEvent(QResizeEvent* event) +{ + if ( event->size() == size() ) + return; + + resizeImg(); + + QWidget::resizeEvent(event); +} + +void ImageNavigator::resize(int w, int h) +{ + resize( QSize(w, h) ); +} + +void ImageNavigator::resize(const QSize& size) +{ + QWidget::resize(size); + + // update image + resizeImg(); +} + +void ImageNavigator::resizeImg() +{ + if ( m_img.isNull() ) + return; + + QRectF imgRect = QRectF( QPoint(), m_img.size() ); + + QTransform overviewImgMatrix = getScaledImageMatrix(); // matrix that always resizes the image to the current viewport + QRectF overviewImgRect = overviewImgMatrix.mapRect(imgRect); + overviewImgRect.setTop(overviewImgRect.top() + 1); + overviewImgRect.setLeft(overviewImgRect.left() + 1); + overviewImgRect.setWidth(overviewImgRect.width() - 1); // we have a border... correct that... + overviewImgRect.setHeight(overviewImgRect.height() - 1); + + // fast downscaling + m_imgT = m_img.scaled(overviewImgRect.size().width(), overviewImgRect.size().height(), Qt::KeepAspectRatio, Qt::SmoothTransformation); +} + +QTransform ImageNavigator::getScaledImageMatrix() +{ + if ( m_img.isNull() ) + return QTransform(); + + // the image resizes as we zoom + QRectF imgRect = QRectF( QPoint(), m_img.size() ); + float ratioImg = imgRect.width() / imgRect.height(); + float ratioWin = (float)width() / (float)height(); + + QTransform imgMatrix; + float s; + + if (imgRect.width() == 0 || imgRect.height() == 0) + s = 1.0f; + else + s = (ratioImg > ratioWin) ? (float)width() / imgRect.width() : (float)height() / imgRect.height(); + + imgMatrix.scale(s, s); + + QRectF imgViewRect = imgMatrix.mapRect(imgRect); + imgMatrix.translate( ( width() - imgViewRect.width() ) * 0.5f / s, ( height() - imgViewRect.height() ) * 0.5f / s ); + + return imgMatrix; +} diff -Nru syncwall-1.6.0/src/ImageView.h syncwall-1.7.4/src/ImageView.h --- syncwall-1.6.0/src/ImageView.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/ImageView.h 2013-05-05 23:37:34.000000000 +0000 @@ -0,0 +1,180 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#ifndef _IMAGEVIEW_H_ +#define _IMAGEVIEW_H_ + +#include +#include +#include +#include +#include + +class ImageNavigator; + +class ImageView : + public QGraphicsView +{ + Q_OBJECT + +public: + + ImageView(QWidget *parent = 0, Qt::WFlags flags = 0); + virtual ~ImageView(); + + void release(); + + void zoom( float factor = 0.5, const QPointF & center = QPointF(-1,-1) ); + float getZoom(); + + QImage& getImage(); + void setDisplayInfos(bool val) + { + m_displayInfos = val; + } + +public slots: + + void moveLeft(); + void moveRight(); + void moveUp(); + void moveDown(); + void zoomIn(); + void zoomOut(); + void resetView(); + + void resizeEvent(QResizeEvent* event); + void paintEvent(QPaintEvent* event); + + void setShowOverview(bool); + void moveView(const QPointF &); + + // file actions + void load(const QString & file); + + virtual void setImage(const QImage &newImg); + +signals: + + void infos(const QString &); + void newZoomFactor(float); + +protected: + + void keyPressEvent(QKeyEvent *event); + + void mousePressEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + + void wheelEvent(QWheelEvent *event); + +private: + + // functions + void initBackground(); + virtual void draw(QPainter *painter); + bool isImageInside(); + void updateImageMatrix(); + QTransform getScaledImageMatrix(); + void controlImagePosition(float lb = -1, float ub = -1); + void centerImage(); + + void getPixelInfo(const QPoint& pos); + + bool m_displayInfos; + QPixmap m_tileBg; + QImage m_image; + + QTransform m_imgMatrix; + QTransform m_worldMatrix; + QRectF m_imgViewRect; + QRectF m_viewportRect; + QRectF m_imgRect; + + ImageNavigator* m_navigatorWindow; + + QPointF m_lastPos; + QPointF m_enterPos; + + // overview rendering + float m_navigatorSize; + float m_navigatorMargin; + + bool m_showNavigator; +}; + +class ImageNavigator : + public QWidget +{ + Q_OBJECT + +public: + + ImageNavigator(QWidget * parent = 0, Qt::WindowFlags f = 0); + ~ImageNavigator() {} + + void resize(int w, int h); + void resize(const QSize& size); + + void setImage(QImage img) + { + m_img = img; + resizeImg(); + } + + void setTransforms(QTransform* worldMatrix, QTransform* imgMatrix) + { + m_worldMatrix = worldMatrix; + m_imgMatrix = imgMatrix; + } + + void setViewPortRect(QRectF viewPortRect) + { + m_viewPortRect = viewPortRect; + } + +signals: + + void moveViewSignal(const QPointF &dxy); + +protected: + + void resizeImg(); + void paintEvent(QPaintEvent *event); + void mouseMoveEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + void mousePressEvent(QMouseEvent *event); + void resizeEvent(QResizeEvent* event); + QTransform getScaledImageMatrix(); + +private: + + QImage m_img; + QImage m_imgT; + QTransform* m_worldMatrix; + QTransform* m_imgMatrix; + QRectF m_viewPortRect; + QPointF m_lastPos; + QPointF m_enterPos; + QColor m_backgroundColor; +}; + +#endif // _IMAGEVIEW_H_ diff -Nru syncwall-1.6.0/src/ImageViewer.cpp syncwall-1.7.4/src/ImageViewer.cpp --- syncwall-1.6.0/src/ImageViewer.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/ImageViewer.cpp 2013-05-05 23:37:34.000000000 +0000 @@ -0,0 +1,68 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#include +#include +#include +#include + +#include "ImageViewer.h" + +//----------------------------------------------------------------------------------------- +// Image Viewer + +ImageViewer::ImageViewer( const QString &fileName, QWidget *parent ) : QWidget(parent) +{ + setupUi(this); + + // update default widget size to half screen size + QRect geom = QApplication::desktop()->screenGeometry( ); + resize( geom.width() / 2, geom.height() / 2 ); + + // connect view data to the widget display + connect( graphicsView,SIGNAL( infos(const QString &) ),this,SLOT( updateInfos(const QString &) ) ); + connect( graphicsView,SIGNAL( newZoomFactor(float) ),this,SLOT( updateZoomFactor(float) ) ); + + // load image + graphicsView->load(fileName); + graphicsView->setDisplayInfos(true); + + m_name = QFileInfo(fileName).baseName(); + m_name += QString(" - %1x%2").arg( graphicsView->getImage().size().width() ).arg( graphicsView->getImage().size().height() ); +} + +void ImageViewer::closeEvent ( QCloseEvent * /*event*/ ) +{ + deleteLater(); +} + +ImageViewer::~ImageViewer() +{ +} + +void ImageViewer::updateInfos(const QString &infos) +{ + labelInfos->setText(infos); +} + +void ImageViewer::updateZoomFactor(float val) +{ + setWindowTitle(m_name + " - " + QString::number( (int)val ) + "%"); +} diff -Nru syncwall-1.6.0/src/ImageViewer.h syncwall-1.7.4/src/ImageViewer.h --- syncwall-1.6.0/src/ImageViewer.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/ImageViewer.h 2013-05-05 23:37:34.000000000 +0000 @@ -0,0 +1,60 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#ifndef _IMAGEVIEWER_H_ +#define _IMAGEVIEWER_H_ + +#include +#include +#include +#include +#include +#include "ImageView.h" + +#include "ui_ImageViewer.h" + +class ImageNavigator; +class ImageView; + +class ImageViewer : + public QWidget, public Ui::ImageViewer +{ + Q_OBJECT + +public: + + ImageViewer(const QString &file, QWidget *parent = 0); + ~ImageViewer(); + +public slots: + + void updateInfos(const QString &); + void updateZoomFactor(float); + +protected: + + void closeEvent ( QCloseEvent * ); + +private: + + QString m_name; +}; + +#endif // _IMAGEVIEWER_H_ diff -Nru syncwall-1.6.0/src/InfosUpdater.cpp syncwall-1.7.4/src/InfosUpdater.cpp --- syncwall-1.6.0/src/InfosUpdater.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/InfosUpdater.cpp 2013-05-05 23:37:32.000000000 +0000 @@ -0,0 +1,112 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#include + +#include "InfosUpdater.h" +#include "ImageInfos.h" + +#include "DatabaseManager.h" + +InfosUpdater::InfosUpdater( QObject *parent ) : QObject(parent), + m_abort( false ), + m_isRunning(false) +{ + m_dbm = new DatabaseManager; +} + +InfosUpdater::~InfosUpdater() +{ + cancel(); + delete m_dbm; +} + +void InfosUpdater::storeInfos( ImageInfos *ii ) +{ + m_dbm->storeInfos(ii); +} + +void InfosUpdater::removeInfos( const QString &url) +{ + m_dbm->removeInfos(url); +} + +void InfosUpdater::check( ImageInfos *ii ) +{ + m_iiQueue.append( ii ); + run(); +} + +void InfosUpdater::check( const QList &list ) +{ + m_iiQueue.append( list ); + run(); +} + +void InfosUpdater::cancel() +{ + m_mutex.lock(); + m_abort = true; + m_iiQueue.clear(); + m_mutex.unlock(); +} + +bool InfosUpdater::isRunning() +{ + return m_isRunning; +} + +void InfosUpdater::run() +{ + m_abort = false; + m_isRunning = true; + bool ok = true; + + while(ok) + { + m_mutex.lock(); + + if ( m_iiQueue.isEmpty() ) + { + ok = false; + } + else + { + ImageInfos *ii = m_iiQueue.dequeue(); + m_dbm->retrieveInfos(ii); + bool somethingDone = ii->update(); + + if (somethingDone) + { + m_dbm->storeInfos(ii); + emit updated(ii); + } + } + m_mutex.unlock(); + } + + m_isRunning = false; + emit finished(); +} + +void InfosUpdater::clearCache() +{ + m_dbm->clearDB(); +} diff -Nru syncwall-1.6.0/src/InfosUpdater.h syncwall-1.7.4/src/InfosUpdater.h --- syncwall-1.6.0/src/InfosUpdater.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/InfosUpdater.h 2013-05-05 23:37:34.000000000 +0000 @@ -0,0 +1,67 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#ifndef _INFOSUPDATER_H_ +#define _INFOSUPDATER_H_ + +#include +#include +#include + +class ImageInfos; +class DatabaseManager; + +class InfosUpdater : public QObject +{ + Q_OBJECT + +public: + + InfosUpdater( QObject *parent = 0 ); + ~InfosUpdater(); + + void cancel(); + void clearCache(); + bool isRunning(); + +public slots: + + void check( ImageInfos * ); + void storeInfos( ImageInfos * ); + void removeInfos( const QString &); + void check( const QList & ); + +signals: + + void updated(ImageInfos *); + void finished(); + +private: + + void run(); + + QMutex m_mutex; + bool m_abort; + bool m_isRunning; + QQueue m_iiQueue; + DatabaseManager *m_dbm; +}; + +#endif // _INFOSUPDATER_H_ diff -Nru syncwall-1.6.0/src/ListImagesModel.cpp syncwall-1.7.4/src/ListImagesModel.cpp --- syncwall-1.6.0/src/ListImagesModel.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/ListImagesModel.cpp 2013-05-05 23:37:30.000000000 +0000 @@ -0,0 +1,555 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#include +#include + +#include "ListImagesModel.h" +#include "ImageInfos.h" +#include "InfosUpdater.h" +#include "ThreadPool.h" + +const int shadowBorderSize = 3; +const int whiteBorderSize = 3; +const int shadowStrength = 127; + +bool lessThanByRow( const QModelIndex &indexA, const QModelIndex &indexB) +{ + return( indexA.row() > indexB.row() ); +} + +QPixmap ListImagesModel::generateFuzzyRect(const QSize& size, const QColor& color, int radius) const +{ + QPixmap pix(size); + const QColor transparent(0, 0, 0, 0); + pix.fill(transparent); + + QPainter painter(&pix); + painter.setRenderHint(QPainter::Antialiasing, true); + + // Fill middle + painter.fillRect(pix.rect().adjusted(radius, radius, -radius, -radius), color); + + // Corners + QRadialGradient gradient; + gradient.setColorAt(0, color); + gradient.setColorAt(1, transparent); + gradient.setRadius(radius); + QPoint center; + + // Top Left + center = QPoint(radius, radius); + gradient.setCenter(center); + gradient.setFocalPoint(center); + painter.fillRect(0, 0, radius, radius, gradient); + + // Top right + center = QPoint(size.width() - radius, radius); + gradient.setCenter(center); + gradient.setFocalPoint(center); + painter.fillRect(center.x(), 0, radius, radius, gradient); + + // Bottom left + center = QPoint(radius, size.height() - radius); + gradient.setCenter(center); + gradient.setFocalPoint(center); + painter.fillRect(0, center.y(), radius, radius, gradient); + + // Bottom right + center = QPoint(size.width() - radius, size.height() - radius); + gradient.setCenter(center); + gradient.setFocalPoint(center); + painter.fillRect(center.x(), center.y(), radius, radius, gradient); + + // Borders + QLinearGradient linearGradient; + linearGradient.setColorAt(0, color); + linearGradient.setColorAt(1, transparent); + + // Top + linearGradient.setStart(0, radius); + linearGradient.setFinalStop(0, 0); + painter.fillRect(radius, 0, size.width() - 2 * radius, radius, linearGradient); + + // Bottom + linearGradient.setStart(0, size.height() - radius); + linearGradient.setFinalStop( 0, size.height() ); + painter.fillRect(radius, int( linearGradient.start().y() ), size.width() - 2 * radius, radius, linearGradient); + + // Left + linearGradient.setStart(radius, 0); + linearGradient.setFinalStop(0, 0); + painter.fillRect(0, radius, radius, size.height() - 2 * radius, linearGradient); + + // Right + linearGradient.setStart(size.width() - radius, 0); + linearGradient.setFinalStop(size.width(), 0); + painter.fillRect(int( linearGradient.start().x() ), radius, radius, size.height() - 2 * radius, linearGradient); + return pix; +} + +void ListImagesModel::drawShadow(QPainter* painter, const QRect& rect) const +{ + const QPoint shadowOffset(-shadowBorderSize, -shadowBorderSize + 1); + + int key = rect.height() * 1000 + rect.width(); + + QMap::Iterator it = m_shadowCache.find(key); + if ( it == m_shadowCache.end() ) + { + QSize size = QSize(rect.width() + 2 * shadowBorderSize, rect.height() + 2 * shadowBorderSize); + QColor color(0, 0, 0, shadowStrength); + QPixmap shadow = generateFuzzyRect(size, color, shadowBorderSize); + it = m_shadowCache.insert(key, shadow); + } + painter->drawPixmap( rect.topLeft() + shadowOffset, it.value() ); +} + +QPixmap ListImagesModel::shadoizePixmap(const QImage &pm) const +{ + QPixmap icon = QPixmap( pm.width() + 2 * shadowBorderSize + 2 * whiteBorderSize,pm.height() + 2 * shadowBorderSize + 2 * whiteBorderSize); + + QPainter painter(&icon); + icon.fill( QColor(244,244,244) ); + + QRect thumbnailRect = QRect( + shadowBorderSize + whiteBorderSize, + shadowBorderSize + whiteBorderSize - 1, + pm.width() + whiteBorderSize, + pm.height() + whiteBorderSize); + + drawShadow(&painter, thumbnailRect); + + // fill the "photo border" + painter.fillRect(shadowBorderSize,shadowBorderSize,pm.width() + 2 * whiteBorderSize,pm.height() + 2 * whiteBorderSize,Qt::white); + + // fill the center pixmap + painter.drawPixmap( shadowBorderSize + whiteBorderSize,shadowBorderSize + whiteBorderSize,QPixmap::fromImage(pm) ); + + painter.end(); + + return icon; +} + +ListImagesModel::ListImagesModel(QObject *parent) + : QAbstractItemModel( parent ), + m_updater(NULL), + m_mode(MODE_DETAILS), + m_lastAppliedRow(-1), + m_lastPreviewedRow(-1), + m_nbScreens(1) +{ + // create updater infos + m_updater = new InfosUpdater(); + + // move the updater to this thread + m_updater->moveToThread( ThreadPool::getInstance()->getThread() ); + + qRegisterMetaType >("QList"); + + connect( m_updater, SIGNAL( updated( ImageInfos * ) ), this, SLOT( refresh( ImageInfos *) ) ); + connect( m_updater, SIGNAL( finished( ) ), this, SIGNAL( updateFinished() ) ); + + connect( this, SIGNAL( updateInfos(const QList &) ), m_updater, SLOT( check( const QList & ) ) ); + connect( this, SIGNAL( storeInfos(ImageInfos *) ), m_updater, SLOT( storeInfos(ImageInfos *) ) ); + connect( this, SIGNAL( removeInfos(const QString &) ), m_updater, SLOT( removeInfos(const QString &) ) ); +} + +ListImagesModel::~ListImagesModel() +{ + m_updater->cancel(); + delete m_updater; +} + +QVariant ListImagesModel::headerData (int inSection, Qt::Orientation inOrientation, int inRole) const +{ + if (inRole != Qt::DisplayRole || inOrientation != Qt::Horizontal || m_mode != MODE_DETAILS) + return QVariant (); + + switch (inSection) + { + case COLUMN_NAME: + return tr ("Name"); + + case COLUMN_RATE: + return tr ("Rate"); + + case COLUMN_IMAGESIZE: + return tr ("Image size"); + + case COLUMN_FILESIZE: + return tr ("File size"); + + case COLUMN_USER_ADJUST: + return tr ("Offset defined by user"); + } + return QVariant(); +} + +QVariant ListImagesModel::data( const QModelIndex &index, int role ) const +{ + if( !index.isValid() ) + return QVariant(); + + if (m_mode == MODE_DETAILS) + return dataDetails(index, role); + else + return dataIcons(index, role); + + return QVariant(); +} + +QVariant ListImagesModel::dataDetails( const QModelIndex &index, int role ) const +{ + if( !index.isValid() ) + return QVariant(); + + if( role == Qt::DisplayRole ) + { + if (index.column() == COLUMN_NAME) + return m_filesList.at( index.row() )->getFilename(); + else if (index.column() == COLUMN_RATE) + return m_filesList.at( index.row() )->getRate(); + else if (index.column() == COLUMN_IMAGESIZE) + return m_filesList.at( index.row() )->getImageSize(); + else if (index.column() == COLUMN_FILESIZE) + return m_filesList.at( index.row() )->getFileSizeAsString(); + else if (index.column() == COLUMN_USER_ADJUST) + return m_filesList.at( index.row() )->getOffsetAsString(m_nbScreens); + } + + // "highlight" current wallpaper + else if (role == Qt::BackgroundRole && index.row() == m_lastAppliedRow) + { + return QBrush ( QColor(255,200,0) ); + } + + return QVariant(); +} + +QVariant ListImagesModel::dataIcons( const QModelIndex &index, int role ) const +{ + if( !index.isValid() ) + return QVariant(); + + if( role == Qt::DecorationRole ) + return shadoizePixmap( m_filesList.at( index.row() )->getThumbnail() ); + + //return QPixmap::fromImage(m_filesList.at( index.row() )->getThumbnail()); + + if ( role == Qt::ToolTipRole) + return m_filesList.at( index.row() )->getFilename(); + + if( role == Qt::DisplayRole ) + return m_filesList.at( index.row() )->getLabel(); + + if( role == Qt::UserRole ) + return m_filesList.at( index.row() )->getImageSize(); + + return QVariant(); +} + +bool ListImagesModel::setData(const QModelIndex &index, const QVariant &value, int role) +{ + if (!index.isValid() || role != Qt::EditRole) + return false; + + if (index.column() == ListImagesModel::COLUMN_RATE) + { + m_filesList.at( index.row() )->setRate( value.toInt() ); + emit storeInfos( m_filesList.at( index.row() ) ); // save to db + emit dataChanged(index, index); // update view + // must recompute random indexes + emit updateFinished(); + return true; + } + else if (index.column() == ListImagesModel::COLUMN_USER_ADJUST) + { + m_filesList.at( index.row() )->setOffset(value.toPoint(),m_nbScreens); + emit storeInfos( m_filesList.at( index.row() ) ); // save to db + emit dataChanged(index, index); // update view + return true; + } + + return false; +} + +Qt::ItemFlags ListImagesModel::flags( const QModelIndex &index ) const +{ + if( !index.isValid() ) + return Qt::ItemIsDropEnabled; + + if (index.column() == ListImagesModel::COLUMN_RATE) + return ( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable ); + else + return ( Qt::ItemIsEnabled | Qt::ItemIsSelectable); +} + +int ListImagesModel::rowCount( const QModelIndex &parent ) const +{ + if( parent.isValid() ) + return 0; + + return m_filesList.size(); +} + +void ListImagesModel::setDisplayMode(int mode) +{ + if (mode == m_mode) + return; + + m_mode = mode; + + reset(); +} + +QModelIndex ListImagesModel::index(int row, int column, const QModelIndex &parent) const +{ + if ( !parent.isValid() ) // root item + { + if(row >= (int)m_filesList.size() || row < 0) + return QModelIndex(); + + return createIndex(row, column, m_filesList[row]); + } + + return QModelIndex(); +} + +QModelIndex ListImagesModel::parent ( const QModelIndex & /*index*/ ) const +{ + return QModelIndex(); +} + +int ListImagesModel::columnCount ( const QModelIndex & /*parent*/ ) const +{ + switch (m_mode) + { + case MODE_DETAILS: + return COLUMN_NB; + } + return 1; +} + +void ListImagesModel::refresh (ImageInfos *ii) +{ + int index = m_filesList.indexOf(ii); + if (index >= 0) + { + QModelIndex mIndex = createIndex(index, 0, m_filesList[index]); + emit dataChanged( mIndex,mIndex.sibling(0,0) ); + } +} + +ImageInfos *ListImagesModel::getInfos(const QString &filename) +{ + // TO BE ENHANCED + foreach (ImageInfos * ii, m_filesList) + { + if (ii->getFilename() == filename) + return ii; + } + return NULL; +} + +void ListImagesModel::addImages( const QStringList & list ) +{ + int row = m_filesList.size(); + + // check for double + QStringList valid; + QList oldIIList; // store already defined file (just update infos) + foreach (const QString &file, list) + { + if ( !m_alreadyDefined.contains(file) ) + { + valid << file; + m_alreadyDefined << file; + } + else + { + oldIIList << getInfos(file); + } + } + + beginInsertRows( QModelIndex(), row, row + valid.size() ); + + QList newIIList; + foreach( const QString &location, valid ) + newIIList << new ImageInfos(location); + m_filesList.append(newIIList); + + newIIList << oldIIList; // update also existing file (just in case) + + emit updateInfos(newIIList); + + endInsertRows(); +} + +void ListImagesModel::removeRows(const QModelIndexList& indexes) +{ + // we must sort the index by order + QModelIndexList sorted(indexes); + qSort(sorted.begin(),sorted.end(),lessThanByRow); + + foreach(const QModelIndex &index, sorted) + { + if (index.row() == m_lastAppliedRow) + m_lastAppliedRow = -1; + removeRows(index.row(),1); + } +} + +bool ListImagesModel::removeRows( int row, int count, const QModelIndex &parent ) +{ + if( parent.isValid() ) + return false; + + if( row >= m_filesList.size() || row + count <= 0 ) + return false; + + int beginRow = qMax( 0, row ); + int endRow = qMin( row + count - 1, m_filesList.size() - 1 ); + + beginRemoveRows( parent, beginRow, endRow ); + + while( beginRow <= endRow ) + { + ImageInfos *ii = m_filesList.takeAt( beginRow ); + emit removeInfos( ii->getFilename() ); + m_alreadyDefined.remove( ii->getFilename() ); // update map + delete ii; + ++beginRow; + } + + endRemoveRows(); + + // recompute random indexes + emit updateFinished(); + return true; +} + +void ListImagesModel::clear() +{ + m_updater->cancel(); + while( m_updater->isRunning() ) + ; + qDeleteAll(m_filesList); + m_filesList.clear(); + reset(); +} + +int ListImagesModel::getIndex(const QModelIndex &index) const +{ + if ( index.isValid() ) + return index.row(); + + return -1; +} + +int ListImagesModel::getIndex(const QString &filename) const +{ + // TO BE ENHANCED + for(int i = 0; i < m_filesList.size(); i++) + if (m_filesList[i]->getFilename() == filename) + return i; + + + return -1; +} + +int ListImagesModel::getRating(int row) const +{ + if ( row >= 0 && row < m_filesList.size() ) + return m_filesList[row]->getRate(); + + return 0; +} + +QString ListImagesModel::getFilename(int row) const +{ + if ( row >= 0 && row < m_filesList.size() ) + return m_filesList[row]->getFilename(); + + return QString(); +} + +QString ListImagesModel::getFilename(const QModelIndex &index) const +{ + if ( index.isValid() ) + return m_filesList[index.row()]->getFilename(); + + return QString(); +} + +QPoint ListImagesModel::getOffset(int row) const +{ + if ( row >= 0 && row < m_filesList.size() ) + return m_filesList[row]->getOffset(m_nbScreens); + + return QPoint(); +} + +QPoint ListImagesModel::getOffset(const QModelIndex &index) const +{ + if ( index.isValid() ) + return m_filesList[index.row()]->getOffset(m_nbScreens); + + return QPoint(); +} + +void ListImagesModel::setLastAppliedRow(int ind) +{ + if (ind == m_lastAppliedRow) + return; + + // update display + QModelIndex prevIndex = createIndex(m_lastAppliedRow, 0); + m_lastAppliedRow = ind; + QModelIndex newIndex = createIndex(m_lastAppliedRow, 0); + + if ( prevIndex.isValid() ) + emit dataChanged( prevIndex,prevIndex.sibling(0,0) ); + if ( newIndex.isValid() ) + emit dataChanged( newIndex,newIndex.sibling(0,0) ); +} + +void ListImagesModel::setLastPreviewedRow(int ind) +{ + m_lastPreviewedRow = ind; +} + +void ListImagesModel::resetChache() +{ + m_updater->cancel(); + m_updater->clearCache(); + foreach(ImageInfos * ii, m_filesList) + ii->reset(); + emit updateInfos(m_filesList); +} + +void ListImagesModel::setScreenNumber(int num) +{ + if (num == m_nbScreens) + return; + + m_nbScreens = num; + reset(); // must take all new config for new screen number +} diff -Nru syncwall-1.6.0/src/ListImagesModel.h syncwall-1.7.4/src/ListImagesModel.h --- syncwall-1.6.0/src/ListImagesModel.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/ListImagesModel.h 2013-05-05 23:37:34.000000000 +0000 @@ -0,0 +1,131 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#ifndef _LISTIMAGESMODEL_H_ +#define _LISTIMAGESMODEL_H_ + +#include +#include +#include +#include +#include +#include + +class ImageInfos; +class InfosUpdater; + +class ListImagesModel : public QAbstractItemModel +{ + Q_OBJECT + +public: + + enum + { + MODE_LIST = 0, // not used anymore + MODE_DETAILS, + MODE_ICONS + } typMode; + + enum + { + COLUMN_NAME = 0, + COLUMN_RATE, + COLUMN_IMAGESIZE, + COLUMN_FILESIZE, + COLUMN_USER_ADJUST, + COLUMN_NB + } typColumn; + + ListImagesModel( QObject *parent = 0 ); + virtual ~ListImagesModel(); + + virtual QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const; + virtual QModelIndex parent ( const QModelIndex & index ) const; + virtual int columnCount ( const QModelIndex & parent = QModelIndex() ) const; + + virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const; + virtual QVariant headerData (int inSection, Qt::Orientation inOrientation, int inRole) const; + virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); + virtual Qt::ItemFlags flags( const QModelIndex &index ) const; + + bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() ); + + void removeRows( const QModelIndexList& indexes ); + + int rowCount( const QModelIndex &parent = QModelIndex() ) const; + int getImageCount() const { return m_filesList.size(); } + + void addImages( const QStringList & list ); + + QString getFilename(const QModelIndex &index) const; + QString getFilename(int) const; + QPoint getOffset(const QModelIndex &index) const; + QPoint getOffset(int) const; + int getRating(int) const; + int getIndex(const QModelIndex &index) const; + int getIndex(const QString &filename) const; + + void setDisplayMode(int); + int getDisplayMode() const { return m_mode; } + + void clear(); + + void setLastAppliedRow(int); + void setLastPreviewedRow(int); + + void resetChache(); + + void setScreenNumber(int); + +signals: + + void updateInfos(const QList &); + void storeInfos(ImageInfos *); + void removeInfos(const QString &); + void updateFinished(); + +private slots: + + void refresh (ImageInfos *); + +private: + + //QVariant dataList( const QModelIndex &index, int role = Qt::DisplayRole ) const; + QVariant dataDetails( const QModelIndex &index, int role = Qt::DisplayRole ) const; + QVariant dataIcons( const QModelIndex &index, int role = Qt::DisplayRole ) const; + + QPixmap shadoizePixmap(const QImage &pm) const; + void drawShadow(QPainter* painter, const QRect& rect) const; + QPixmap generateFuzzyRect(const QSize& size, const QColor& color, int radius) const; + ImageInfos * getInfos(const QString &filename); + + QList m_filesList; + + InfosUpdater *m_updater; + int m_mode; + mutable QMap m_shadowCache; + QSet m_alreadyDefined; + int m_lastAppliedRow; // last applied wallpaper + int m_lastPreviewedRow; // last previewed file + int m_nbScreens; +}; + +#endif // _LISTIMAGESMODEL_H_ diff -Nru syncwall-1.6.0/src/LogHandler.cpp syncwall-1.7.4/src/LogHandler.cpp --- syncwall-1.6.0/src/LogHandler.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/LogHandler.cpp 2013-05-05 23:37:30.000000000 +0000 @@ -0,0 +1,142 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#include "LogHandler.h" +#include + +LogHandler* LogHandler::m_Instance = 0; + +LogHandler *LogHandler::getInstance() +{ + static QMutex mutex; + + if (!m_Instance) + { + mutex.lock(); + + if (!m_Instance) + m_Instance = new LogHandler; + + mutex.unlock(); + } + + return m_Instance; +} + +LogHandler::~LogHandler() +{ + static QMutex mutex; + mutex.lock(); + m_Instance = 0; + mutex.unlock(); +} + +LogHandler::LogHandler( ) : + m_currLevel(MSG_DEBUG), + m_bufferized(true) +{ +} + +void LogHandler::reportMessage(MessageLevel level, const QString &message ) +{ + // message Ignored + if (level < m_currLevel) + return; + + QString msgText( message ); + msgText.replace( "<", "<" ); + msgText.replace( ">", ">" ); + + // add the current time + msgText = QTime::currentTime().toString("[hh:mm:ss]: ") + msgText; + QString msg; + + switch (level) + { + case MSG_DEBUG: + { + msg = QString( "DEBUG: " ) + msgText; + break; + } + + case MSG_INFO: + { + msg = QString( "INFO: " ) + msgText; + break; + } + + case MSG_WARNING: + { + msg = QString( "WARNING: " ) + msgText; + break; + } + + case MSG_ERROR: + { + msg = QString( " ERROR:" ) + msgText; + break; + } + + default: + { + msg = msgText; + break; + } + } + + qDebug( "%s",msg.toStdString().c_str() ); + if (m_bufferized) + m_buffer << msg; + else + emit newMessage(msg); +} + +void LogHandler::reportDebug(const QString &message ) +{ + reportMessage(IMessageHandler::MSG_DEBUG,message); +} + +void LogHandler::reportInfo(const QString &message ) +{ + reportMessage(IMessageHandler::MSG_INFO,message); +} + +void LogHandler::reportWarning(const QString &message ) +{ + reportMessage(IMessageHandler::MSG_WARNING,message); +} + +void LogHandler::reportError(const QString &message ) +{ + reportMessage(IMessageHandler::MSG_ERROR,message); +} + +void LogHandler::setBufferization(bool val) +{ + m_bufferized = val; + if (!m_bufferized) // send all stored messages + { + foreach (const QString &mess, m_buffer) + { + emit newMessage(mess); + } + m_buffer.clear(); + } +} diff -Nru syncwall-1.6.0/src/LogHandler.h syncwall-1.7.4/src/LogHandler.h --- syncwall-1.6.0/src/LogHandler.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/LogHandler.h 2013-05-05 23:37:34.000000000 +0000 @@ -0,0 +1,82 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#ifndef _LOGHANDLER_H_ +#define _LOGHANDLER_H_ + +#include "IMessageHandler.h" + +#include +#include +#include + +//! A dialog for displaying message from reader/writer + +/*! + * Displaying colored message by taking care of the message level + */ + +class LogHandler : + public QObject, public IMessageHandler +{ + Q_OBJECT + +public: + + static LogHandler *getInstance(); + ~LogHandler(); + + void setMessageLevel(MessageLevel level) + { + m_currLevel = level; + } + + void setBufferization(bool); + +public slots: + + void reportMessage(MessageLevel level, const QString &message ); + void reportDebug(const QString &message ); + void reportInfo(const QString &message ); + void reportWarning(const QString &message ); + void reportError(const QString &message ); + +signals: + + void newMessage(const QString &); + +private: + + LogHandler( ); + + LogHandler(const LogHandler &); // hide copy constructor + LogHandler& operator=(const LogHandler &); // hide assign op + // we leave just the declarations, so the compiler will warn us + // if we try to use those two functions by accident + +private: + + static LogHandler* m_Instance; + MessageLevel m_currLevel; + QStringList m_buffer; + bool m_bufferized; +}; + +#endif // _LOGHANDLER_H_ diff -Nru syncwall-1.6.0/src/MiscFunctions.cpp syncwall-1.7.4/src/MiscFunctions.cpp --- syncwall-1.6.0/src/MiscFunctions.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/MiscFunctions.cpp 2013-07-13 05:30:42.000000000 +0000 @@ -0,0 +1,309 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "MiscFunctions.h" +#include "LogHandler.h" +#include "AppSettings.h" + +#if !defined(WIN32) +#include // for unlink +#endif + +QString MiscFunctions::getValidStorage() +{ +#ifdef Q_WS_X11 // on unix => write to the user home + return QDir::homePath() + "/." + PACKAGE_NAME; + +#else // other case + return QDesktopServices::storageLocation(QDesktopServices::DataLocation); + +#endif +} + +void MiscFunctions::cleanTempStorage(const QStringList &filter, const QString &root) +{ + LogHandler::getInstance()->reportDebug( QObject::tr("Cleaning temp storage %1 ...").arg( getValidStorage() ) ); + QDir dir( getValidStorage() ); + QFileInfoList list = dir.entryInfoList(filter); + foreach (const QFileInfo &info, list) + { + if ( root.isEmpty() ) + { + unlink( info.absoluteFilePath().toStdString().c_str() ); + } + else // restrict unlink to file containing the "root" value + { + if ( info.absoluteFilePath().contains(root) ) + { + unlink( info.absoluteFilePath().toStdString().c_str() ); + LogHandler::getInstance()->reportDebug( QObject::tr("Deleting %1").arg( info.absoluteFilePath() ) ); + } + } + } +} + +QStringList MiscFunctions::getAvailablesImageFormatsList() +{ + QList supportedFormats = QImageReader::supportedImageFormats(); + QStringList result; + QListIterator supportedFormat(supportedFormats); + QByteArray format; + + while ( supportedFormat.hasNext() ) + { + format = supportedFormat.next().toLower(); + + if ( !result.contains(format) ) + result << format; + } + + return result; +} + +/* + * Extract from Wally - Qt4 wallpaper/background changer + * Copyright (C) 2009 Antonio Di Monaco + */ + +QMap MiscFunctions::getLongImageFormats() +{ + QMap formats; + + formats["bw"] = "Black & White"; + formats["eps"] = "Encapsulated Postscript"; + formats["epsf"] = "Encapsulated PostScript"; + formats["epsi"] = "Encapsulated PostScript Interchange"; + formats["exr"] = "OpenEXR"; + formats["pcx"] = "PC Paintbrush Exchange"; + formats["psd"] = "Photoshop Document"; + formats["rgb"] = "Raw red, green, and blue samples"; + formats["rgba"] = "Raw red, green, blue, and alpha samples"; + formats["sgi"] = "Irix RGB"; + formats["tga"] = "Truevision Targa"; + formats["xcf"] = "eXperimental Computing Facility (GIMP)"; + formats["dds"] = "DirectDraw Surface"; + formats["xv"] = "Khoros Visualization"; + formats["bmp"] = "Windows Bitmap"; + formats["gif"] = "Graphic Interchange Format"; + formats["jpg"] = "Joint Photographic Experts Group"; + formats["jpeg"] = "Joint Photographic Experts Group"; + formats["jp2"] = "Joint Photographic Experts Group 2000"; + formats["mng"] = "Multiple-image Network Graphics"; + formats["png"] = "Portable Network Graphics"; + formats["pbm"] = "Portable Bitmap"; + formats["pgm"] = "Portable Graymap"; + formats["ppm"] = "Portable Pixmap"; + formats["tiff"] = "Tagged Image File Format"; + formats["tif"] = "Tagged Image File Format"; + formats["xbm"] = "X11 Bitmap"; + formats["xpm"] = "X11 Pixmap"; + formats["ico"] = "Icon Image"; + formats["svg"] = "Scalable Vector Graphics"; + + return formats; +} + +QString MiscFunctions::getAvailablesImageFormats() +{ + QString imglist; + QStringList formats = getAvailablesImageFormatsList(); + for (int i = 0; i < formats.size(); ++i) + imglist += "*." + formats[i] + " "; + + return imglist; +} + +QString MiscFunctions::getTranslationsPath() +{ + // search in application path + QStringList ldir; + ldir << QCoreApplication::applicationDirPath () + "/lang"; + ldir << QCoreApplication::applicationDirPath () + "/../lang"; + ldir << QCoreApplication::applicationDirPath () + "/../../lang"; + ldir << "/usr/local/share/locale"; + ldir << "/usr/share/local/locale"; + + foreach (const QString &dir, ldir) + { + QDir gdp (dir); + if ( QDir(dir).exists() ) + return dir; + } + + return ""; +} + +QMap MiscFunctions::getAvailableLanguages() +{ + QMap languageMap; + QDir dir( MiscFunctions::getTranslationsPath() ); + QRegExp expr(QString("^%1_(\\w+)\\.qm$").arg(PACKAGE_NAME).toLower()); + QStringList files = dir.entryList(QDir::Files, QDir::Name); + + LogHandler::getInstance()->reportDebug( QObject::tr("translations path %1").arg( dir.path() ) ); + + foreach ( const QString &file, files ) + { + if ( !file.contains(expr) ) + continue; + + QString lang = expr.cap(1); + QString name = QString("%1 (%2)").arg(QLocale::languageToString( QLocale(lang).language() ), lang); + + languageMap[name] = lang; + } + return languageMap; +} + +void MiscFunctions::setDefaultLanguage() +{ + QString lang; + AppSettings settings; + + settings.beginGroup("Application"); + lang = settings.value("currentLanguage","auto").toString(); + settings.endGroup(); + + if ( lang.isEmpty() ) + lang = QLocale::system().name().left(2); + + if ( !lang.isEmpty() ) + setLanguage(lang); +} + +void MiscFunctions::setLanguage(const QString& lang) +{ + QString language(lang); + LogHandler::getInstance()->reportDebug( QObject::tr("setting language to : %1").arg(language) ); + + // special cases + if (language == "auto") // auto detection + { + language = QLocale::system().name().left(2); + } + else if (language == "default") // no use of translator + { + return; + } + + // try load the qt translator for selected language + QTranslator *qt = new QTranslator(); + QStringList excludedFiles; + QString globalTranslationPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath); + if (!QFileInfo(globalTranslationPath).exists()) + globalTranslationPath = MiscFunctions::getTranslationsPath(); + + if ( qt->load( "qt_" + language, globalTranslationPath ) ) + { + LogHandler::getInstance()->reportDebug( QObject::tr("successfully loaded data from %1").arg( globalTranslationPath + "/qt_" + language ) ); + QCoreApplication::installTranslator(qt); + excludedFiles << "qt_" + language + ".qm"; + } + else + { + delete qt; + } + + QString suff = language + ".qm"; + QDir dir( MiscFunctions::getTranslationsPath() ); + + foreach ( const QString &s, dir.entryList(QDir::Files | QDir::Readable) ) + { + if ( !s.endsWith(suff) || excludedFiles.contains(s)) + continue; + QTranslator *t = new QTranslator(); + + if ( t->load( dir.filePath(s) ) ) + { + QCoreApplication::installTranslator(t); + LogHandler::getInstance()->reportDebug( QObject::tr("successfully loaded data from %1").arg( dir.filePath(s) ) ); + } + else + { + delete t; + LogHandler::getInstance()->reportDebug( QObject::tr("failed to load data from %1").arg( dir.filePath(s) ) ); + } + } +} + +QPixmap MiscFunctions::getScreenShot(int screenNb) +{ + QDesktopWidget *scr = QApplication::desktop(); + return QPixmap::grabWindow( scr->screen(screenNb)->winId() ); +} + +QString MiscFunctions::getSignificantPart(const QString &file) +{ + // we send only the last dir and the basename of the file + QStringList list = file.split( QRegExp("/") ); + + if (list.size() >= 2) + return list[list.size() - 2 ] + "/" + list[list.size() - 1]; + + return list[list.size() - 1]; +} + +QString MiscFunctions::launchExternalSynchronousProcess(const QString program, const QStringList &arguments) +{ + QProcess proc; + + /* Start process */ + proc.setReadChannelMode(QProcess::MergedChannels); + proc.start(program, arguments); + proc.waitForFinished(); + + /* Retrieve the output results and get the difference value */ + QString output = ( QString( proc.readAllStandardOutput() ) ).trimmed(); + proc.kill(); + proc.waitForFinished(); + return output; +} + +void MiscFunctions::updateApplicationIdentity() +{ + QCoreApplication::setApplicationName(PACKAGE_NAME); + QCoreApplication::setApplicationVersion(PACKAGE_VERSION); + QCoreApplication::setOrganizationName(PACKAGE_ORGANIZATION); +} + +bool MiscFunctions::hasSmallUI() +{ + QRect screen = QApplication::desktop()->screenGeometry(); + + // A bit ugly, no ? TODO find a better way to define a "small" screen + if (screen.height() < 400 * 2) + return true; + else + return false; +} diff -Nru syncwall-1.6.0/src/MiscFunctions.h syncwall-1.7.4/src/MiscFunctions.h --- syncwall-1.6.0/src/MiscFunctions.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/MiscFunctions.h 2013-05-05 23:37:34.000000000 +0000 @@ -0,0 +1,56 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#ifndef _MISCFUNCTIONS_H_ +#define _MISCFUNCTIONS_H_ + +#include +#include + +class MiscFunctions +{ +public: + + // give a valid directory for temporary files + static QString getValidStorage(); + + // clean temporary files according to files + static void cleanTempStorage(const QStringList &filter, const QString &root = ""); + + // images function + static QString getAvailablesImageFormats(); + static QStringList getAvailablesImageFormatsList(); + static QMap getLongImageFormats(); + + // translations functions + static QString getTranslationsPath(); + static QMap getAvailableLanguages(); + static void setDefaultLanguage(); + static void setLanguage(const QString& lang); + static QPixmap getScreenShot(int screen = -1); + static QString getSignificantPart(const QString &file); + static QString launchExternalSynchronousProcess(const QString program, const QStringList &arguments); + + static void updateApplicationIdentity(); + + static bool hasSmallUI(); +}; + +#endif // _MISCFUNCTIONS_H_ diff -Nru syncwall-1.6.0/src/NetworkManager.cpp syncwall-1.7.4/src/NetworkManager.cpp --- syncwall-1.6.0/src/NetworkManager.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/NetworkManager.cpp 2013-05-05 23:37:30.000000000 +0000 @@ -0,0 +1,269 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#include +#include +#include + +#include "NetworkManager.h" +#include "LogHandler.h" +#include "AppSettings.h" + +const int defaultUdpPort = 55555; +const int defaultPingTimeout = 15 * 1000; + +NetworkManager::NetworkManager(QObject *parent) + : QObject(parent), + m_udpSocket(NULL), + m_timer(NULL), + m_pingTimer(NULL), + m_udpPort(0), + m_mode(0), + m_desc("no description"), + m_waitAnswer(NULL), + m_initialized(false) +{ + loadSettings(); + + // can't initialize other member because current thread isn't final thread !!! +} + +NetworkManager::~NetworkManager() +{ + //saveSettings(); + //delete m_udpSocket; + + m_timer->stop(); + m_waitAnswer->stop(); +} + +void NetworkManager::initialize() +{ + if (m_initialized) + return; + + m_timer = new QTimer(this); + m_pingTimer = new QTimer(this); + m_waitAnswer = new QTimer(this); + + m_udpSocket = new QUdpSocket(); + + connect( m_udpSocket, SIGNAL( readyRead() ),this, SLOT( processPendingDatagrams() ) ); + connect( m_waitAnswer, SIGNAL( timeout() ), this, SIGNAL( serverDown() ), Qt::QueuedConnection ); + connect( m_pingTimer, SIGNAL( timeout() ), this, SLOT( pingServer() ) ); + + m_initialized = true; +} + +void NetworkManager::start() +{ + initialize(); + + updateConfig(); + if (m_mode != MODE_SERVER) + pingServer(); +} + +void NetworkManager::loadSettings() +{ + AppSettings settings; + + settings.beginGroup("NetworkManager"); + + m_udpPort = settings.value("udpPort",defaultUdpPort).toInt(); + m_serverName = settings.value("serverName","").toString(); + m_mode = settings.value("mode",MODE_SERVER).toInt(); + + settings.endGroup(); +} + +void NetworkManager::saveSettings() +{ + AppSettings settings; + + settings.beginGroup("NetworkManager"); + + settings.setValue("udpPort", m_udpPort); + settings.setValue("serverName", m_serverName); + settings.setValue("mode", m_mode); + + settings.endGroup(); +} + +void NetworkManager::setServerName(const QString &name) +{ + m_serverName = name; +} + +void NetworkManager::updateConfig() +{ + int port; + + // listen to different port switch network mode + if (m_mode == MODE_SERVER) + { + port = m_udpPort; + m_pingTimer->stop(); + LogHandler::getInstance()->reportDebug( QObject::tr("NetworkManager: Mode SERVER listen to %1 port").arg(port) ); + } + else + { + port = m_udpPort + 1; + + // start the "ping" server timer + m_pingTimer->start(defaultPingTimeout); + LogHandler::getInstance()->reportDebug( QObject::tr("NetworkManager: Mode CLIENT listen to %1 port").arg(port) ); + } + + m_udpSocket->disconnectFromHost(); + m_udpSocket->bind(port); +} + +void NetworkManager::setPort(int p) +{ + if (p == m_udpPort) + return; + + m_udpPort = p; + + updateConfig(); +} + +void NetworkManager::setMode(int mode) +{ + if (m_mode == mode) + return; + + m_mode = mode; + + // clear client list + if (m_mode == MODE_CLIENT) + m_clients.clear(); + + updateConfig(); +} + +void NetworkManager::broadcastDatagramSendServerIdentification(const QHostAddress &addr) +{ + int port; + + if (m_mode == MODE_SERVER) + port = m_udpPort + 1; + else + port = m_udpPort; + + LogHandler::getInstance()->reportDebug( QObject::tr("NetworkManager: Send Server Identification for \"%1\" on port %2").arg( addr.toString() ).arg(port) ); + + // prepare identification and description + QByteArray datagram = QString("Syncwall Server Answer desc=#%2#").arg(m_desc).toLatin1(); + m_udpSocket->writeDatagram(datagram.data(), datagram.size(),addr, port); +} + +void NetworkManager::processPendingDatagrams() +{ + while ( m_udpSocket->hasPendingDatagrams() ) + { + QByteArray datagram; + datagram.resize( m_udpSocket->pendingDatagramSize() ); + QHostAddress sender; + quint16 senderPort; + m_udpSocket->readDatagram(datagram.data(), datagram.size(),&sender, &senderPort); + + LogHandler::getInstance()->reportDebug( QObject::tr("NetworkManager: Received message on port %1").arg(senderPort) ); + + if ( datagram.startsWith("Syncwall Server Call") ) + { + LogHandler::getInstance()->reportDebug( QObject::tr("NetworkManager: Received Server call datagram: \"%1\"").arg( datagram.data() ) ); + broadcastDatagramSendServerIdentification(sender); + + if ( !m_clients.contains(sender) ) + { + LogHandler::getInstance()->reportDebug( QObject::tr("NetworkManager: Adding %1 to client list").arg( sender.toString() ) ); + m_clients << sender; + } + else + { + LogHandler::getInstance()->reportDebug( QObject::tr("NetworkManager: %1 is already in the client list").arg( sender.toString() ) ); + } + + // send the current background + broadcastDatagramSendBackground(sender); + } + else if ( datagram.startsWith("Syncwall Server Answer") ) + { + m_waitAnswer->stop(); + emit serverAlive(); + } + else if ( datagram.startsWith("Syncwall Change Background") ) + { + QList bg = datagram.split(' '); + LogHandler::getInstance()->reportDebug( QObject::tr("NetworkManager: Received background change: \"%1\"").arg( QString(bg[3]) ) ); + emit newMessage( QString(bg[3]) ); + } + } +} + +void NetworkManager::searchServer(const QString &hostname) +{ + QHostInfo info = QHostInfo::fromName(hostname); + if ( !info.addresses().isEmpty() ) + { + broadcastDatagramSearchServers(info.addresses()[0]); + m_waitAnswer->start(2000); + } + else + LogHandler::getInstance()->reportError( QObject::tr("NetworkManager: no address found for host %1 (%2)").arg(hostname).arg( info.errorString() ) ); +} + +void NetworkManager::broadcastDatagramSearchServers(const QHostAddress &addr) +{ + LogHandler::getInstance()->reportDebug( QObject::tr("NetworkManager: Send Server Call for \"%1\" on port %2").arg( addr.toString() ).arg(m_udpPort) ); + QByteArray datagram = "Syncwall Server Call"; + m_udpSocket->writeDatagram(datagram.data(), datagram.size(), addr, m_udpPort); +} + +void NetworkManager::broadcastDatagramSendBackground(const QHostAddress &addr) +{ + LogHandler::getInstance()->reportDebug( QObject::tr("NetworkManager: Send message to \"%1\" (%2) on port %3").arg( addr.toString() ).arg(m_currentMessage).arg(m_udpPort + 1) ); + QByteArray datagram = QString("Syncwall Change Background %1").arg(m_currentMessage).toLatin1(); + m_udpSocket->writeDatagram(datagram.data(), datagram.size(), addr, m_udpPort + 1); +} + +void NetworkManager::sendNewMessage(const QString &img) +{ + m_currentMessage = img; + + for (int i = 0; i < m_clients.size(); i++) + { + LogHandler::getInstance()->reportDebug( QObject::tr("NetworkManager:: Sending new message to client %1 ").arg( m_clients[i].toString() ) ); + broadcastDatagramSendBackground(m_clients[i]); + } +} + +QAbstractSocket::SocketState NetworkManager::getState() const +{ + return m_udpSocket->state(); +} + +void NetworkManager::pingServer() +{ + LogHandler::getInstance()->reportDebug( QObject::tr("NetworkManager:: Ping server %1").arg(m_serverName) ); + searchServer(m_serverName); +} diff -Nru syncwall-1.6.0/src/NetworkManager.h syncwall-1.7.4/src/NetworkManager.h --- syncwall-1.6.0/src/NetworkManager.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/NetworkManager.h 2013-05-05 23:37:34.000000000 +0000 @@ -0,0 +1,96 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#ifndef _NETWORKMANAGER_H_ +#define _NETWORKMANAGER_H_ + +#include +#include + +class QTimer; +class QUdpSocket; + +class NetworkManager : + public QObject +{ + Q_OBJECT + +public: + + enum NetworkMode + { + MODE_SERVER = 0, + MODE_CLIENT + }; + + NetworkManager(QObject *parent = 0); + virtual ~NetworkManager(); + + int getPort() const {return m_udpPort; } + int getMode() const {return m_mode; } + const QString & getServerName() const {return m_serverName; } + QAbstractSocket::SocketState getState() const; + int getClientNb() const {return m_clients.size(); } + +signals: + + void serverAlive(); + void serverDown(); + void newMessage(const QString&); + +public slots: + + void start(); + void setServerName(const QString &name); + void setPort(int port); + void setMode(int mode); + + void searchServer(const QString &hostname); + void sendNewMessage(const QString &); + void saveSettings(); + +private slots: + + void broadcastDatagramSearchServers(const QHostAddress &addr); + void broadcastDatagramSendServerIdentification(const QHostAddress &adr); + void broadcastDatagramSendBackground(const QHostAddress &addr); + void processPendingDatagrams(); + void pingServer(); + +private: + + void updateConfig(); + void loadSettings(); + void initialize(); + + QUdpSocket *m_udpSocket; + QTimer *m_timer; + QTimer *m_pingTimer; + int m_udpPort; + QString m_serverName; + int m_mode; + QString m_desc; + QString m_currentMessage; + QTimer *m_waitAnswer; + QList m_clients; + bool m_initialized; +}; + +#endif // _NETWORKMANAGER_H_ diff -Nru syncwall-1.6.0/src/NetworkManagerConfigWidget.cpp syncwall-1.7.4/src/NetworkManagerConfigWidget.cpp --- syncwall-1.6.0/src/NetworkManagerConfigWidget.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/NetworkManagerConfigWidget.cpp 2013-05-05 23:37:30.000000000 +0000 @@ -0,0 +1,177 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#include "NetworkManagerConfigWidget.h" +#include "NetworkManager.h" +#include "ThreadPool.h" + +#include "ui_NetworkManagerConfigWidget.h" + +NetworkManagerConfigWidget::NetworkManagerConfigWidget(QWidget *parent) + : QWidget(parent), + ui(new Ui::NetworkManagerConfigWidget) +{ + ui->setupUi(this); + + m_manager = new NetworkManager(); + + m_manager->moveToThread( ThreadPool::getInstance()->getThread() ); + + // transmit NetworkManager signals + connect( m_manager, SIGNAL( serverAlive() ), this, SIGNAL( newState() ) ); + connect( m_manager, SIGNAL( serverAlive() ), this, SLOT( serverConnected() ) ); + connect( m_manager, SIGNAL( serverDown() ), this, SIGNAL( newState() ) ); + connect( m_manager, SIGNAL( serverDown() ), this, SLOT( serverDisconnected() ) ); + connect( m_manager, SIGNAL( newMessage(const QString &) ), this, SIGNAL( newMessage(const QString &) ) ); + + connect( this, SIGNAL( sigSearchServer(const QString &) ), m_manager, SLOT( searchServer(const QString &) ) ); + connect( this, SIGNAL( sigSetPort(int) ), m_manager, SLOT( setPort(int) ) ); + connect( this, SIGNAL( sigSetServerName(const QString &) ), m_manager, SLOT( setServerName(const QString &) ) ); + connect( this, SIGNAL( sigSetMode(int) ), m_manager, SLOT( setMode(int) ) ); + connect( this, SIGNAL( sigSendNewMessage(const QString &) ), m_manager, SLOT( sendNewMessage(const QString &) ) ); + connect( this, SIGNAL( sigSaveSetting() ), m_manager, SLOT( saveSettings() ) ); + connect( this, SIGNAL( sigStart() ), m_manager, SLOT( start() ) ); + + updateUI(); +} + +NetworkManagerConfigWidget::~NetworkManagerConfigWidget() +{ + delete m_manager; + delete ui; +} + +void NetworkManagerConfigWidget::updateUI() +{ + ui->groupBoxServer->setChecked(m_manager->getMode() == NetworkManager::MODE_CLIENT); + ui->lineEditServerName->setText( m_manager->getServerName() ); + ui->lineEditServerPort->setText( QString::number( m_manager->getPort() ) ); +} + +void NetworkManagerConfigWidget::on_pushButtonTestConnection_pressed() +{ + QString serverName = ui->lineEditServerName->text(); + int udpPort = ui->lineEditServerPort->text().toInt(); + + if (serverName.isEmpty() || !udpPort) + return; + + emit sigSetPort(udpPort); + + // clear the previous text + ui->labelTestConnection->setText(""); + emit sigSearchServer(serverName); +} + +void NetworkManagerConfigWidget::on_lineEditServerName_returnPressed() +{ + // change color to valid modification + QPalette pal; + pal.setColor(QPalette::Text, Qt::black); + ui->lineEditServerName->setPalette(pal); + + emit sigSetServerName( ui->lineEditServerName->text() ); +} + +void NetworkManagerConfigWidget::on_lineEditServerPort_returnPressed() +{ + // change color to valid modification + QPalette pal; + pal.setColor(QPalette::Text, Qt::black); + ui->lineEditServerPort->setPalette(pal); + + emit sigSetPort( ui->lineEditServerPort->text().toInt() ); +} + +void NetworkManagerConfigWidget::serverConnected() +{ + ui->labelTestConnection->setText( tr("Server %1 reached ...").arg( m_manager->getServerName() ) ); + emit synchronizeByNetwork(true); +} + +void NetworkManagerConfigWidget::serverDisconnected() +{ + ui->labelTestConnection->setText( tr("Disconnection from server %1 ...").arg( m_manager->getServerName() ) ); +} + +void NetworkManagerConfigWidget::on_groupBoxServer_clicked(bool val) +{ + bool synchroServer = val; + + // update the network manager + if (synchroServer) + { + emit sigSetMode(NetworkManager::MODE_CLIENT); + on_pushButtonTestConnection_pressed(); // check connection with server + } + else + { + emit sigSetMode(NetworkManager::MODE_SERVER); + } + + emit synchronizeByNetwork(synchroServer); + emit newState(); +} + +void NetworkManagerConfigWidget::on_lineEditServerName_textEdited(const QString & /*text*/) +{ + // change color to highlight modification + QPalette pal; + pal.setColor(QPalette::Text, Qt::red); + ui->lineEditServerName->setPalette(pal); +} + +void NetworkManagerConfigWidget::on_lineEditServerPort_textEdited(const QString & /*text*/) +{ + // change color to highlight modification + QPalette pal; + pal.setColor(QPalette::Text, Qt::red); + ui->lineEditServerPort->setPalette(pal); +} + +void NetworkManagerConfigWidget::sendNewMessage(const QString &mess) +{ + emit sigSendNewMessage(mess); +} + +void NetworkManagerConfigWidget::saveSettings() +{ + m_manager->saveSettings(); +} + +int NetworkManagerConfigWidget::getNetworkMode() const +{ + return m_manager->getMode(); +} + +int NetworkManagerConfigWidget::getClientNb() const +{ + return m_manager->getClientNb(); +} + +QAbstractSocket::SocketState NetworkManagerConfigWidget::getState() const +{ + return m_manager->getState(); +} + +void NetworkManagerConfigWidget::start() +{ + emit sigStart(); +} diff -Nru syncwall-1.6.0/src/NetworkManagerConfigWidget.h syncwall-1.7.4/src/NetworkManagerConfigWidget.h --- syncwall-1.6.0/src/NetworkManagerConfigWidget.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/NetworkManagerConfigWidget.h 2013-05-05 23:37:34.000000000 +0000 @@ -0,0 +1,88 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#ifndef _NETWORKMANAGERCONFIGWIDGET_H_ +#define _NETWORKMANAGERCONFIGWIDGET_H_ + +#include +#include + +class NetworkManager; + +namespace Ui +{ +class NetworkManagerConfigWidget; +} + +class NetworkManagerConfigWidget : public QWidget +{ + Q_OBJECT + +public: + + NetworkManagerConfigWidget(QWidget *parent = 0); + ~NetworkManagerConfigWidget(); + + int getNetworkMode() const; + int getClientNb() const; + QAbstractSocket::SocketState getState() const; + + void start(); + +signals: + + void newState(); + void newMessage(const QString&); + void synchronizeByNetwork(bool); + + void sigSearchServer(const QString &); + void sigSetPort(int); + void sigSetServerName(const QString &); + void sigSetMode(int); + void sigSendNewMessage(const QString &); + void sigSaveSetting(); + void sigStart(); + +public slots: + + void on_pushButtonTestConnection_pressed(); + void on_lineEditServerName_returnPressed(); + void on_lineEditServerName_textEdited(const QString &); + void on_lineEditServerPort_returnPressed(); + void on_lineEditServerPort_textEdited(const QString &); + void on_groupBoxServer_clicked(bool); + + void serverDisconnected(); + void serverConnected(); + + void sendNewMessage(const QString &mess); + + void saveSettings(); + +private: + + void updateUI(); + + Ui::NetworkManagerConfigWidget *ui; + + NetworkManager *m_manager; +}; + +#endif // _NETWORKMANAGERCONFIGWIDGET_H_ diff -Nru syncwall-1.6.0/src/Scheduler.cpp syncwall-1.7.4/src/Scheduler.cpp --- syncwall-1.6.0/src/Scheduler.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/Scheduler.cpp 2013-05-05 23:37:30.000000000 +0000 @@ -0,0 +1,225 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#include + +#include "Scheduler.h" +#include "AppSettings.h" + +#include "LogHandler.h" + +const int minInterval = 30; // 30 sec + +Scheduler::Scheduler(QObject *parent) + : QObject(parent), + m_changeAtStartup(false), + m_quitAfterChange(false), + m_intervalBetweenChangeMode(false), + m_changeByInterval(true), + m_changeInterval( QTime(0,30) ), // 30 min by default + m_idle(true) +{ + loadSettings(); + + m_eventTimer.setSingleShot(true); + connect( &m_eventTimer, SIGNAL( timeout() ), this, SLOT( newSchedule() ) ); +} + +Scheduler::~Scheduler() +{ + //saveSettings(); +} + +void Scheduler::start() +{ + m_idle = false; + checkInitState(); +} + +void Scheduler::checkInitState() +{ + if (m_changeAtStartup && !m_idle) + { + QTimer::singleShot( 1000, this, SLOT( newSchedule() ) ); + LogHandler::getInstance()->reportDebug("Change at Startup ..."); + + if (m_quitAfterChange) + { + LogHandler::getInstance()->reportDebug("Auto Quit application is 30 sec ..."); + QTimer::singleShot( 30000, this, SIGNAL( quit() ) ); + } + } + + setupNextInterval(); +} + +void Scheduler::setupNextInterval() +{ + if (!m_intervalBetweenChangeMode || m_idle) + return; + + m_referenceTime = QDateTime::currentDateTime(); + + if (m_changeByInterval) // stable interval between each event + { + int count = -m_changeInterval.secsTo( QTime(0,0,0) ); + if (count < minInterval) + { + LogHandler::getInstance()->reportDebug( tr("update interval is to low (%1) => force to %2 sec ...").arg(count).arg(minInterval) ); + count = minInterval; + } + m_eventTimer.start(count * 1000); + LogHandler::getInstance()->reportDebug( tr("Start new timer for %1 sec ...").arg(count) ); + } + else // variable interval (list of Time Of Day) + { + // search for next valid time + QTime currentTime = QTime::currentTime(); + foreach (const QTime &time, m_listTimeOfDay) + { + if (time > currentTime) + { + int count = currentTime.secsTo(time); + m_eventTimer.start(count * 1000); + LogHandler::getInstance()->reportDebug( tr("Start new timer for %1 sec ...").arg(count) ); + break; + } + } + } +} + +void Scheduler::newSchedule() +{ + if (m_idle) + return; + + LogHandler::getInstance()->reportDebug( tr("New Schedule fired ...") ); + emit newEvent(); + setupNextInterval(); +} + +void Scheduler::restartScheduler() +{ + setupNextInterval(); +} + +void Scheduler::loadSettings() +{ + AppSettings settings; + + settings.beginGroup("Scheduler"); + + m_changeAtStartup = settings.value("changeAtStartup",false).toBool(); + m_quitAfterChange = settings.value("quitAfterChange",false).toBool(); + m_intervalBetweenChangeMode = settings.value("intervalBetweenChangeMode",false).toBool(); + + m_changeByInterval = settings.value("changeByInterval",true).toBool(); + + m_changeInterval = settings.value("changeInterval","").toTime(); + + int size = settings.beginReadArray("listTimeOfDay"); + for (int i = 0; i < size; ++i) + { + settings.setArrayIndex(i); + m_listTimeOfDay << settings.value("tod").toTime(); + } + settings.endArray(); + + settings.endGroup(); +} + +void Scheduler::saveSettings() +{ + AppSettings settings; + + settings.beginGroup("Scheduler"); + + settings.setValue("changeAtStartup", m_changeAtStartup); + settings.setValue("quitAfterChange", m_quitAfterChange); + settings.setValue("intervalBetweenChangeMode", m_intervalBetweenChangeMode); + + settings.setValue("changeByInterval", m_changeByInterval); + + settings.setValue("changeInterval", m_changeInterval); + + settings.beginWriteArray( "listTimeOfDay", m_listTimeOfDay.count() ); + for (int i = 0; i < m_listTimeOfDay.size(); ++i) + { + settings.setArrayIndex(i); + settings.setValue( "tod", m_listTimeOfDay.at(i) ); + } + settings.endArray(); + + settings.endGroup(); +} + +void Scheduler::setChangeByInterval(bool val) +{ + m_changeByInterval = val; + setupNextInterval(); +} + +void Scheduler::setChangeAtStartup(bool val) +{ + m_changeAtStartup = val; +} + +void Scheduler::setQuitAfterChange(bool val) +{ + m_quitAfterChange = val; +} + +void Scheduler::setIntervalBetweenChangeMode(bool val) +{ + m_intervalBetweenChangeMode = val; + setupNextInterval(); +} + +void Scheduler::setInterval(const QTime &time) +{ + m_changeInterval = time; + setupNextInterval(); +} + +bool Scheduler::addTOD(const QTime &tod) +{ + if (m_listTimeOfDay.indexOf(tod) != -1) + return false; + + m_listTimeOfDay << tod; + qSort(m_listTimeOfDay); + setupNextInterval(); + return true; +} + +bool Scheduler::deleteTOD(const QTime &tod) +{ + bool ok = m_listTimeOfDay.removeOne(tod); + if (ok) + setupNextInterval(); + return ok; +} + +void Scheduler::setIdle(bool val) +{ + m_idle = val; + if (!m_idle) + setupNextInterval(); +} diff -Nru syncwall-1.6.0/src/Scheduler.h syncwall-1.7.4/src/Scheduler.h --- syncwall-1.6.0/src/Scheduler.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/Scheduler.h 2013-05-05 23:37:34.000000000 +0000 @@ -0,0 +1,98 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#ifndef _SCHEDULER_H_ +#define _SCHEDULER_H_ + +#include +#include +#include +#include + +class Scheduler : + public QObject +{ + Q_OBJECT + +public: + + Scheduler(QObject *parent = NULL); + virtual ~Scheduler(); + + void start(); + + void setIdle(bool); + bool isIdle() const {return m_idle; } + + // settings Accessors + void setChangeAtStartup(bool val); + bool getChangeAtStartup() const {return m_changeAtStartup; } + + void setQuitAfterChange(bool val); + bool getQuitAfterChange() const {return m_quitAfterChange; } + + void setIntervalBetweenChangeMode(bool val); + bool getIntervalBetweenChangeMode() const {return m_intervalBetweenChangeMode; } + + void setInterval(const QTime &); + const QTime &getInterval() const {return m_changeInterval; } + + void setChangeByInterval(bool); + bool getChangeByInterval() const { return m_changeByInterval; } + + bool addTOD(const QTime &); + bool deleteTOD(const QTime &); + const QList & getTODList() const { return m_listTimeOfDay; } + + void restartScheduler(); + +public slots: + + void newSchedule(); + void checkInitState(); + void saveSettings(); + +signals: + + void newEvent(); + void quit(); + +private: + + void loadSettings(); + + void setupNextInterval(); + + // preferences + + bool m_changeAtStartup; + bool m_quitAfterChange; + bool m_intervalBetweenChangeMode; + + bool m_changeByInterval; + + QTime m_changeInterval; + QList m_listTimeOfDay; + QTimer m_eventTimer; + QDateTime m_referenceTime; + bool m_idle; +}; + +#endif // _SCHEDULER_H_ diff -Nru syncwall-1.6.0/src/SchedulerConfigWidget.cpp syncwall-1.7.4/src/SchedulerConfigWidget.cpp --- syncwall-1.6.0/src/SchedulerConfigWidget.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/SchedulerConfigWidget.cpp 2013-05-05 23:37:30.000000000 +0000 @@ -0,0 +1,124 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#include "SchedulerConfigWidget.h" + +#include "ui_SchedulerConfigWidget.h" + +SchedulerConfigWidget::SchedulerConfigWidget(QWidget *parent) : + QWidget(parent), + ui(new Ui::SchedulerConfigWidgetClass) +{ + ui->setupUi(this); + + // transmit scheduler signals + connect( &m_scheduler, SIGNAL( newEvent() ), this, SIGNAL( newEvent() ) ); + connect( &m_scheduler, SIGNAL( quit() ), this, SIGNAL( quit() ) ); + + updateUI(); +} + +SchedulerConfigWidget::~SchedulerConfigWidget() +{ + delete ui; +} + +void SchedulerConfigWidget::updateUI() +{ + ui->checkBoxStartup->setChecked( m_scheduler.getChangeAtStartup() ); + ui->checkBoxStartupAndQuit->setChecked( m_scheduler.getQuitAfterChange() ); + ui->groupBoxFrequency->setChecked( m_scheduler.getIntervalBetweenChangeMode() ); + ui->radioButtonInterval->setChecked( m_scheduler.getChangeByInterval() ); + ui->radioButtonTimeOfDay->setChecked( !m_scheduler.getChangeByInterval() ); + ui->timeEditInterval->setTime( m_scheduler.getInterval() ); + rebuildTODList(); +} + +void SchedulerConfigWidget::on_checkBoxStartup_stateChanged ( int state ) +{ + m_scheduler.setChangeAtStartup(state); +} + +void SchedulerConfigWidget::on_checkBoxStartupAndQuit_stateChanged ( int state ) +{ + m_scheduler.setQuitAfterChange(state); +} + +void SchedulerConfigWidget::on_groupBoxFrequency_clicked(bool val) +{ + m_scheduler.setIntervalBetweenChangeMode(val); + emit newState(); +} + +void SchedulerConfigWidget::on_radioButtonInterval_toggled(bool val) +{ + m_scheduler.setChangeByInterval(val); +} + +void SchedulerConfigWidget::on_radioButtonTimeOfDay_toggled(bool /*val*/) +{ +} + +void SchedulerConfigWidget::on_timeEditInterval_timeChanged(const QTime & time) +{ + m_scheduler.setInterval(time); +} + +void SchedulerConfigWidget::on_pushButtonAddTOD_pressed() +{ + if ( m_scheduler.addTOD( ui->timeEditTOD->time() ) ) + rebuildTODList(); +} + +void SchedulerConfigWidget::on_pushButtonDeleteTOD_pressed() +{ + QList items = ui->listWidgetTOD->selectedItems (); + + if ( items.isEmpty() ) + return; + + foreach (QListWidgetItem * item, items) + { + m_scheduler.deleteTOD( QTime::fromString(item->text(), "hh:mm:ss") ); + } + + rebuildTODList(); +} + +void SchedulerConfigWidget::rebuildTODList() +{ + ui->listWidgetTOD->clear(); + const QList &list = m_scheduler.getTODList(); + foreach(const QTime &time, list) + { + new QListWidgetItem(time.toString(), ui->listWidgetTOD); + } +} + +void SchedulerConfigWidget::setIdle(bool val) +{ + ui->groupBoxProperties->setEnabled(val == false); + m_scheduler.setIdle(val); +} + +void SchedulerConfigWidget::saveSettings() +{ + m_scheduler.saveSettings(); +} diff -Nru syncwall-1.6.0/src/SchedulerConfigWidget.h syncwall-1.7.4/src/SchedulerConfigWidget.h --- syncwall-1.6.0/src/SchedulerConfigWidget.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/SchedulerConfigWidget.h 2013-05-05 23:37:34.000000000 +0000 @@ -0,0 +1,83 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#ifndef _SCHEDULERCONFIGWIDGET_H_ +#define _SCHEDULERCONFIGWIDGET_H_ + +#include + +#include + +#include "Scheduler.h" + +namespace Ui +{ +class SchedulerConfigWidgetClass; +} + +class SchedulerConfigWidget : public QWidget +{ + Q_OBJECT + +public: + + explicit SchedulerConfigWidget(QWidget *parent = 0); + ~SchedulerConfigWidget(); + + void start() {m_scheduler.start(); } + + bool getIntervalBetweenChangeMode() const {return m_scheduler.getIntervalBetweenChangeMode(); } + + void restartScheduler() {m_scheduler.restartScheduler(); } + +public slots: + + void on_checkBoxStartup_stateChanged ( int ); + void on_checkBoxStartupAndQuit_stateChanged ( int ); + void on_groupBoxFrequency_clicked(bool); + void on_radioButtonInterval_toggled(bool); + void on_radioButtonTimeOfDay_toggled(bool); + + void on_timeEditInterval_timeChanged(const QTime & time); + + void on_pushButtonAddTOD_pressed(); + void on_pushButtonDeleteTOD_pressed(); + + void setIdle(bool); + + void saveSettings(); + +signals: + + void newState(); + void newEvent(); + void quit(); + +private: + + void rebuildTODList(); + void updateUI(); + + Ui::SchedulerConfigWidgetClass *ui; + + Scheduler m_scheduler; +}; + +#endif // _SCHEDULERCONFIGWIDGET_H_ diff -Nru syncwall-1.6.0/src/ScreenItem.cpp syncwall-1.7.4/src/ScreenItem.cpp --- syncwall-1.6.0/src/ScreenItem.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/ScreenItem.cpp 2013-05-05 23:37:30.000000000 +0000 @@ -0,0 +1,354 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#include "ScreenItem.h" +#include +#include + +const int decoMargin = 2; // default pen width + supplementary contour if selected (so 1 + 1) +const int penWidth = 1; +const int cornerSize = 2; +const int fontFactor = 15; + +ScreenItem::ScreenItem ( const QSize &size, int num, QGraphicsItem * parent ) : QGraphicsItem(parent), + m_realSize(size), + m_size(size), + m_screenNum(num), + m_marginLeft(70), + m_marginRight(70), + m_marginTop(0), + m_marginBottom(0), + m_useMargins(true), + m_drawText(true), + m_opaque(true) +{ + setFlag(QGraphicsItem::ItemIsMovable, true); + setFlag(QGraphicsItem::ItemIsSelectable, true); + setFlag(QGraphicsItem::ItemIsFocusable, true); +} + +void ScreenItem::setSize(const QSize &size) +{ + m_realSize = size; + m_size = size; +} + +void ScreenItem::setNumber(int num) +{ + m_screenNum = num; +} + +QSize ScreenItem::getRealSizeWithMargins() const +{ + QSize size(m_realSize); + if (m_useMargins) + { + size.rwidth() += (m_marginLeft + m_marginRight); + size.rheight() += (m_marginTop + m_marginBottom); + } + return size; +} + +QSize ScreenItem::getSizeWithMargins() const +{ + QSize size(m_size); + if (m_useMargins) + { + size.rwidth() += (m_marginLeft + m_marginRight); + size.rheight() += (m_marginTop + m_marginBottom); + } + return size; +} + +QRectF ScreenItem::boundingRect() const +{ + QRectF res; + if (m_useMargins) + res = QRectF( + -(m_size.width() + m_marginLeft + m_marginRight ) / 2 - decoMargin, + -(m_size.height() + m_marginTop + m_marginBottom) / 2 - decoMargin, + m_size.width() + m_marginLeft + m_marginRight + 2 * decoMargin, + m_size.height() + m_marginTop + m_marginBottom + 2 * decoMargin + ); + else + res = QRectF( + -( m_size.width() ) / 2 - decoMargin, + -( m_size.height() ) / 2 - decoMargin, + m_size.width() + 2 * decoMargin, + m_size.height() + 2 * decoMargin + ); + + return res; +} + +QRectF ScreenItem::getPreviewSceneWithMarginsBoundingRect() +{ + QRectF sceneRect = sceneBoundingRect(); + QRectF res; + if (m_useMargins) + res = QRectF ( + (sceneRect.x() + (m_marginLeft + m_marginRight) / 2 + decoMargin) / 10.0f, + (sceneRect.y() + (m_marginTop + m_marginBottom) / 2 + decoMargin) / 10.0f, + m_size.width() / 10.0f, + m_size.height() / 10.0f + ); + else + res = QRectF ( + (sceneRect.x() / 2 + decoMargin) / 10.0f, + (sceneRect.y() / 2 + decoMargin) / 10.0f, + m_size.width() / 10.0f, + m_size.height() / 10.0f + ); + return res; +} + +QRectF ScreenItem::getPreviewSceneBoundingRect() +{ + QRectF sceneRect = sceneBoundingRect(); + return QRectF ( + (sceneRect.x() + decoMargin) / 10.0f, + (sceneRect.y() + decoMargin) / 10.0f, + m_size.width() / 10.0f, + m_size.height() / 10.0f + ); +} + +QRectF ScreenItem::getValidSceneBoundingRect() +{ + QRectF sceneRect = sceneBoundingRect(); + QRectF res; + + if (m_useMargins) + res = QRectF ( + sceneRect.x() + (m_marginLeft + m_marginRight) / 2 + decoMargin, + sceneRect.y() + (m_marginTop + m_marginBottom) / 2 + decoMargin, + m_size.width(), + m_size.height() + ); + else + res = QRectF ( + sceneRect.x() / 2 + decoMargin, + sceneRect.y() / 2 + decoMargin, + m_size.width(), + m_size.height() + ); + return res; +} + +void ScreenItem::setImage(const QImage &image) +{ + m_image = image; + m_cropimage = m_image.copy( getPreviewSceneWithMarginsBoundingRect().toRect() ); + update(); +} + +void ScreenItem::updateImage() +{ + m_cropimage = m_image.copy( getPreviewSceneWithMarginsBoundingRect().toRect() ); + update(); +} + +void ScreenItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget * /* widget */) +{ + QFont font; + font.setPixelSize(10 * fontFactor); + painter->setFont(font); + + QPen pen(Qt::black); + pen.setWidth(1); + pen.setCosmetic(true); + + //draw out box + pen.setBrush(Qt::black); + painter->setPen(pen); + + QRectF itemRect = boundingRect().translated(decoMargin - penWidth,decoMargin - penWidth); + + painter->drawRoundedRect(itemRect,cornerSize,cornerSize); + + // draw borders + if (m_useMargins) + drawMargins(painter); + + // draw image + drawDesktop(painter); + + // draw screen number + if (m_drawText) + drawTextEffect( painter, QString::number(m_screenNum),itemRect.translated(9 * fontFactor,9 * fontFactor), Qt::AlignLeft, QPoint(fontFactor, fontFactor) ); + + // display resolution + if (m_drawText) + { + font.setPixelSize(5 * fontFactor); + painter->setFont(font); + QString res = QString("%1x%2").arg( m_realSize.width() ).arg( m_realSize.height() ); + drawTextEffect( painter, res,itemRect.translated(9 * fontFactor,itemRect.height() - 20 * fontFactor), Qt::AlignLeft, QPoint(fontFactor / 2, fontFactor / 2) ); + } + + // draw highlight if needed + if (option->state & QStyle::State_Selected) + { + pen.setBrush(Qt::red); + painter->setPen(pen); + painter->drawRoundedRect(itemRect, cornerSize, cornerSize); + } +} + +void ScreenItem::drawTextEffect(QPainter *painter, const QString &text, const QRectF & rect, int alignment, const QPoint &offset) +{ + // Draw shadow. + painter->setPen( QPen(Qt::gray) ); + painter->drawText(rect.translated(offset), alignment, text); + + // Draw text. + painter->setPen( QPen(Qt::black) ); + painter->drawText(rect, alignment, text); +} + +void ScreenItem::drawDesktop(QPainter *painter) +{ + if ( m_image.isNull() ) + { + painter->fillRect ( + -m_size.width() / 2, + -m_size.height() / 2, + m_size.width(), + m_size.height(), + Qt::white ); + } + else + { + QRectF target( + -m_size.width() / 2, + -m_size.height() / 2, + m_size.width(), + m_size.height() + ); + if (m_opaque) + painter->drawImage( target,m_cropimage,m_cropimage.rect() ); + + // add a reflextion effect just for fun !! + QImage reflection(":/syncwall/reflection.png"); + painter->drawImage( target, reflection, reflection.rect() ); + } +} + +void ScreenItem::drawMargins(QPainter *painter) +{ + int x0 = -(m_size.width() + m_marginLeft + m_marginRight) / 2; + int y0 = -(m_size.height() + m_marginTop + m_marginBottom) / 2; + + if (m_marginTop) + { + painter->fillRect ( + x0, + y0, + m_size.width() + m_marginLeft + m_marginRight, + m_marginTop, + Qt::black ); + } + + if (m_marginBottom) + { + painter->fillRect ( + x0, + y0 + m_marginTop + m_size.height(), + m_size.width() + m_marginLeft + m_marginRight, + m_marginBottom, + Qt::black ); + } + + if (m_marginRight) + { + painter->fillRect ( + x0 + m_marginLeft + m_size.width(), + y0, + m_marginRight, + m_size.height() + m_marginTop + m_marginBottom, + Qt::black ); + } + + if (m_marginLeft) + { + painter->fillRect ( + x0, + y0, + m_marginLeft, + m_size.height() + m_marginTop + m_marginBottom, + Qt::black ); + } +} + +void ScreenItem::setMargings(int top, int bottom, int left, int right) +{ + prepareGeometryChange(); + m_marginTop = top; + m_marginBottom = bottom; + m_marginLeft = left; + m_marginRight = right; + update(); +} + +void ScreenItem::setMargingTop(int val) +{ + prepareGeometryChange(); + m_marginTop = val; + update(); +} + +void ScreenItem::setMargingBottom(int val) +{ + prepareGeometryChange(); + m_marginBottom = val; + update(); +} + +void ScreenItem::setMargingLeft(int val) +{ + prepareGeometryChange(); + m_marginLeft = val; + update(); +} + +void ScreenItem::setMargingRight(int val) +{ + prepareGeometryChange(); + m_marginRight = val; + update(); +} + +void ScreenItem::setUseMargins(bool val) +{ + m_useMargins = val; + update(); +} + +void ScreenItem::setDrawText(bool val) +{ + m_drawText = val; + update(); +} + +void ScreenItem::setOpaque(bool val) +{ + m_opaque = val; + update(); +} diff -Nru syncwall-1.6.0/src/ScreenItem.h syncwall-1.7.4/src/ScreenItem.h --- syncwall-1.6.0/src/ScreenItem.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/ScreenItem.h 2013-05-05 23:37:34.000000000 +0000 @@ -0,0 +1,97 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#ifndef _SCREENITEM_H_ +#define _SCREENITEM_H_ + +#include +#include +#include + +class ScreenItem : public QGraphicsItem +{ +public: + + ScreenItem ( const QSize &size, int num, QGraphicsItem * parent = 0 ); + + QRectF boundingRect() const; + + void setSize(const QSize &size); + void setNumber(int); + + QSize getRealSize() const {return m_realSize; } + QSize getRealSizeWithMargins() const; + QSize getSizeWithMargins() const; + QSize getSize() const {return m_size; } + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,QWidget *widget); + int getNumber() const { return m_screenNum; } + + void setMargings(int top, int bottom, int left, int right); + void setMargingTop(int val); + int getMarginTop() const {return m_marginTop; } + void setMargingBottom(int val); + int getMarginBottom() const {return m_marginBottom; } + void setMargingLeft(int val); + int getMarginLeft() const {return m_marginLeft; } + void setMargingRight(int val); + int getMarginRight() const {return m_marginRight; } + + // use margins or not + void setUseMargins(bool); + bool getUseMargins(){ return m_useMargins; } + + // draw text or not + void setDrawText(bool); + bool getDrawText(){ return m_drawText; } + + QRectF getValidSceneBoundingRect(); + + void setImage(const QImage &); + void updateImage(); + + void setOpaque(bool val); + +private: + + void drawMargins(QPainter *painter); + void drawDesktop(QPainter *painter); + void drawTextEffect(QPainter *painter, const QString &text, const QRectF & rect, int alignment, const QPoint &offset); + + QRectF getPreviewSceneBoundingRect(); + QRectF getPreviewSceneWithMarginsBoundingRect(); + + QSize m_realSize; + QSize m_size; + int m_screenNum; + + int m_marginLeft; + int m_marginRight; + int m_marginTop; + int m_marginBottom; + + QImage m_image; + QImage m_cropimage; + bool m_useMargins; + bool m_drawText; + bool m_opaque; +}; + +#endif // _SCREENITEM_H_ diff -Nru syncwall-1.6.0/src/SingleApplication.cpp syncwall-1.7.4/src/SingleApplication.cpp --- syncwall-1.6.0/src/SingleApplication.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/SingleApplication.cpp 2013-05-05 23:37:30.000000000 +0000 @@ -0,0 +1,104 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#include + +#include "SingleApplication.h" + +SingleApplication::SingleApplication(int &argc, char *argv[], const QString &uniqueKey) : QApplication(argc, argv), + m_isRunning(false), + m_uniqueKey(uniqueKey), + m_localServer(NULL) +{ +#ifndef QT_NO_SHAREDMEMORY // for os/2 compilation + m_sharedMemory.setKey(m_uniqueKey); + if ( m_sharedMemory.attach() ) + m_isRunning = true; + else + { + m_isRunning = false; + + // create shared memory. + if ( !m_sharedMemory.create(1) ) + { + qDebug("Unable to create single instance."); + return; + } + + // create local server and listen to incomming messages from other instances. + m_localServer = new QLocalServer(this); + connect( m_localServer, SIGNAL( newConnection() ), this, SLOT( receiveMessage() ) ); + m_localServer->listen(m_uniqueKey); + } +#endif +} + +SingleApplication::~SingleApplication() +{ +#ifndef QT_NO_SHAREDMEMORY // for os/2 compilation + m_sharedMemory.detach(); +#endif +} + +// public slots. + +void SingleApplication::receiveMessage() +{ + QLocalSocket *localSocket = m_localServer->nextPendingConnection(); + if ( !localSocket->waitForReadyRead(m_timeout) ) + { + qDebug( "%s",localSocket->errorString().toStdString().c_str() ); + return; + } + QByteArray byteArray = localSocket->readAll(); + QString message = QString::fromUtf8( byteArray.constData() ); + emit messageAvailable(message); + localSocket->disconnectFromServer(); +} + +// public functions. + +bool SingleApplication::isRunning() +{ + return m_isRunning; +} + +bool SingleApplication::sendMessage(const QString &message) +{ + if (!m_isRunning) + return false; + + QLocalSocket localSocket(this); + localSocket.connectToServer(m_uniqueKey, QIODevice::WriteOnly); + if ( !localSocket.waitForConnected(m_timeout) ) + { + qDebug( "%s",localSocket.errorString().toStdString().c_str() ); + return false; + } + + localSocket.write( message.toUtf8() ); + if ( !localSocket.waitForBytesWritten(m_timeout) ) + { + qDebug( "%s",localSocket.errorString().toStdString().c_str() ); + return false; + } + localSocket.disconnectFromServer(); + return true; +} diff -Nru syncwall-1.6.0/src/SingleApplication.h syncwall-1.7.4/src/SingleApplication.h --- syncwall-1.6.0/src/SingleApplication.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/SingleApplication.h 2013-05-05 23:37:32.000000000 +0000 @@ -0,0 +1,70 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +//------------------------------------------------------------------------------ +// extract from http://www.qtcentre.org/wiki/index.php?title=SingleApplication +//------------------------------------------------------------------------------ + +#ifndef _SINGLE_APPLICATION_H_ +#define _SINGLE_APPLICATION_H_ + +#include +#include + +#ifndef QT_NO_SHAREDMEMORY // for os/2 compilation +#include +#endif // QT_NO_SHAREDMEMORY + +class SingleApplication : + public QApplication +{ + Q_OBJECT + +public: + + SingleApplication(int &argc, char *argv[], const QString &uniqueKey); + ~SingleApplication(); + + bool isRunning(); + bool sendMessage(const QString &message); + +public slots: + + void receiveMessage(); + +signals: + + void messageAvailable(const QString &message); + +private: + + bool m_isRunning; + QString m_uniqueKey; + + QLocalServer *m_localServer; + + static const int m_timeout = 1000; + +#ifndef QT_NO_SHAREDMEMORY // for os/2 compilation + QSharedMemory m_sharedMemory; +#endif // QT_NO_SHAREDMEMORY +}; + +#endif // _SINGLE_APPLICATION_H_ diff -Nru syncwall-1.6.0/src/SplashScreen.cpp syncwall-1.7.4/src/SplashScreen.cpp --- syncwall-1.6.0/src/SplashScreen.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/SplashScreen.cpp 2013-05-05 23:37:30.000000000 +0000 @@ -0,0 +1,121 @@ + +/****************************************************************************** + HotShots: Screenshot utility + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#include "SplashScreen.h" + +#include +#include +#include +#include + +SplashScreen::SplashScreen(const QPixmap& pixmap, unsigned int minimalDisplayDuration, int screenId, bool transparentBackground, Qt::WindowFlags /* f */) + : QSplashScreen(), + m_nextWidget(NULL), + m_timerFired(false), + m_currAlign(Qt::AlignLeft), + m_currColor(Qt::black), + m_screenId(screenId) +{ + setWindowModality(Qt::ApplicationModal); + setSplash(pixmap,transparentBackground); + startTimer(minimalDisplayDuration); +} + +void SplashScreen::timerEvent(QTimerEvent *event) +{ + killTimer( event->timerId() ); + m_timerFired = true; + if (m_nextWidget) + { + m_nextWidget->show(); + } + QSplashScreen::finish(m_nextWidget); +} + +void SplashScreen::setSplash(const QPixmap& pixmap,bool transparentBackground) +{ + QPixmap extract( pixmap.width(),pixmap.height() ); + if (transparentBackground) // extract background from desktop + { + QRect geom = QApplication::desktop()->screenGeometry( m_screenId ); + QPixmap desktopPixmap = QPixmap::grabWindow( QApplication::desktop()->winId(), geom.x(), geom.y(), geom.width(), geom.height() ); + + int x0 = desktopPixmap.width() / 2.0 - pixmap.width() / 2.0; + int y0 = desktopPixmap.height() / 2.0 - pixmap.height() / 2.0; + extract = desktopPixmap.copy( x0,y0,pixmap.width(),pixmap.height() ); + } + else // create a dummy background + { + QPainter painter(&extract); + QLinearGradient linearGrad( 0, 0, 0, extract.height() ); + linearGrad.setColorAt( 0.0, QColor(255,190,0) ); + linearGrad.setColorAt( 1.0, QColor(255,160,0) ); + painter.setBrush( linearGrad ); + painter.fillRect( 0, 0, extract.width(),extract.height(), QBrush(linearGrad) ); + painter.setBrush( QBrush() ); + painter.drawRect( 0, 0, extract.width() - 1,extract.height() - 1); + } + + QImage resultImage = QImage(pixmap.size(), QImage::Format_ARGB32_Premultiplied); + QPainter painter(&resultImage); + painter.setCompositionMode(QPainter::CompositionMode_SourceOver); + painter.drawImage( 0, 0, extract.toImage() ); + painter.drawImage( 0, 0, pixmap.toImage() ); + painter.end(); + setPixmap( QPixmap::fromImage(resultImage) ); + + // must move the splashscreen by taking ito account screen Number + move( QApplication::desktop()->screenGeometry(m_screenId).center() - resultImage.rect().center() ); + repaint(); +} + +void SplashScreen::delayedFinish(QWidget *next) +{ + m_nextWidget = next; + if (m_timerFired && m_nextWidget) + m_nextWidget->show(); +} + +void SplashScreen::closeEvent(QCloseEvent *event) +{ + QWidget::closeEvent(event); +} + +void SplashScreen::drawContents(QPainter *painter) +{ + painter->setPen(m_currColor); + + QPixmap pm = QSplashScreen::pixmap(); + QRect r( 0, 0, pm.width(), pm.height() ); + + r.setRect(r.x() + 100, r.y() - 15, r.width() - 10, r.height() - 10); + painter->setFont( QFont("arial", 8) ); + painter->drawText(r, m_currAlign, m_currStatus); +} + +void SplashScreen::showMessage(const QString &message, int alignment, + const QColor &color) +{ + m_currStatus = message; + m_currAlign = alignment; + m_currColor = color; + emit messageChanged(m_currStatus); + repaint(); +} diff -Nru syncwall-1.6.0/src/SplashScreen.h syncwall-1.7.4/src/SplashScreen.h --- syncwall-1.6.0/src/SplashScreen.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/SplashScreen.h 2013-05-05 23:37:32.000000000 +0000 @@ -0,0 +1,69 @@ + +/****************************************************************************** + HotShots: Screenshot utility + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#ifndef _SPLASHSCREEN_H_ +#define _SPLASHSCREEN_H_ + +#include +#include +#include +#include +#include + +class SplashScreen : + public QSplashScreen +{ + Q_OBJECT + +public: + + SplashScreen(const QPixmap& pixmap, unsigned int minimalDisplayDuration = 0, int screenId = -1, bool transparentBackground = true, Qt::WindowFlags f = 0); + + void delayedFinish(QWidget *next = 0); + void showMessage(const QString &message, int alignment = Qt::AlignLeft, const QColor &color = Qt::black); + +signals: + + void finished(); + +protected: + + void drawContents(QPainter *painter); + +private slots: + + void closeEvent(QCloseEvent *event); + void timerEvent(QTimerEvent *event); + +private: + + void init(unsigned int minimalDisplayDuration); + void setSplash(const QPixmap& pixmap,bool transparentBackground = true); + + QWidget *m_nextWidget; + bool m_timerFired; + QPixmap m_pixmap; + QString m_currStatus; + int m_currAlign; + QColor m_currColor; + int m_screenId; +}; + +#endif // _SPLASHSCREEN_H_ diff -Nru syncwall-1.6.0/src/StarDelegate.cpp syncwall-1.7.4/src/StarDelegate.cpp --- syncwall-1.6.0/src/StarDelegate.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/StarDelegate.cpp 2013-05-05 23:37:30.000000000 +0000 @@ -0,0 +1,127 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#include + +#include "StarDelegate.h" +#include "StarEditor.h" +#include "StarRating.h" + +StarDelegate::StarDelegate(QWidget *parent) : QStyledItemDelegate(parent), + m_column(0) +{ +} + +void StarDelegate::setStarColumn(int val) +{ + m_column = val; +} + +void StarDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index) const +{ + if (index.column() == m_column) + { + StarRating starRating( index.data().toInt() ); + + if (option.state & QStyle::State_Selected) + painter->fillRect( option.rect, option.palette.highlight() ); + else + { + QColor c = index.data(Qt::BackgroundRole).value(); + if ( c.isValid() ) + painter->fillRect( option.rect, c); + } + + starRating.paint(painter, option.rect, option.palette, + StarRating::ReadOnly); + } + else + { + QStyledItemDelegate::paint(painter, option, index); + } +} + +QSize StarDelegate::sizeHint(const QStyleOptionViewItem &option, + const QModelIndex & index) const +{ + if (index.column() == m_column) + { + return StarRating( index.data().toInt() ).sizeHint(); + } + else + { + return QStyledItemDelegate::sizeHint(option, index); + } +} + +QWidget *StarDelegate::createEditor(QWidget * parent, + const QStyleOptionViewItem &option, + const QModelIndex & index) const + +{ + if (index.column() == m_column) + { + StarEditor *editor = new StarEditor(parent); + connect( editor, SIGNAL( editingFinished() ), + this, SLOT( commitAndCloseEditor() ) ); + return editor; + } + else + { + return QStyledItemDelegate::createEditor(parent, option, index); + } +} + +void StarDelegate::setEditorData(QWidget * editor, + const QModelIndex &index) const +{ + if (index.column() == m_column) + { + StarRating starRating( index.data().toInt() ); + StarEditor *starEditor = qobject_cast(editor); + starEditor->setStarRating(starRating); + } + else + { + QStyledItemDelegate::setEditorData(editor, index); + } +} + +void StarDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, + const QModelIndex &index) const +{ + if (index.column() == m_column) + { + StarEditor *starEditor = qobject_cast(editor); + model->setData( index, starEditor->starRating().starCount() ); + } + else + { + QStyledItemDelegate::setModelData(editor, model, index); + } +} + +void StarDelegate::commitAndCloseEditor() +{ + StarEditor *editor = qobject_cast( sender() ); + emit commitData(editor); + emit closeEditor(editor); +} diff -Nru syncwall-1.6.0/src/StarDelegate.h syncwall-1.7.4/src/StarDelegate.h --- syncwall-1.6.0/src/StarDelegate.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/StarDelegate.h 2013-05-05 23:37:32.000000000 +0000 @@ -0,0 +1,55 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#ifndef _STARDELEGATE_H_ +#define _STARDELEGATE_H_ + +#include + +class StarDelegate : public QStyledItemDelegate +{ + Q_OBJECT + +public: + + StarDelegate(QWidget *parent = 0); + + void paint(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index) const; + QSize sizeHint(const QStyleOptionViewItem &option, + const QModelIndex & index) const; + QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, + const QModelIndex &index) const; + void setEditorData(QWidget *editor, const QModelIndex &index) const; + void setModelData(QWidget *editor, QAbstractItemModel *model, + const QModelIndex &index) const; + + void setStarColumn(int); + +private slots: + + void commitAndCloseEditor(); + +private: + + int m_column; +}; + +#endif // _STARDELEGATE_H_ diff -Nru syncwall-1.6.0/src/StarEditor.cpp syncwall-1.7.4/src/StarEditor.cpp --- syncwall-1.6.0/src/StarEditor.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/StarEditor.cpp 2013-05-05 23:37:30.000000000 +0000 @@ -0,0 +1,69 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#include + +#include "StarEditor.h" +#include "StarRating.h" + +StarEditor::StarEditor(QWidget *parent) + : QWidget(parent) +{ + setMouseTracking(true); + setAutoFillBackground(true); +} + +QSize StarEditor::sizeHint() const +{ + return myStarRating.sizeHint(); +} + +void StarEditor::paintEvent(QPaintEvent *) +{ + QPainter painter(this); + myStarRating.paint(&painter, rect(), this->palette(), + StarRating::Editable); +} + +void StarEditor::mouseMoveEvent(QMouseEvent *event) +{ + int star = starAtPosition( event->x() ); + + if (star != myStarRating.starCount() && star != -1) + { + myStarRating.setStarCount(star); + update(); + } +} + +void StarEditor::mouseReleaseEvent(QMouseEvent * /* event */) +{ + emit editingFinished(); +} + +int StarEditor::starAtPosition(int x) +{ + int star = ( x / ( myStarRating.sizeHint().width() + / myStarRating.maxStarCount() ) ) + 1; + if ( star <= 0 || star > myStarRating.maxStarCount() ) + return -1; + + return star; +} diff -Nru syncwall-1.6.0/src/StarEditor.h syncwall-1.7.4/src/StarEditor.h --- syncwall-1.6.0/src/StarEditor.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/StarEditor.h 2013-05-05 23:37:32.000000000 +0000 @@ -0,0 +1,60 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#ifndef _STAREDITOR_H_ +#define _STAREDITOR_H_ + +#include + +#include "StarRating.h" + +class StarEditor : public QWidget +{ + Q_OBJECT + +public: + + StarEditor(QWidget *parent = 0); + + QSize sizeHint() const; + void setStarRating(const StarRating &starRating) { + myStarRating = starRating; + } + + StarRating starRating() { return myStarRating; } + +signals: + + void editingFinished(); + +protected: + + void paintEvent(QPaintEvent *event); + void mouseMoveEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + +private: + + int starAtPosition(int x); + + StarRating myStarRating; +}; + +#endif // _STAREDITOR_H_ diff -Nru syncwall-1.6.0/src/StarRating.cpp syncwall-1.7.4/src/StarRating.cpp --- syncwall-1.6.0/src/StarRating.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/StarRating.cpp 2013-05-05 23:37:30.000000000 +0000 @@ -0,0 +1,85 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#include +#include + +#include "StarRating.h" + +const int PaintingScaleFactor = 10; + +StarRating::StarRating(int starCount, int maxStarCount) +{ + myStarCount = starCount; + myMaxStarCount = maxStarCount; + + starPolygon << QPointF(1.0, 0.5); + for (int i = 1; i < 5; ++i) + starPolygon << QPointF( 0.5 + 0.5 * cos(0.8 * i * 3.14), + 0.5 + 0.5 * sin(0.8 * i * 3.14) ); + + diamondPolygon << QPointF(0.4, 0.5) << QPointF(0.5, 0.4) + << QPointF(0.6, 0.5) << QPointF(0.5, 0.6) + << QPointF(0.4, 0.5); +} + +QSize StarRating::sizeHint() const +{ + return PaintingScaleFactor * QSize(myMaxStarCount, 1); +} + +void StarRating::paint(QPainter *painter, const QRect &rect, + const QPalette &palette, EditMode mode) const +{ + painter->save(); + + painter->setRenderHint(QPainter::Antialiasing, true); + painter->setPen(Qt::NoPen); + + if (mode == Editable) + { + painter->setPen(Qt::black); + painter->setBrush( palette.highlight() ); + } + else + { + painter->setPen(Qt::black); + painter->setBrush(Qt::yellow); + } + + int yOffset = (rect.height() - PaintingScaleFactor) / 2; + painter->translate(rect.x(), rect.y() + yOffset); + painter->scale(PaintingScaleFactor, PaintingScaleFactor); + + for (int i = 0; i < myMaxStarCount; ++i) + { + if (i < myStarCount) + { + painter->drawPolygon(starPolygon, Qt::WindingFill); + } + else if (mode == Editable) + { + painter->drawPolygon(diamondPolygon, Qt::WindingFill); + } + painter->translate(1.0, 0.0); + } + + painter->restore(); +} diff -Nru syncwall-1.6.0/src/StarRating.h syncwall-1.7.4/src/StarRating.h --- syncwall-1.6.0/src/StarRating.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/StarRating.h 2013-05-05 23:37:32.000000000 +0000 @@ -0,0 +1,60 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#ifndef _STARRATING_H_ +#define _STARRATING_H_ + +#include +#include +#include +#include + +#include + +class StarRating +{ +public: + + enum EditMode + { + Editable, ReadOnly + }; + + StarRating(int starCount = 1, int maxStarCount = 5); + + void paint(QPainter *painter, const QRect &rect, + const QPalette &palette, EditMode mode) const; + QSize sizeHint() const; + int starCount() const { return myStarCount; } + int maxStarCount() const { return myMaxStarCount; } + void setStarCount(int starCount) { myStarCount = starCount; } + void setMaxStarCount(int maxStarCount) { myMaxStarCount = maxStarCount; } + +private: + + QPolygonF starPolygon; + QPolygonF diamondPolygon; + int myStarCount; + int myMaxStarCount; +}; + +Q_DECLARE_METATYPE(StarRating) + +#endif // _STARRATING_H_ diff -Nru syncwall-1.6.0/src/SyncWall.cpp syncwall-1.7.4/src/SyncWall.cpp --- syncwall-1.6.0/src/SyncWall.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/SyncWall.cpp 2013-05-17 12:31:48.000000000 +0000 @@ -0,0 +1,1741 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#include "SyncWall.h" + +#include + +#include +#include +#include +#include + +#include + +#include +#include + +#include "LogHandler.h" + +#include "AppSettings.h" +#include "WallpaperProvider.h" + +#include "MiscFunctions.h" +#include "DesktopScene.h" +#include "ImageViewer.h" +#include "ListImagesModel.h" +#include "TreeImagesView.h" +#include "IconViewDelegate.h" +#include "NetworkManager.h" + +#include "ThreadPool.h" +#include "StarDelegate.h" + +#include + +#ifdef Q_WS_WIN // for wallpaper set on windows platform + +#include +#include + +#endif + +#ifndef Q_WS_PM // OS/2 +#include +#endif + +#include "ui_SyncWall.h" + +const int defaultBlinkInterval = 1000; // 1 sec +const int defaultBlinkingTime = 5000; // 5 sec +const int saveSettingsInterval = 10 * 60 * 1000; // 10 min + +SyncWall::SyncWall(QWidget *parent, Qt::WFlags flags) + : QMainWindow(parent, flags), + ui(new Ui::SyncWallClass), + m_useGlobalHotKey(false), + m_globalHotkeyNext("Ctrl+F11"), + m_globalHotkeyPrev("Ctrl+F12"), + m_globalHotkeyOpen("Ctrl+F10"), + m_globalHotkeyOffset("Ctrl+F9"), +#ifndef Q_WS_PM // OS/2 + m_shortCutNext(NULL), + m_shortCutPrev(NULL), + m_shortCutOpen(NULL), + m_shortCutOffset(NULL), +#endif + m_firstCloseMessage(false), + m_appName(PACKAGE_NAME), + m_version(PACKAGE_VERSION), + m_trayIcon(NULL), + m_scheduler(NULL), + m_logLevel(LogHandler::MSG_DEBUG), + m_randomOrderChange(false), + m_currentImageIndex(-1), + m_blinking(true), + m_startInTray(false), + m_splashscreenAtStartup(true), + m_splashscreenTransparentBackground(true), + m_startWithSystem(false), + m_listModel(NULL), + m_resetConfig(false), + m_currentListIndex(-1) +{ + ui->setupUi(this); + + // load the settings + loadSettings(); + + // create/connect specific class/ui->widget and setup various parameters + updateUi(); + + // update wallpaper file list + refreshWallpaperProviders(); +} + +SyncWall::~SyncWall() +{ + saveSettings(); + ThreadPool::getInstance()->stop(); + qDeleteAll(m_currentProviders); + delete ui; +} + +void SyncWall::updateUi() +{ + //checkForSmallInterface(); + + initStateDefs(); + + // setup app name, release, ... + updateApplicationIdentity(); + + // setup About dialog with some informations + updateAbout(); + + // update language data + updatePrefsLanguage(); + + // create and connect the log handler + connect( LogHandler::getInstance(),SIGNAL( newMessage(const QString &) ),this,SLOT( printToLog(const QString &) ) ); + LogHandler::getInstance()->setBufferization(false); // get all stored messages if exists + + // force always tab(0) + ui->tabWidgetMain->setCurrentIndex(0); + ui->tabWidgetPreferences->setCurrentIndex(0); + + createActionsSystemTray(); + createTrayIcon(); + + // limit log display + ui->textBrowserLog->document()->setMaximumBlockCount(1000); + + // init random generator to a "random" value !! :) + qsrand( QTime::currentTime().msec() ); + + // temp storage check + QString tmpPath = MiscFunctions::getValidStorage(); + + if ( !QDir(tmpPath).exists() ) + { + if ( !QDir::home().mkpath(tmpPath) ) + QMessageBox::warning( this,m_appName,tr("Can't create storage location, check why ?! (%1)").arg(tmpPath) ); + } + +#ifdef Q_WS_WIN + + SHELLFLAGSTATE shfs; + + SHGetSettings(&shfs,SSF_DESKTOPHTML); + + if (shfs.fDesktopHTML) + QMessageBox::warning( this,m_appName,tr("Active Desktop must be disabled !!") ); + +#else + ui->checkBoxStartWithSystem->hide(); // hide autostart checkbox only usable on Windows +#endif + + // connect network manager signals + connect( ui->widgetNetworkParameters, SIGNAL( newState() ), this, SLOT( checkState() ) ); + connect( ui->widgetNetworkParameters, SIGNAL( newMessage(const QString & ) ), ui->widgetImageParameters, SLOT( decodeAndApplyMessage(const QString & ) ) ); + connect( ui->widgetNetworkParameters, SIGNAL( synchronizeByNetwork(bool) ), ui->widgetScheduler, SLOT( setIdle(bool) ) ); + connect( this, SIGNAL( sigSaveSettings() ), ui->widgetNetworkParameters, SLOT( saveSettings() ) ); + + connect( ui->widgetImageParameters, SIGNAL( requestNewImage() ), this, SLOT( changeWallpaper() ) ); + connect( ui->widgetImageParameters, SIGNAL( decodedImage(const QString & ) ), this, SLOT( searchForWallpaper(const QString & ) ) ); + connect( ui->widgetImageParameters, SIGNAL( parametersChange() ), this, SLOT( changeMonitorSupport() ) ); + connect( this, SIGNAL( sigSaveSettings() ), ui->widgetImageParameters, SLOT( saveSettings() ) ); + + // connect scheduler signals + connect( ui->widgetScheduler, SIGNAL( newState() ), this, SLOT( checkState() ) ); + connect( ui->widgetScheduler, SIGNAL( newEvent() ), this, SLOT( checkForBlinking() ) ); + connect( ui->widgetScheduler, SIGNAL( quit() ), this, SLOT( on_pushButtonQuit_pressed() ) ); + connect( this, SIGNAL( sigSaveSettings() ), ui->widgetScheduler, SLOT( saveSettings() ) ); + + // starting network before scheduler + ui->widgetNetworkParameters->start(); + ui->widgetScheduler->start(); + + // setup "blinking" timer + m_blinkTimer.setInterval(defaultBlinkInterval); + connect( &m_blinkTimer, SIGNAL( timeout() ), this, SLOT( blink() ) ); + + // connect painter to system integration + connect( ui->widgetImageParameters, SIGNAL( newImage(const QImage &) ), ui->widgetSystem, SLOT( applyWallpaper(const QImage &) ) ); + connect( ui->widgetImageParameters, SIGNAL( newImages(const QList &) ), ui->widgetSystem, SLOT( applyWallpaper(const QList &) ) ); + + // connect painter to network + connect( ui->widgetImageParameters, SIGNAL( newConfiguration(const QString &) ), ui->widgetNetworkParameters, SLOT( sendNewMessage(const QString &) ) ); + + connect( this, SIGNAL( sigSaveSettings() ), ui->widgetSystem, SLOT( saveSettings() ) ); + + ui->graphicsViewDesktop->setScene( ui->widgetImageParameters->getScenePreview() ); + + // create the exclusive button + QButtonGroup *buttonGroup = new QButtonGroup(this); + buttonGroup->setExclusive(true); + + //buttonGroup->addButton(ui->pushButtonViewList); + buttonGroup->addButton(ui->pushButtonViewDetail); + buttonGroup->addButton(ui->pushButtonViewThumbnail); + + m_listModel = new ListImagesModel(this); + + // when infos are retrieve from database => must recompute index list to take into account rating + connect ( m_listModel,SIGNAL( updateFinished() ), this, SLOT( computeIndexList() ) ); + + StarDelegate *sd = new StarDelegate(this); + sd->setStarColumn(ListImagesModel::COLUMN_RATE); + ui->treeViewFiles->setItemDelegate(sd); // add specific star delegate delegate to view + ui->treeViewFiles->setModel(m_listModel); + + ui->listViewFiles->setItemDelegate( new IconViewDelegate(this) ); // add specific icon delegate to view + ui->listViewFiles->setModel(m_listModel); + + ui->stackedWidgetFiles->setCurrentIndex(0); // switch to treeView + + connect( ui->treeViewFiles->selectionModel(),SIGNAL ( selectionChanged (const QItemSelection &, const QItemSelection & ) ), this, SLOT( selectionChanged(const QItemSelection &, const QItemSelection & ) ) ); + connect( ui->listViewFiles->selectionModel(),SIGNAL ( selectionChanged (const QItemSelection &, const QItemSelection & ) ), this, SLOT( selectionChanged(const QItemSelection &, const QItemSelection & ) ) ); + + // global hotkey not available for OS/2 +#ifdef Q_WS_PM // OS/2 + ui->groupBoxHotKey->hide(); +#endif + + // create a timer for automatically save settings + QTimer * timer = new QTimer(this); + connect( timer, SIGNAL( timeout() ), this, SLOT( saveSettings() ) ); + timer->start(saveSettingsInterval); + + // disable user move button if needed + checkIfUserCanMove(); + + // install event filter to receive keypress from view + ui->listViewFiles->installEventFilter(this); + ui->treeViewFiles->installEventFilter(this); + + // simple check of sql driver installed + QStringList listDrivers(QSqlDatabase::drivers()); + LogHandler::getInstance()->reportDebug(QString("Syncwall: available Sql drivers: %1").arg(listDrivers.join(", "))); + if (!listDrivers.contains("QSQLITE") && !listDrivers.contains("QSQLITE3")) + QMessageBox::warning( this,m_appName,tr("The application can't find a valid SQLITE driver, its performance and functionality will be degraded") ); + +} + +// on laptop => we have to reduce the icon decoration size +void SyncWall::checkForSmallInterface() +{ + /* + QRect screen = QApplication::desktop()->screenGeometry(); + qDebug() << screen; + qDebug() << size(); + QSize size = minimumSizeHint () ; + if (size.height() > screen.height()/2.0f) + { + // resize decoration icon + QSize smallSize = ui->labelDecoration->pixmap()->size(); + smallSize /= 2; + ui->labelDecoration->setPixmap(ui->labelDecoration->pixmap()->scaled(smallSize)); + ui->labelDecoration_2->setPixmap(ui->labelDecoration_2->pixmap()->scaled(smallSize)); + ui->labelDecoration_3->setPixmap(ui->labelDecoration_3->pixmap()->scaled(smallSize)); + ui->widgetNetworkParameters->labelDecoration->setPixmap(ui->widgetNetworkParameters->labelDecoration->pixmap()->scaled(smallSize)); + ui->widgetImageParameters->labelDecoration->setPixmap(ui->widgetImageParameters->labelDecoration->pixmap()->scaled(smallSize)); + ui->widgetScheduler->labelDecoration->setPixmap(ui->widgetScheduler->labelDecoration->pixmap()->scaled(smallSize)); + } + */ +} + +void SyncWall::setupGlobalKeys() +{ +#ifndef Q_WS_PM // OS/2 + // Next + m_shortCutNext = new QxtGlobalShortcut(this); + connect( m_shortCutNext, SIGNAL( activated() ), this, SLOT( on_actionNextWallpaper_activated() ) ); + QKeySequence keyNext(m_globalHotkeyNext); + m_shortCutNext->setShortcut(keyNext); + ui->widgetKeySequenceNext->setKeySequence(keyNext); + ui->widgetKeySequenceNext->setClearButtonIcon( QIcon( (":/syncwall/delete.png") ) ); + + // Prev + m_shortCutPrev = new QxtGlobalShortcut(this); + connect( m_shortCutPrev, SIGNAL( activated() ), this, SLOT( on_actionPreviousWallpaper_activated() ) ); + QKeySequence keyPrev(m_globalHotkeyPrev); + m_shortCutPrev->setShortcut(keyPrev); + ui->widgetKeySequencePrev->setKeySequence(keyPrev); + ui->widgetKeySequencePrev->setClearButtonIcon( QIcon( (":/syncwall/delete.png") ) ); + + // Open + m_shortCutOpen = new QxtGlobalShortcut(this); + connect( m_shortCutOpen, SIGNAL( activated() ), this, SLOT( on_actionShowUI_triggered() ) ); + QKeySequence keyOpen(m_globalHotkeyOpen); + m_shortCutOpen->setShortcut(keyOpen); + ui->widgetKeySequenceOpen->setKeySequence(keyOpen); + ui->widgetKeySequenceOpen->setClearButtonIcon( QIcon( (":/syncwall/delete.png") ) ); + + // Offset + m_shortCutOffset = new QxtGlobalShortcut(this); + connect( m_shortCutOffset, SIGNAL( activated() ), this, SLOT( on_pushButtonUserMove_pressed() ) ); + QKeySequence keyOffset(m_globalHotkeyOffset); + m_shortCutOffset->setShortcut(keyOffset); + ui->widgetKeySequenceOffset->setKeySequence(keyOffset); + ui->widgetKeySequenceOffset->setClearButtonIcon( QIcon( (":/syncwall/delete.png") ) ); +#endif +} + +void SyncWall::updatePrefsLanguage() +{ + // set detected language + QString detectedLanguage = QLocale::system().name().left(2); + ui->labelDetectedLanguage->setText( tr("detected language: %1").arg(detectedLanguage) ); + + // fill ui->comboBox + const QMap &mapLang = MiscFunctions::getAvailableLanguages(); + QStringList names = mapLang.keys(); + ui->comboBoxLanguage->addItem(tr("Automatic detection"), "auto"); + if (m_currentLanguage == "auto") + ui->comboBoxLanguage->setCurrentIndex(ui->comboBoxLanguage->count() - 1); + ui->comboBoxLanguage->addItem(tr("Default (no use of translation files)"),"default"); + if (m_currentLanguage == "default") + ui->comboBoxLanguage->setCurrentIndex(ui->comboBoxLanguage->count() - 1); + foreach (const QString &lang, names) + { + ui->comboBoxLanguage->addItem(lang,mapLang[lang]); + if (mapLang[lang] == m_currentLanguage) + ui->comboBoxLanguage->setCurrentIndex(ui->comboBoxLanguage->count() - 1); + } +} + +void SyncWall::on_comboBoxLanguage_activated(int index) +{ + QString lang = ui->comboBoxLanguage->itemData(index).toString(); + if (lang == m_currentLanguage) + return; + + m_currentLanguage = lang; + + // check if recursive scan + int ret = QMessageBox::question(this, m_appName, + tr("The application need to restart in order to take into account new translation\n, Do you want to restart application now ?"), + QMessageBox::Yes + | QMessageBox::No); + + if (ret == QMessageBox::Yes) + restart(); +} + +void SyncWall::restart() +{ + QProcess::startDetached( qApp->arguments()[0], QStringList() << qApp->arguments().mid(1) ); + QApplication::exit(0); +} + +void SyncWall::on_pushButtonQuit_pressed() +{ + QApplication::exit(0); +} + +void SyncWall::on_pushButtonHelp_pressed() +{ + QDesktopServices::openUrl( QUrl( QString(PACKAGE_ONLINE_HELP_URL) ) ); +} + +void SyncWall::on_pushButtonClearLog_pressed() +{ + ui->textBrowserLog->clear(); +} + +void SyncWall::on_pushButtonSaveLog_pressed() +{ + QString logFile = QFileDialog::getSaveFileName( + this, + tr("Log file"), + m_lastDirectory, + "Log file (*.log)"); + + if ( logFile.isEmpty() ) + return; + + QFile file(logFile); + if ( !file.open(QIODevice::WriteOnly | QIODevice::Text) ) + { + LogHandler::getInstance()->reportError( tr("Can't save log file !!: %1").arg(logFile) ); + } + + QTextStream out(&file); + out << ui->textBrowserLog->document()->toPlainText(); + file.close(); +} + +void SyncWall::on_pushButtonAddDirectory_pressed() +{ + QString dir = QFileDialog::getExistingDirectory(this, tr("Add Wallpaper Directory"), + m_lastDirectory, + QFileDialog::ShowDirsOnly + | QFileDialog::DontResolveSymlinks); + + if ( dir.isEmpty() ) + return; + + // check if recursive scan + int rep = QMessageBox::question(this, m_appName, + tr("Add all found directories recursively ?"), + QMessageBox::Yes + | QMessageBox::No); + + bool recursiveSearch = (rep == QMessageBox::Yes); + + // check if watch at + rep = QMessageBox::question(this, m_appName, + tr("Watch for modifications in these directories at application startup ?"), + QMessageBox::Yes + | QMessageBox::No); + + bool watchForModification = (rep == QMessageBox::Yes); + + addDirToProviders(dir,recursiveSearch,watchForModification); +} + +void SyncWall::addDirToProviders(const QString &dir, bool recursiveSearch, bool watchForModification) +{ + if ( dir.isEmpty() ) + return; + + m_lastDirectory = dir; // save current directory + + QStringList listDir; + + if (recursiveSearch) + listDir = getSubDirectoryList( QDir(dir,"",QDir::Name,QDir::Dirs) ); + + listDir << dir; + + int typeProvider = WallpaperProvider::MODE_FILELIST; + if (watchForModification) + typeProvider = WallpaperProvider::MODE_DIRECTORY; + + foreach (const QString &folder, listDir) + { + LogHandler::getInstance()->reportDebug( tr("add %1 folder").arg(folder) ); + WallpaperProvider *wp = new WallpaperProvider(folder,typeProvider); + m_currentProviders << wp; + updateDisplayedFileList(wp); // update UI + } +} + +void SyncWall::on_pushButtonAddFiles_pressed() +{ + QString formats = MiscFunctions::getAvailablesImageFormats(); + QStringList list = QFileDialog::getOpenFileNames( + this, + tr("Select one or more wallpapers"), + m_lastDirectory, + tr("Images (%1)").arg(formats) ); + + if ( !list.isEmpty() ) + { + m_lastDirectory = QFileInfo(list[0]).absolutePath(); // save current directory + WallpaperProvider *wp = new WallpaperProvider(list); + m_currentProviders << wp; + updateDisplayedFileList(wp); // update UI + } +} + +void SyncWall::on_pushButtonRefresh_pressed() +{ + refreshWallpaperProviders(true); +} + +//-------------------------------------------------------------------------------------- +// LOG Functions +//-------------------------------------------------------------------------------------- + +void SyncWall::printToLog(const QString & mess) +{ + ui->textBrowserLog->append(mess); +} + +//-------------------------------------------------------------------------------------- + +void SyncWall::on_pushButtonDeleteImage_pressed() +{ + on_actionDeleteImage_triggered(); +} + +//----------------------------------------------------------------------- +// tray icon functions +//----------------------------------------------------------------------- + +void SyncWall::closeEvent(QCloseEvent *event) +{ + if ( m_trayIcon && m_trayIcon->isVisible() ) + { + if (!m_firstCloseMessage) + { + QMessageBox::information( this, tr("Systray"), + tr("The program will keep running in the " + "system tray. To terminate the program, " + "choose Quit in the context menu " + "of the system tray entry.") ); + m_firstCloseMessage = true; + } + + hide(); + event->ignore(); + } +} + +void SyncWall::on_actionQuit_activated() +{ + on_pushButtonQuit_pressed(); +} + +void SyncWall::on_actionNextWallpaper_activated() +{ + changeWallpaper( getNextImageIndex() ); +} + +void SyncWall::on_actionPreviousWallpaper_activated() +{ + changeWallpaper( getPrevImageIndex() ); +} + +void SyncWall::createActionsSystemTray() +{ + // nothing to do yet +} + +void SyncWall::on_actionShowUI_triggered() +{ + show(); +} + +void SyncWall::createTrayIcon() +{ + // tray menu + m_trayIconMenu = new QMenu(this); + + m_trayIconMenu->addAction(ui->actionShowUI); + m_trayIconMenu->addAction(ui->actionNextWallpaper); + m_trayIconMenu->addAction(ui->actionPreviousWallpaper); + m_trayIconMenu->addAction(ui->actionUserOffset); + m_trayIconMenu->insertSeparator(ui->actionQuit); + m_trayIconMenu->addAction(ui->actionQuit); + + m_trayIconMenu->setTitle(m_appName); + m_trayIconMenu->setIcon( QIcon(":/syncwall/logo_big.png") ); + + m_trayIcon = new QSystemTrayIcon(this); + m_trayIcon->setContextMenu(m_trayIconMenu); + + connect( m_trayIcon, SIGNAL( activated(QSystemTrayIcon::ActivationReason) ), + this, SLOT( iconActivated(QSystemTrayIcon::ActivationReason) ) ); + + m_trayIcon->setIcon( QIcon(":/syncwall/logo_big.png") ); + + m_trayIcon->show(); +} + +//----------------------------------------------------------------------- +// Save/Restore parameters functions +//----------------------------------------------------------------------- + +void SyncWall::saveSettings() +{ + AppSettings settings; + + settings.beginGroup("MainWindow"); + + settings.setValue( "MainWindowState",saveState(0) ); + + settings.setValue( "size", size() ); + settings.setValue( "pos", pos() ); + + settings.setValue( "fullScreen", isFullScreen() ); + + // save the screen number for the splashsreeen ... + if ( QApplication::desktop()->isVirtualDesktop() ) + settings.setValue( "screenNumber", QApplication::desktop()->screenNumber( pos() ) ); + else + settings.setValue( "screenNumber", QApplication::desktop()->screenNumber(this) ); + + settings.setValue( "screenNumber", QApplication::desktop()->screenNumber(this) ); + + settings.endGroup(); + + settings.beginGroup("Application"); + + settings.setValue("useGlobalHotKey", m_useGlobalHotKey); + settings.setValue("globalHotkeyNext", m_globalHotkeyNext); + settings.setValue("globalHotkeyPrev", m_globalHotkeyPrev); + settings.setValue("globalHotkeyOpen", m_globalHotkeyOpen); + settings.setValue("globalHotkeyOffset", m_globalHotkeyOffset); + + settings.setValue("randomOrderChange", m_randomOrderChange); + + settings.setValue("currentLanguage", m_currentLanguage); + + settings.setValue("resetConfig", m_resetConfig); + + // providers + settings.beginWriteArray( "providers", m_currentProviders.count() ); + + for (int i = 0; i < m_currentProviders.size(); ++i) + { + settings.setArrayIndex(i); + settings.setValue( "mode", m_currentProviders.at(i)->getMode() ); + settings.setValue( "inputs", m_currentProviders.at(i)->getInputList() ); + } + + settings.endArray(); + + settings.setValue("lastDirectory", m_lastDirectory); + settings.setValue("lastFile", m_lastFile); + settings.setValue("startInTray", m_startInTray); + settings.setValue("splashscreenAtStartup", m_splashscreenAtStartup); + settings.setValue("splashscreenTransparentBackground", m_splashscreenTransparentBackground); + settings.setValue("startWithSystem", m_startWithSystem); + + settings.endGroup(); + + // save child class settings + emit sigSaveSettings(); +} + +void SyncWall::loadSettings() +{ + AppSettings settings; + + settings.beginGroup("MainWindow"); + + restoreState(settings.value("MainWindowState").toByteArray(), 0); + + resize( settings.value( "size", QSize(400, 400) ).toSize() ); + move( settings.value( "pos", QPoint(200, 200) ).toPoint() ); + + bool fullScreen = settings.value("fullScreen",false).toBool(); + + if (fullScreen) + showFullScreen (); + + settings.endGroup(); + + settings.beginGroup("Application"); + + m_useGlobalHotKey = settings.value("useGlobalHotKey",false).toBool(); + + m_globalHotkeyNext = settings.value("globalHotkeyNext","Ctrl+F11").toString(); + m_globalHotkeyPrev = settings.value("globalHotkeyPrev","Ctrl+F12").toString(); + m_globalHotkeyOpen = settings.value("globalHotkeyOpen","Ctrl+F10").toString(); + m_globalHotkeyOffset = settings.value("globalHotkeyOffset","Ctrl+F9").toString(); + + // setup global key menu + setupGlobalKeys(); + ui->groupBoxHotKey->setChecked(m_useGlobalHotKey); + on_groupBoxHotKey_clicked(m_useGlobalHotKey); + + m_randomOrderChange = settings.value("randomOrderChange",false).toBool(); + ui->checkBoxRandomOrder->setChecked(m_randomOrderChange); + + m_resetConfig = settings.value("resetConfig", false).toBool(); + + m_currentLanguage = settings.value("currentLanguage","auto").toString(); + + if ( m_currentLanguage.isEmpty() ) + m_currentLanguage = QLocale::system().name().left(2); + + // providers + int size = settings.beginReadArray("providers"); + + for (int i = 0; i < size; ++i) + { + settings.setArrayIndex(i); + int mode = settings.value("mode").toInt(); + + if (mode == WallpaperProvider::MODE_DIRECTORY) + m_currentProviders << new WallpaperProvider(settings.value("inputs").toStringList()[0]); + else + m_currentProviders << new WallpaperProvider( settings.value("inputs").toStringList() ); + } + + settings.endArray(); + + m_lastDirectory = settings.value("lastDirectory",QDesktopServices::storageLocation(QDesktopServices::HomeLocation)).toString(); + m_lastFile = settings.value("lastFile",QDesktopServices::storageLocation(QDesktopServices::HomeLocation)).toString(); + + m_startInTray = settings.value("startInTray",false).toBool(); + ui->checkBoxStartInTray->setChecked(m_startInTray); + + // start hidden => no message + if (m_startInTray) + m_firstCloseMessage = true; + + m_splashscreenAtStartup = settings.value("splashscreenAtStartup",true).toBool(); + ui->checkBoxSplashscreenAtStartup->setChecked(m_splashscreenAtStartup); + + m_splashscreenTransparentBackground = settings.value("splashscreenTransparentBackground",true).toBool(); + ui->checkBoxSplashscreenTransparentBackground->setChecked(m_splashscreenTransparentBackground); + + m_startWithSystem = settings.value("startWithSystem",false).toBool(); + ui->checkBoxStartWithSystem->setChecked(m_startWithSystem); + + settings.endGroup(); +} + +// preferences +void SyncWall::iconActivated(QSystemTrayIcon::ActivationReason reason) +{ + switch (reason) + { + case QSystemTrayIcon::Trigger: + break; + + case QSystemTrayIcon::DoubleClick: + showNormal (); + QWidget::setVisible(true); + break; + + case QSystemTrayIcon::MiddleClick: + + //showMessage(); + break; + + default: + ; + } + + // activate action only if needed !! + ui->actionUserOffset->setEnabled( ui->widgetImageParameters->isUserMoveAllowed() ); +} + +void SyncWall::refreshWallpaperProviders(bool force) +{ + //m_listModel->clear(); // clear ui->widget + //m_listFiles.clear(); // clear global wallpaper list + + foreach (WallpaperProvider * wp, m_currentProviders) + { + if (force) + wp->refreshWallpaperList(); + + updateDisplayedFileList(wp); + } + + // update the fixed list of index + computeIndexList(); +} + +void SyncWall::updateDisplayedFileList(WallpaperProvider *wp) +{ + if (!wp) + return; + + m_listModel->addImages( wp->getWallpaperList() ); // update global wallpaper list + + // update the "stats" + ui->labelStats->setText( tr("%1 images in list").arg( m_listModel->rowCount() ) ); +} + +QStringList SyncWall::getSubDirectoryList(const QDir & dir) +{ + QStringList res; + QFileInfoList qsl = dir.entryInfoList(); + foreach (const QFileInfo &entry, qsl) + { + if ( entry.isDir() ) + { + QString dirname = entry.fileName(); + + if ( (dirname==".") || (dirname == "..") ) + continue; + + res << entry.absoluteFilePath(); + res.append( getSubDirectoryList( QDir( entry.absoluteFilePath(),"",QDir::Name,QDir::Dirs) ) ); + } + } + return res; +} + +void SyncWall::on_pushButtonSetWallpaper_pressed() +{ + on_actionSetWallpaper_triggered(); +} + +void SyncWall::checkForBlinking() +{ + if (!m_blinking) // direct wallpaper change + { + changeWallpaper(); + } + else + { + m_blinkTimer.start(); + QTimer::singleShot( defaultBlinkingTime, this, SLOT( changeWallpaper() ) ); + } +} + +void SyncWall::changeWallpaper(int index, bool manual) +{ + m_blinkTimer.stop(); + + if (m_listModel->rowCount() == 0) + return; + + if (index < 0) // mode auto compute next wallpaper + index = getNextImageIndex(); + + m_currentImageIndex = index; + + // manual => reset the sheduler manually + if (manual) + ui->widgetScheduler->restartScheduler(); + + // update user offset + QPoint offset = m_listModel->getOffset(m_currentImageIndex); + ui->widgetImageParameters->setUserOffset(offset); + + // send new wallpaper to connected client if needed + ui->widgetImageParameters->processImage(m_listModel->getFilename(m_currentImageIndex),manual); + + // change list style + m_listModel->setLastAppliedRow(m_currentImageIndex); + + // update header + updateApplicationIdentity(); + + // track file in list view + trackFileInView(m_currentImageIndex); +} + +void SyncWall::trackFileInView(int ind) +{ + QModelIndex index = m_listModel->index(ind,0); + + // ensure line visible + ui->treeViewFiles->scrollTo(index); + ui->listViewFiles->scrollTo(index); + // force selection to current index + ui->treeViewFiles->selectionModel()->select(index,QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); + ui->listViewFiles->selectionModel()->select(index,QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); +} + +int SyncWall::getRandomIndex(int max) +{ + if (max > 1) + return qrand() % (max); + else + return 0; +} + +//! COmpute a list of random index +void SyncWall::computeIndexList() +{ + // bad location to do that !!! + ui->treeViewFiles->resizeColumnToContents(0); + + m_listIndex.clear(); + m_currentListIndex = 0; + + if (!m_listModel) + return; + + for (int i = 0; i < m_listModel->rowCount(); i++) + { + if (m_randomOrderChange) + { + // construct vector + for (int index = 0; index < m_listModel->getRating(i); index++) + m_listIndex.push_back(i); + } + else + { + m_listIndex.push_back(i); + } + } + + if (m_randomOrderChange) + std::random_shuffle( m_listIndex.begin(), m_listIndex.end() ); + +} + +int SyncWall::getNextImageIndex() +{ + if ( !m_listIndex.size() ) + return -1; + + m_currentListIndex++; + m_currentListIndex = m_currentListIndex % m_listIndex.size(); + + return m_listIndex[m_currentListIndex]; +} + +int SyncWall::getPrevImageIndex() +{ + if ( !m_listIndex.size() ) + return -1; + + m_currentListIndex--; + if (m_currentListIndex < 0) + m_currentListIndex = m_listIndex.size() - 1; + + return m_listIndex[m_currentListIndex]; +} + +void SyncWall::selectionChanged(const QItemSelection& selected, const QItemSelection& /*deselected*/) // update only the preview +{ + QModelIndexList indexes = selected.indexes(); + if ( indexes.isEmpty() ) + return; + + // take only first index for previewed file + m_currPreviewImage = m_listModel->getFilename(indexes[0]); + QPoint offset = m_listModel->getOffset(indexes[0]); + + ui->widgetImageParameters->setUserOffset(offset); + + // change list style + m_listModel->setLastPreviewedRow( indexes[0].row() ); + ui->widgetImageParameters->previewImage(m_currPreviewImage); + + // force row selection if detail mode + if (m_listModel->getDisplayMode() == ListImagesModel::MODE_DETAILS) + { + ui->treeViewFiles->selectionModel()->select(selected,QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); + } +} + +void SyncWall::on_listViewFiles_doubleClicked(const QModelIndex & /*index*/) +{ + QModelIndexList selected = ui->listViewFiles->selectionModel()->selectedRows (); + if ( !selected.isEmpty() ) + { + // reset preview + m_listModel->setLastPreviewedRow(-1); + changeWallpaper(m_listModel->getIndex(selected[0]),true); + } +} + +void SyncWall::on_treeViewFiles_doubleClicked(const QModelIndex & /*index*/) +{ + // check if column != starrating column + QModelIndexList selected = ui->treeViewFiles->selectionModel()->selectedIndexes (); + if (!selected.isEmpty() && selected[0].column() != ListImagesModel::COLUMN_RATE) + { + changeWallpaper(m_listModel->getIndex(selected[0]),true); + } +} + +void SyncWall::on_pushButtonPreview_pressed() +{ + on_actionPreviewImage_triggered(); +} + +void SyncWall::on_actionPreviewImage_triggered() +{ + QModelIndexList selected; + if (m_listModel->getDisplayMode() != ListImagesModel::MODE_ICONS) + selected = ui->treeViewFiles->selectionModel()->selectedRows (); + else + selected = ui->listViewFiles->selectionModel()->selectedRows (); + + if ( !selected.isEmpty() ) + { + ImageViewer *viewer = new ImageViewer( m_listModel->getFilename( selected.at(0) ) ); + viewer->show(); + } +} + +void SyncWall::on_actionSetWallpaper_triggered() +{ + QModelIndexList selected; + if (m_listModel->getDisplayMode() != ListImagesModel::MODE_ICONS) + selected = ui->treeViewFiles->selectionModel()->selectedRows (); + else + selected = ui->listViewFiles->selectionModel()->selectedRows (); + + if ( !selected.isEmpty() ) + { + m_currentImageIndex = m_listModel->getIndex(selected[0]); + changeWallpaper(m_currentImageIndex,true); + } +} + +void SyncWall::on_actionDeleteImage_triggered() +{ + bool somethingToDo = false; + + QModelIndexList selected; + if (m_listModel->getDisplayMode() != ListImagesModel::MODE_ICONS) + selected = ui->treeViewFiles->selectionModel()->selectedRows (); + else + selected = ui->listViewFiles->selectionModel()->selectedRows (); + + foreach(const QModelIndex &index, selected) + { + QString file = m_listModel->getFilename(index); + foreach (WallpaperProvider * wp, m_currentProviders) + { + wp->deleteInput(file); + } + somethingToDo = true; + + //m_listModel->removeRows( index.row(), 1) ); + } + + m_listModel->removeRows(selected); + + // reset the list + if (somethingToDo) + { + // search for empty providers + for (int i = m_currentProviders.size() - 1; i >= 0; i--) + if ( m_currentProviders.at(i)->getWallpaperList().isEmpty() ) + delete m_currentProviders.takeAt(i); + + refreshWallpaperProviders(); + } +} + +void SyncWall::on_checkBoxRandomOrder_stateChanged ( int state) +{ + m_randomOrderChange = state; + + // update the fixed list of index + computeIndexList(); +} + +void SyncWall::updateApplicationIdentity() +{ + QString title = m_appName + " - " + m_version + " - " + m_listModel->getFilename(m_currentImageIndex); + setWindowTitle(title); +} + +void SyncWall::updateAbout() +{ + // setup credits ... + updateCredits(); + + // setup changelog ... + updateChangelog(); + updateInfosImageFormats(); + updateInfosLanguages(); + ui->labelRelease->setText(m_appName + " " + m_version); + ui->labelCheckRelease->setText(tr("Check for new release ...").arg(PACKAGE_CHECK_RELEASE_URL)); +} + +void SyncWall::updateInfosImageFormats() +{ + // update format list + + // clear the current list + ui->listWidgetFormats->clear(); + + QStringList formats = MiscFunctions::getAvailablesImageFormatsList(); + QMap longFormats = MiscFunctions::getLongImageFormats(); + + foreach (const QString &format, formats) + { + if ( longFormats.contains(format) ) + new QListWidgetItem(longFormats[format] + " (*." + format + ")", ui->listWidgetFormats); + else + new QListWidgetItem(format, ui->listWidgetFormats); + } + + // Qt version + ui->labelQtVersion->setText(tr("Qt version %1").arg(QT_VERSION_STR)); +} + +void SyncWall::updateInfosLanguages() +{ +// update translation list + const QMap &mapLang = MiscFunctions::getAvailableLanguages(); + QStringList names = mapLang.keys(); + ui->listWidgetTranslations->clear(); + + QString currentLang = m_currentLanguage; + + if (currentLang.isEmpty() || currentLang == "auto") + currentLang = QLocale::system().name().left(2); + + foreach (const QString &lang, names) + { + QString text; + + if (mapLang[lang] == currentLang) + text = lang + " *"; + else + text = lang; + + QListWidgetItem *item = new QListWidgetItem(text, ui->listWidgetTranslations); + item->setData(Qt::UserRole,mapLang[lang]); // save the lang acronym + } +} + +void SyncWall::searchForWallpaper(const QString &file) +{ + LogHandler::getInstance()->reportInfo( tr("new file received : %1").arg(file) ); + + for (int i = 0; i < m_listModel->rowCount(); i++) + if ( m_listModel->getFilename(i).endsWith(file) ) + { + m_currentImageIndex = i; + ui->widgetImageParameters->processImage( m_listModel->getFilename(m_currentImageIndex) ); + return; + } + + LogHandler::getInstance()->reportError( tr("Can't find local file as received : %1").arg(file) ); +} + +void SyncWall::blink() +{ + static int i = 0; + + if (i++ % 2) + checkState(); + else + m_trayIcon->setIcon( QIcon(":/syncwall/mode_idle.png") ); +} + +void SyncWall::changeTrayIcon() +{ + m_trayIcon->setIcon( QIcon(":/syncwall/mode_standard.png") ); + m_trayIcon->setIcon( QIcon(":/syncwall/mode_client_connected.png") ); + m_trayIcon->setIcon( QIcon(":/syncwall/mode_client_disconnected.png") ); + m_trayIcon->setIcon( QIcon(":/syncwall/mode_server.png") ); +} + +int SyncWall::getState() +{ + /* + STATE_STANDARD = 0, // scheduling on, no connected client + STATE_IDLE, // scheduling off, no connected client + STATE_SERVER, // connected client + STATE_CLIENT_CONNECTED, // connected to server + STATE_CLIENT_DISCONNECTED, // can't connect to server + STATE_CLIENT_INVALID // connected to server but invalid protocol (version ?) + */ + int state = STATE_STANDARD; + + if (ui->widgetNetworkParameters->getNetworkMode() == NetworkManager::MODE_SERVER) + { + if (ui->widgetNetworkParameters->getClientNb() == 0) // no client + { + if ( ui->widgetScheduler->getIntervalBetweenChangeMode() ) // change by interval + state = STATE_STANDARD; + else + state = STATE_IDLE; + } + else + state = STATE_SERVER; + } + else // mode client + { + if (ui->widgetNetworkParameters->getState() != QAbstractSocket::UnconnectedState) + { + state = STATE_CLIENT_CONNECTED; + + // check for invalid connection not yet defined !! + } + else + { + state = STATE_CLIENT_DISCONNECTED; + } + } + return state; +} + +void SyncWall::initStateDefs() +{ + m_mapToStateDesc[STATE_STANDARD] = tr("Standard state. Scheduling is activated"); + m_mapToStateDesc[STATE_IDLE] = tr("Idle state. No scheduling and no server connection"); + m_mapToStateDesc[STATE_SERVER] = tr("Server state. Al least a client is connected"); + m_mapToStateDesc[STATE_CLIENT_CONNECTED] = tr("Client state. Connected to server"); + m_mapToStateDesc[STATE_CLIENT_DISCONNECTED] = tr("Client state but disconnected from server"); + m_mapToStateDesc[STATE_CLIENT_INVALID] = tr("Client state but the protocol isn't correct. Upgrade client or server !"); + + m_mapToStateIcon[STATE_STANDARD] = ":/syncwall/mode_standard.png"; + m_mapToStateIcon[STATE_IDLE] = ":/syncwall/mode_idle.png"; + m_mapToStateIcon[STATE_SERVER] = ":/syncwall/mode_server.png"; + m_mapToStateIcon[STATE_CLIENT_CONNECTED] = ":/syncwall/mode_client_connected.png"; + m_mapToStateIcon[STATE_CLIENT_DISCONNECTED] = ":/syncwall/mode_client_disconnected.png"; + m_mapToStateIcon[STATE_CLIENT_INVALID] = ":/syncwall/mode_client_invalid.png"; +} + +void SyncWall::checkState() +{ + int state = getState(); + + // update UI labels + ui->labelStateDesc->setText(m_mapToStateDesc[state]); + ui->labelStateImg->setPixmap( QPixmap(m_mapToStateIcon[state]) ); + + // update tray icon + m_trayIcon->setIcon( QIcon(m_mapToStateIcon[state]) ); + m_trayIcon->setToolTip(m_mapToStateDesc[state]); +} + +void SyncWall::updateChangelog() +{ + fillTextedit("Changelog.txt", ui->textEditChangelog); +} + +void SyncWall::updateCredits() +{ + fillTextedit("CREDITS.txt", ui->textEditCredits); +} + +void SyncWall::fillTextedit(const QString &file, QTextEdit *text) +{ + text->viewport ()->setAutoFillBackground(false); + QStringList paths; + QString filePath; + paths << QApplication::applicationDirPath () + "/" + file; + paths << QApplication::applicationDirPath () + "/../" + file; + paths << QApplication::applicationDirPath () + "/../../" + file; + paths << QApplication::applicationDirPath () + "/../../../" + file; + paths << "/usr/share/" + QString("%1").arg(PACKAGE_NAME).toLower() + "/" + file; + paths << "/usr/local/share/" + QString("%1").arg(PACKAGE_NAME).toLower() + "/" + file; + + foreach (const QString &path, paths) + { + if ( QFileInfo(path).exists() ) + { + filePath = path; + break; + } + } + + // perhaps, not found !! + if ( QFileInfo(filePath).exists() ) + { + QFile f( filePath ); + LogHandler::getInstance()->reportDebug( QObject::tr("%1 found").arg( filePath ) ); + if( f.open( QIODevice::ReadOnly | QIODevice::Text ) ) + { + text->setText( f.readAll() ); + f.close(); + return; + } + } + text->setText( tr("The %1 file can't be found, sorry ...").arg(file) ); +} + +void SyncWall::on_groupBoxHotKey_clicked(bool val) +{ +#ifndef Q_WS_PM // OS/2 + m_useGlobalHotKey = val; + m_shortCutNext->setEnabled(m_useGlobalHotKey); + m_shortCutPrev->setEnabled(m_useGlobalHotKey); + m_shortCutOpen->setEnabled(m_useGlobalHotKey); + m_shortCutOffset->setEnabled(m_useGlobalHotKey); + + // Add shortcut to systray menu ui->action + ui->actionNextWallpaper->setShortcuts( m_useGlobalHotKey ? QList() << m_shortCutNext->shortcut() : QList() ); + ui->actionPreviousWallpaper->setShortcuts( m_useGlobalHotKey ? QList() << m_shortCutPrev->shortcut() : QList() ); + ui->actionShowUI->setShortcuts( m_useGlobalHotKey ? QList() << m_shortCutOpen->shortcut() : QList() ); + ui->actionUserOffset->setShortcuts( m_useGlobalHotKey ? QList() << m_shortCutOffset->shortcut() : QList() ); +#endif +} + +void SyncWall::on_widgetKeySequenceNext_keySequenceChanged(const QKeySequence &seq) +{ +#ifndef Q_WS_PM // OS/2 + m_shortCutNext->setShortcut(seq); + m_globalHotkeyNext = seq.toString(); +#endif +} + +void SyncWall::on_widgetKeySequencePrev_keySequenceChanged(const QKeySequence &seq) +{ +#ifndef Q_WS_PM // OS/2 + m_shortCutPrev->setShortcut(seq); + m_globalHotkeyPrev = seq.toString(); +#endif +} + +void SyncWall::on_widgetKeySequenceOpen_keySequenceChanged(const QKeySequence &seq) +{ +#ifndef Q_WS_PM // OS/2 + m_shortCutOpen->setShortcut(seq); + m_globalHotkeyOpen = seq.toString(); +#endif +} + +void SyncWall::on_widgetKeySequenceOffset_keySequenceChanged(const QKeySequence &seq) +{ +#ifndef Q_WS_PM // OS/2 + m_shortCutOffset->setShortcut(seq); + m_globalHotkeyOffset = seq.toString(); +#endif +} + +void SyncWall::on_checkBoxStartInTray_stateChanged ( int state ) +{ + m_startInTray = state; +} + +void SyncWall::on_checkBoxSplashscreenAtStartup_stateChanged ( int state ) +{ + m_splashscreenAtStartup = state; +} + +void SyncWall::on_checkBoxSplashscreenTransparentBackground_stateChanged ( int state ) +{ + m_splashscreenTransparentBackground = state; +} + +void SyncWall::on_checkBoxStartWithSystem_stateChanged ( int state ) +{ + m_startWithSystem = state; + +#ifdef Q_WS_WIN + QSettings regSettings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat); + + if (m_startWithSystem) + regSettings.setValue( PACKAGE_NAME,QDir::toNativeSeparators( QCoreApplication::applicationFilePath () ) ); + else + regSettings.remove(PACKAGE_NAME); +#endif +} + +void SyncWall::on_pushButtonViewDetail_pressed() +{ + QModelIndexList selected; + if (m_listModel->getDisplayMode() != ListImagesModel::MODE_ICONS) + selected = ui->treeViewFiles->selectionModel()->selectedIndexes (); + else + selected = ui->listViewFiles->selectionModel()->selectedIndexes (); + + m_listModel->setDisplayMode(ListImagesModel::MODE_DETAILS); + ui->treeViewFiles->header()->setVisible(true); + ui->treeViewFiles->resizeColumnToContents(0); + + ui->treeViewFiles->setFocus(Qt::MouseFocusReason); + + // restore selection + if ( !selected.isEmpty() ) + { + ui->treeViewFiles->selectionModel()->blockSignals(true); + ui->treeViewFiles->selectionModel()->clearSelection(); + QSet doneRow; + foreach (const QModelIndex &index, selected) + { + if ( !doneRow.contains( index.row() ) ) + { + ui->treeViewFiles->selectionModel()->select(m_listModel->index(index.row(),0),QItemSelectionModel::Select | QItemSelectionModel::Rows); + doneRow << index.row(); + } + } + ui->treeViewFiles->selectionModel()->blockSignals(false); + // scroll to first selection + //ui->treeViewFiles->scrollTo(m_listModel->index(selected[0].row(),0)); + } + + ui->stackedWidgetFiles->setCurrentIndex(0); // switch to treeview +} + +void SyncWall::on_pushButtonViewThumbnail_pressed() +{ + QModelIndexList selected; + if (m_listModel->getDisplayMode() != ListImagesModel::MODE_ICONS) + selected = ui->treeViewFiles->selectionModel()->selectedIndexes (); + else + selected = ui->listViewFiles->selectionModel()->selectedIndexes (); + + m_listModel->setDisplayMode(ListImagesModel::MODE_ICONS); + + ui->listViewFiles->setFocus(Qt::MouseFocusReason); + + // restore selection + if ( !selected.isEmpty() ) + { + ui->listViewFiles->selectionModel()->blockSignals(true); + ui->listViewFiles->selectionModel()->clearSelection(); + QSet doneRow; + foreach (const QModelIndex &index, selected) + { + if ( !doneRow.contains( index.row() ) ) + { + ui->listViewFiles->selectionModel()->select(m_listModel->index(index.row(),0),QItemSelectionModel::Select | QItemSelectionModel::Rows); + doneRow << index.row(); + } + } + ui->listViewFiles->selectionModel()->blockSignals(false); + // scroll to first selection + //ui->listViewFiles->scrollTo(m_listModel->index(selected[0].row(),0)); + } + + ui->stackedWidgetFiles->setCurrentIndex(1); // switch to iconview +} + +void SyncWall::dragEnterEvent(QDragEnterEvent *event) +{ + if ( event->mimeData()->hasUrls() ) + event->acceptProposedAction(); +} + +void SyncWall::dropEvent(QDropEvent *event) +{ + if ( event->mimeData()->hasUrls() ) + { + QList urls = event->mimeData()->urls(); + QStringList files; + QStringList dirs; + for (int i = 0; i < urls.size(); ++i) + { + if ( QFileInfo( urls[i].toLocalFile() ).isDir() ) + dirs << urls[i].toLocalFile(); + else + files << urls[i].toLocalFile(); + } + + // processing files in a single WallpaperProvider + if ( !files.isEmpty() ) + { + WallpaperProvider *wp = new WallpaperProvider(files); + m_currentProviders << wp; + updateDisplayedFileList(wp); // update UI + } + + // processing directoriesfiles in a single WallpaperProvider + if ( !dirs.isEmpty() ) + { + // check if recursive scan + int rep = QMessageBox::question(this, m_appName, + tr("Add all found directories recursively ?"), + QMessageBox::Yes + | QMessageBox::No); + + bool recursiveSearch = (rep == QMessageBox::Yes); + + // check if watch at + rep = QMessageBox::question(this, m_appName, + tr("Watch for modifications in these directories at application startup ?"), + QMessageBox::Yes + | QMessageBox::No); + + bool watchForModification = (rep == QMessageBox::Yes); + + foreach(const QString &dir, dirs) + addDirToProviders(dir,recursiveSearch,watchForModification); + } + } +} + +void SyncWall::on_listViewFiles_customContextMenuRequested(const QPoint & pos) +{ + QModelIndex index = ui->listViewFiles->indexAt(pos); + if ( index.isValid() ) + { + QMenu menu(this); + + // if multi selection => only display the same value on each element + QModelIndexList proxyList = ui->listViewFiles->selectionModel()->selectedRows (); + + ui->actionPreviewImage->setEnabled(false); + ui->actionSetWallpaper->setEnabled(false); + ui->actionDeleteImage->setEnabled(false); + + if (proxyList.size() > 0) + { + ui->actionPreviewImage->setEnabled(true); + ui->actionSetWallpaper->setEnabled(true); + ui->actionDeleteImage->setEnabled(true); + } + + menu.addAction(ui->actionPreviewImage); + menu.addAction(ui->actionSetWallpaper); + menu.addAction(ui->actionDeleteImage); + + menu.exec( ui->listViewFiles->viewport()->mapToGlobal(pos) ); + } +} + +void SyncWall::on_treeViewFiles_customContextMenuRequested(const QPoint & pos) +{ + QModelIndex index = ui->treeViewFiles->indexAt(pos); + if ( index.isValid() ) + { + QMenu menu(this); + + // if multi selection => only display the same value on each element + QModelIndexList proxyList = ui->treeViewFiles->selectionModel()->selectedRows (); + + ui->actionPreviewImage->setEnabled(false); + ui->actionSetWallpaper->setEnabled(false); + ui->actionDeleteImage->setEnabled(false); + + if (proxyList.size() > 0) + { + ui->actionPreviewImage->setEnabled(true); + ui->actionSetWallpaper->setEnabled(true); + ui->actionDeleteImage->setEnabled(true); + } + + menu.addAction(ui->actionPreviewImage); + menu.addAction(ui->actionSetWallpaper); + menu.addAction(ui->actionDeleteImage); + + menu.exec( ui->treeViewFiles->viewport()->mapToGlobal(pos) ); + } +} + +void SyncWall::on_pushButtonResetPreferences_pressed() +{ + // check if recursive scan + int ret = QMessageBox::question(this, m_appName, + tr("Do you want to reset all the preferences to default value ?\n If yes, the application will be relaunch"), + QMessageBox::Yes + | QMessageBox::No); + + if (ret == QMessageBox::Yes) + { + m_resetConfig = true; + restart(); + } +} + +void SyncWall::on_pushButtonResetCache_pressed() +{ + // check if recursive scan + int ret = QMessageBox::question(this, m_appName, + tr("Do you want to reset all cached data (thumbnails and ratings) ?"), + QMessageBox::Yes + | QMessageBox::No); + + if (ret == QMessageBox::Yes) + m_listModel->resetChache(); +} + +void SyncWall::wakeUp(const QString &mess) +{ + LogHandler::getInstance()->reportWarning(mess); + show(); +} + +void SyncWall::enableBrowsing(bool val) +{ + ui->stackedWidgetFiles->setEnabled(val); + ui->pushButtonAddDirectory->setEnabled(val); + ui->pushButtonAddFiles->setEnabled(val); + ui->pushButtonDeleteImage->setEnabled(val); + ui->pushButtonRefresh->setEnabled(val); + ui->pushButtonSetWallpaper->setEnabled(val); + ui->pushButtonPreview->setEnabled(val); +} + +void SyncWall::on_pushButtonUserMove_pressed() +{ + show(); // show the ui + ui->pushButtonUserMove->setEnabled(false); + ui->pushButtonUserValid->setEnabled(true); + ui->pushButtonUserCancel->setEnabled(true); + + ui->widgetImageParameters->getScenePreview()->setSceneState(DesktopScene::STATE_MOVING_BACKGROUND); + ui->graphicsViewDesktop->zoomToFit(); + enableBrowsing(false); +} + +void SyncWall::on_pushButtonUserValid_pressed() +{ + ui->pushButtonUserMove->setEnabled(true); + ui->pushButtonUserValid->setEnabled(false); + ui->pushButtonUserCancel->setEnabled(false); + + QPointF offset = ui->widgetImageParameters->validCurrentUserPositioning(); + + QModelIndexList selected; + if (m_listModel->getDisplayMode() != ListImagesModel::MODE_ICONS) + selected = ui->treeViewFiles->selectionModel()->selectedIndexes(); + else + selected = ui->listViewFiles->selectionModel()->selectedIndexes (); + + if ( !selected.isEmpty() ) + m_listModel->setData( m_listModel->index(selected[0].row(),ListImagesModel::COLUMN_USER_ADJUST),offset.toPoint() ); + + ui->widgetImageParameters->getScenePreview()->setSceneState(DesktopScene::STATE_IDLE); + ui->graphicsViewDesktop->zoomToFit(); + + // if previewed file and current wallpaper is the same => apply the modification + if ( m_currentImageIndex == m_listModel->getIndex(m_currPreviewImage) ) + changeWallpaper(m_currentImageIndex,true); + + //restore state + enableBrowsing(true); +} + +void SyncWall::on_pushButtonUserCancel_pressed() +{ + ui->pushButtonUserMove->setEnabled(ui->widgetImageParameters->isUserMoveAllowed()); + ui->pushButtonUserValid->setEnabled(false); + ui->pushButtonUserCancel->setEnabled(false); + + ui->widgetImageParameters->getScenePreview()->setSceneState(DesktopScene::STATE_IDLE); + ui->graphicsViewDesktop->zoomToFit(); + + //restore state + enableBrowsing(true); +} + +void SyncWall::on_tabWidgetMain_currentChanged(int index) +{ + if (index == 0) + { + ui->widgetImageParameters->getScenePreview()->setSceneState(DesktopScene::STATE_IDLE); + ui->graphicsViewDesktop->zoomToFit(); + } + + // just in case ... + on_pushButtonUserCancel_pressed(); +} + +void SyncWall::on_tabWidgetPreferences_currentChanged(int index) +{ + if (index == 2) + { + ui->widgetImageParameters->getScenePreview()->setSceneState(DesktopScene::STATE_MOVING_SCREEN); + } +} + +void SyncWall::changeMonitorSupport() +{ + checkIfUserCanMove(); + + // update preview offset + QPoint offset = m_listModel->getOffset( m_listModel->getIndex(m_currPreviewImage) ); + ui->widgetImageParameters->setUserOffset(offset); +} + +void SyncWall::checkIfUserCanMove() +{ + if ( ui->widgetImageParameters->isUserMoveAllowed() ) + { + ui->pushButtonUserMove->setEnabled(true); + ui->pushButtonUserValid->setEnabled(false); + ui->pushButtonUserCancel->setEnabled(false); + } + else + { + ui->pushButtonUserMove->setEnabled(false); + ui->pushButtonUserValid->setEnabled(false); + ui->pushButtonUserCancel->setEnabled(false); + } + + // update all the current screen number for list image + m_listModel->setScreenNumber( ui->widgetImageParameters->getScreenNumberByConfig() ); +} + +void SyncWall::on_listWidgetTranslations_itemClicked( QListWidgetItem * item) +{ + QString lang = item->data(Qt::UserRole).toString(); + QString file( MiscFunctions::getTranslationsPath() ); + file += QString("/%1_%2.qm").arg( QString(PACKAGE_NAME).toLower() ).arg(lang); + + QTranslator translator; + translator.load(file); + ui->labelTranslation->setText( translator.translate("","release of translation and translator name please","put your name here dear translator and the release of the translation file !!") ); +} + +// key events -------------------------------------------------------------------- + +void SyncWall::keyPressEvent(QKeyEvent* event) +{ + switch( event->key() ) + { + case Qt::Key_Plus: + { + QModelIndexList selected; + if (m_listModel->getDisplayMode() != ListImagesModel::MODE_ICONS) + selected = ui->treeViewFiles->selectionModel()->selectedIndexes (); + else + selected = ui->listViewFiles->selectionModel()->selectedIndexes (); + + if ( !selected.isEmpty() ) + { + QSet doneRow; + foreach (const QModelIndex &index, selected) + { + if ( !doneRow.contains( index.row() ) ) + { + int previousRate = m_listModel->getRating( index.row() ); + m_listModel->setData( m_listModel->index(index.row(),ListImagesModel::COLUMN_RATE),++previousRate ); + doneRow << index.row(); + } + } + } + break; + } + case Qt::Key_Minus: + { + QModelIndexList selected; + if (m_listModel->getDisplayMode() != ListImagesModel::MODE_ICONS) + selected = ui->treeViewFiles->selectionModel()->selectedIndexes (); + else + selected = ui->listViewFiles->selectionModel()->selectedIndexes (); + + if ( !selected.isEmpty() ) + { + QSet doneRow; + foreach (const QModelIndex &index, selected) + { + if ( !doneRow.contains( index.row() ) ) + { + int previousRate = m_listModel->getRating( index.row() ); + m_listModel->setData( m_listModel->index(index.row(),ListImagesModel::COLUMN_RATE),--previousRate ); + doneRow << index.row(); + } + } + } + break; + } + default: + break; + } + QMainWindow::keyPressEvent(event); +} + +bool SyncWall::eventFilter(QObject* /*watched*/, QEvent* event) +{ + if (event->type() != QEvent::KeyPress) + return false; + + QKeyEvent *keyEvent = static_cast(event); + keyPressEvent(keyEvent); + return false; +} diff -Nru syncwall-1.6.0/src/SyncWall.h syncwall-1.7.4/src/SyncWall.h --- syncwall-1.6.0/src/SyncWall.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/SyncWall.h 2013-05-05 23:37:32.000000000 +0000 @@ -0,0 +1,281 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#ifndef _SYNCWALL_H_ +#define _SYNCWALL_H_ + +#include +#include +#include +#include + +#include +#include +#include + +class QTextEdit; +class QListWidgetItem; + +// forward declarations +class Scheduler; +class WallpaperProvider; +#ifndef Q_WS_PM // OS/2 +class QxtGlobalShortcut; +#endif +class ListImagesModel; + +namespace Ui +{ +class SyncWallClass; +} + +class SyncWall : public QMainWindow +{ + Q_OBJECT + +public: + + enum typState + { + STATE_STANDARD = 0, // scheduling on, no connected client + STATE_IDLE, // scheduling off, no connected client + STATE_SERVER, // connected client + STATE_CLIENT_CONNECTED, // connected to server + STATE_CLIENT_DISCONNECTED, // can't connect to server + STATE_CLIENT_INVALID // connected to server but invalid protocol (version ?) + }; + + explicit SyncWall(QWidget *parent = 0, Qt::WFlags flags = 0); + ~SyncWall(); + +signals: + + void sigSaveSettings(); + +private slots: + + void on_pushButtonQuit_pressed(); + void on_pushButtonHelp_pressed(); + + void on_pushButtonAddDirectory_pressed(); + void on_pushButtonAddFiles_pressed(); + void on_pushButtonRefresh_pressed(); + void on_pushButtonDeleteImage_pressed(); + void on_pushButtonClearLog_pressed(); + void on_pushButtonSaveLog_pressed(); + void on_pushButtonSetWallpaper_pressed(); + + void on_actionPreviewImage_triggered(); + void on_actionSetWallpaper_triggered(); + void on_actionDeleteImage_triggered(); + + void on_pushButtonPreview_pressed(); + void on_groupBoxHotKey_clicked(bool val); + + void on_checkBoxRandomOrder_stateChanged ( int ); + void on_actionShowUI_triggered(); + + // preferences + + void closeEvent(QCloseEvent *event); + + void iconActivated(QSystemTrayIcon::ActivationReason reason); + + void printToLog(const QString & mess); + + void selectionChanged(const QItemSelection&, const QItemSelection&); + void changeWallpaper(int index = -1, bool manual = false); + + // slot for network + void searchForWallpaper(const QString &); + + void checkForBlinking(); + void blink(); + + void checkState(); + + void on_widgetKeySequenceNext_keySequenceChanged(const QKeySequence &seq); + void on_widgetKeySequencePrev_keySequenceChanged(const QKeySequence &seq); + void on_widgetKeySequenceOpen_keySequenceChanged(const QKeySequence &seq); + void on_widgetKeySequenceOffset_keySequenceChanged(const QKeySequence &seq); + void on_checkBoxStartInTray_stateChanged ( int state ); + void on_checkBoxSplashscreenAtStartup_stateChanged ( int state ); + void on_checkBoxSplashscreenTransparentBackground_stateChanged ( int state ); + void on_checkBoxStartWithSystem_stateChanged ( int state ); + + // view list/icon/... + //void on_pushButtonViewList_pressed(); + void on_pushButtonViewDetail_pressed(); + void on_pushButtonViewThumbnail_pressed(); + void on_actionQuit_activated(); + void on_actionNextWallpaper_activated(); + void on_actionPreviousWallpaper_activated(); + + void dropEvent(QDropEvent *event); + void dragEnterEvent(QDragEnterEvent *event); + + void keyPressEvent(QKeyEvent* event); + + void on_listViewFiles_customContextMenuRequested(const QPoint & pos); + void on_treeViewFiles_customContextMenuRequested(const QPoint & pos); + void on_treeViewFiles_doubleClicked(const QModelIndex & index); + void on_listViewFiles_doubleClicked(const QModelIndex & index); + + // language + void on_comboBoxLanguage_activated(int); + + // prefs + void on_pushButtonResetPreferences_pressed(); + + void on_pushButtonResetCache_pressed(); + + void wakeUp(const QString &mess); + + void saveSettings(); + + void computeIndexList(); + + void on_pushButtonUserMove_pressed(); + void on_pushButtonUserValid_pressed(); + void on_pushButtonUserCancel_pressed(); + + void on_tabWidgetMain_currentChanged(int); + void on_tabWidgetPreferences_currentChanged(int); + + void checkIfUserCanMove(); + void changeMonitorSupport(); + + void on_listWidgetTranslations_itemClicked( QListWidgetItem * item); + +private: + + void updateUi(); + void updateAbout(); + void updateInfosImageFormats(); + void updateInfosLanguages(); + void updatePrefsLanguage(); + + bool eventFilter(QObject* watched, QEvent* event); + + // setup + void setupGlobalKeys(); + + // settings + + void loadSettings(); + + // tray icon + void createTrayIcon(); + void createActionsSystemTray(); + + QStringList getSubDirectoryList(const QDir & dir); + void refreshWallpaperProviders(bool force = false); + void updateDisplayedFileList(WallpaperProvider *ws); + + int getRandomIndex(int max); + + void updateApplicationIdentity(); + QString availablesImageFormats(); + QStringList availablesImageFormatsList(); + + void changeTrayIcon(); + + int getState(); + void initStateDefs(); + + void updateCredits(); + void updateChangelog(); + void fillTextedit(const QString &file, QTextEdit *); + void restart(); + + void addDirToProviders(const QString &,bool,bool); + + void checkForSmallInterface(); + void enableBrowsing(bool); + + // index + + int getNextImageIndex(); + int getPrevImageIndex(); + + void trackFileInView(int ind); + + Ui::SyncWallClass *ui; + + // global key variables + bool m_useGlobalHotKey; + QString m_globalHotkeyNext; + QString m_globalHotkeyPrev; + QString m_globalHotkeyOpen; + QString m_globalHotkeyOffset; +#ifndef Q_WS_PM // OS/2 + QxtGlobalShortcut *m_shortCutNext; + QxtGlobalShortcut *m_shortCutPrev; + QxtGlobalShortcut *m_shortCutOpen; + QxtGlobalShortcut *m_shortCutOffset; +#endif + + bool m_firstCloseMessage; + + QString m_appName; + QString m_version; + QString m_title; + + QString m_lastDirectory; + QString m_lastFile; + + //QStringList m_listFiles; + + //system tray + QSystemTrayIcon *m_trayIcon; + QMenu *m_trayIconMenu; + + Scheduler *m_scheduler; + int m_logLevel; + bool m_randomOrderChange; + + // preferences + + QList m_currentProviders; + + // display + int m_currentImageIndex; + + QString m_currentLanguage; + QTimer m_blinkTimer; + bool m_blinking; + + QMap m_mapToStateDesc; + QMap m_mapToStateIcon; + + bool m_startInTray; + bool m_splashscreenAtStartup; + bool m_splashscreenTransparentBackground; + bool m_startWithSystem; + + ListImagesModel *m_listModel; + bool m_resetConfig; + + QVector m_listIndex; + int m_currentListIndex; + QString m_currPreviewImage; +}; + +#endif // _SYNCWALL_H_ diff -Nru syncwall-1.6.0/src/SystemIntegration.cpp syncwall-1.7.4/src/SystemIntegration.cpp --- syncwall-1.6.0/src/SystemIntegration.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/SystemIntegration.cpp 2013-07-11 14:57:42.000000000 +0000 @@ -0,0 +1,787 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#include +#include +#include +#include + +#include +#include + +//#include + +#include "SystemIntegration.h" + +#include "AppSettings.h" +#include "LogHandler.h" +#include "MiscFunctions.h" + +#ifdef Q_WS_WIN // for wallpaper set on windows platform +#include +#endif + +#ifdef Q_WS_MAC +#include +#include +#include +#endif + +#ifdef Q_WS_PM +#define INCL_WINWORKPLACE +#include +#include +#endif + +#if !defined(WIN32) +#include // for unlink +#endif + +SystemIntegration::SystemIntegration(QObject *parent) + : QObject(parent), + m_desktopType(DESKTOP_UNKNOWN) +{ + loadSettings(); + + // force desktop type for known platform +#if defined(Q_WS_WIN) + m_desktopType = DESKTOP_WINDOWS; +#elif defined(Q_WS_MAC) + m_desktopType = DESKTOP_MACOSX; +#elif defined(Q_WS_PM) + m_desktopType = DESKTOP_OS2; +#endif + + // not yet defined => try auto detect + if (m_desktopType == DESKTOP_UNKNOWN) + m_desktopType = detectCurrentDesktop(); + + LogHandler::getInstance()->reportInfo( tr("Desktop selected: %1").arg( desktopToString(m_desktopType) ) ); + LogHandler::getInstance()->reportInfo( tr("Number of screen detected: %1").arg( QApplication::desktop()->screenCount() ) ); + + // connect the process runner + connect( &m_processRunner,SIGNAL( readyReadStandardOutput () ),this,SLOT( readStandardOutput() ) ); + connect( &m_processRunner,SIGNAL( readyReadStandardError () ),this,SLOT( readStandardError() ) ); + connect( &m_processRunner,SIGNAL( finished ( int, QProcess::ExitStatus) ),this,SLOT( finishedProcess( int, QProcess::ExitStatus) ) ); + connect( &m_processRunner,SIGNAL( error (QProcess::ProcessError) ),this,SLOT( errorProcess(QProcess::ProcessError) ) ); + + // for debugging purpose displat the environment variables + QProcessEnvironment currentEnv = QProcessEnvironment::systemEnvironment (); + LogHandler::getInstance()->reportDebug("===================== begin system env ========================="); + foreach( const QString &env, currentEnv.toStringList() ) + LogHandler::getInstance()->reportDebug(env); + LogHandler::getInstance()->reportDebug("===================== end system env ========================="); + + updateDesktopTips(); + + // clean temps storage + QStringList fileFormats = MiscFunctions::getAvailablesImageFormats().split(" "); + MiscFunctions::cleanTempStorage(fileFormats,"dynamic_wallpaper"); +} + +SystemIntegration::~SystemIntegration() +{ +} + +void SystemIntegration::applyImage(const QList &imgs) +{ + QString bgImg; + QString command; + QStringList args; + JobDef job; + + if ( imgs.isEmpty() ) + return; + + try + { + switch (m_desktopType) + { + case DESKTOP_WINDOWS: + { + bgImg = convertImage(imgs[0],"BMP"); +#ifdef Q_WS_WIN + QSettings appSettings( "HKEY_CURRENT_USER\\Control Panel\\Desktop", QSettings::NativeFormat); + appSettings.setValue( "Wallpaper", QDir::toNativeSeparators(bgImg) ); + appSettings.setValue("WallpaperStyle","0"); + appSettings.setValue("TileWallpaper","1"); + +#ifdef UNICODE + WCHAR wpath[1024]; + + memset(wpath,0,1024 * sizeof(WCHAR)); + QDir::toNativeSeparators(bgImg).toWCharArray(wpath); + + SystemParametersInfoW(SPI_SETDESKWALLPAPER,0,reinterpret_cast (wpath),SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE); +#else + + QByteArray ba = bgImg.toLatin1(); + SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, reinterpret_cast( ba.data() ), SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE); +#endif + + +#endif + break; + } + + case DESKTOP_KDE3: + { + bgImg = convertImage(imgs[0],"PNG"); + + //1 = none + //2 = tiled + //3 = center tiled + //4 = centered + //5 = scaled + //6 = stretched + QString wmode = "1"; + job.args << "kdesktop" << "KBackgroundIface" << "setWallpaper" << bgImg << wmode; + job.command = "dcop"; + m_cmdQueue.enqueue(job); + + break; + } + + case DESKTOP_KDE4: + { + int screen = 0; + foreach(const QImage &img, imgs) + bgImg = convertImage(img,"PNG",screen++); + + //1 = none + //2 = tiled + //3 = center tiled + //4 = centered + //5 = scaled + //6 = stretched + QString wmode = "1"; + job.args << "kdesktop" << "KBackgroundIface" << "setWallpaper" << "1" << bgImg << wmode; + job.command = "dbus"; + + //m_cmdQueue.enqueue(job); + LogHandler::getInstance()->reportWarning( tr("KDE4 is currently incompletely supported. Please select %1 as the current wallpaper with \"centered\" parameter (it's just a workaround)").arg(bgImg) ); + + break; + } + + case DESKTOP_GNOME: + { + bgImg = convertImage(imgs[0],"PNG"); + job.args << "--type" << "bool" << "--set" << "/desktop/gnome/background/draw_background" << "true"; + job.command = "gconftool-2"; + m_cmdQueue.enqueue(job); + job.args.clear(); + + job.args << "--type" << "string" << "--set" << "/desktop/gnome/background/picture_options" << "centered"; + job.command = "gconftool-2"; + m_cmdQueue.enqueue(job); + job.args.clear(); + + job.args << "--type" << "string" << "--set" << "/desktop/gnome/background/picture_filename" << bgImg; + job.command = "gconftool-2"; + m_cmdQueue.enqueue(job); + + break; + } + + case DESKTOP_GNOME3: + { + bgImg = convertImage(imgs[0],"PNG"); + + job.args << "set" << "org.gnome.desktop.background" << "draw-background" << "true"; + job.command = "gsettings"; + m_cmdQueue.enqueue(job); + job.args.clear(); + + job.args << "set" << "org.gnome.desktop.background" << "picture-options" << "spanned"; + job.command = "gsettings"; + m_cmdQueue.enqueue(job); + job.args.clear(); + + job.args << "set" << "org.gnome.desktop.background" << "picture-uri" << "\"file://" + bgImg + "\""; + job.command = "gsettings"; + m_cmdQueue.enqueue(job); + + break; + } + + case DESKTOP_XFCE: + { + bgImg = convertImage(imgs[0],"PNG"); + QFile xfceFile(QDir::homePath() + "/.config/xfce4/desktop/backdrops.list"); + + if ( !xfceFile.open(QIODevice::WriteOnly | QIODevice::Text) ) + { + LogHandler::getInstance()->reportError( tr("Can't open %1 ").arg( xfceFile.fileName() ) ); + return; + } + + xfceFile.open(QIODevice::WriteOnly); + QTextStream out; + out.setDevice(&xfceFile); + + out << "# xfce backdrop list" << endl; + out << bgImg << endl; + xfceFile.close(); + + job.args << "--reload"; + job.command = "xfdesktop"; + m_cmdQueue.enqueue(job); + + break; + } + + case DESKTOP_OPENBOX: + case DESKTOP_LXDE: + { + bgImg = convertImage(imgs[0],"PNG"); + + // --desktop-pref Open desktop preference dialog + // --set-wallpaper= Set desktop wallpaper + // --wallpaper-mode= Set mode of desktop wallpaper. + // =(color|stretch|fit|center|tile) + + job.args << "--wallpaper-mode=center"; + job.command = "pcmanfm"; + m_cmdQueue.enqueue(job); + job.args.clear(); + + job.args << "--set-wallpaper=" + bgImg; + job.args << "--wallpaper-mode=fit"; // modif 19-04-2013 (margevicius.algimantas@gmail.com) + job.command = "pcmanfm"; + m_cmdQueue.enqueue(job); + + break; + } + + case DESKTOP_XFCE4: + { + bgImg = convertImage(imgs[0],"PNG"); + + job.args << "set" << "-c" << "xfce4-desktop" << "-p" << "/backdrop/screen0/monitor0/image-path" << "-s" << bgImg; + job.command = "xfconf-query"; + m_cmdQueue.enqueue(job); + job.args.clear(); + + job.args << "set" << "-c" << "xfce4-desktop" << "-p" << "/backdrop/screen0/monitor0/image-style" << "-s" << "centered"; + job.command = "xfconf-query"; + m_cmdQueue.enqueue(job); + + break; + } + + case DESKTOP_FLUXBOX: + { + bgImg = convertImage(imgs[0],"PNG"); + + //-f = stretched + //-c = centered + //-t = tiled + job.args << "-c" << bgImg; + job.command = "fbsetbg"; + m_cmdQueue.enqueue(job); + + break; + } + + case DESKTOP_BLACKBOX: + { + bgImg = convertImage(imgs[0],"PNG"); + + //-full = stretched + //-center = centered + //-tile = tiled + job.args << "-center" << bgImg; + job.command = "bsetbg"; + m_cmdQueue.enqueue(job); + + break; + } + + case DESKTOP_ENLIGHTENMENT: + { + bgImg = convertImage(imgs[0],"PNG"); + + // -c center + job.args << "-c" << bgImg; + job.command = "Esetroot"; + m_cmdQueue.enqueue(job); + + break; + } + + case DESKTOP_ICEWM: + { + bgImg = convertImage(imgs[0],"PNG"); + + // use display from ImageMagick + job.args << "-backdrop" << "-window" << "root" << bgImg; + job.command = "display"; + m_cmdQueue.enqueue(job); + + break; + } + + case DESKTOP_WINDOWMAKER: + { + bgImg = convertImage(imgs[0],"PNG"); + + //-t = tiled + //-e = centered + //-s = scaled + job.args << "-e" << bgImg; + job.command = "wmsetbg"; + m_cmdQueue.enqueue(job); + break; + } + + case DESKTOP_FVWM: + { + bgImg = convertImage(imgs[0],"PNG"); + job.args << bgImg; + job.command = "fvwm-root"; + m_cmdQueue.enqueue(job); + break; + } + + case DESKTOP_MACOSX: + { + // extract from wally, a Qt4 wallpaper/background changer Copyright (C) 2009 Antonio Di Monaco + // I've no mac so I can't test + bgImg = convertImage(imgs[0],"PNG"); + + QFile scriptFile(MiscFunctions::getValidStorage() + "/syncwall.scpt"); + QTextStream scriptText(&scriptFile); + + scriptFile.open(QIODevice::WriteOnly); +#ifdef Q_WS_MAC + + if (QSysInfo::MacintoshVersion == QSysInfo::MV_10_6) + { + scriptText << "tell application \"System Events\"" << endl; + scriptText << "set picture of every desktop to POSIX file \"" << bgImg << "\"" << endl; + scriptText << "end tell" << endl; + } + else + { + scriptText << "tell application \"Finder\"" << endl; + scriptText << "set desktop picture to POSIX file \"" << bgImg << "\"" << endl; + scriptText << "end tell" << endl; + } + +#endif + scriptFile.close(); + + job.args << QDir::toNativeSeparators(MiscFunctions::getValidStorage() + "/syncwall.scpt"); + job.command = "osascript"; + m_cmdQueue.enqueue(job); + + break; + } + + case DESKTOP_OS2: + { + bgImg = convertImage(imgs[0],"BMP",0,true); +#ifdef Q_WS_PM + HOBJECT hobj; + const char *objName = ""; + + if ( hobj = WinQueryObject( reinterpret_cast< const unsigned char * > (objName) ) ) + { + WinSetObjectData( hobj,reinterpret_cast< const unsigned char * > ( ( QString("BACKGROUND=%1,S,1,I;").arg( QDir::toNativeSeparators(bgImg) ) ).toStdString().c_str() ) ); + } + else + { + LogHandler::getInstance()->reportDebug( QString ("Can't find object with name (%1)").arg(objName) ); + } + +// The first parameter after = is the file name, obviously. +// Replace the 2nd parameter (N) with S or T to Scale or Tile. +// The third parameter is the scale factor if needed. +// The fourth parameter is I for image or C for colour. +// The fifth parameter (only used for C and not shown here) is an RGB string e.g. 128 128 128 +// +// if (hobj = WinQueryObject("")) +// WinSetObjectData(hobj, "BACKGROUND=c:\\path\\image.bmp,N,1,I;"); + +#endif + break; + } + + default: + {} + } + + startNextJob(); + } + catch (...) + { + LogHandler::getInstance()->reportError( tr("SystemIntegration::applyImage: Problem during saving of temp image %1 !!").arg(bgImg) ); + } +} + +QString SystemIntegration::convertImage(const QImage &img, const QString &format, int screenNum, bool roundrobin) +{ + static int count = 0; + LogHandler::getInstance()->reportDebug( tr("Convert QImage to %1").arg(format) ); + + QString bgpath = QDir::toNativeSeparators( MiscFunctions::getValidStorage() + "/dynamic_wallpaper" + QString::number(screenNum) + "." + format.toLower() ); + + if (roundrobin) // workaround for some wm (the file name must change each time) + { + if ( !m_lastCreatedFile.isEmpty() ) + unlink( m_lastCreatedFile.toStdString().c_str() ); + + // add a "random" value to the filename + m_lastCreatedFile = bgpath.replace( QString(".%1").arg( format.toLower() ),QString("-%1.%2").arg( qrand() ).arg( format.toLower() ) ); + } + + LogHandler::getInstance()->reportDebug( tr("Saving temp file (%1)").arg(bgpath) ); + + if ( !img.save(bgpath) ) + LogHandler::getInstance()->reportInfo( tr("Failed to save temp file (%1)").arg(bgpath) ); + + count++; + return bgpath; +} + +void SystemIntegration::loadSettings() +{ + AppSettings settings; + + settings.beginGroup("SystemIntegration"); + + m_desktopType = settings.value("desktopType",DESKTOP_UNKNOWN).toInt(); + + settings.endGroup(); +} + +void SystemIntegration::saveSettings() +{ + AppSettings settings; + + settings.beginGroup("SystemIntegration"); + + settings.setValue("desktopType", m_desktopType); + + settings.endGroup(); +} + +QString SystemIntegration::desktopToString(int val) +{ + QString desktop; + + switch (val) + { + case DESKTOP_KDE3: + desktop = QObject::tr("KDE3 desktop"); + break; + + case DESKTOP_KDE4: + desktop = QObject::tr("KDE4 desktop"); + break; + + case DESKTOP_GNOME: + desktop = QObject::tr("GNOME desktop"); + break; + + case DESKTOP_GNOME3: + desktop = QObject::tr("GNOME3 desktop"); + break; + + case DESKTOP_XFCE: + desktop = QObject::tr("XFCE desktop"); + break; + + case DESKTOP_XFCE4: + desktop = QObject::tr("XFCE4 desktop"); + break; + + case DESKTOP_FLUXBOX: + desktop = QObject::tr("FLUXBOX desktop"); + break; + + case DESKTOP_BLACKBOX: + desktop = QObject::tr("BLACKBOX desktop"); + break; + + case DESKTOP_ENLIGHTENMENT: + desktop = QObject::tr("Enlightenment desktop"); + break; + + case DESKTOP_ICEWM: + desktop = QObject::tr("ICEWM desktop"); + break; + + case DESKTOP_OPENBOX: + desktop = QObject::tr("OPENBOX desktop"); + break; + + case DESKTOP_LXDE: + desktop = QObject::tr("LXDE desktop"); + break; + + case DESKTOP_WINDOWMAKER: + desktop = QObject::tr("WINDOWMAKER desktop"); + break; + + case DESKTOP_FVWM: + desktop = QObject::tr("FVWM desktop"); + break; + + case DESKTOP_WINDOWS: + desktop = QObject::tr("WINDOWS desktop"); + break; + + case DESKTOP_MACOSX: + desktop = QObject::tr("MACOSX desktop"); + break; + + case DESKTOP_OS2: + desktop = QObject::tr("OS/2 desktop"); + break; + + case DESKTOP_UNKNOWN: + desktop = QObject::tr("Automatic detection"); + break; + + default: + desktop = QObject::tr("No Desktop Environment Detected"); + break; + } + + return desktop; +} + +//---------------------------------------------------------------- +// detectCurrentDesktop is adapted from +// AutoWallpaper 2.1 (Linux) - version 2.1.2.x RC 1 +// Tyler Jones - May 2009 +//---------------------------------------------------------------- + +int SystemIntegration::detectCurrentDesktop() +{ + bool ok; + desktopType temp(DESKTOP_UNKNOWN); + + // force desktop type for known platform +#if defined(Q_WS_WIN) + temp = DESKTOP_WINDOWS; +#elif defined(Q_WS_MAC) + temp = DESKTOP_MACOSX; +#elif defined(Q_WS_PM) + temp = DESKTOP_OS2; +#endif + + QFileInfoList files = QDir("/proc").entryInfoList(QDir::AllDirs | QDir::NoDotAndDotDot); + QListIterator file(files); + int count = 0; + + while ( file.hasNext() && (temp == DESKTOP_UNKNOWN) ) + { + if ( count > files.size() ) // sometimes this loop is infinite ???? + { + LogHandler::getInstance()->reportError( tr("loop detected during environment processing => skip") ); + break; + } + + file.peekNext().fileName().toInt(&ok); + + if (ok) + { + if ( QFileInfo(file.peekNext().absoluteFilePath() + "/exe").symLinkTarget().contains("kdeinit") && + !QFileInfo(file.peekNext().absoluteFilePath() + "/exe").symLinkTarget().contains("kdeinit4") ) + { + LogHandler::getInstance()->reportDebug( tr("detectCurrentDesktop => Detected: KDE3") ); + temp = DESKTOP_KDE3; + } + else if ( QFileInfo(file.peekNext().absoluteFilePath() + "/exe").symLinkTarget().contains("kdeinit4") ) + { + LogHandler::getInstance()->reportDebug( tr("detectCurrentDesktop => Detected: KDE4") ); + temp = DESKTOP_KDE4; + } + else if ( QFileInfo(file.peekNext().absoluteFilePath() + "/exe").symLinkTarget().contains("gconfd-2") ) + { + LogHandler::getInstance()->reportDebug( tr("detectCurrentDesktop => Detected: Gnome") ); + temp = DESKTOP_GNOME; + + // check if gnome 2 or 3 + QString version = MiscFunctions::launchExternalSynchronousProcess("gnome-session", QStringList() << "--version"); + LogHandler::getInstance()->reportDebug( tr("detectCurrentDesktop => Gnome version %1").arg(version) ); + + if ( !version.isEmpty() && version.contains(" ") ) + { + QStringList list = version.split(" "); + + if ( list.size() > 1 && list[1].startsWith("3") ) + temp = DESKTOP_GNOME3; + } + } + else if ( QFileInfo(file.peekNext().absoluteFilePath() + "/exe").symLinkTarget().contains("xfdesktop") ) + { + LogHandler::getInstance()->reportDebug( tr("detectCurrentDesktop => Detected: Xfce") ); + temp = DESKTOP_XFCE; + } + else if ( QFileInfo(file.peekNext().absoluteFilePath() + "/exe").symLinkTarget().contains("xfdesktop") ) // not yet functional !!! + { + LogHandler::getInstance()->reportDebug( tr("detectCurrentDesktop => Detected: Xfce4") ); + temp = DESKTOP_XFCE4; + } + else if ( QFileInfo(file.peekNext().absoluteFilePath() + "/exe").symLinkTarget().contains("fluxbox") ) + { + LogHandler::getInstance()->reportDebug( tr("detectCurrentDesktop => Detected: Fluxbox") ); + temp = DESKTOP_FLUXBOX; + } + else if ( QFileInfo(file.peekNext().absoluteFilePath() + "/exe").symLinkTarget().contains("fvwm") ) + { + LogHandler::getInstance()->reportDebug( tr("detectCurrentDesktop => Detected: FVWM") ); + temp = DESKTOP_FVWM; + } + else if ( QFileInfo(file.peekNext().absoluteFilePath() + "/exe").symLinkTarget().contains("blackbox") ) + { + LogHandler::getInstance()->reportDebug( tr("detectCurrentDesktop => Detected: Blackbox") ); + temp = DESKTOP_BLACKBOX; + } + else if ( QFileInfo(file.peekNext().absoluteFilePath() + "/exe").symLinkTarget().contains("wmaker") ) + { + LogHandler::getInstance()->reportDebug( tr("detectCurrentDesktop => Detected: WindowMaker") ); + temp = DESKTOP_WINDOWMAKER; + } + + file.next(); + } + } + + if (temp == DESKTOP_UNKNOWN) + LogHandler::getInstance()->reportError( tr("No Desktop Environment Detected") ); + + return temp; +} + +void SystemIntegration::errorProcess( QProcess::ProcessError error) +{ + QString mess; + + switch (error) + { + case QProcess::FailedToStart: + { + mess = tr("SystemIntegration: The process failed to start. Either the invoked program is missing, or you may have insufficient permissions to invoke the program."); + break; + } + + case QProcess::Crashed: + { + mess = tr("SystemIntegration: The process crashed some time after starting successfully."); + break; + } + + case QProcess::Timedout: + { + mess = tr("SystemIntegration: The last waitFor...() function timed out. The state of QProcess is unchanged, and you can try calling waitFor...() again."); + break; + } + + case QProcess::WriteError: + { + mess = tr("SystemIntegration: An error occurred when attempting to write to the process. For example, the process may not be running, or it may have closed its input channel."); + break; + } + + case QProcess::ReadError: + { + mess = tr("SystemIntegration: An error occurred when attempting to read from the process. For example, the process may not be running."); + break; + } + + case QProcess::UnknownError: + { + mess = tr("SystemIntegration: An unknown error occurred. This is the default return value of error()."); + break; + } + } + + LogHandler::getInstance()->reportError( mess ); + startNextJob(); +} + +void SystemIntegration::readStandardError() +{ + LogHandler::getInstance()->reportError( m_processRunner.readAllStandardError() ); +} + +void SystemIntegration::readStandardOutput() +{ + QString temp = m_processRunner.readAllStandardOutput(); + LogHandler::getInstance()->reportInfo(temp); +} + +void SystemIntegration::finishedProcess( int /*exitCode*/, QProcess::ExitStatus exitStatus ) +{ + switch (exitStatus) + { + case QProcess::NormalExit: + { + LogHandler::getInstance()->reportInfo( tr("The command exited normally.") ); + break; + } + + case QProcess::CrashExit: + { + LogHandler::getInstance()->reportError( tr("The command crashed.") ); + break; + } + } + + startNextJob(); +} + +void SystemIntegration::startNextJob() +{ + // process already running + if (m_processRunner.state () != QProcess::NotRunning) + { + LogHandler::getInstance()->reportDebug("process already running, waiting ..."); + return; + } + + // no job in queue, exiting ... + if ( m_cmdQueue.isEmpty() ) + return; + + m_currJob = m_cmdQueue.dequeue(); + LogHandler::getInstance()->reportDebug( tr("Running ") + m_currJob.command + " " + m_currJob.args.join(" ") ); + m_processRunner.start(m_currJob.command, m_currJob.args); +} + +QString SystemIntegration::getDesktopTips(int index) +{ + if ( m_desktopTips.contains(index) ) + return m_desktopTips[index]; + else + return ""; +} + +void SystemIntegration::updateDesktopTips() +{ + for (int i = DESKTOP_UNKNOWN; i < DESKTOP_TYPE_NUMBER; i++) + m_desktopTips[i] = ""; + m_desktopTips[DESKTOP_KDE4] = tr("Tips: KDE4 is currently incompletely supported. Please select the generated wallpaper in plasma with \"centered\" parameter (it's just a workaround). For multi monitor with KDE activities, you can create a splitted wallpaper (one file by monitor) by selecting the right option in the \"Image parameters\" panel."); +} diff -Nru syncwall-1.6.0/src/SystemIntegration.h syncwall-1.7.4/src/SystemIntegration.h --- syncwall-1.6.0/src/SystemIntegration.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/SystemIntegration.h 2013-05-05 23:37:32.000000000 +0000 @@ -0,0 +1,120 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#ifndef _SYSTEMINTEGRATION_H_ +#define _SYSTEMINTEGRATION_H_ + +#include +#include +#include +#include +#include +#include + +typedef struct +{ + QString command; + QStringList args; +} JobDef; + +class SystemIntegration : + public QObject +{ + Q_OBJECT + +public: + +// enum Desktop type + enum desktopType + { + DESKTOP_UNKNOWN = 0, + DESKTOP_KDE3, + DESKTOP_KDE4, + DESKTOP_GNOME, + DESKTOP_GNOME3, + DESKTOP_XFCE, + DESKTOP_XFCE4, + DESKTOP_FLUXBOX, + DESKTOP_ICEWM, + DESKTOP_BLACKBOX, + DESKTOP_OPENBOX, + DESKTOP_LXDE, + DESKTOP_WINDOWMAKER, + DESKTOP_ENLIGHTENMENT, + DESKTOP_FVWM, // end Unix desktop + DESKTOP_WINDOWS, // XP, VISTA, SEVEN + DESKTOP_MACOSX, // MAC OSX + DESKTOP_OS2, // OS/2 + DESKTOP_TYPE_NUMBER + }; + + SystemIntegration(QObject *parent = 0); + ~SystemIntegration(); + + QString desktopToString(int val); + int detectCurrentDesktop(); + + QString getDesktopTips(int); + + void setDesktopType(int type) + { + m_desktopType = type; + } + + int getDesktopType() const + { + return m_desktopType; + } + +public slots: + + void applyImage(const QList &); + +//! process errors from QProcess (python script) + void errorProcess( QProcess::ProcessError error); + +//! read the std output errors (output from the script running) + void readStandardError(); + +//! read the std output (output from the script running) + void readStandardOutput(); + +//! called at the end of the script + void finishedProcess( int exitCode, QProcess::ExitStatus exitStatus ); + + void saveSettings(); + +private: + + void loadSettings(); + + QString convertImage(const QImage &img, const QString &format, int screenNum = 0, bool flipflop = false); + void startNextJob(); + void updateDesktopTips(); + + int m_desktopType; + QProcess m_processRunner; + QQueue m_cmdQueue; + JobDef m_currJob; + QMap m_desktopTips; + QString m_lastCreatedFile; +}; + +#endif // _SYSTEMINTEGRATION_H_ diff -Nru syncwall-1.6.0/src/SystemIntegrationConfigWidget.cpp syncwall-1.7.4/src/SystemIntegrationConfigWidget.cpp --- syncwall-1.6.0/src/SystemIntegrationConfigWidget.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/SystemIntegrationConfigWidget.cpp 2013-05-05 23:37:30.000000000 +0000 @@ -0,0 +1,81 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#include "SystemIntegrationConfigWidget.h" + +#include "ui_SystemIntegrationConfigWidget.h" + +SystemIntegrationConfigWidget::SystemIntegrationConfigWidget(QWidget *parent) + : QWidget(parent), + ui(new Ui::SystemIntegrationConfigWidget) +{ + ui->setupUi(this); + + // hide linux settings +#ifndef Q_WS_X11 + ui->groupBoxDesktop->hide(); +#endif + + updateUI(); +} + +SystemIntegrationConfigWidget::~SystemIntegrationConfigWidget() +{ + delete ui; +} + +void SystemIntegrationConfigWidget::updateUI() +{ + for (int i = SystemIntegration::DESKTOP_UNKNOWN; i <= SystemIntegration::DESKTOP_FVWM; i++) + { + ui->comboBoxDesktop->addItem(m_system.desktopToString(i),i); + if (m_system.getDesktopType() == i) + ui->comboBoxDesktop->setCurrentIndex(i); + } + + // update the tips if exists ... + ui->labelTipsSystem->setText( m_system.getDesktopTips( m_system.getDesktopType() ) ); + + // auto detect display + ui->labelDetectedDesktop->setText( tr("detected desktop: %1").arg( m_system.desktopToString( m_system.detectCurrentDesktop() ) ) ); +} + +void SystemIntegrationConfigWidget::on_comboBoxDesktop_activated(int index) +{ + m_system.setDesktopType( ui->comboBoxDesktop->itemData(index).toInt() ); + + // update the tips if exists ... + ui->labelTipsSystem->setText( m_system.getDesktopTips( m_system.getDesktopType() ) ); +} + +void SystemIntegrationConfigWidget::applyWallpaper(const QImage &file) +{ + m_system.applyImage(QList() << file); +} + +void SystemIntegrationConfigWidget::applyWallpaper(const QList &files) +{ + m_system.applyImage(files); +} + +void SystemIntegrationConfigWidget::saveSettings() +{ + m_system.saveSettings(); +} diff -Nru syncwall-1.6.0/src/SystemIntegrationConfigWidget.h syncwall-1.7.4/src/SystemIntegrationConfigWidget.h --- syncwall-1.6.0/src/SystemIntegrationConfigWidget.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/SystemIntegrationConfigWidget.h 2013-05-05 23:37:32.000000000 +0000 @@ -0,0 +1,59 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#ifndef _SYSTEMINTEGRATIONCONFIGWIDGET_H_ +#define _SYSTEMINTEGRATIONCONFIGWIDGET_H_ + +#include + +namespace Ui +{ +class SystemIntegrationConfigWidget; +} + +#include "SystemIntegration.h" + +class SystemIntegrationConfigWidget : public QWidget +{ + Q_OBJECT + +public: + + SystemIntegrationConfigWidget(QWidget *parent = 0); + ~SystemIntegrationConfigWidget(); + +public slots: + + void on_comboBoxDesktop_activated(int index); + void applyWallpaper(const QImage &); + void applyWallpaper(const QList &); + + void saveSettings(); + +private: + + void updateUI(); + + Ui::SystemIntegrationConfigWidget *ui; + + SystemIntegration m_system; +}; + +#endif // _SYSTEMINTEGRATIONCONFIGWIDGET_H_ diff -Nru syncwall-1.6.0/src/TcpClient.cpp syncwall-1.7.4/src/TcpClient.cpp --- syncwall-1.6.0/src/TcpClient.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/TcpClient.cpp 2013-02-20 08:45:22.000000000 +0000 @@ -0,0 +1,313 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *******************************************************************************/ + +#include +#include +#include + +#include "TcpClient.h" +#include "LogHandler.h" + +static quint32 const PAYLOADSIZE = 65536; + +//status strings +static const QString INACTIVE_STRING = "inactive"; +static const QString LISTENING_STRING = "listening"; +static const QString CONNECTING_STRING = "connecting"; +static const QString NEGOTIATING_STRING = "negotiating"; +static const QString SENDING_STRING = "sending"; +static const QString RECEIVING_STRING = "receiving"; +static const QString FINISHED_STRING = "finished"; +static const QString UNKNOWN_STRING = "unknown"; + +//--------------------------------------------------------------------------------------------- +TcpClient::TcpClient(QObject *parent) : + QObject(parent), + m_file(0) +{ + m_socket = new QTcpSocket(this); + + m_timeOutCounter = 0; + m_connectionTimer = new QTimer(this); + + QObject::connect( m_socket, SIGNAL( connected() ), + this, SLOT( on_socketConnected() ) ); + + QObject::connect( m_socket, SIGNAL( bytesWritten(qint64) ), + this, SLOT( updateClientProgress(qint64) ) ); + + QObject::connect( m_socket, SIGNAL( disconnected() ), + this, SLOT( on_socketDisconnected() ) ); + + QObject::connect( m_connectionTimer, SIGNAL( timeout() ), + this, SLOT( timeout() ) ); +} + +//--------------------------------------------------------------------------------------------- +TcpClient::~TcpClient() +{ + delete m_socket; +} + +//--------------------------------------------------------------------------------------------- +QString TcpClient::getStateAsString(quint8 state) +{ + QString state_string = ""; + + switch(state) + { + case INACTIVE: + state_string = INACTIVE_STRING; + break; + + case CONNECTING: + state_string = CONNECTING_STRING; + break; + + case NEGOTIATING: + state_string = NEGOTIATING_STRING; + break; + + case SENDING: + state_string = SENDING_STRING; + break; + + case FINISHED: + state_string = FINISHED_STRING; + break; + + default: + state_string = UNKNOWN_STRING; + } + + return state_string; +} + +//--------------------------------------------------------------------------------------------- +void TcpClient::setState(quint8 new_state) +{ + m_currentState = new_state; + LogHandler::getInstance()->reportInfo( tr("Client: State changed to '%1'").arg( getStateAsString(new_state) ) ); + + switch(m_currentState) + { + case INACTIVE: + + m_bytesWritten = 0; + m_blockSize = 0; + m_connectionTimer->stop(); + m_tempBytesWritten = 0; + m_timeOutCounter = 0; + + if(m_socket) + m_socket->abort(); + + if( m_file && m_file->isOpen() ) + m_file->close(); + + break; + + case CONNECTING: + + break; + + case NEGOTIATING: + break; + + case SENDING: + break; + } + + emit stateChanged(new_state); +} + +//--------------------------------------------------------------------------------------------- +void TcpClient::timeout() +{ + quint32 speed = (m_bytesWritten - m_tempBytesWritten) >> 10; + m_tempBytesWritten = m_bytesWritten; + + if(speed > 0) + { + m_timeOutCounter = 0; + } + else + { + if(++m_timeOutCounter == m_timeOut) + { + LogHandler::getInstance()->reportInfo( tr("Client: Connection timed out") ); + setState(INACTIVE); + } + } +} + +//--------------------------------------------------------------------------------------------- +void TcpClient::updateClientProgress(qint64 num_bytes) +{ + if(m_currentState != SENDING) + return; + + m_bytesWritten += (int)num_bytes; + + if(m_bytesToWrite > 0) + { + m_fileBlock = m_file->read(PAYLOADSIZE); + m_bytesToWrite -= (int)m_socket->write( m_fileBlock.left( qMin(m_bytesToWrite, PAYLOADSIZE) ) ); + } + + if(m_bytesWritten >= m_fileSize) + { + setState(FINISHED); + LogHandler::getInstance()->reportInfo( tr("Client: File transfer complete") ); + setState(INACTIVE); + } +} + +//--------------------------------------------------------------------------------------------- +void TcpClient::on_socketConnected() +{ + LogHandler::getInstance()->reportInfo( tr("Client: Connection to server established") ); + setState(NEGOTIATING); + + sendFileInformation(); + + QObject::connect( m_socket, SIGNAL( readyRead() ), + this, SLOT( readMessage() ) ); +} + +//--------------------------------------------------------------------------------------------- +void TcpClient::sendFileInformation() +{ + QString filepath; // = filename_textbox_->text(); + QString filename = filepath; + QFile file(filepath); + + if( !file.exists() ) + { + LogHandler::getInstance()->reportError( tr("Client: File '%1' does not exist").arg(filepath) ); + setState(INACTIVE); + return; + } + + //extract filename only (without the path) + int index = filename.lastIndexOf('/'); + + if(index != -1) + filename = filename.right(filename.length() - index - 1); + + //send the file information + QByteArray block; + QDataStream out(&block, QIODevice::WriteOnly); + quint32 filesize = file.size(); + + out.setVersion(QDataStream::Qt_4_0); + out << (quint16)0; + out << (quint8)'I' << filename << filesize; + out.device()->seek(0); + out << (quint16)( block.size() - sizeof(quint16) ); + + m_socket->write(block); + + m_connectionTimer->start(1000); + + LogHandler::getInstance()->reportInfo( tr("Client: File information sent to server") ); +} + +//--------------------------------------------------------------------------------------------- +void TcpClient::sendFile() +{ + QString filepath; // = filename_textbox_->text(); + m_file = new QFile(filepath); + + if( !m_file->open(QIODevice::ReadOnly) ) + { + LogHandler::getInstance()->reportError( tr("Client: Error reading file '%1'").arg(filepath) ); + setState(INACTIVE); + return; + } + + m_timeOutCounter = 0; + m_tempBytesWritten = 0; + + //m_connectionTimer->start(1000); + + LogHandler::getInstance()->reportInfo( tr("Client: Starting file transfer ...") ); + setState(SENDING); + + m_fileSize = m_file->size(); + m_fileBlock = m_file->read(PAYLOADSIZE); + + m_bytesToWrite = m_fileSize - (int)m_socket->write(m_fileBlock); +} + +//--------------------------------------------------------------------------------------------- +void TcpClient::readMessage() +{ + QDataStream in(m_socket); + in.setVersion(QDataStream::Qt_4_0); + + if(m_blockSize == 0) + { + if( m_socket->bytesAvailable() < (int)sizeof(quint16) ) + return; + + in >> m_blockSize; + } + + if(m_socket->bytesAvailable() < m_blockSize) + return; + + quint8 message_type; + in >> message_type; + + if(m_currentState == NEGOTIATING) + { + switch(message_type) + { + case 'A': //Peer accepted the file + LogHandler::getInstance()->reportInfo( tr("Client: Sever accepted the file") ); + sendFile(); + break; + + default: + if(m_currentState != NEGOTIATING) + LogHandler::getInstance()->reportError( tr("Received unknown message type: %1").arg(message_type) ); + } + } +} + +//--------------------------------------------------------------------------------------------- +void TcpClient::on_socketError(int socket_error) +{ + LogHandler::getInstance()->reportError( tr("Unable to connect: %1.").arg( m_socket->errorString() ) ); + + setState(INACTIVE); +} + +//--------------------------------------------------------------------------------------------- +void TcpClient::on_socketDisconnected() +{ + if( (m_currentState == NEGOTIATING || m_currentState == SENDING) ) + { + LogHandler::getInstance()->reportError( tr("Client: Connection closed. Transfer aborted.") ); + } + + setState(INACTIVE); +} diff -Nru syncwall-1.6.0/src/TcpClient.h syncwall-1.7.4/src/TcpClient.h --- syncwall-1.6.0/src/TcpClient.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/TcpClient.h 2013-02-20 08:45:24.000000000 +0000 @@ -0,0 +1,89 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *******************************************************************************/ + +#ifndef _TCPCLIENT_H_ +#define _TCPCLIENT_H_ + +#include + +class QTcpSocket; +class QTimer; +class QFile; + +class TcpClient : + public QObject +{ + Q_OBJECT + +public: + + enum States + { + INACTIVE, + CONNECTING, + NEGOTIATING, + SENDING, + FINISHED + }; + + TcpClient(QObject *parent = 0); + + virtual ~TcpClient(); + + QString getStateAsString(quint8 state); + +signals: + + void stateChanged(quint8 new_state); + +private slots: + + void updateClientProgress(qint64 num_bytes); + void timeout(); + void readMessage(); + void on_socketConnected(); + void on_socketError(int socket_error); + void on_socketDisconnected(); + +private: + + //------------------------ + + void setState(quint8 new_state); + void sendFileInformation(); + void sendFile(); + + QTcpSocket *m_socket; + quint8 m_currentState; + quint16 m_blockSize; + quint32 m_bytesWritten; + quint32 m_bytesToWrite; + quint32 m_fileSize; + QByteArray m_fileBlock; + QFile *m_file; + + //timeout variables------- + quint32 m_tempBytesWritten; + quint16 m_timeOut; + quint16 m_timeOutCounter; + QTimer *m_connectionTimer; +}; + +#endif // _TCPCLIENT_H_ diff -Nru syncwall-1.6.0/src/TcpServer.cpp syncwall-1.7.4/src/TcpServer.cpp --- syncwall-1.6.0/src/TcpServer.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/TcpServer.cpp 2013-02-20 08:45:22.000000000 +0000 @@ -0,0 +1,401 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2012 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *******************************************************************************/ + +#include "TcpServer.h" +#include "LogHandler.h" + +#include +#include + +static quint32 const PAYLOADSIZE = 65536; + +//status strings +static const QString INACTIVE_STRING = "inactive"; +static const QString LISTENING_STRING = "listening"; +static const QString CONNECTING_STRING = "connecting"; +static const QString NEGOTIATING_STRING = "negotiating"; +static const QString SENDING_STRING = "sending"; +static const QString RECEIVING_STRING = "receiving"; +static const QString FINISHED_STRING = "finished"; +static const QString UNKNOWN_STRING = "unknown"; + +//--------------------------------------------------------------------------------------------- +TcpServer::TcpServer(QObject *parent) + : QObject(parent) +{ + m_server = new QTcpServer(parent); + m_connectionTimer = new QTimer(this); + m_file = 0; + m_socket = 0; + m_port = 0; + m_timeOutCounter = 0; + m_timeOut = 10; //FIXXXME: Should be set by the user + + QObject::connect( m_server, SIGNAL( newConnection() ), + this, SLOT( on_server__newConnection() ) ); + + QObject::connect( m_connectionTimer, SIGNAL( timeout() ), + this, SLOT( timeout() ) ); + + m_currentState = 0; + m_reverseConnection = false; +} + +//--------------------------------------------------------------------------------------------- +TcpServer::~TcpServer() +{ + if(m_server) + delete m_server; +} + +//--------------------------------------------------------------------------------------------- +QString TcpServer::getStateAsString(quint8 state) +{ + QString state_string = ""; + + switch(state) + { + case INACTIVE: + state_string = INACTIVE_STRING; + break; + + case LISTENING: + state_string = LISTENING_STRING; + break; + + case CONNECTING: + state_string = CONNECTING_STRING; + break; + + case NEGOTIATING: + state_string = NEGOTIATING_STRING; + break; + + case RECEIVING: + state_string = RECEIVING_STRING; + break; + + case FINISHED: + state_string = FINISHED_STRING; + break; + + default: + state_string = UNKNOWN_STRING; + } + + return state_string; +} + +//--------------------------------------------------------------------------------------------- +bool TcpServer::start(quint16 port) +{ + m_port = port; + + if(m_reverseConnection) + { + LogHandler::getInstance()->reportInfo( tr("TcpServer: Initiating reverse connection") ); + + if(!m_socket) + m_socket = new QTcpSocket(this); + + QObject::connect( m_socket, SIGNAL( connected() ), + this, SLOT( on_socketConnected() ) ); + QObject::connect( m_socket, SIGNAL( readyRead() ), + this, SLOT( readMessage() ) ); + QObject::connect( m_socket, SIGNAL( disconnected() ), + this, SLOT( on_socketDisconnected() ) ); + + QString target; // = parent_->getTargetReceiveCombobox()->lineEdit()->text(); + + //if(parent_->isIP(target)) + // m_socket->connectToHost(QHostAddress(target), m_port); + //else + m_socket->connectToHost(target, m_port); + } + else + { + while( !m_server->isListening() && !m_server->listen(QHostAddress::Any, m_port) ) + { + LogHandler::getInstance()->reportInfo( tr("TcpServer: Unable to start the server: %1").arg( m_server->errorString() ) ); + return false; + } + + LogHandler::getInstance()->reportInfo( tr("TcpServer: Starting server...") ); + } + + m_blockSize = 0; + m_bytesReceived = 0; + m_tempBytesReceived = 0; + + setState(LISTENING); + return true; +} + +//--------------------------------------------------------------------------------------------- +void TcpServer::stop() +{ + if( m_server->isListening() ) + m_server->close(); + + setState(INACTIVE); + LogHandler::getInstance()->reportInfo( tr("TcpServer: TcpServer stopped") ); +} + +//--------------------------------------------------------------------------------------------- +void TcpServer::timeout() +{ + quint32 speed = (m_bytesReceived - m_tempBytesReceived) >> 10; + m_tempBytesReceived = m_bytesReceived; + + if(speed > 0) + { + m_timeOutCounter = 0; + } + else + { + if(++m_timeOutCounter == m_timeOut) + { + LogHandler::getInstance()->reportInfo( tr("TcpServer: Connection timed out") ); + abort(); + } + } +} + +//--------------------------------------------------------------------------------------------- +void TcpServer::abort() +{ + if( m_currentState == RECEIVING && m_file->exists() ) + m_file->remove(); + + stop(); +} + +//--------------------------------------------------------------------------------------------- +QString TcpServer::errorString() const +{ + return m_server->errorString(); +} + +//--------------------------------------------------------------------------------------------- +void TcpServer::setState(quint8 new_state) +{ + m_currentState = new_state; + LogHandler::getInstance()->reportInfo( tr("TcpServer: State changed to '%1'").arg( getStateAsString(new_state) ) ); + + switch(m_currentState) + { + case INACTIVE: + if(m_socket) + m_socket->abort(); + + if(m_file) + { + m_file->close(); + delete m_file; + m_file = 0; + } + + m_saveFilename = ""; + m_fileSize = 0; + m_blockSize = 0; + + m_connectionTimer->stop(); + m_tempBytesReceived = 0; + m_timeOutCounter = 0; + + break; + + case RECEIVING: + + break; + + default: + break; + } + + emit stateChanged(new_state); +} + +//--------------------------------------------------------------------------------------------- +void TcpServer::on_server__newConnection() +{ + if(m_socket) + delete m_socket; + + m_socket = m_server->nextPendingConnection(); + LogHandler::getInstance()->reportInfo( tr("TcpServer: %1 is connecting...").arg( m_socket->peerAddress().toString() ) ); + setState(CONNECTING); + + QObject::connect( m_socket, SIGNAL( readyRead() ), + this, SLOT( readMessage() ) ); + + QObject::connect( m_socket, SIGNAL( disconnected() ), + this, SLOT( on_socketDisconnected() ) ); +} + +//--------------------------------------------------------------------------------------------- +void TcpServer::on_socketDisconnected() +{ + if(m_currentState == RECEIVING) + { + LogHandler::getInstance()->reportInfo( tr("TcpServer: Connection closed. Transfer aborted.") ); + abort(); + } +} + +//--------------------------------------------------------------------------------------------- +void TcpServer::updateTcpServerProgress() +{ + m_bytesReceived += (int)m_socket->bytesAvailable(); + m_fileData.clear(); + m_fileData.resize(PAYLOADSIZE); + m_fileData = m_socket->readAll(); + + m_file->write(m_fileData); + + if(m_bytesReceived == m_fileSize) + { + setState(FINISHED); + m_socket->close(); + m_file->flush(); + m_file->close(); + delete m_file; + m_file = 0; + + LogHandler::getInstance()->reportInfo( tr("TcpServer: File transfer complete") ); + stop(); + } +} + +//--------------------------------------------------------------------------------------------- +void TcpServer::readMessage() +{ + QDataStream in(m_socket); + in.setVersion(QDataStream::Qt_4_0); + + if(m_blockSize == 0) + { + if( m_socket->bytesAvailable() < (int)sizeof(quint16) ) + return; + + in >> m_blockSize; + } + + if(m_socket->bytesAvailable() < m_blockSize) + return; + + if(m_currentState == CONNECTING) + { + setState(NEGOTIATING); + + quint8 messageType; + QString filename; + QString filesizeString; + + in >> messageType; + + switch(messageType) + { + case 'I': //File info + { + in >> filename >> m_fileSize; + + if(m_fileSize < 1024) + filesizeString = tr("%1 Byte").arg(m_fileSize); + else if(m_fileSize < 1048576) + filesizeString = tr("%1 KB").arg(static_cast(m_fileSize) / 1024, 0, 'f', 2); + else if(m_fileSize < 1073741824) + filesizeString = tr("%1 MB").arg(static_cast(m_fileSize) / 1048576, 0, 'f', 2); + else + filesizeString = tr("%1 GB").arg(static_cast(m_fileSize) / 1073741824, 0, 'f', 2); + + LogHandler::getInstance()->reportInfo( tr("TcpServer: Received file information:") ); + LogHandler::getInstance()->reportInfo( tr(" '%1', size: %2").arg(filename).arg(filesizeString) ); + +// m_saveFilename = QFileDialog::getSaveFileName(parent_, "Save file as...", +// last_dir_.append(filename), ""); + m_file = new QFile(m_saveFilename); + + if( !m_file->open(QIODevice::WriteOnly) ) + { + LogHandler::getInstance()->reportError( tr("Error writing to file. Transfert aborted.") ); + setState(INACTIVE); + } + + sendAcceptMessage(); + + m_fileData.resize(PAYLOADSIZE); + QObject::connect( m_socket, SIGNAL( readyRead() ),this, SLOT( updateTcpServerProgress() ) ); + + m_timeOutCounter = 0; + m_connectionTimer->start(1000); + setState(RECEIVING); + + break; + } + + default: + + LogHandler::getInstance()->reportError( tr("Received unknown message type: %1").arg(messageType) ); + break; + } + } +} + +//--------------------------------------------------------------------------------------------- +void TcpServer::sendAcceptMessage() +{ + QByteArray block; + QDataStream out(&block, QIODevice::WriteOnly); + + out.setVersion(QDataStream::Qt_4_0); + out << (quint16)0; + out << (quint8)'A'; + out.device()->seek(0); + out << (quint16)( block.size() - sizeof(quint16) ); + + m_socket->write(block); + LogHandler::getInstance()->reportInfo( tr("TcpServer: Accept message sent") ); +} + +//--------------------------------------------------------------------------------------------- +void TcpServer::setTimeOut(quint16 time_out) +{ + m_timeOut = time_out; +} + +//--------------------------------------------------------------------------------------------- +void TcpServer::setReverseConnection(bool reverse_connection) +{ + m_reverseConnection = reverse_connection; +} + +//--------------------------------------------------------------------------------------------- +void TcpServer::on_socketConnected() +{ + LogHandler::getInstance()->reportInfo( tr("TcpServer: Reverse connection to %1 established").arg( m_socket->peerAddress().toString() ) ); + setState(CONNECTING); +} + +//--------------------------------------------------------------------------------------------- +bool TcpServer::getReverseConnection() +{ + return m_reverseConnection; +} diff -Nru syncwall-1.6.0/src/TcpServer.h syncwall-1.7.4/src/TcpServer.h --- syncwall-1.6.0/src/TcpServer.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/TcpServer.h 2013-02-20 08:45:24.000000000 +0000 @@ -0,0 +1,98 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2012 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *******************************************************************************/ + +#ifndef _TCPSERVER_H_ +#define _TCPSERVER_H_ + +#include +#include +#include + +class TcpServer : public QObject +{ + Q_OBJECT + +public: + + enum States + { + INACTIVE = 0, + LISTENING, + CONNECTING, + NEGOTIATING, + RECEIVING, + FINISHED + }; + + TcpServer(QObject * parent = 0); + virtual ~TcpServer(); + + static QString getStateAsString(quint8 state); + bool start(quint16 port); + void stop(); + void abort(); + QString errorString() const; + void setTimeOut(quint16 time_out); + QString getLastDir() const; + void setLastDir(const QString &last_dir); + void setReverseConnection(bool reverseConnection); + bool getReverseConnection(); + +signals: + + void stateChanged(quint8 new_state); + +private slots: + + void updateTcpServerProgress(); + void on_server__newConnection(); + void readMessage(); + void on_socketDisconnected(); + void timeout(); + void on_socketConnected(); + +private: + + void sendAcceptMessage(); + void setState(quint8 new_state); + + QTcpServer *m_server; + QTcpSocket *m_socket; + quint8 m_currentState; + quint16 m_blockSize; + quint16 m_port; + quint32 m_fileSize; + quint32 m_bytesReceived; + bool m_reverseConnection; + + //timeout variables------- + quint32 m_tempBytesReceived; + quint16 m_timeOut; + quint16 m_timeOutCounter; + QTimer *m_connectionTimer; + + //------------------------ + + QString m_saveFilename; + QFile *m_file; + QByteArray m_fileData; +}; + +#endif // _TCPSERVER_H_ diff -Nru syncwall-1.6.0/src/ThreadPool.cpp syncwall-1.7.4/src/ThreadPool.cpp --- syncwall-1.6.0/src/ThreadPool.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/ThreadPool.cpp 2013-05-05 23:37:30.000000000 +0000 @@ -0,0 +1,84 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#include "ThreadPool.h" + +bool ThreadPool::instanceFlag = false; +ThreadPool* ThreadPool::single = NULL; + +ThreadPool* ThreadPool::getInstance() +{ + if(!instanceFlag) + { + single = new ThreadPool(); + instanceFlag = true; + return single; + } + else + { + return single; + } +} + +ThreadPool::ThreadPool() +{ +// create the treads + for (int i = 0; i < QThread::idealThreadCount(); i++) + { + m_threadPool << new QThread; + + m_threadPool.at(i)->start(); + } +} + +void ThreadPool::stop() +{ + // stop each running thread properly + foreach(QThread * th, m_threadPool) + { + if ( th->isRunning() ) + { + th->quit(); + th->wait(1000); + } + } + + foreach(QThread * th, m_reservedThreadPool) + { + if ( th->isRunning() ) + { + th->quit(); + th->wait(1000); + } + } +} + +QThread *ThreadPool::getThread() +{ + return m_threadPool[qrand() % m_threadPool.size()]; +} + +QThread *ThreadPool::getReservedThread() +{ + QThread *th = new QThread(); + m_reservedThreadPool << th; + th->start(); + return th; +} diff -Nru syncwall-1.6.0/src/ThreadPool.h syncwall-1.7.4/src/ThreadPool.h --- syncwall-1.6.0/src/ThreadPool.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/ThreadPool.h 2013-05-05 23:37:32.000000000 +0000 @@ -0,0 +1,65 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#ifndef _THREADPOOL_H_ +#define _THREADPOOL_H_ + +// this class provide a way to get access to the thread pool + +#include +#include +#include +#include + +class ThreadPool : public QObject +{ + Q_OBJECT + +private: + + static bool instanceFlag; + static ThreadPool *single; + + QList m_threadPool; + QList m_reservedThreadPool; + + QMutex m_lock; + + ThreadPool(); //private constructor + +public: + + static ThreadPool* getInstance(); + ~ThreadPool() + { + instanceFlag = false; + } + + void stop(); + + QThread *getThread(); + QThread *getReservedThread(); + +public slots: + +signals: +}; + +#endif // _THREADPOOL_H_ diff -Nru syncwall-1.6.0/src/TreeImagesView.cpp syncwall-1.7.4/src/TreeImagesView.cpp --- syncwall-1.6.0/src/TreeImagesView.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/TreeImagesView.cpp 2013-05-05 23:37:30.000000000 +0000 @@ -0,0 +1,61 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#include "TreeImagesView.h" + +#include +#include +#include +#include + +TreeImagesView::TreeImagesView( QWidget *parent ) + : QTreeView( parent ) +{ +} + +void TreeImagesView::paintEvent( QPaintEvent *event ) +{ + if( model() && model()->rowCount() > 0 ) + { + QTreeView::paintEvent( event ); + return; + } + + QPainter painter( viewport() ); + + QPalette palette; + + QPen pen( palette.color( QPalette::Highlight ) ); + + QFont font = painter.font(); + font.setBold( true ); + font.setPointSize( font.pointSize() + 10 ); + + const QString text = tr( "Add some images to begin" ); + + const QFontMetrics fm( font ); + if( fm.width( text ) > viewport()->rect().width() ) + return; + + painter.setPen( pen ); + painter.setFont( font ); + + painter.drawText( rect(), Qt::AlignCenter, text ); +} diff -Nru syncwall-1.6.0/src/TreeImagesView.h syncwall-1.7.4/src/TreeImagesView.h --- syncwall-1.6.0/src/TreeImagesView.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/TreeImagesView.h 2013-05-05 23:37:32.000000000 +0000 @@ -0,0 +1,40 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#ifndef _TREEIMAGEVIEW_H_ +#define _TREEIMAGEVIEW_H_ + +#include + +class TreeImagesView : + public QTreeView +{ + Q_OBJECT + +public: + + TreeImagesView( QWidget *parent = 0 ); + +protected: + + void paintEvent( QPaintEvent *event ); +}; + +#endif // _TREEIMAGEVIEW_H_ diff -Nru syncwall-1.6.0/src/WallpaperProvider.cpp syncwall-1.7.4/src/WallpaperProvider.cpp --- syncwall-1.6.0/src/WallpaperProvider.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/WallpaperProvider.cpp 2013-05-05 23:37:30.000000000 +0000 @@ -0,0 +1,141 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#include +#include "WallpaperProvider.h" + +#include "LogHandler.h" +#include "MiscFunctions.h" + +WallpaperProvider::WallpaperProvider(const QString &dir, int mode, QObject *parent) + : QObject(parent), + m_mode(mode) +{ + m_inputList << dir; + refreshWallpaperList(); +} + +WallpaperProvider::WallpaperProvider(const QStringList &files, int mode, QObject *parent) + : QObject(parent), + m_mode(mode), + m_inputList(files) +{ + refreshWallpaperList(); +} + +WallpaperProvider::~WallpaperProvider() +{ +} + +void WallpaperProvider::refreshWallpaperList() +{ + foreach (const QString &input, m_inputList) + { + if (m_mode == MODE_DIRECTORY) // scan directory + { + foreach (const QString &dir, m_inputList) + { + QStringList files = scanDirectory(dir); + m_listWallpaper << files; + } + } + else + { + if ( QFileInfo(input).isDir() ) // replace the input dir by all the included files + { + QStringList files = scanDirectory(input); + m_listWallpaper << files; + m_inputList << files; // add the files to the input list + m_inputList.removeOne(input); // delete the input directory + } + else + { + if ( QFileInfo(input).isReadable() ) + m_listWallpaper << input; + } + } + } + + m_inputList.removeDuplicates(); + m_listWallpaper.removeDuplicates (); +} + +QStringList WallpaperProvider::scanDirectory(const QString &val) +{ + QDir dir(val); + QStringList files; + + if ( !dir.exists() ) + { + LogHandler::getInstance()->reportError( tr( "Cannot find the directory %1",val.toStdString().c_str() ) ); + return files; + } + + QStringList formats = MiscFunctions::getAvailablesImageFormats().split(" "); + +// QStringList ext; +// ext << "*.png" << "*.jpg" << "*.bmp" << "*.gif" ; + QFileInfoList list = dir.entryInfoList(formats); + + foreach (const QFileInfo &info, list) + { + files << info.absoluteFilePath(); + } + return files; +} + +bool WallpaperProvider::addInputs(const QStringList &inputs) +{ + bool ok = true; + foreach (const QString input, inputs) + ok &= addInput(input); + return ok; +} + +bool WallpaperProvider::addInput(const QString &input) +{ + if (m_inputList.indexOf(input) != -1) + return false; + + if ( !QFileInfo(input).isReadable() ) + return false; + + if (m_mode == MODE_DIRECTORY) + { + scanDirectory(input); + } + else + { + m_listWallpaper << input; + } + + return true; +} + +bool WallpaperProvider::deleteInput(const QString &input) +{ + m_inputList.removeAll(input); + if ( m_listWallpaper.removeAll(input) ) + { + return true; + } + + return false; +} diff -Nru syncwall-1.6.0/src/WallpaperProvider.h syncwall-1.7.4/src/WallpaperProvider.h --- syncwall-1.6.0/src/WallpaperProvider.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/WallpaperProvider.h 2013-05-05 23:37:32.000000000 +0000 @@ -0,0 +1,63 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#ifndef _WALLPAPERPROVIDER_H_ +#define _WALLPAPERPROVIDER_H_ + +#include +#include + +class WallpaperProvider : + public QObject +{ + Q_OBJECT + +public: + + enum + { + MODE_DIRECTORY = 0, + MODE_FILELIST + }; + + WallpaperProvider(const QString &, int mode = MODE_DIRECTORY, QObject *parent = NULL); + WallpaperProvider(const QStringList &, int mode = MODE_FILELIST, QObject *parent = NULL); + virtual ~WallpaperProvider(); + + bool addInput(const QString &); + bool addInputs(const QStringList &); + bool deleteInput(const QString &); + const QStringList & getInputList() const {return m_inputList; } + const QStringList & getWallpaperList() const {return m_listWallpaper; } + void refreshWallpaperList(); + int getMode() const {return m_mode; } + +signals: + +private: + + QStringList scanDirectory(const QString &val); + + QStringList m_listWallpaper; + int m_mode; + QStringList m_inputList; +}; + +#endif // _WALLPAPERPROVIDER_H_ diff -Nru syncwall-1.6.0/src/lfiles.txt syncwall-1.7.4/src/lfiles.txt --- syncwall-1.6.0/src/lfiles.txt 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/lfiles.txt 2013-03-21 04:49:18.000000000 +0000 @@ -0,0 +1,68 @@ +AppSettings.cpp +BackgroundItem.cpp +BackgroundPainter.cpp +BackgroundPainterConfigWidget.cpp +DatabaseManager.cpp +DesktopScene.cpp +DesktopView.cpp +IconViewDelegate.cpp +ImageInfos.cpp +ImageView.cpp +ImageViewer.cpp +InfosUpdater.cpp +ListImagesModel.cpp +LogHandler.cpp +main.cpp +MiscFunctions.cpp +NetworkManager.cpp +NetworkManagerConfigWidget.cpp +Scheduler.cpp +SchedulerConfigWidget.cpp +ScreenItem.cpp +SingleApplication.cpp +SplashScreen.cpp +StarDelegate.cpp +StarEditor.cpp +StarRating.cpp +SyncWall.cpp +SystemIntegration.cpp +SystemIntegrationConfigWidget.cpp +TcpClient.cpp +TcpServer.cpp +ThreadPool.cpp +TreeImagesView.cpp +WallpaperProvider.cpp +AppSettings.h +BackgroundItem.h +BackgroundPainter.h +BackgroundPainterConfigWidget.h +DatabaseManager.h +DesktopScene.h +DesktopView.h +IconViewDelegate.h +ImageInfos.h +ImageView.h +ImageViewer.h +IMessageHandler.h +InfosUpdater.h +ListImagesModel.h +LogHandler.h +MiscFunctions.h +NetworkManager.h +NetworkManagerConfigWidget.h +Scheduler.h +SchedulerConfigWidget.h +ScreenItem.h +SingleApplication.h +SplashScreen.h +StarDelegate.h +StarEditor.h +StarRating.h +SyncWall.h +SystemIntegration.h +SystemIntegrationConfigWidget.h +TcpClient.h +TcpServer.h +ThreadPool.h +TreeImagesView.h +WallpaperProvider.h diff -Nru syncwall-1.6.0/src/main.cpp syncwall-1.7.4/src/main.cpp --- syncwall-1.6.0/src/main.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/src/main.cpp 2013-05-05 23:37:30.000000000 +0000 @@ -0,0 +1,174 @@ + +/****************************************************************************** + SyncWall: Wallpaper manager + Copyright(C) 2011-2013 xbee@xbee.net + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *******************************************************************************/ + +#include +#include +#include +#include + +#include "SyncWall.h" +#include "SingleApplication.h" +#include "AppSettings.h" +#include "MiscFunctions.h" +#include "SplashScreen.h" + +#ifdef Q_OS_WIN +#include // for Sleep +#endif + +#ifdef Q_OS_UNIX +#include +#endif + +// extract from QTest ... +void qSleep(int ms) +{ +#ifdef Q_OS_WIN + Sleep( uint(ms) ); +#else + struct timespec ts = { + ms / 1000, (ms % 1000) * 1000 * 1000 + }; + nanosleep(&ts, NULL); +#endif +} + +void usage() +{ + QTextStream out(stdout); + out << endl; + out << QObject::tr("Wallpaper manager.") << endl; + out << QObject::tr("Usage: ") << QCoreApplication::arguments().at(0) << " " << QObject::tr("[options]") << endl; + out << endl; + out << QObject::tr("Following options are known:") << endl; + out << QObject::tr(" --help : displays this help.") << endl; + out << QObject::tr(" --reset-config : clear the saved preference parameters.") << endl; + out << QObject::tr(" --no-singleinstance : enable the use of multiple instance of program (not recommended).") << endl; + out << endl; +} + +int main(int argc, char *argv[]) +{ + Q_INIT_RESOURCE(syncwall); + + qSleep(1000); // waiting sometimes for restart case ... + + SingleApplication app(argc, argv, PACKAGE_NAME); + + // update some application infos (use by some platform for temp storage, ...) + MiscFunctions::updateApplicationIdentity(); + + // add possible image plugin path + app.addLibraryPath( QApplication::applicationDirPath() + "./plugins"); + + // set default language for application (computed or saved) + MiscFunctions::setDefaultLanguage(); + + // modifying base look + QApplication::setStyle(new QPlastiqueStyle); + + // check for special argument + bool forceResetConfig = false; + bool ignoreSingleInstance = false; + QStringList args = QApplication::arguments(); + for ( int i = 1; i < args.count(); ++i ) + { + const QString arg = args.at(i); + + if ( arg == "--reset-config" ) + { + forceResetConfig = true; + } + else if ( arg == "--no-singleinstance" ) + { + ignoreSingleInstance = true; + } + else if (arg == "--help") + { + usage(); + return 0; + } + } + + // check for multiple instance of program + if (app.isRunning() && !ignoreSingleInstance) + { + app.sendMessage( QObject::tr("message from other instance.") ); + QMessageBox::critical( 0,PACKAGE_NAME,QObject::tr("%1 is already running !!").arg(PACKAGE_NAME) ); + return 0; + } + + AppSettings settings; + + // in order to display splashscreen on the same screen than application ... + settings.beginGroup("MainWindow"); + int screenNumber = settings.value("screenNumber",0).toInt(); + settings.endGroup(); + + settings.beginGroup("Application"); + + // reset the saved configuration if needed + bool resetConfig = settings.value("resetConfig",false).toBool(); + if (resetConfig || forceResetConfig) + { + settings.clear(); + settings.sync(); + } + + bool splashscreenAtStartup = settings.value("splashscreenAtStartup",true).toBool(); + bool splashscreenTransparentBackground = settings.value("splashscreenTransparentBackground",true).toBool(); + bool startInTray = settings.value("startInTray",false).toBool(); + settings.endGroup(); + + // splash screen + SplashScreen sScreen(QPixmap(":/syncwall/splashscreen.png"), 3000, screenNumber,splashscreenTransparentBackground); + if (splashscreenAtStartup) + sScreen.show(); + + // check if small screen => reduce default font size + if ( MiscFunctions::hasSmallUI() ) + { + QFont font = QApplication::font(); + font.setPointSize(font.pointSize() - 1); + QApplication::setFont(font); + } + + SyncWall w; + QObject::connect( &app, SIGNAL( messageAvailable(const QString &) ), &w, SLOT( wakeUp(const QString &) ) ); + QObject::connect( &app, SIGNAL( lastWindowClosed() ), &app, SLOT( quit() ) ); + + // splash screen + if (splashscreenAtStartup) + { + if (!startInTray) + sScreen.delayedFinish(&w); + } + + { +#ifdef _DEBUG // ugly hack for debugging + if (startInTray) + w.show(); +#endif + if (!startInTray) + w.show(); + } + + return app.exec(); +} diff -Nru syncwall-1.6.0/tcpclient.cpp syncwall-1.7.4/tcpclient.cpp --- syncwall-1.6.0/tcpclient.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/tcpclient.cpp 2012-10-31 08:46:58.000000000 +0000 @@ -0,0 +1,252 @@ +#include +#include + +#include "tcpclient.h" +#include "core/log/loghandler.h" + +using namespace Spy; + + +const int connectionTimeOut = 10000; + +#define MSG_SIZE_ALIGN(size) (((size) + 1023) & ~1023) + + +static bool check_header(int at, int c) +{ + static const char prefix[] = "DATA"; + if (at < MSG_LEN_OFFSET) + return (c == prefix[at]); + return isdigit(c); +} + +static bool check_header2(int at1, int at2) +{ + static const char prefix[] = "DATA"; + if ((at1 < MSG_LEN_OFFSET) && (at2 < MSG_LEN_OFFSET)) + return (prefix[at1] == prefix[at2]); + if ((at1 < MSG_LEN_OFFSET) && (at2 >= MSG_LEN_OFFSET)) + return isdigit(prefix[at1]); + if ((at1 >= MSG_LEN_OFFSET) && (at2 < MSG_LEN_OFFSET)) + return isdigit(prefix[at2]); + return true; +} + +TcpClient::TcpClient(QObject *parent) : + QObject(parent), + m_host("localhost"), + m_port(45454) +{ + m_socket = new QTcpSocket(this); + m_buffer.capacity = MSG_SIZE_ALIGN(MSG_HEADER_SIZE); + m_buffer.base = new char[m_buffer.capacity]; + memset(m_buffer.base,0,m_buffer.capacity); + m_buffer.start = m_buffer.base; + m_buffer.state = READ_HEADER; + m_buffer.accept = 0; + m_buffer.payload = 0; + + initMessageHeader(); + + m_connectionTimer = new QTimer(this); + m_connectionTimer->setInterval(connectionTimeOut); + m_connectionTimer->setSingleShot(true); + + QObject::connect( m_socket, SIGNAL( connected() ), + this, SLOT( on_socketConnected() ) ); + + QObject::connect( m_socket, SIGNAL( disconnected() ), + this, SLOT( on_socketDisconnected() ) ); + + QObject::connect( m_connectionTimer, SIGNAL( timeout() ), + this, SLOT( timeout() ) ); +} + +TcpClient::~TcpClient() +{ + if (m_socket != NULL) + delete m_socket; + delete[] m_buffer.base; +} + +void TcpClient::start(const QString &host, int port) +{ + qDebug() << "TcpClient::start " << host << " " << port; + m_host = host; + m_port = port; + restart(); +} + +void TcpClient::restart() +{ + qDebug() << "TcpClient::restart"; + stop(); + m_connectionTimer->start(); + m_socket->connectToHost(m_host, m_port); +} + +void TcpClient::stop() +{ + m_connectionTimer->stop(); + m_socket->abort(); +} + + +void TcpClient::timeout() +{ + LogHandler::getInstance()->reportInfo( tr("Client: Connection to server timed out => restarting") ); + restart(); +} + +void TcpClient::on_socketConnected() +{ + qDebug() << "####client connected"; + LogHandler::getInstance()->reportInfo( tr("Client: Connection to server established") ); + emit stateChanged(true); //--CB + //setState(NEGOTIATING); + + QObject::connect( m_socket, SIGNAL( readyRead() ), + this, SLOT( readMessage() ) ); + m_connectionTimer->stop(); + //sendAcceptMessage(); +} + +void TcpClient::readMessage() +{ + bool match; + int bytes = 0; + while (m_socket->bytesAvailable() > 0) + { + if (m_buffer.state == READ_HEADER) + { + if (m_buffer.accept < MSG_HEADER_SIZE) + { + if ((bytes = m_socket->read(m_buffer.start,MSG_HEADER_SIZE)) < 0) + break; + while ((bytes > 0) && m_buffer.accept < MSG_HEADER_SIZE) + { + if ((match = check_header(m_buffer.accept,*m_buffer.start))) + m_header.val[m_buffer.accept] = *m_buffer.start; + while (!match && (m_buffer.accept >= 0)) + { + m_buffer.accept = m_header.kmp[m_buffer.accept]; + match = check_header(m_buffer.accept,*m_buffer.start); + } + m_buffer.accept++; + m_buffer.start++; + bytes--; + } + } + if (m_buffer.accept == MSG_HEADER_SIZE) + { + m_buffer.payload = QString::fromUtf8(m_header.val+MSG_LEN_OFFSET,MSG_HEADER_SIZE-MSG_LEN_OFFSET).toInt(); + if (m_buffer.capacity < m_buffer.payload) + { + char* old = m_buffer.base; + m_buffer.capacity = MSG_SIZE_ALIGN(m_buffer.payload); + m_buffer.base = new char[m_buffer.capacity]; + memcpy(m_buffer.base,old,m_buffer.start-old); + delete[] old; + } + if (m_buffer.payload > 0) + m_buffer.state = READ_PAYLOAD; + if (bytes > 0) + memmove(m_buffer.base,m_buffer.start,bytes); + m_buffer.start = m_buffer.base + bytes; + m_buffer.accept = qMin(m_buffer.payload,bytes); + } + } + if (m_buffer.state == READ_PAYLOAD) + { + if (m_buffer.accept < m_buffer.payload) + { + int remaining = m_buffer.payload - m_buffer.accept; + if ((bytes = m_socket->read(m_buffer.start,remaining)) < 0) + break; + m_buffer.start += bytes; + m_buffer.accept += bytes; + } + if (m_buffer.accept == m_buffer.payload) + { + QString message = QString::fromUtf8(m_buffer.base,m_buffer.payload); + //qDebug() << "#######message:" << message; + emit messageReceived(message); + m_buffer.state = READ_HEADER; + int bytes = m_buffer.start - (m_buffer.base + m_buffer.payload); + if (bytes > 0) + memmove(m_buffer.base,m_buffer.start,bytes); + m_buffer.start = m_buffer.base + bytes; + m_buffer.accept = 0; + } + } + } +} + +void TcpClient::sendRawMessage(const RawMessage &mess) +{ + QByteArray block; + QDataStream out(&block, QIODevice::WriteOnly); + + //out.setVersion(QDataStream::Qt_4_0); + out << mess; + + m_socket->write(block); + m_socket->flush(); + + //qDebug() << "Client send " << block.size(); + qint64 offset = out.device()->pos(); // current offset in s + //qDebug() << "Client datastream offset " << offset; + + emit messageEmitted(mess.data); +} + +void TcpClient::send(const Message& message) +{ + try + { + RawMessage raw_msg; + raw_msg.data = message.toXml(); + sendRawMessage(raw_msg); + } + catch (const ErrorType& err) + { + Spy::LogHandler::getInstance()->reportError(QString("!!! Error found on <%1> : %2").arg(err.logged.origin).arg(err.logged.message)); + } +} + +void TcpClient::on_socketError(int ) +{ + LogHandler::getInstance()->reportError( tr("Unable to connect: %1.").arg( m_socket->errorString() ) ); + emit stateChanged(false); //--CB + //setState(INACTIVE); +} + +void TcpClient::on_socketDisconnected() +{ + LogHandler::getInstance()->reportError( tr("Client: Connection closed")); + emit stateChanged(false); //--CB + /* + if( (m_currentState == NEGOTIATING ) ) + { + LogHandler::getInstance()->reportError( tr("Client: Connection closed. Transfer aborted.") ); + } + setState(INACTIVE); + */ +} + +void TcpClient::initMessageHeader() +{ + int check = -1; + m_header.kmp[0] = -1; + for (int iter=0; iter < MSG_HEADER_SIZE-1; iter++) + { + while (check >=0 && !check_header2(iter,check)) + check = m_header.kmp[check]; + check++; + if (check_header2(iter+1,check)) + m_header.kmp[iter+1] = m_header.kmp[check]; + else + m_header.kmp[iter+1] = check; + } + memset(m_header.val,0,sizeof(m_header.val)); +} \ No newline at end of file diff -Nru syncwall-1.6.0/tcpclient.h syncwall-1.7.4/tcpclient.h --- syncwall-1.6.0/tcpclient.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/tcpclient.h 2012-10-31 08:46:58.000000000 +0000 @@ -0,0 +1,68 @@ +#ifndef _TCPCLIENT_H_ +#define _TCPCLIENT_H_ + +#include +#include "msgdefinition.h" + +class QTcpSocket; +class QTimer; + + +#define MSG_HEADER_SIZE 8 +#define MSG_LEN_OFFSET 4 + +class TcpClient : public QObject +{ + Q_OBJECT + +public: + TcpClient(QObject *parent = 0); + + virtual ~TcpClient(); + + void start(const QString &host, int port); + void restart(); + void stop(); + void sendRawMessage(const RawMessage &mess); + void send(const Message& message); //--CB + +signals: + void stateChanged(bool); + void messageReceived(const QString&); + void messageEmitted(const QString &); + +private slots: + void timeout(); + void readMessage(); + void on_socketConnected(); + void on_socketError(int socket_error); + void on_socketDisconnected(); + +private: + void initMessageHeader(); + + QTcpSocket* m_socket; + + struct + { + char val[MSG_HEADER_SIZE+1]; + int kmp[MSG_HEADER_SIZE]; + } m_header; + + enum {READ_HEADER, READ_PAYLOAD}; + struct + { + char* base; + char* start; + int capacity; + int accept; + int payload; + int state; + } m_buffer; + + QTimer* m_connectionTimer; + QString m_host; + int m_port; +}; + +#endif // _TCPCLIENT_H_ diff -Nru syncwall-1.6.0/tcpserver.cpp syncwall-1.7.4/tcpserver.cpp --- syncwall-1.6.0/tcpserver.cpp 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/tcpserver.cpp 2012-10-22 06:44:16.000000000 +0000 @@ -0,0 +1,304 @@ + +#include "tcpserver.h" +#include "core/log/loghandler.h" + +#include +#include + +using namespace Spy; + +//status strings +static const QString INACTIVE_STRING = "inactive"; +static const QString LISTENING_STRING = "listening"; +static const QString CONNECTING_STRING = "connecting"; +static const QString NEGOTIATING_STRING = "negotiating"; +static const QString CONNECTED_STRING = "connected"; +static const QString FINISHED_STRING = "finished"; +static const QString UNKNOWN_STRING = "unknown"; + +const int scheduleTime = 50; + +//--------------------------------------------------------------------------------------------- +TcpServer::TcpServer(QObject *parent) + : QObject(parent) +{ + m_server = new QTcpServer(parent); + m_connectionTimer = new QTimer(this); + m_scheduler = new QTimer(this); + m_scheduler->setInterval(scheduleTime); + connect(m_scheduler,SIGNAL(timeout()), this, SLOT(sendScheduledMessage())); + m_socket = 0; + m_port = 0; + m_timeOutCounter = 0; + m_timeOut = 10; + + memset(m_buffer,0,10000); + + QObject::connect( m_server, SIGNAL( newConnection() ), + this, SLOT( serverNewConnection() ) ); + + QObject::connect( m_connectionTimer, SIGNAL( timeout() ), + this, SLOT( timeout() ) ); + + m_currentState = 0; +} + +//--------------------------------------------------------------------------------------------- +TcpServer::~TcpServer() +{ + if(m_server) + delete m_server; +} + +//--------------------------------------------------------------------------------------------- +QString TcpServer::getStateAsString(quint8 state) +{ + QString state_string = ""; + + switch(state) + { + case INACTIVE: + state_string = INACTIVE_STRING; + break; + + case CONNECTED: + state_string = CONNECTED_STRING; + break; + + default: + state_string = UNKNOWN_STRING; + } + + return state_string; +} + +//--------------------------------------------------------------------------------------------- +bool TcpServer::start(quint16 port) +{ + m_port = port; + + while( !m_server->isListening() && !m_server->listen(QHostAddress::Any, m_port) ) + { + LogHandler::getInstance()->reportInfo( tr("TcpServer: Unable to start the server: %1").arg( m_server->errorString() ) ); + return false; + } + + LogHandler::getInstance()->reportInfo( tr("TcpServer: Starting server...") ); + + m_bytesReceived = 0; + m_tempBytesReceived = 0; + + setState(LISTENING); + return true; +} + +//--------------------------------------------------------------------------------------------- +void TcpServer::stop() +{ + if( m_server->isListening() ) + m_server->close(); + + setState(INACTIVE); + LogHandler::getInstance()->reportInfo( tr("TcpServer: TcpServer stopped") ); +} + +//--------------------------------------------------------------------------------------------- +void TcpServer::timeout() +{ + quint32 speed = (m_bytesReceived - m_tempBytesReceived) >> 10; + m_tempBytesReceived = m_bytesReceived; + + if(speed > 0) + { + m_timeOutCounter = 0; + } + else + { + if(++m_timeOutCounter == m_timeOut) + { + LogHandler::getInstance()->reportInfo( tr("TcpServer: Connection timed out") ); + abort(); + } + } +} + +//--------------------------------------------------------------------------------------------- +void TcpServer::abort() +{ + stop(); +} + +//--------------------------------------------------------------------------------------------- +QString TcpServer::errorString() const +{ + return m_server->errorString(); +} + +//--------------------------------------------------------------------------------------------- +void TcpServer::setState(quint8 new_state) +{ + if (m_currentState == new_state) + return; + m_currentState = new_state; + LogHandler::getInstance()->reportInfo( tr("TcpServer: State changed to '%1'").arg( getStateAsString(new_state) ) ); + + switch(m_currentState) + { + case INACTIVE: + if(m_socket) + m_socket->abort(); + + m_blockSize = 0; + + m_connectionTimer->stop(); + m_tempBytesReceived = 0; + m_timeOutCounter = 0; + + break; + + case LISTENING: + break; + + case CONNECTED: + break; + } + + emit stateChanged(new_state); +} + +//--------------------------------------------------------------------------------------------- +void TcpServer::serverNewConnection() +{ + if(m_socket) + delete m_socket; + + m_socket = m_server->nextPendingConnection(); + LogHandler::getInstance()->reportInfo( tr("TcpServer: %1 is connecting...").arg( m_socket->peerAddress().toString() ) ); + //--CBsetState(CONNECTING); + setState(CONNECTED); + + QObject::connect( m_socket, SIGNAL( readyRead() ), this, SLOT( onReceipt() ) ); + QObject::connect( m_socket, SIGNAL( disconnected() ), this, SLOT( on_socketDisconnected() ) ); +} + +//--------------------------------------------------------------------------------------------- +void TcpServer::on_socketDisconnected() +{ + if(m_currentState == CONNECTED) + { + LogHandler::getInstance()->reportInfo( tr("TcpServer: Disconnection Client side. Transfer aborted.") ); + + // we consider there will be only one client for the moment + // when this one disconnect, the server must listen any possible client reconnection + setState(LISTENING); + } +} + +//--------------------------------------------------------------------------------------------- + +void TcpServer::onReceipt() +{ + if (m_receivedStarted == false) + { + /* There it's a new message we are receiving. + To start receiving it we must know its length, i.e. the 2 first bytes */ + if (m_socket->bytesAvailable() < 8) // DATA id + lenght + return; + + /* Ok now we can start */ + m_receivedStarted = true; + + /* getting the length of the message */ + char data[5]; + memset(data,0,5); + m_socket->read(data,4); + m_socket->read(data,4); + QString sizeStr(data); + m_remainingLength = sizeStr.toInt(); + /* Recursive call to write less code =) */ + onReceipt(); + } + else + { + /* Checking if the command is complete! */ + if (m_socket->bytesAvailable() >= m_remainingLength) + { + m_connectionTimer->stop(); + + m_socket->read(m_buffer,m_remainingLength); + RawMessage mess; + mess.size = m_remainingLength; + mess.data = m_buffer; + + emit messageReceived(mess.data); + + m_receivedStarted = false; + + /* Recursive call to spare code =), there may be still data pending */ + onReceipt(); + } + } +} + +//--------------------------------------------------------------------------------------------- + +void TcpServer::readMessage() +{ + //setState(CONNECTED); + + //qDebug() << "server receive " << m_socket->bytesAvailable (); + + QDataStream in(m_socket); + + //in.setVersion(QDataStream::Qt_4_0); + + RawMessage mess; + in >> mess; + emit messageReceived(mess.data); +} + +void TcpServer::sendRawMessage(const RawMessage &mess) +{ + if (!m_socket) + return; + + + if (!m_scheduler->isActive()) + m_scheduler->start(); + + m_messagesToSend << mess; +} + +void TcpServer::sendScheduledMessage() +{ + if (m_messagesToSend.isEmpty()) + { + m_scheduler->stop(); + return; + } + + if (!m_socket) + return; + + + RawMessage mess = m_messagesToSend.takeFirst(); + + QByteArray block; + QDataStream out(&block, QIODevice::WriteOnly); + + out.setVersion(QDataStream::Qt_4_0); + out << mess; + + m_socket->write(block); + m_socket->flush(); + + //qint64 offset = out.device()->pos(); // current offset in s + + emit messageEmitted(mess.data); +} + +//--------------------------------------------------------------------------------------------- +void TcpServer::setTimeOut(quint16 time_out) +{ + m_timeOut = time_out; +} diff -Nru syncwall-1.6.0/tcpserver.h syncwall-1.7.4/tcpserver.h --- syncwall-1.6.0/tcpserver.h 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/tcpserver.h 2012-10-22 04:28:06.000000000 +0000 @@ -0,0 +1,81 @@ + +#ifndef _TCPSERVER_H_ +#define _TCPSERVER_H_ + +#include +#include +#include + +#include "msgdefinition.h" + +class TcpServer : + public QObject +{ + Q_OBJECT + +public: + + enum States + { + INACTIVE = 0, + LISTENING, + CONNECTED + }; + + TcpServer(QObject * parent = 0); + virtual ~TcpServer(); + + static QString getStateAsString(quint8 state); + bool start(quint16 port); + void stop(); + void abort(); + QString errorString() const; + void setTimeOut(quint16 time_out); + void sendRawMessage(const RawMessage &); + +signals: + + void stateChanged(quint8 new_state); + void messageReceived(const RawMessage &); +// void messageReceived(const RawMessage &); +// void messageEmited(const RawMessage &); + void messageReceived(const QString &); + void messageEmitted(const QString &); + + +private slots: + + void serverNewConnection(); + void readMessage(); + void on_socketDisconnected(); + void timeout(); + void sendScheduledMessage(); + void onReceipt(); + +private: + + void sendAcceptMessage(); + void setState(quint8 new_state); + + QTcpServer *m_server; + QTcpSocket *m_socket; + quint8 m_currentState; + quint16 m_port; + quint32 m_bytesReceived; + quint32 m_blockSize; + + //timeout variables------- + quint32 m_tempBytesReceived; + quint16 m_timeOut; + quint16 m_timeOutCounter; + QTimer *m_connectionTimer; + + QTimer *m_scheduler; + QList m_messagesToSend; + bool m_receivedStarted; + qint64 m_remainingLength; + char m_buffer[10000]; + +}; + +#endif // _TCPSERVER_H_ diff -Nru syncwall-1.6.0/ui/BackgroundPainterConfigWidget.ui syncwall-1.7.4/ui/BackgroundPainterConfigWidget.ui --- syncwall-1.6.0/ui/BackgroundPainterConfigWidget.ui 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/ui/BackgroundPainterConfigWidget.ui 2013-05-03 06:54:20.000000000 +0000 @@ -0,0 +1,343 @@ + + + BackgroundPainterConfigWidget + + + + 0 + 0 + 650 + 561 + + + + BackgroundPainterConfigWidget + + + + + + Image parameters + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 0 + 0 + + + + 0 + + + + + :/syncwall/basic_user.png:/syncwall/basic_user.png + + + Basic + + + + 6 + + + 3 + + + + + + + + + + + Horizontal alignment + + + + + + + + + + Resizing method + + + + + + + Vertical alignment + + + + + + + Multi monitor support + + + + + + + Multi monitor display + + + + + + + + + + + + :/syncwall/expert_user.png:/syncwall/expert_user.png + + + Expert + + + + 6 + + + 3 + + + + + + 50 + 16777215 + + + + + + + + + + + + + + + + + ignore image parameters from server (client) + + + + + + + skip image too small for resizing (<50% of final image) + + + + + + + export image parameters to clients (server) + + + + + + + Background + + + + + + + + 50 + 16777215 + + + + + + + false + + + + + + + Inverse gradient color + + + + + + + Special effect + + + + + + + Rotate image according to Metadata + + + + + + + 360.000000000000000 + + + + + + + Upsampling method + + + + + + + + + + (Can greatly increase the computation time) + + + + + + + + + + + + + + Preview desktop + + + + 6 + + + 6 + + + 3 + + + + + + 0 + 1 + + + + + 200 + 100 + + + + + + + + + 7 + + + + No data + + + + + + + + 7 + + + + Tips: You can reorder and align screens by drag&drop + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + :/syncwall/display_big.png + + + + + + + + + + + DesktopView + QGraphicsView +
DesktopView.h
+
+
+ + + + +
diff -Nru syncwall-1.6.0/ui/ImageViewer.ui syncwall-1.7.4/ui/ImageViewer.ui --- syncwall-1.6.0/ui/ImageViewer.ui 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/ui/ImageViewer.ui 2011-12-17 10:38:12.000000000 +0000 @@ -0,0 +1,49 @@ + + + ImageViewer + + + + 0 + 0 + 456 + 364 + + + + ImageViewer + + + + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + + + + + no info + + + + + labelInfos + graphicsView + graphicsView + + + + + ImageView + QGraphicsView +
ImageViewer.h
+
+
+ + +
diff -Nru syncwall-1.6.0/ui/NetworkManagerConfigWidget.ui syncwall-1.7.4/ui/NetworkManagerConfigWidget.ui --- syncwall-1.6.0/ui/NetworkManagerConfigWidget.ui 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/ui/NetworkManagerConfigWidget.ui 2012-11-07 07:53:00.000000000 +0000 @@ -0,0 +1,129 @@ + + + NetworkManagerConfigWidget + + + + 0 + 0 + 617 + 327 + + + + NetworkManagerConfigWidget + + + + + + Synchronise with server + + + true + + + + + + Server (name or IP) + + + + + + + + + + + 0 + 0 + + + + No connection + + + + + + + + 0 + 0 + + + + Test Connection + + + + :/syncwall/check.png:/syncwall/check.png + + + + + + + UDP Port + + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + :/syncwall/network_big.png + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + diff -Nru syncwall-1.6.0/ui/SchedulerConfigWidget.ui syncwall-1.7.4/ui/SchedulerConfigWidget.ui --- syncwall-1.6.0/ui/SchedulerConfigWidget.ui 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/ui/SchedulerConfigWidget.ui 2012-11-21 13:40:50.000000000 +0000 @@ -0,0 +1,335 @@ + + + SchedulerConfigWidgetClass + + + + 0 + 0 + 610 + 263 + + + + SchedulerConfigWidget + + + + + + Scheduling parameters + + + + + + Auto change at startup + + + + + + + false + + + Quit application after startup change (30s) + + + + + + + true + + + Change Interval + + + true + + + true + + + true + + + + + + Interval between change (h:m:s) + + + true + + + + + + + true + + + set time of day (h:m:s) + + + + + + + false + + + + + + + + + + false + + + + 0 + 0 + + + + Add to the timeofday list + + + + + + + :/syncwall/add.png:/syncwall/add.png + + + + + + + false + + + QAbstractItemView::ExtendedSelection + + + + + + + false + + + Delete selected timeofday + + + + + + + :/syncwall/delete.png:/syncwall/delete.png + + + + + + + Qt::Vertical + + + + 25 + 20 + + + + + + + + + + + + + + h:mm:ss + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 2 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + :/syncwall/scheduling_big.png + + + + + + + + + + + + + + + + + + + + + + + radioButtonInterval + toggled(bool) + timeEditInterval + setEnabled(bool) + + + 109 + 102 + + + 247 + 102 + + + + + radioButtonTimeOfDay + toggled(bool) + timeEditTOD + setEnabled(bool) + + + 84 + 134 + + + 247 + 138 + + + + + radioButtonTimeOfDay + toggled(bool) + listWidgetTOD + setEnabled(bool) + + + 130 + 137 + + + 241 + 174 + + + + + radioButtonTimeOfDay + toggled(bool) + pushButtonAddTOD + setEnabled(bool) + + + 60 + 135 + + + 433 + 149 + + + + + radioButtonTimeOfDay + toggled(bool) + pushButtonDeleteTOD + setEnabled(bool) + + + 48 + 139 + + + 433 + 179 + + + + + checkBoxStartup + toggled(bool) + checkBoxStartupAndQuit + setEnabled(bool) + + + 65 + 42 + + + 69 + 64 + + + + + diff -Nru syncwall-1.6.0/ui/SyncWall.ui syncwall-1.7.4/ui/SyncWall.ui --- syncwall-1.6.0/ui/SyncWall.ui 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/ui/SyncWall.ui 2013-05-17 12:32:16.000000000 +0000 @@ -0,0 +1,1549 @@ + + + SyncWallClass + + + + 0 + 0 + 694 + 442 + + + + SyncWall + + + + :/syncwall/logo_big.png:/syncwall/logo_big.png + + + + + + + + + + + 0 + 0 + + + + 0 + + + + + :/syncwall/display_big.png:/syncwall/display_big.png + + + Preview + + + + + + + 0 + 0 + + + + No wallpaper + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + + 10 + 20 + + + + + + + + Qt::LeftToRight + + + Auto change in random order + + + + + + + 4 + + + + + + 0 + 0 + + + + Quit + + + + + + + + + + + + + + + + + + + :/syncwall/icon_quit2.png:/syncwall/icon_quit2.png + + + + 22 + 22 + + + + + + + + Qt::Vertical + + + + 31 + 50 + + + + + + + + Online Help + + + + + + + :/syncwall/help_blue.png:/syncwall/help_blue.png + + + + 22 + 22 + + + + + + + + + 0 + 0 + + + + Add a new folder + + + + + + + + + + + + + + + + + + + :/syncwall/dir_add.png:/syncwall/dir_add.png + + + + 22 + 22 + + + + + + + + + 0 + 0 + + + + Add new file(s) + + + Add new file(s) + + + + + + + + + + + + + :/syncwall/files_add.png:/syncwall/files_add.png + + + + 22 + 22 + + + + + + + + true + + + + 0 + 0 + + + + Delete selected wallpaper from list + + + + + + + :/syncwall/delete2.png:/syncwall/delete2.png + + + + 22 + 22 + + + + + + + + + 0 + 0 + + + + Refresh file list + + + + + + + + + + + + + + + + + + + :/syncwall/refresh2.png:/syncwall/refresh2.png + + + + 22 + 22 + + + + + + + + + 0 + 0 + + + + Set wallpaper + + + + + + + + + + + + + + + + + + + :/syncwall/monitor_paint2.png:/syncwall/monitor_paint2.png + + + + 22 + 22 + + + + + + + + Preview selected wallpaper + + + + + + + + + + + + + + + + + + + :/syncwall/preview2.png:/syncwall/preview2.png + + + + 22 + 22 + + + + + + + + + + Qt::Vertical + + + + Preview desktop + + + + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + false + + + Apply user positioning + + + + + + + :/syncwall/apply2.png:/syncwall/apply2.png + + + + + + + Enter image positioning by user + + + + + + + :/syncwall/user_move.png:/syncwall/user_move.png + + + + + + + false + + + Cancel user positioning + + + + + + + :/syncwall/delete2.png:/syncwall/delete2.png + + + + + + + + + QLayout::SetNoConstraint + + + + + + + + + + 0 + 0 + + + + State ... + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + + + + + + 0 + 0 + + + + + 32 + 32 + + + + + + + :/syncwall/mode_standard.png + + + true + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + true + + + + 24 + 16777215 + + + + Qt::NoFocus + + + View list and infos + + + + + + + :/syncwall/view-detail2.png:/syncwall/view-detail2.png + + + true + + + true + + + false + + + true + + + + + + + true + + + + 24 + 16777215 + + + + Qt::NoFocus + + + View thumbnails + + + + + + + :/syncwall/view-thumbnail2.png:/syncwall/view-thumbnail2.png + + + true + + + true + + + + + + + + + + 0 + 0 + + + + QFrame::StyledPanel + + + 1 + + + + + + + Qt::CustomContextMenu + + + QAbstractItemView::ExtendedSelection + + + QAbstractItemView::SelectItems + + + false + + + false + + + + + + + + + + + + 0 + 0 + + + + Qt::CustomContextMenu + + + QAbstractItemView::ExtendedSelection + + + + 100 + 100 + + + + Qt::ElideLeft + + + QAbstractItemView::ScrollPerItem + + + QListView::Static + + + QListView::Adjust + + + QListView::Batched + + + + 130 + 130 + + + + QListView::IconMode + + + false + + + false + + + + + + + + + + + + + + + + + :/syncwall/preferences.png:/syncwall/preferences.png + + + Preferences + + + + 6 + + + 3 + + + + + QTabWidget::South + + + 1 + + + + + :/syncwall/startup_big.png:/syncwall/startup_big.png + + + Startup + + + + 6 + + + 3 + + + + + true + + + Use Global Hotkey for manual change of wallpaper + + + true + + + false + + + + 6 + + + 3 + + + + + + + + + + + + + + + 0 + 0 + + + + Next wallpaper: + + + + + + + Previous wallpaper: + + + + + + + Open main interface: + + + + + + + Change image offset: + + + + + + + + + + + + + Language + + + + + + + + + Detected language ... + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Startup + + + + 6 + + + 3 + + + + + Start in notification tray (minimized) + + + + + + + Display splashscreen at startup + + + + + + + Auto start with system + + + + + + + Reset all preferences + + + Reset preferences + + + + :/syncwall/reset.png:/syncwall/reset.png + + + + + + + Qt::Horizontal + + + + 10 + 20 + + + + + + + + false + + + Splashscreen with transparent background + + + true + + + + + + + Reset cached data + + + Reset cache + + + + :/syncwall/reset2.png:/syncwall/reset2.png + + + + + + + + + + + + Qt::Vertical + + + + 20 + 1 + + + + + + + + + + + :/syncwall/startup_big.png + + + + + + + + + Qt::Vertical + + + + 20 + 1 + + + + + + + + + 0 + 20 + + + + + + + + + + :/syncwall/scheduling_big.png:/syncwall/scheduling_big.png + + + Scheduling + + + + 6 + + + 3 + + + + + + + + + + :/syncwall/display_big.png:/syncwall/display_big.png + + + Display Parameters + + + + 6 + + + 3 + + + + + + + + + + :/syncwall/network_big.png:/syncwall/network_big.png + + + Network + + + + 6 + + + 3 + + + + + + + + + + + + + + :/syncwall/about.png:/syncwall/about.png + + + About + + + + 6 + + + 3 + + + + + + + Qt::Vertical + + + QSizePolicy::MinimumExpanding + + + + 20 + 40 + + + + + + + + + 0 + 0 + + + + + + + :/syncwall/logo_big.png + + + + + + + + + + 0 + 0 + + + + Release Number + + + false + + + + + + + + + + Qt::RichText + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + Qt::TextBrowserInteraction + + + + + + + + + Supported formats (via Qt plugins) + + + + + + + 0 + 0 + + + + true + + + + + + + + 7 + + + + + + + + + + + + + + Available translations + + + + + + + 0 + 0 + + + + true + + + + + + + + 7 + + + + + + + + + + + + + + + + QTabWidget::South + + + 0 + + + + Credits + + + + + + + 0 + 0 + + + + + 8 + + + + false + + + QFrame::NoFrame + + + QFrame::Plain + + + true + + + + + + + + Changelog + + + + + + + 0 + 0 + + + + + 8 + + + + false + + + QFrame::NoFrame + + + QFrame::Plain + + + true + + + + + + + + + + + + + :/syncwall/scroll.png:/syncwall/scroll.png + + + Log + + + + 6 + + + 3 + + + + + + 0 + 0 + + + + Clear Log + + + + + + + :/syncwall/trash.png:/syncwall/trash.png + + + + + + + + 0 + 0 + + + + Save log to file + + + + + + + :/syncwall/camera.png:/syncwall/camera.png + + + + + + + Qt::Horizontal + + + + 10 + 21 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 0 + 0 + + + + + + + :/syncwall/scroll.png + + + + + + + + + + + + + + + + + + 0 + 0 + 694 + 21 + + + + + + + :/syncwall/preview2.png:/syncwall/preview2.png + + + Preview Image + + + + + + :/syncwall/monitor_paint2.png:/syncwall/monitor_paint2.png + + + Set wallpaper + + + + + + :/syncwall/delete2.png:/syncwall/delete2.png + + + Delete Image + + + + + + :/syncwall/display_big.png:/syncwall/display_big.png + + + Show main interface + + + Show User Interface + + + + + + :/syncwall/icon_quit.png:/syncwall/icon_quit.png + + + Quit + + + Quit application + + + + + + :/syncwall/refresh2.png:/syncwall/refresh2.png + + + Next Wallpaper + + + + + + :/syncwall/reset.png:/syncwall/reset.png + + + Previous Wallpaper + + + + + + :/syncwall/user_move.png:/syncwall/user_move.png + + + Change Image Offset + + + Change Image Offset + + + + + + :/syncwall/help_blue.png:/syncwall/help_blue.png + + + Help + + + + + + + QKeySequenceWidget + QWidget +
qkeysequencewidget.h
+ 1 +
+ + DesktopView + QGraphicsView +
DesktopView.h
+
+ + SchedulerConfigWidget + QWidget +
SchedulerConfigWidget.h
+ 1 +
+ + BackgroundPainterConfigWidget + QWidget +
BackgroundPainterConfigWidget.h
+ 1 +
+ + NetworkManagerConfigWidget + QWidget +
NetworkManagerConfigWidget.h
+ 1 +
+ + SystemIntegrationConfigWidget + QWidget +
SystemIntegrationConfigWidget.h
+ 1 +
+ + TreeImagesView + QTreeView +
TreeImagesView.h
+
+
+ + + + + + checkBoxSplashscreenAtStartup + toggled(bool) + checkBoxSplashscreenTransparentBackground + setEnabled(bool) + + + 136 + 136 + + + 276 + 155 + + + + + + + 5 + + + 5 + + + true + + + true + + + true + + +
diff -Nru syncwall-1.6.0/ui/SystemIntegrationConfigWidget.ui syncwall-1.7.4/ui/SystemIntegrationConfigWidget.ui --- syncwall-1.6.0/ui/SystemIntegrationConfigWidget.ui 1970-01-01 00:00:00.000000000 +0000 +++ syncwall-1.7.4/ui/SystemIntegrationConfigWidget.ui 2012-01-23 09:22:48.000000000 +0000 @@ -0,0 +1,76 @@ + + + SystemIntegrationConfigWidget + + + + 0 + 0 + 536 + 186 + + + + SystemIntegrationConfigWidget + + + + 0 + + + + + Desktop integration + + + + + + + + + no detection ... + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + The auto detection can failed. In this case, you have to set manually your desktop ... + + + true + + + + + + + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + + + + + + diff -Nru syncwall-1.6.0/uncrustify.cfg syncwall-1.7.4/uncrustify.cfg --- syncwall-1.6.0/uncrustify.cfg 2011-12-21 10:32:00.000000000 +0000 +++ syncwall-1.7.4/uncrustify.cfg 2012-11-23 11:32:24.000000000 +0000 @@ -1,12 +1,19 @@ +tok_split_gte=false +utf8_byte=false +utf8_force=false +indent_cmt_with_tabs=false indent_align_string=true indent_braces=false indent_braces_no_func=false +indent_braces_no_class=false +indent_braces_no_struct=false indent_brace_parent=false indent_namespace=false indent_extern=false indent_class=true indent_class_colon=false indent_else_if=false +indent_var_def_cont=false indent_func_call_param=false indent_func_def_param=false indent_func_proto_param=false @@ -20,6 +27,7 @@ indent_paren_nl=false indent_comma_paren=false indent_bool_paren=false +indent_first_bool_expr=false indent_square_nl=false indent_preserve_sql=false indent_align_assign=true @@ -40,7 +48,8 @@ align_single_line_brace=false align_nl_cont=false align_left_shift=true -nl_collapse_empty_body=true +align_oc_decl_colon=false +nl_collapse_empty_body=false nl_assign_leave_one_liners=true nl_class_leave_one_liners=false nl_enum_leave_one_liners=false @@ -56,7 +65,11 @@ nl_after_brace_open=true nl_after_brace_open_cmt=true nl_after_vbrace_open=false +nl_after_vbrace_open_empty=false nl_after_brace_close=false +nl_after_vbrace_close=false +nl_after_access_spec = 2 +nl_before_access_spec = 2 nl_define_macro=false nl_squeeze_ifdef=false nl_ds_struct_enum_cmt=false @@ -69,6 +82,7 @@ nl_after_multiline_comment=false eat_blanks_after_open_brace=true eat_blanks_before_close_brace=true +mod_full_brace_if_chain=false mod_pawn_semicolon=false mod_full_paren_if_bool=false mod_remove_extra_semicolon=true @@ -136,6 +150,5 @@ nl_class_init_args=force nl_func_type_name=remove nl_return_expr=remove -nl_class_colon=force mod_full_brace_for=remove mod_full_brace_while=remove