diff --git a/CMakeLists.txt b/CMakeLists.txt index fff4ad9..a16f6c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,75 +1,75 @@ project( klook ) cmake_minimum_required( VERSION 2.6 ) find_package( KDE4 REQUIRED ) include( KDE4Defaults ) find_package(KDeclarative) find_package( Qt4 REQUIRED QtCore QtGui QtDeclarative ) include( ${QT_USE_FILE} ) qt4_automoc( ${qtproject_SRCS} ) add_definitions( ${QT_DEFINITIONS}) include_directories( ${KDE4_INCLUDES} ${QT_QDECLARATIVE_INCLUDE_DIR} ${KDECLARATIVE_INCLUDE_DIRS} ) add_subdirectory( icons ) set(EXIV2_MIN_VERSION "0.19") find_package(Exiv2) macro_log_feature(EXIV2_FOUND "Exiv2" "Provides image metadata support" "http://www.exiv2.org" TRUE ${EXIV2_MIN_VERSION} "") set( RESOURCES src/resources.qrc ) QT4_ADD_RESOURCES( QRC_SOURCES ${RESOURCES} ) file( GLOB qml_files "${CMAKE_CURRENT_SOURCE_DIR}/src/qml/*.qml" ) set( klook_SRCS src/main.cpp src/declarativeviewer.cpp src/video.cpp src/text.cpp src/file.cpp src/listitem.cpp src/previewgenerator.cpp src/previewprovider.cpp src/filemodel.cpp src/klookapp.cpp src/audio.cpp src/mimeprovider.cpp src/kpartsdeclarativeitem.cpp src/kpartswidget.cpp src/listitemcontent.cpp src/exifimageprovider.cpp src/rotatedimage.cpp ${qml_files} ) -#set( KDE4_ICON_DIR ${CMAKE_INSTALL_PREFIX}/share/icons ) +set_source_files_properties(src/rotatedimage.cpp PROPERTIES COMPILE_FLAGS ${KDE4_ENABLE_EXCEPTIONS}) kde4_add_app_icon( klook_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/icons/hi*-apps-klook.png" ) kde4_add_executable( klook ${klook_SRCS} ${QRC_SOURCES} ) target_link_libraries( klook ${KDE4_KIO_LIBS} ${EXIV2_LIBRARIES} ${KDE4_PHONON_LIBS} ${KDE4_PLASMA_LIBS} ${KDE4_KFILE_LIBS} kparts ${KDECLARATIVE_LIBRARIES} ${QT_LIBRARIES} ${QT_QDECLARATIVE_LIBRARIES} ) install( TARGETS klook ${INSTALL_TARGETS_DEFAULT_ARGS} ) install( FILES ${qml_files} DESTINATION ${DATA_INSTALL_DIR}/${PROJECT_NAME}/ ) install( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/qml/images/ DESTINATION ${DATA_INSTALL_DIR}/${PROJECT_NAME}/images ) #Translations if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/locale) find_package( Msgfmt REQUIRED ) find_package( Gettext REQUIRED ) add_subdirectory( locale ) endif() diff --git a/src/rotatedimage.cpp b/src/rotatedimage.cpp index 0c99d85..ed4045f 100644 --- a/src/rotatedimage.cpp +++ b/src/rotatedimage.cpp @@ -1,104 +1,112 @@ /* KLook * Copyright (c) 2011-2012 ROSA * Authors: Evgeniy Auzhin, Sergey Borovkov. * License: GPLv3 * * 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 3, * 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 "rotatedimage.h" #include #include #include RotatedImage::RotatedImage(const QString& path) : m_path(path) { rotateImage(); } void RotatedImage::rotateImage() { - Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(qPrintable(m_path)); - image->readMetadata(); + try { + Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(qPrintable(m_path)); + image->readMetadata(); - Exiv2::ExifData &exifData = image->exifData(); - if (exifData.empty()) - return; + Exiv2::ExifData &exifData = image->exifData(); + if (exifData.empty()) + return; - int orientation = 0; - Exiv2::ExifKey key("Exif.Image.Orientation"); - Exiv2::ExifData::iterator it = exifData.findKey(key); + int orientation = 0; + Exiv2::ExifKey key("Exif.Image.Orientation"); + Exiv2::ExifData::iterator it = exifData.findKey(key); - if (it == exifData.end()) - return; + if (it == exifData.end()) + return; - orientation = it->toLong(); + orientation = it->toLong(); - QMatrix rot90 = createRotMatrix(90); - QMatrix hflip = createScaleMatrix(-1, 1); - QMatrix vflip = createScaleMatrix(1, -1); + QMatrix rot90 = createRotMatrix(90); + QMatrix hflip = createScaleMatrix(-1, 1); + QMatrix vflip = createScaleMatrix(1, -1); - switch(orientation) - { - case NOT_AVAILABLE : - case NORMAL : - m_matrix = QMatrix(); - break; - case HFLIP : - m_matrix = hflip; - break; - case ROT_180: - m_matrix = createRotMatrix(180); - break; - case VFLIP: - m_matrix = vflip; - break; - case TRANSPOSE: - m_matrix = hflip * rot90; - break; - case ROT_90: - m_matrix = rot90; - break; - case TRANSVERSE: - m_matrix = vflip * rot90; - break; - case ROT_270: - m_matrix = createRotMatrix(270); - break; + switch(orientation) + { + case NOT_AVAILABLE : + case NORMAL : + m_matrix = QMatrix(); + break; + case HFLIP : + m_matrix = hflip; + break; + case ROT_180: + m_matrix = createRotMatrix(180); + break; + case VFLIP: + m_matrix = vflip; + break; + case TRANSPOSE: + m_matrix = hflip * rot90; + break; + case ROT_90: + m_matrix = rot90; + break; + case TRANSVERSE: + m_matrix = vflip * rot90; + break; + case ROT_270: + m_matrix = createRotMatrix(270); + break; + } } + catch(...) { + // we don't really care about this + // let's just return + return; + } + } QMatrix RotatedImage::createRotMatrix(int angle) { QMatrix matrix; matrix.rotate(angle); return matrix; } QMatrix RotatedImage::createScaleMatrix(int dx, int dy) { QMatrix matrix; matrix.scale(dx, dy); return matrix; } QMatrix RotatedImage::rotationMatrix() const { return m_matrix; }