mirror of
https://invent.kde.org/graphics/okular
synced 2024-10-02 14:14:10 +00:00
Merge remote-tracking branch 'origin/master' into dont-use-docdata-for-annots-and-forms
This commit is contained in:
commit
04ed10d3ea
3
.arcconfig
Normal file
3
.arcconfig
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"phabricator.uri" : "https://phabricator.kde.org/"
|
||||
}
|
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
CMakeLists.txt.user*
|
||||
*.kdev4
|
||||
*.swp
|
||||
/build/
|
258
CMakeLists.txt
258
CMakeLists.txt
|
@ -1,36 +1,106 @@
|
|||
project(okular)
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
|
||||
find_package(KDE4 4.6.0 REQUIRED)
|
||||
include(KDE4Defaults)
|
||||
include(MacroLibrary)
|
||||
include(MacroOptionalAddSubdirectory)
|
||||
# KDE Application Version, managed by release script
|
||||
set (KDE_APPLICATIONS_VERSION_MAJOR "17")
|
||||
set (KDE_APPLICATIONS_VERSION_MINOR "11")
|
||||
set (KDE_APPLICATIONS_VERSION_MICRO "70")
|
||||
set (KDE_APPLICATIONS_VERSION "${KDE_APPLICATIONS_VERSION_MAJOR}.${KDE_APPLICATIONS_VERSION_MINOR}.${KDE_APPLICATIONS_VERSION_MICRO}")
|
||||
|
||||
project(okular VERSION 1.2.${KDE_APPLICATIONS_VERSION_MICRO})
|
||||
|
||||
set(QT_REQUIRED_VERSION "5.6.0")
|
||||
set(KF5_REQUIRED_VERSION "5.16.0")
|
||||
|
||||
find_package(ECM 5.19.0 CONFIG REQUIRED)
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH})
|
||||
|
||||
include(ECMInstallIcons)
|
||||
include(ECMSetupVersion)
|
||||
include(ECMOptionalAddSubdirectory)
|
||||
include(GenerateExportHeader)
|
||||
include(FeatureSummary)
|
||||
include(ECMAddAppIcon)
|
||||
include(KDECompilerSettings NO_POLICY_SCOPE)
|
||||
include(KDEInstallDirs)
|
||||
include(KDECMakeSettings)
|
||||
include(ECMAddTests)
|
||||
include(ECMAddAppIcon)
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
ecm_setup_version(${PROJECT_VERSION}
|
||||
VARIABLE_PREFIX OKULAR
|
||||
VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/core/version.h"
|
||||
PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/Okular5ConfigVersion.cmake")
|
||||
|
||||
find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED COMPONENTS Core DBus Test Widgets PrintSupport Svg Qml Quick)
|
||||
find_package(Qt5 ${QT_REQUIRED_VERSION} OPTIONAL_COMPONENTS TextToSpeech)
|
||||
if (NOT Qt5TextToSpeech_FOUND)
|
||||
message(STATUS "Qt5TextToSpeech not found, speech features will be disabled")
|
||||
else()
|
||||
add_definitions(-DHAVE_SPEECH)
|
||||
endif()
|
||||
|
||||
find_package(KF5 ${KF5_REQUIRED_VERSION} REQUIRED COMPONENTS
|
||||
Archive
|
||||
Bookmarks
|
||||
Completion
|
||||
Config
|
||||
ConfigWidgets
|
||||
CoreAddons
|
||||
DocTools
|
||||
IconThemes
|
||||
JS
|
||||
KIO
|
||||
Parts
|
||||
ThreadWeaver
|
||||
Wallet
|
||||
WindowSystem
|
||||
)
|
||||
if(NOT WIN32)
|
||||
find_package(KF5 ${KF5_REQUIRED_VERSION} REQUIRED COMPONENTS
|
||||
Activities
|
||||
)
|
||||
endif()
|
||||
find_package(KF5Kirigami2)
|
||||
set_package_properties(KF5Kirigami2 PROPERTIES
|
||||
DESCRIPTION "A QtQuick based components set"
|
||||
PURPOSE "Required at runtime by the mobile app"
|
||||
TYPE RUNTIME
|
||||
)
|
||||
find_package(Phonon4Qt5 CONFIG REQUIRED)
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/modules)
|
||||
|
||||
macro_optional_find_package(QImageBlitz)
|
||||
macro_log_feature(QIMAGEBLITZ_FOUND "QImageBlitz" "An image effects library" "http://sourceforge.net/projects/qimageblitz" TRUE "kdesupport" "Required to build Okular.")
|
||||
find_package(ZLIB REQUIRED)
|
||||
|
||||
macro_optional_find_package(LibKScreen)
|
||||
macro_log_feature(LibKScreen_FOUND "LibKScreen" "KDE screen management library" "https://projects.kde.org/projects/kdereview/libkscreen" FALSE "1.0.2" "DPI detection support")
|
||||
|
||||
add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
|
||||
add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${KDE4_INCLUDES}
|
||||
${QIMAGEBLITZ_INCLUDES}
|
||||
${LibKScreen_INCLUDE_DIR}
|
||||
)
|
||||
add_definitions(-DTRANSLATION_DOMAIN="okular")
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${PHONON_INCLUDES} core/synctex ${ZLIB_INCLUDE_DIR} ${CMAKE_BINARY_DIR}/core)
|
||||
|
||||
add_subdirectory( mobile )
|
||||
option(BUILD_COVERAGE "Build the project with gcov support" OFF)
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0.0")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsuggest-override" )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(BUILD_COVERAGE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov")
|
||||
endif()
|
||||
|
||||
add_subdirectory( active )
|
||||
add_subdirectory( ui )
|
||||
add_subdirectory( shell )
|
||||
add_subdirectory( generators )
|
||||
add_subdirectory( tests )
|
||||
macro_optional_add_subdirectory(doc)
|
||||
add_subdirectory( autotests )
|
||||
add_subdirectory( conf/autotests )
|
||||
|
||||
add_subdirectory(doc)
|
||||
|
||||
include(OkularConfigureChecks.cmake)
|
||||
include(MacroWriteBasicCMakeVersionFile)
|
||||
|
||||
if(NOT WIN32)
|
||||
set(MATH_LIB m)
|
||||
|
@ -56,6 +126,7 @@ set(okularcore_SRCS
|
|||
core/misc.cpp
|
||||
core/movie.cpp
|
||||
core/observer.cpp
|
||||
core/debug.cpp
|
||||
core/page.cpp
|
||||
core/pagecontroller.cpp
|
||||
core/pagesize.cpp
|
||||
|
@ -80,9 +151,11 @@ set(okularcore_SRCS
|
|||
core/script/kjs_field.cpp
|
||||
core/script/kjs_spell.cpp
|
||||
core/script/kjs_util.cpp
|
||||
core/synctex/synctex_parser.c
|
||||
core/synctex/synctex_parser_utils.c
|
||||
)
|
||||
|
||||
kde4_add_ui_files(okularcore_SRCS
|
||||
ki18n_wrap_ui(okularcore_SRCS
|
||||
conf/textdocumentsettings.ui
|
||||
)
|
||||
|
||||
|
@ -95,7 +168,6 @@ install( FILES
|
|||
core/form.h
|
||||
core/generator.h
|
||||
core/global.h
|
||||
core/okular_export.h
|
||||
core/page.h
|
||||
core/pagesize.h
|
||||
core/pagetransition.h
|
||||
|
@ -106,11 +178,12 @@ install( FILES
|
|||
core/textpage.h
|
||||
core/tile.h
|
||||
core/utils.h
|
||||
core/version.h
|
||||
core/fileprinter.h
|
||||
core/observer.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/core/version.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/core/okularcore_export.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/settings_core.h
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/okular/core COMPONENT Devel)
|
||||
DESTINATION ${KDE_INSTALL_INCLUDEDIR}/okular/core COMPONENT Devel)
|
||||
|
||||
install( FILES
|
||||
interfaces/configinterface.h
|
||||
|
@ -118,40 +191,56 @@ install( FILES
|
|||
interfaces/printinterface.h
|
||||
interfaces/saveinterface.h
|
||||
interfaces/viewerinterface.h
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/okular/interfaces COMPONENT Devel)
|
||||
DESTINATION ${KDE_INSTALL_INCLUDEDIR}/okular/interfaces COMPONENT Devel)
|
||||
|
||||
kde4_add_ui_files(okularcore_SRCS
|
||||
ki18n_wrap_ui(okularcore_SRCS
|
||||
core/chooseenginewidget.ui
|
||||
)
|
||||
|
||||
kde4_add_kcfg_files(okularcore_SRCS conf/settings_core.kcfgc )
|
||||
kconfig_add_kcfg_files(okularcore_SRCS conf/settings_core.kcfgc )
|
||||
|
||||
kde4_add_library(okularcore SHARED ${okularcore_SRCS})
|
||||
add_library(okularcore SHARED ${okularcore_SRCS})
|
||||
generate_export_header(okularcore BASE_NAME okularcore EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/core/okularcore_export.h")
|
||||
|
||||
# Special handling for linking okularcore on OSX/Apple
|
||||
IF(APPLE)
|
||||
SET(OKULAR_IOKIT "-framework IOKit" CACHE STRING "Apple IOKit framework")
|
||||
ENDIF(APPLE)
|
||||
|
||||
target_link_libraries(okularcore ${OKULAR_IOKIT} ${KDE4_KIO_LIBS} ${KDE4_PHONON_LIBRARY} ${KDE4_KJSAPI_LIBRARY} ${MATH_LIB} ${KDE4_THREADWEAVER_LIBRARY} )
|
||||
target_link_libraries(okularcore
|
||||
PRIVATE
|
||||
${OKULAR_IOKIT}
|
||||
KF5::Archive
|
||||
KF5::JS
|
||||
KF5::JSApi
|
||||
KF5::KIOCore
|
||||
KF5::KIOWidgets
|
||||
KF5::I18n
|
||||
KF5::ThreadWeaver
|
||||
KF5::Wallet
|
||||
KF5::Bookmarks
|
||||
Phonon::phonon4qt5
|
||||
${MATH_LIB}
|
||||
${ZLIB_LIBRARIES}
|
||||
PUBLIC # these are included from the installed headers
|
||||
KF5::CoreAddons
|
||||
KF5::XmlGui
|
||||
KF5::ConfigGui
|
||||
Qt5::PrintSupport
|
||||
Qt5::Widgets
|
||||
)
|
||||
|
||||
if(LibKScreen_FOUND)
|
||||
target_link_libraries(okularcore ${LibKScreen_LIBRARY})
|
||||
endif(LibKScreen_FOUND)
|
||||
set_target_properties(okularcore PROPERTIES VERSION 7.0.0 SOVERSION 7 OUTPUT_NAME Okular5Core EXPORT_NAME Core)
|
||||
|
||||
set_target_properties(okularcore PROPERTIES VERSION 5.0.0 SOVERSION 5 )
|
||||
install(TARGETS okularcore EXPORT Okular5Targets ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
|
||||
|
||||
install(TARGETS okularcore ${INSTALL_TARGETS_DEFAULT_ARGS} )
|
||||
|
||||
install(FILES conf/okular.kcfg DESTINATION ${KCFG_INSTALL_DIR})
|
||||
install(FILES conf/okular_core.kcfg DESTINATION ${KCFG_INSTALL_DIR})
|
||||
install(FILES core/okularGenerator.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR})
|
||||
install(FILES conf/okular.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR})
|
||||
install(FILES conf/okular_core.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR})
|
||||
install(FILES core/okularGenerator.desktop DESTINATION ${KDE_INSTALL_KSERVICETYPES5DIR})
|
||||
|
||||
# okularpart
|
||||
|
||||
set(okularpart_SRCS
|
||||
part.cpp
|
||||
extensions.cpp
|
||||
set(okularpart_conf_SRCS
|
||||
conf/preferencesdialog.cpp
|
||||
conf/dlgaccessibility.cpp
|
||||
conf/dlgdebug.cpp
|
||||
|
@ -160,7 +249,17 @@ set(okularpart_SRCS
|
|||
conf/dlgannotations.cpp
|
||||
conf/dlgperformance.cpp
|
||||
conf/dlgpresentation.cpp
|
||||
conf/editannottooldialog.cpp
|
||||
conf/editdrawingtooldialog.cpp
|
||||
conf/widgetannottools.cpp
|
||||
conf/widgetconfigurationtoolsbase.cpp
|
||||
conf/widgetdrawingtools.cpp
|
||||
)
|
||||
|
||||
set(okularpart_SRCS
|
||||
${okularpart_conf_SRCS}
|
||||
part.cpp
|
||||
extensions.cpp
|
||||
ui/embeddedfilesdialog.cpp
|
||||
ui/annotwindow.cpp
|
||||
ui/annotationmodel.cpp
|
||||
|
@ -170,6 +269,8 @@ set(okularpart_SRCS
|
|||
ui/annotationtools.cpp
|
||||
ui/annotationwidgets.cpp
|
||||
ui/bookmarklist.cpp
|
||||
ui/debug_ui.cpp
|
||||
ui/drawingtoolactions.cpp
|
||||
ui/fileprinterpreview.cpp
|
||||
ui/findbar.cpp
|
||||
ui/formwidgets.cpp
|
||||
|
@ -177,10 +278,12 @@ set(okularpart_SRCS
|
|||
ui/ktreeviewsearchline.cpp
|
||||
ui/latexrenderer.cpp
|
||||
ui/minibar.cpp
|
||||
ui/okmenutitle.cpp
|
||||
ui/pageitemdelegate.cpp
|
||||
ui/pagepainter.cpp
|
||||
ui/pagesizelabel.cpp
|
||||
ui/pageviewannotator.cpp
|
||||
ui/pageviewmouseannotation.cpp
|
||||
ui/pageview.cpp
|
||||
ui/magnifierview.cpp
|
||||
ui/pageviewutils.cpp
|
||||
|
@ -196,11 +299,16 @@ set(okularpart_SRCS
|
|||
ui/toc.cpp
|
||||
ui/tocmodel.cpp
|
||||
ui/toolaction.cpp
|
||||
ui/tts.cpp
|
||||
ui/videowidget.cpp
|
||||
ui/layers.cpp
|
||||
)
|
||||
|
||||
kde4_add_ui_files(okularpart_SRCS
|
||||
if (Qt5TextToSpeech_FOUND)
|
||||
set(okularpart_SRCS ${okularpart_SRCS}
|
||||
ui/tts.cpp)
|
||||
endif()
|
||||
|
||||
ki18n_wrap_ui(okularpart_SRCS
|
||||
conf/dlgaccessibilitybase.ui
|
||||
conf/dlgeditorbase.ui
|
||||
conf/dlggeneralbase.ui
|
||||
|
@ -209,31 +317,67 @@ kde4_add_ui_files(okularpart_SRCS
|
|||
conf/dlgpresentationbase.ui
|
||||
)
|
||||
|
||||
kde4_add_kcfg_files(okularpart_SRCS conf/settings.kcfgc )
|
||||
kconfig_add_kcfg_files(okularpart_SRCS conf/settings.kcfgc )
|
||||
|
||||
qt4_add_dbus_interfaces(okularpart_SRCS ${KDE4_DBUS_INTERFACES_DIR}/org.kde.KSpeech.xml)
|
||||
add_library(okularpart SHARED ${okularpart_SRCS})
|
||||
generate_export_header(okularpart BASE_NAME okularpart)
|
||||
|
||||
kde4_add_plugin(okularpart SHARED ${okularpart_SRCS})
|
||||
target_link_libraries(okularpart okularcore
|
||||
${MATH_LIB}
|
||||
Qt5::Svg
|
||||
Phonon::phonon4qt5
|
||||
KF5::Archive
|
||||
KF5::Bookmarks
|
||||
KF5::I18n
|
||||
KF5::IconThemes
|
||||
KF5::ItemViews
|
||||
KF5::KIOCore
|
||||
KF5::KIOFileWidgets
|
||||
KF5::KIOWidgets
|
||||
KF5::KIONTLM
|
||||
KF5::Parts
|
||||
KF5::Solid
|
||||
KF5::Wallet
|
||||
KF5::WindowSystem
|
||||
)
|
||||
|
||||
target_link_libraries(okularpart okularcore ${KDE4_KPARTS_LIBS} ${KDE4_KPRINTUTILS_LIBS} ${MATH_LIB} ${QIMAGEBLITZ_LIBRARIES} ${KDE4_PHONON_LIBRARY} ${KDE4_SOLID_LIBRARY})
|
||||
set_target_properties(okularpart PROPERTIES PREFIX "")
|
||||
|
||||
install(TARGETS okularpart DESTINATION ${PLUGIN_INSTALL_DIR})
|
||||
if (Qt5TextToSpeech_FOUND)
|
||||
target_link_libraries(okularpart Qt5::TextToSpeech)
|
||||
endif()
|
||||
install(TARGETS okularpart DESTINATION ${KDE_INSTALL_PLUGINDIR})
|
||||
|
||||
|
||||
########### install files ###############
|
||||
|
||||
install(FILES okular.upd DESTINATION ${DATA_INSTALL_DIR}/kconf_update)
|
||||
install(FILES okular.upd DESTINATION ${KDE_INSTALL_DATADIR}/kconf_update)
|
||||
|
||||
install( FILES okular_part.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
|
||||
install( FILES part.rc part-viewermode.rc DESTINATION ${DATA_INSTALL_DIR}/okular )
|
||||
install( FILES okular_part.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR} )
|
||||
install( FILES part.rc part-viewermode.rc DESTINATION ${KDE_INSTALL_KXMLGUI5DIR}/okular )
|
||||
|
||||
install( FILES okular.categories DESTINATION ${KDE_INSTALL_CONFDIR} )
|
||||
|
||||
########### cmake files #################
|
||||
|
||||
macro_write_basic_cmake_version_file(${CMAKE_CURRENT_BINARY_DIR}/OkularConfigVersion.cmake 0 11 80)
|
||||
set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/Okular5")
|
||||
configure_package_config_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/Okular5Config.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/Okular5Config.cmake"
|
||||
INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}
|
||||
PATH_VARS INCLUDE_INSTALL_DIR CMAKE_INSTALL_PREFIX
|
||||
)
|
||||
|
||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/OkularConfig.cmake
|
||||
${CMAKE_CURRENT_BINARY_DIR}/OkularConfigVersion.cmake
|
||||
DESTINATION ${LIB_INSTALL_DIR}/cmake/Okular )
|
||||
install(FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/Okular5Config.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/Okular5ConfigVersion.cmake"
|
||||
DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
|
||||
COMPONENT Devel
|
||||
)
|
||||
|
||||
macro_display_feature_log()
|
||||
install(EXPORT Okular5Targets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE Okular5Targets.cmake NAMESPACE Okular::)
|
||||
|
||||
########### summary #################
|
||||
|
||||
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
|
||||
|
||||
|
|
11
Mainpage.dox
11
Mainpage.dox
|
@ -329,7 +329,7 @@ MimeType=application/x-magic;
|
|||
Terminal=false
|
||||
Name=okular
|
||||
GenericName=Document Viewer
|
||||
Exec=okular %U %i -caption %c
|
||||
Exec=okular %U %i
|
||||
Icon=okular
|
||||
Type=Application
|
||||
InitialPreference=7
|
||||
|
@ -658,7 +658,7 @@ class HTMLGenerator : public Okular::Generator
|
|||
bool canGeneratePixmap() const;
|
||||
void generatePixmap( Okular::PixmapRequest *request );
|
||||
|
||||
virtual const Okular::DocumentInfo* generateDocumentInfo();
|
||||
virtual Okular::DocumentInfo generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const;
|
||||
|
||||
virtual const Okular::DocumentSynopsis* generateDocumentSynopsis();
|
||||
|
||||
|
@ -801,9 +801,9 @@ void HTMLGenerator::generatePixmap( Okular::PixmapRequest *request )
|
|||
signalPixmapRequestDone( request );
|
||||
}
|
||||
|
||||
const Okular::DocumentInfo* HTMLGenerator::generateDocumentInfo()
|
||||
Okular::DocumentInfo HTMLGenerator::generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const
|
||||
{
|
||||
return &mDocumentInfo;
|
||||
return mDocumentInfo;
|
||||
}
|
||||
|
||||
const Okular::DocumentSynopsis* HTMLGenerator::generateDocumentSynopsis()
|
||||
|
@ -859,6 +859,3 @@ the pages vector with them.
|
|||
Afterwards we fill our Okular::DocumentInfo object with data. Since extracting the HTML meta data
|
||||
would need a lot of code we work with static data here. [to be continued]
|
||||
*/
|
||||
|
||||
// DOXYGEN_EXCLUDE = conf generators shell ui
|
||||
// DOXYGEN_FILE_PATTERNS = core/*.h *.dox
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#!/bin/sh
|
||||
$EXTRACTRC *.rc */*.rc >> rc.cpp || exit 11
|
||||
$EXTRACTRC $(find conf/ -name "*.ui") $(find core/ -name "*.ui") $(find ui/ -name "*.ui") $(ls . | grep -E '\.ui') >> rc.cpp || exit 12
|
||||
$EXTRACTATTR --attr=tool,name ui/data/drawingtools.xml >> rc.cpp || exit 13
|
||||
$XGETTEXT $(find conf/ -name "*.cpp" -o -name "*.h") $(find core/ -name "*.cpp" -o -name "*.h") $(find ui/ -name "*.cpp" -o -name "*.h") $(find shell/ -name "*.cpp" -o -name "*.h") $(ls . | grep -E '\.cpp$') $(ls . | grep -E '\.h$') -o $podir/okular.pot
|
||||
|
|
10
Okular5Config.cmake.in
Normal file
10
Okular5Config.cmake.in
Normal file
|
@ -0,0 +1,10 @@
|
|||
@PACKAGE_INIT@
|
||||
|
||||
find_dependency(Qt5Core @QT_REQUIRED_VERSION@)
|
||||
find_dependency(Qt5PrintSupport @QT_REQUIRED_VERSION@)
|
||||
find_dependency(Qt5Widgets @QT_REQUIRED_VERSION@)
|
||||
find_dependency(KF5CoreAddons @KF5_REQUIRED_VERSION@)
|
||||
find_dependency(KF5Config @KF5_REQUIRED_VERSION@)
|
||||
find_dependency(KF5XmlGui @KF5_REQUIRED_VERSION@)
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/Okular5Targets.cmake")
|
|
@ -1,24 +0,0 @@
|
|||
# get from the full path to OkularConfig.cmake up to the base dir dir:
|
||||
get_filename_component( _okularBaseDir ${CMAKE_CURRENT_LIST_FILE} PATH)
|
||||
get_filename_component( _okularBaseDir ${_okularBaseDir} PATH)
|
||||
get_filename_component( _okularBaseDir ${_okularBaseDir} PATH)
|
||||
get_filename_component( _okularBaseDir ${_okularBaseDir} PATH)
|
||||
|
||||
|
||||
# find the full paths to the library and the includes:
|
||||
find_path(OKULAR_INCLUDE_DIR okular/core/document.h
|
||||
HINTS ${_okularBaseDir}/include
|
||||
NO_DEFAULT_PATH)
|
||||
|
||||
find_library(OKULAR_CORE_LIBRARY okularcore
|
||||
HINTS ${_okularBaseDir}/lib
|
||||
NO_DEFAULT_PATH)
|
||||
|
||||
set(OKULAR_LIBRARIES ${OKULAR_CORE_LIBRARY})
|
||||
|
||||
# Compat: the old FindOkular.cmake was setting OKULAR_FOUND and the
|
||||
# new one sets Okular_FOUND.
|
||||
if(OKULAR_INCLUDE_DIR AND OKULAR_CORE_LIBRARY)
|
||||
set(OKULAR_FOUND TRUE)
|
||||
endif()
|
||||
|
39
aboutdata.h
39
aboutdata.h
|
@ -10,36 +10,37 @@
|
|||
#ifndef _ABOUTDATA_H_
|
||||
#define _ABOUTDATA_H_
|
||||
|
||||
#include <kaboutdata.h>
|
||||
#include <KAboutData>
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
inline KAboutData okularAboutData( const char* name, const char* iname )
|
||||
#include <klocalizedstring.h>
|
||||
|
||||
inline KAboutData okularAboutData()
|
||||
{
|
||||
KAboutData about(
|
||||
name, //"okular",
|
||||
"okular",
|
||||
ki18n(iname), //I18N_NOOP("okular"),
|
||||
OKULAR_VERSION_STRING,
|
||||
ki18n("Okular, a universal document viewer"),
|
||||
KAboutData::License_GPL,
|
||||
ki18n("(C) 2002 Wilco Greven, Christophe Devriese\n"
|
||||
QStringLiteral("okular"),
|
||||
i18n("Okular"),
|
||||
QStringLiteral(OKULAR_VERSION_STRING),
|
||||
i18n("Okular, a universal document viewer"),
|
||||
KAboutLicense::GPL,
|
||||
i18n("(C) 2002 Wilco Greven, Christophe Devriese\n"
|
||||
"(C) 2004-2005 Enrico Ros\n"
|
||||
"(C) 2005 Piotr Szymanski\n"
|
||||
"(C) 2004-2009 Albert Astals Cid\n"
|
||||
"(C) 2006-2009 Pino Toscano"),
|
||||
KLocalizedString(),
|
||||
"http://okular.kde.org"
|
||||
QString(),
|
||||
QStringLiteral("http://okular.kde.org")
|
||||
);
|
||||
|
||||
about.addAuthor(ki18n("Pino Toscano"), ki18n("Former maintainer"), "pino@kde.org");
|
||||
about.addAuthor(ki18n("Tobias Koenig"), ki18n("Lots of framework work, ODT and FictionBook backends"), "tokoe@kde.org");
|
||||
about.addAuthor(ki18n("Albert Astals Cid"), ki18n("Current maintainer"), "aacid@kde.org");
|
||||
about.addAuthor(ki18n("Piotr Szymanski"), ki18n("Created Okular from KPDF codebase"), "djurban@pld-dc.org");
|
||||
about.addAuthor(ki18n("Enrico Ros"), ki18n("KPDF developer"), "eros.kde@email.it");
|
||||
about.addCredit(ki18n("Eugene Trounev"), ki18n("Annotations artwork"), "eugene.trounev@gmail.com");
|
||||
about.addCredit(ki18n("Jiri Baum - NICTA"), ki18n("Table selection tool"), "jiri@baum.com.au");
|
||||
about.addCredit(ki18n("Fabio D'Urso"), ki18n("Annotation improvements"), "fabiodurso@hotmail.it");
|
||||
about.addAuthor(QStringLiteral("Pino Toscano"), i18n("Former maintainer"), QStringLiteral("pino@kde.org"));
|
||||
about.addAuthor(QStringLiteral("Tobias Koenig"), i18n("Lots of framework work, ODT and FictionBook backends"), QStringLiteral("tokoe@kde.org"));
|
||||
about.addAuthor(QStringLiteral("Albert Astals Cid"), i18n("Developer"), QStringLiteral("aacid@kde.org"));
|
||||
about.addAuthor(QStringLiteral("Piotr Szymanski"), i18n("Created Okular from KPDF codebase"), QStringLiteral("djurban@pld-dc.org"));
|
||||
about.addAuthor(QStringLiteral("Enrico Ros"), i18n("KPDF developer"), QStringLiteral("eros.kde@email.it"));
|
||||
about.addCredit(QStringLiteral("Eugene Trounev"), i18n("Annotations artwork"), QStringLiteral("eugene.trounev@gmail.com"));
|
||||
about.addCredit(QStringLiteral("Jiri Baum - NICTA"), i18n("Table selection tool"), QStringLiteral("jiri@baum.com.au"));
|
||||
about.addCredit(QStringLiteral("Fabio D'Urso"), i18n("Annotation improvements"), QStringLiteral("fabiodurso@hotmail.it"));
|
||||
|
||||
return about;
|
||||
}
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
|
||||
macro_optional_find_package(ActiveApp)
|
||||
macro_log_feature(ACTIVEAPP_FOUND "ActiveApp" "Support for developing applications for Plasma Active" "https://projects.kde.org/projects/extragear/base/plasma-mobile" FALSE "0.1")
|
||||
|
||||
if (ACTIVEAPP_FOUND)
|
||||
add_subdirectory( app )
|
||||
endif (ACTIVEAPP_FOUND)
|
||||
|
||||
add_subdirectory( components )
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
|
||||
include_directories( ${KDE4_INCLUDES} ${QT_INCLUDES} )
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
# QML-only thing
|
||||
install(DIRECTORY package/ DESTINATION ${DATA_INSTALL_DIR}/plasma/packages/org.kde.active.documentviewer)
|
||||
|
||||
|
||||
install(FILES active-documentviewer.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
#! /usr/bin/env bash
|
||||
$EXTRACTRC `find . -name \*.rc -o -name \*.ui -o -name \*.kcfg` >> rc.cpp
|
||||
$XGETTEXT `find . -name \*.qml` -L Java -o $podir/org.kde.active.documentviewer.temp.pot
|
||||
$XGETTEXT `find src/ -name "*.cpp" -o -name "*.h"` -o $podir/org.kde.active.documentviewer.pot
|
||||
$MSGCAT $podir/org.kde.active.documentviewer.temp.pot $podir/org.kde.active.documentviewer.pot -o $podir/org.kde.active.documentviewer.pot
|
||||
rm -f $podir/org.kde.active.documentviewer.temp.pot
|
||||
rm -f rc.cpp
|
|
@ -1,150 +0,0 @@
|
|||
[Desktop Entry]
|
||||
Name=Reader
|
||||
Name[ar]=التصيير
|
||||
Name[bg]=Четец
|
||||
Name[bs]=Čitač
|
||||
Name[ca]=Lector
|
||||
Name[ca@valencia]=Lector
|
||||
Name[cs]=Čtečka
|
||||
Name[da]=Læser
|
||||
Name[de]=Lesegerät
|
||||
Name[el]=Πρόγραμμα ανάγνωσης
|
||||
Name[en_GB]=Reader
|
||||
Name[es]=Lector
|
||||
Name[et]=Lugeja
|
||||
Name[fi]=Lukija
|
||||
Name[fr]=Lecteur
|
||||
Name[ga]=Léitheoir
|
||||
Name[gl]=Lector
|
||||
Name[hu]=Olvasó
|
||||
Name[ia]=Lector
|
||||
Name[is]=Lesari
|
||||
Name[it]=Lettore
|
||||
Name[kk]=Оқу құралы
|
||||
Name[ko]=리더
|
||||
Name[lt]=Skaitytuvas
|
||||
Name[mr]=वाचक
|
||||
Name[nb]=Leser
|
||||
Name[nds]=Leser
|
||||
Name[nl]=Lezer
|
||||
Name[pa]=ਰੀਡਰ
|
||||
Name[pl]=Czytnik
|
||||
Name[pt]=Leitor
|
||||
Name[pt_BR]=Leitor
|
||||
Name[ro]=Cititor
|
||||
Name[ru]=Просмотрщик
|
||||
Name[sk]=Čítačka
|
||||
Name[sl]=Bralnik
|
||||
Name[sr]=Читач
|
||||
Name[sr@ijekavian]=Читач
|
||||
Name[sr@ijekavianlatin]=Čitač
|
||||
Name[sr@latin]=Čitač
|
||||
Name[sv]=Läsprogram
|
||||
Name[tr]=Okuyucu
|
||||
Name[ug]=ئوقۇغۇ
|
||||
Name[uk]=Переглядач
|
||||
Name[x-test]=xxReaderxx
|
||||
Name[zh_CN]=阅读器
|
||||
Name[zh_TW]=閱讀器
|
||||
GenericName=Document viewer
|
||||
GenericName[ar]=عارض المستندات
|
||||
GenericName[bg]=Преглед на документи
|
||||
GenericName[bs]=Prikazivač dokumenata
|
||||
GenericName[ca]=Visualitzador de documents
|
||||
GenericName[ca@valencia]=Visualitzador de documents
|
||||
GenericName[cs]=Prohlížeč dokumentů
|
||||
GenericName[da]=Dokumentfremviser
|
||||
GenericName[de]=Dokumentenbetrachter
|
||||
GenericName[el]=Προβολέας εγγράφων
|
||||
GenericName[en_GB]=Document Viewer
|
||||
GenericName[es]=Visor de documentos
|
||||
GenericName[et]=Dokumendinäitaja
|
||||
GenericName[fi]=Asiakirjakatselin
|
||||
GenericName[fr]=Afficheur de document
|
||||
GenericName[ga]=Amharcán cáipéisí
|
||||
GenericName[gl]=Visor de documentos
|
||||
GenericName[hu]=Dokumentummegjelenítő
|
||||
GenericName[ia]=Visor de documento
|
||||
GenericName[is]=Skjalaskoðari
|
||||
GenericName[it]=Visore di documenti
|
||||
GenericName[kk]=Құжатты қарау құралы
|
||||
GenericName[ko]=문서 뷰어
|
||||
GenericName[lt]=Dokumentų žiūryklė
|
||||
GenericName[mr]=दस्तऐवज प्रदर्शक
|
||||
GenericName[nb]=Dokumentviser
|
||||
GenericName[nds]=Dokmentkieker
|
||||
GenericName[nl]=Documentenviewer
|
||||
GenericName[pa]=ਡੌਕੂਮੈਂਟ ਦਰਸ਼ਕ
|
||||
GenericName[pl]=Przeglądarka dokumentów
|
||||
GenericName[pt]=Visualizador de documentos
|
||||
GenericName[pt_BR]=Visualizador de documentos
|
||||
GenericName[ro]=Vizualizor de documente
|
||||
GenericName[ru]=Просмотр документов
|
||||
GenericName[sk]=Prehliadač dokumentov
|
||||
GenericName[sl]=Pregledovalnik dokumentov
|
||||
GenericName[sr]=Приказивач докумената
|
||||
GenericName[sr@ijekavian]=Приказивач докумената
|
||||
GenericName[sr@ijekavianlatin]=Prikazivač dokumenata
|
||||
GenericName[sr@latin]=Prikazivač dokumenata
|
||||
GenericName[sv]=Dokumentvisare
|
||||
GenericName[tr]=Belge görüntüleyici
|
||||
GenericName[uk]=Переглядач документів
|
||||
GenericName[x-test]=xxDocument viewerxx
|
||||
GenericName[zh_CN]=文档查看器
|
||||
GenericName[zh_TW]=文件檢視器
|
||||
Comment=Viewer for various types of documents
|
||||
Comment[ar]=عارض للعديد من أنواع المستندات
|
||||
Comment[bg]=Преглед на различни видове документи
|
||||
Comment[bs]=Pregledač raznih vrsta dokumenata
|
||||
Comment[ca]=Visualitzador de diversos tipus de documents
|
||||
Comment[ca@valencia]=Visualitzador de diversos tipus de documents
|
||||
Comment[cs]=Prohlížeč různých typů dokumentů
|
||||
Comment[da]=Fremviser af diverse dokumenttyper
|
||||
Comment[de]=Betrachter für verschiedene Arten von Dokumenten
|
||||
Comment[el]=Πρόγραμμα προβολής για διάφορους τύπους εγγράφων
|
||||
Comment[en_GB]=Viewer for various types of documents
|
||||
Comment[es]=Visor de diversos tipos de documentos
|
||||
Comment[et]=Eri tüüpi dokumentide näitaja
|
||||
Comment[fi]=Monenlaisten asiakirjojen katseluohjelma
|
||||
Comment[fr]=Afficheur pour différents types de documents
|
||||
Comment[ga]=Amharcán le haghaidh cáipéisí éagsúla
|
||||
Comment[gl]=Visor de varios tipos de documentos.
|
||||
Comment[hu]=Megjelenítő különféle típusú dokumentumokhoz
|
||||
Comment[ia]=Visor pro varie typos de documento
|
||||
Comment[is]=Skoðari fyrir ýmsar gerðir skjala
|
||||
Comment[it]=Visore per vari tipi di documenti
|
||||
Comment[kk]=Түрлі құжаттар қарау құралы
|
||||
Comment[ko]=여러 형식의 문서 뷰어
|
||||
Comment[lt]=Žiūryklė įvairiems dokumentų tipams
|
||||
Comment[mr]=विविध प्रकारच्या दस्तऐवजांचा प्रदर्शक
|
||||
Comment[nb]=Framviser for forskjellige dokumenttyper
|
||||
Comment[nds]=Kieker för en Reeg Dokmenttypen
|
||||
Comment[nl]=Viewer voor verschillende typen documenten
|
||||
Comment[pa]=ਕਈ ਕਿਸਮ ਦੇ ਡੌਕੂਮੈਂਟ ਵੇਖਾਉਣ ਲਈ ਦਰਸ਼ਕ
|
||||
Comment[pl]=Przeglądarka dla różnych typów dokumentów
|
||||
Comment[pt]=Visualizador de vários tipos de documentos
|
||||
Comment[pt_BR]=Visualizador para vários tipos de documentos
|
||||
Comment[ro]=Vizualizor pentru diferite tipuri de documente
|
||||
Comment[ru]=Программа для просмотра различных типов документов
|
||||
Comment[sk]=Prehliadač pre rôzne typy dokumentov
|
||||
Comment[sl]=Pregledovalnik raznih vrst dokumentov
|
||||
Comment[sr]=Приказивач различитих врста докумената
|
||||
Comment[sr@ijekavian]=Приказивач различитих врста докумената
|
||||
Comment[sr@ijekavianlatin]=Prikazivač različitih vrsta dokumenata
|
||||
Comment[sr@latin]=Prikazivač različitih vrsta dokumenata
|
||||
Comment[sv]=Visningsprogram för diverse typer av dokument
|
||||
Comment[tr]=Çeşitli belge türü için görüntüleyici
|
||||
Comment[ug]=ھەر خىل تىپتىكى پۈتۈكلەرنى كۆرىدىغان پروگرامما
|
||||
Comment[uk]=Програма для перегляду документів різних типів
|
||||
Comment[x-test]=xxViewer for various types of documentsxx
|
||||
Comment[zh_CN]=可以查看多种文档的工具
|
||||
Comment[zh_TW]=多種型態文件的檢視器
|
||||
|
||||
Exec=active-documentviewer %u
|
||||
Terminal=false
|
||||
Icon=okular
|
||||
Type=Application
|
||||
Categories=Qt;KDE;Graphics;Office;Viewer;
|
||||
InitialPreference=6
|
||||
NoDisplay=true
|
||||
MimeType=application/vnd.kde.okular-archive;
|
|
@ -1,253 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012 Marco Martin <mart@kde.org>
|
||||
*
|
||||
* 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,
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import QtQuick 1.1
|
||||
import org.kde.plasma.components 0.1 as PlasmaComponents
|
||||
import org.kde.plasma.extras 0.1 as PlasmaExtras
|
||||
import org.kde.plasma.core 0.1 as PlasmaCore
|
||||
import org.kde.plasma.mobilecomponents 0.1 as MobileComponents
|
||||
import org.kde.qtextracomponents 0.1
|
||||
import org.kde.okular 0.1 as Okular
|
||||
|
||||
|
||||
MobileComponents.OverlayDrawer {
|
||||
id: resourceBrowser
|
||||
property string currentUdi
|
||||
anchors.fill: parent
|
||||
|
||||
MouseEventListener {
|
||||
id: pageArea
|
||||
anchors.fill: parent
|
||||
//enabled: !delegate.interactive
|
||||
property Item delegate: delegate1
|
||||
property Item oldDelegate: delegate2
|
||||
property bool incrementing: delegate.delta > 0
|
||||
Connections {
|
||||
target: pageArea.delegate
|
||||
onDeltaChanged: {
|
||||
pageArea.oldDelegate.delta = pageArea.delegate.delta
|
||||
if (pageArea.delegate.delta > 0) {
|
||||
pageArea.oldDelegate.visible = true
|
||||
pageArea.oldDelegate.pageNumber = pageArea.delegate.pageNumber + 1
|
||||
documentItem.currentPage = pageArea.oldDelegate.pageNumber
|
||||
pageArea.oldDelegate.visible = !(pageArea.delegate.pageNumber == documentItem.pageCount-1)
|
||||
} else if (pageArea.delegate.delta < 0) {
|
||||
pageArea.oldDelegate.pageNumber = pageArea.delegate.pageNumber - 1
|
||||
documentItem.currentPage = pageArea.oldDelegate.pageNumber
|
||||
|
||||
pageArea.oldDelegate.visible = pageArea.delegate.pageNumber != 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
property int startMouseScreenX
|
||||
property int startMouseScreenY
|
||||
onPressed: {
|
||||
startMouseScreenX = mouse.screenX
|
||||
startMouseScreenY = mouse.screenY
|
||||
}
|
||||
onPositionChanged: {
|
||||
if (Math.abs(mouse.screenX - startMouseScreenX) > width/5) {
|
||||
delegate.pageSwitchEnabled = true
|
||||
}
|
||||
}
|
||||
onReleased: {
|
||||
delegate.pageSwitchEnabled = false
|
||||
if (Math.abs(mouse.screenX - startMouseScreenX) < 20 &&
|
||||
Math.abs(mouse.screenY - startMouseScreenY) < 20) {
|
||||
if (browserFrame.state == "Closed") {
|
||||
browserFrame.state = "Hidden"
|
||||
} else {
|
||||
browserFrame.state = "Closed"
|
||||
}
|
||||
|
||||
} else if (oldDelegate.visible && delegate.delta != 0 &&
|
||||
(Math.abs(mouse.screenX - startMouseScreenX) > width/5) &&
|
||||
Math.abs(mouse.screenX - startMouseScreenX) > Math.abs(mouse.screenY - startMouseScreenY)) {
|
||||
oldDelegate = delegate
|
||||
delegate = (delegate == delegate1) ? delegate2 : delegate1
|
||||
switchAnimation.running = true
|
||||
}
|
||||
}
|
||||
FullScreenDelegate {
|
||||
id: delegate2
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
}
|
||||
FullScreenDelegate {
|
||||
id: delegate1
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
Component.onCompleted: pageNumber = documentItem.currentPage
|
||||
}
|
||||
|
||||
SequentialAnimation {
|
||||
id: switchAnimation
|
||||
NumberAnimation {
|
||||
target: pageArea.oldDelegate
|
||||
properties: "x"
|
||||
to: pageArea.incrementing ? -pageArea.oldDelegate.width : pageArea.oldDelegate.width
|
||||
easing.type: Easing.InQuad
|
||||
duration: 250
|
||||
}
|
||||
ScriptAction {
|
||||
script: {
|
||||
pageArea.oldDelegate.z = 0
|
||||
pageArea.delegate.z = 10
|
||||
pageArea.oldDelegate.x = 0
|
||||
pageArea.delegate.x = 0
|
||||
}
|
||||
}
|
||||
ScriptAction {
|
||||
script: delegate1.delta = delegate2.delta = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
PlasmaComponents.ScrollBar {
|
||||
flickableItem: pageArea.delegate.flickable
|
||||
orientation: Qt.Vertical
|
||||
anchors {
|
||||
right: pageArea.right
|
||||
top: pageArea.top
|
||||
bottom: pageArea.bottom
|
||||
left: undefined
|
||||
}
|
||||
}
|
||||
PlasmaComponents.ScrollBar {
|
||||
flickableItem: pageArea.delegate.flickable
|
||||
orientation: Qt.Horizontal
|
||||
anchors {
|
||||
left: pageArea.left
|
||||
right: pageArea.right
|
||||
bottom: pageArea.bottom
|
||||
top: undefined
|
||||
}
|
||||
}
|
||||
|
||||
drawer: Item {
|
||||
id: browserFrame
|
||||
anchors.fill: parent
|
||||
state: "Hidden"
|
||||
|
||||
|
||||
PlasmaComponents.ToolBar {
|
||||
id: mainToolBar
|
||||
|
||||
y: pageStack.currentPage.contentY <= 0 ? 0 : -height
|
||||
transform: Translate {
|
||||
y: Math.max(0, -pageStack.currentPage.contentY)
|
||||
}
|
||||
tools: pageStack.currentPage.tools
|
||||
Behavior on y {
|
||||
NumberAnimation {
|
||||
duration: 250
|
||||
}
|
||||
}
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PlasmaComponents.PageStack {
|
||||
id: pageStack
|
||||
anchors {
|
||||
left: parent.left
|
||||
top: mainToolBar.bottom
|
||||
right: parent.right
|
||||
bottom: parent.bottom
|
||||
}
|
||||
clip: true
|
||||
toolBar: mainToolBar
|
||||
}
|
||||
|
||||
Connections {
|
||||
id: scrollConnection
|
||||
property int oldContentY:0
|
||||
target: pageStack.currentPage
|
||||
|
||||
onContentYChanged: {
|
||||
|
||||
if (pageStack.currentPage.contentHeight <= pageStack.height ||
|
||||
(scrollConnection.oldContentY < pageStack.currentPage.contentY &&
|
||||
pageStack.currentPage.contentY > 0)) {
|
||||
tabsToolbar.y = tabsToolbar.parent.height - tabsToolbar.height
|
||||
} else {
|
||||
tabsToolbar.y = tabsToolbar.parent.height
|
||||
}
|
||||
scrollConnection.oldContentY = pageStack.currentPage.contentY
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaComponents.ToolBar {
|
||||
id: tabsToolbar
|
||||
y: parent.height
|
||||
anchors {
|
||||
top: undefined
|
||||
bottom: undefined
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
tools: Item {
|
||||
width: parent.width
|
||||
height: childrenRect.height
|
||||
PlasmaComponents.TabBar {
|
||||
id: mainTabBar
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
PlasmaComponents.TabButton {
|
||||
id: thumbnailsButton
|
||||
text: i18n("Thumbnails")
|
||||
onCheckedChanged: {
|
||||
if (checked) {
|
||||
pageStack.replace(Qt.createComponent("Thumbnails.qml"))
|
||||
}
|
||||
}
|
||||
}
|
||||
PlasmaComponents.TabButton {
|
||||
id: tocButton
|
||||
enabled: documentItem.tableOfContents.count > 0
|
||||
text: i18n("Table of contents")
|
||||
onCheckedChanged: {
|
||||
if (checked) {
|
||||
pageStack.replace(Qt.createComponent("TableOfContents.qml"))
|
||||
}
|
||||
}
|
||||
}
|
||||
PlasmaComponents.TabButton {
|
||||
id: bookmarksButton
|
||||
enabled: documentItem.bookmarkedPages.length > 0
|
||||
text: i18n("Bookmarks")
|
||||
onCheckedChanged: {
|
||||
if (checked) {
|
||||
pageStack.replace(Qt.createComponent("Bookmarks.qml"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Behavior on y {
|
||||
NumberAnimation {
|
||||
duration: 250
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,193 +0,0 @@
|
|||
/*
|
||||
* Copyright 2011 Marco Martin <mart@kde.org>
|
||||
*
|
||||
* 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,
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import QtQuick 1.1
|
||||
import org.kde.plasma.core 0.1 as PlasmaCore
|
||||
import org.kde.plasma.extras 0.1 as PlasmaExtra
|
||||
import org.kde.plasma.components 0.1 as PlasmaComponents
|
||||
import org.kde.plasma.mobilecomponents 0.1 as MobileComponents
|
||||
import org.kde.qtextracomponents 0.1
|
||||
import org.kde.okular 0.1 as Okular
|
||||
|
||||
MouseEventListener {
|
||||
id: root
|
||||
//+1: switch to next image on mouse release
|
||||
//-1: switch to previous image on mouse release
|
||||
//0: do nothing
|
||||
property int delta
|
||||
|
||||
|
||||
property Item flickable: mainFlickable
|
||||
property bool pageSwitchEnabled: false
|
||||
property alias document: mainPage.document
|
||||
property alias pageNumber: mainPage.pageNumber
|
||||
property Item pageItem: mainPage
|
||||
|
||||
onWheelMoved: {
|
||||
if (wheel.modifiers == Qt.ControlModifier) {
|
||||
var factor = wheel.delta > 0 ? 1.1 : 0.9
|
||||
if (scale(factor)) {
|
||||
pageArea.oldDelegate.scale(mainPage.width / mainPage.implicitWidth, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function scale(zoom, absolute) {
|
||||
var newScale = absolute ? zoom : (mainPage.width / mainPage.implicitWidth) * zoom;
|
||||
if (newScale < 0.3 || newScale > 3) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (imageMargin.zooming) {
|
||||
// pinch is happening!
|
||||
mainPage.width = imageMargin.startWidth * zoom
|
||||
mainPage.height = imageMargin.startHeight * zoom
|
||||
} else if (absolute) {
|
||||
// we were given an absolute, not a relative, scale
|
||||
mainPage.width = mainPage.implicitWidth * zoom
|
||||
mainPage.height = mainPage.implicitHeight * zoom
|
||||
} else {
|
||||
mainPage.width *= zoom
|
||||
mainPage.height *= zoom
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: backgroundRectangle
|
||||
x: -mainFlickable.contentX + mainPage.x
|
||||
y: 0
|
||||
anchors {
|
||||
top: parent.top
|
||||
bottom: parent.bottom
|
||||
}
|
||||
width: mainPage.width
|
||||
color: "white"
|
||||
|
||||
Image {
|
||||
source: "image://appbackgrounds/shadow-left"
|
||||
fillMode: Image.TileVertically
|
||||
opacity: 0.5
|
||||
anchors {
|
||||
right: parent.left
|
||||
top: parent.top
|
||||
bottom: parent.bottom
|
||||
}
|
||||
}
|
||||
Image {
|
||||
source: "image://appbackgrounds/shadow-right"
|
||||
fillMode: Image.TileVertically
|
||||
opacity: 0.5
|
||||
anchors {
|
||||
left: parent.right
|
||||
top: parent.top
|
||||
bottom: parent.bottom
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Flickable {
|
||||
id: mainFlickable
|
||||
property real ratio : width / height
|
||||
anchors.fill: parent
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
contentWidth: imageMargin.width
|
||||
contentHeight: imageMargin.height
|
||||
|
||||
onContentXChanged: {
|
||||
if (atXBeginning && contentX < 0) {
|
||||
root.delta = -1
|
||||
} else if (atXEnd) {
|
||||
root.delta = +1
|
||||
} else {
|
||||
root.delta = 0
|
||||
}
|
||||
}
|
||||
|
||||
PinchArea {
|
||||
id: imageMargin
|
||||
width: Math.max(mainFlickable.width + (pageSwitchEnabled ? 1: 0), mainPage.width)
|
||||
height: Math.max(mainFlickable.height, mainPage.height)
|
||||
|
||||
property real startWidth
|
||||
property real startHeight
|
||||
property real startY
|
||||
property real startX
|
||||
property bool zooming: false
|
||||
onPinchStarted: {
|
||||
startWidth = mainPage.width
|
||||
startHeight = mainPage.height
|
||||
zooming = true
|
||||
startY = pinch.center.y
|
||||
startX = pinch.center.x
|
||||
pageArea.oldDelegate.visible = false
|
||||
}
|
||||
onPinchUpdated: {
|
||||
var deltaWidth = mainPage.width < imageMargin.width ? ((startWidth * pinch.scale) - mainPage.width) : 0
|
||||
var deltaHeight = mainPage.height < imageMargin.height ? ((startHeight * pinch.scale) - mainPage.height) : 0
|
||||
if (root.scale(pinch.scale)) {
|
||||
mainFlickable.contentY += pinch.previousCenter.y - pinch.center.y + startY * (pinch.scale - pinch.previousScale) - deltaHeight
|
||||
mainFlickable.contentX += pinch.previousCenter.x - pinch.center.x + startX * (pinch.scale - pinch.previousScale) - deltaWidth
|
||||
}
|
||||
}
|
||||
onPinchFinished: {
|
||||
mainFlickable.returnToBounds()
|
||||
pageArea.oldDelegate.scale(mainPage.width / mainPage.implicitWidth)
|
||||
pageArea.oldDelegate.visible = true
|
||||
zooming = false
|
||||
}
|
||||
|
||||
Okular.PageItem {
|
||||
id: mainPage
|
||||
document: documentItem
|
||||
flickable: mainFlickable
|
||||
property real ratio: implicitWidth / implicitHeight
|
||||
|
||||
x: Math.round((parent.width - width) / 2)
|
||||
y: Math.round((parent.height - height) / 2)
|
||||
width: implicitWidth
|
||||
height: implicitHeight
|
||||
}
|
||||
}
|
||||
}
|
||||
Image {
|
||||
source: "bookmark.png"
|
||||
anchors {
|
||||
top: parent.top
|
||||
right: backgroundRectangle.right
|
||||
rightMargin: -5
|
||||
topMargin: mainPage.bookmarked ? -30 : -120
|
||||
}
|
||||
Behavior on anchors.topMargin {
|
||||
NumberAnimation {
|
||||
duration: 250
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors {
|
||||
fill: parent
|
||||
margins: -8
|
||||
}
|
||||
onClicked: mainPage.bookmarked = !mainPage.bookmarked
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 3.8 KiB |
Binary file not shown.
|
@ -1,61 +0,0 @@
|
|||
[Desktop Entry]
|
||||
Name=Document viewer
|
||||
Name[ar]=عارض المستندات
|
||||
Name[bg]=Преглед на документи
|
||||
Name[bs]=Prikazivač dokumenata
|
||||
Name[ca]=Visualitzador de documents
|
||||
Name[ca@valencia]=Visualitzador de documents
|
||||
Name[cs]=Prohlížeč dokumentů
|
||||
Name[da]=Dokumentfremviser
|
||||
Name[de]=Dokumentenbetrachter
|
||||
Name[el]=Προβολέας εγγράφων
|
||||
Name[en_GB]=Document viewer
|
||||
Name[es]=Visor de documentos
|
||||
Name[et]=Dokumendinäitaja
|
||||
Name[fi]=Asiakirjakatselin
|
||||
Name[fr]=Afficheur de documents
|
||||
Name[ga]=Amharcán cáipéisí
|
||||
Name[gl]=Visor de documentos
|
||||
Name[hu]=Dokumentummegjelenítő
|
||||
Name[ia]=Visor de documento
|
||||
Name[is]=Skjalaskoðari
|
||||
Name[it]=Visore di documenti
|
||||
Name[kk]=Құжатты қарау құралы
|
||||
Name[ko]=문서 뷰어
|
||||
Name[lt]=Dokumentų žiūryklė
|
||||
Name[mr]=दस्तऐवज प्रदर्शक
|
||||
Name[nb]=Dokumentviser
|
||||
Name[nds]=Dokmentkieker
|
||||
Name[nl]=Documentenviewer
|
||||
Name[pa]=ਡੌਕੂਮੈਂਟ ਦਰਸ਼ਕ
|
||||
Name[pl]=Przeglądarka dokumentów
|
||||
Name[pt]=Visualizador de documentos
|
||||
Name[pt_BR]=Visualizador de documentos
|
||||
Name[ro]=Vizualizor de documente
|
||||
Name[ru]=Просмотр документов
|
||||
Name[sk]=Prehliadač dokumentov
|
||||
Name[sl]=Pregledovalnik dokumentov
|
||||
Name[sr]=Приказивач докумената
|
||||
Name[sr@ijekavian]=Приказивач докумената
|
||||
Name[sr@ijekavianlatin]=Prikazivač dokumenata
|
||||
Name[sr@latin]=Prikazivač dokumenata
|
||||
Name[sv]=Dokumentvisare
|
||||
Name[tr]=Belge görüntüleyici
|
||||
Name[uk]=Переглядач документів
|
||||
Name[x-test]=xxDocument viewerxx
|
||||
Name[zh_CN]=文档查看器
|
||||
Name[zh_TW]=文件檢視器
|
||||
Encoding=UTF-8
|
||||
Type=Service
|
||||
Icon=okular
|
||||
X-KDE-ParentApp=
|
||||
X-KDE-PluginInfo-Author=Marco Martin
|
||||
X-KDE-PluginInfo-Email=mart@kde.org
|
||||
X-KDE-PluginInfo-Name=org.kde.active.documentviewer
|
||||
X-KDE-PluginInfo-Version=1.0
|
||||
X-KDE-PluginInfo-Website=http://kde.org
|
||||
X-KDE-PluginInfo-Category=Office
|
||||
X-KDE-PluginInfo-Depends=
|
||||
X-KDE-PluginInfo-License=GPL
|
||||
X-KDE-PluginInfo-EnabledByDefault=true
|
||||
X-Plasma-MainScript=ui/main.qml
|
|
@ -1,21 +0,0 @@
|
|||
|
||||
set(active-documentviewer_SRCS
|
||||
main.cpp
|
||||
)
|
||||
|
||||
kde4_add_executable(active-documentviewer ${active-documentviewer_SRCS})
|
||||
|
||||
find_package(ActiveApp REQUIRED)
|
||||
|
||||
include_directories( ${KDE4_INCLUDES} ${QT_INCLUDES} ${ACTIVEAPP_INCLUDE_DIR})
|
||||
|
||||
target_link_libraries(active-documentviewer
|
||||
${QT_QTDECLARATIVE_LIBRARY}
|
||||
${QT_QTOPENGL_LIBRARY}
|
||||
${KDE4_KDEUI_LIBS}
|
||||
${KDE4_PLASMA_LIBS}
|
||||
${ACTIVEAPP_LIBRARIES}
|
||||
)
|
||||
|
||||
install(TARGETS active-documentviewer ${INSTALL_TARGETS_DEFAULT_ARGS} )
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
/***************************************************************************
|
||||
* *
|
||||
* Copyright 2011 Sebastian Kügler <sebas@kde.org> *
|
||||
* Copyright 2012 Marco Martin <mart@kde.org> *
|
||||
* *
|
||||
* 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 . *
|
||||
***************************************************************************/
|
||||
|
||||
// KDE
|
||||
#include <KApplication>
|
||||
#include <KAboutData>
|
||||
#include <KCmdLineArgs>
|
||||
#include <KDebug>
|
||||
#include <KDE/KLocale>
|
||||
#include <KConfigGroup>
|
||||
|
||||
#include "kdeclarativemainwindow.h"
|
||||
#include "kdeclarativeview.h"
|
||||
|
||||
static const char description[] = I18N_NOOP("Document viewer for Plasma Active using Okular");
|
||||
|
||||
static const char version[] = "0.1";
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
KAboutData about("active-documentviewer", 0, ki18n("Reader"), version, ki18n(description),
|
||||
KAboutData::License_GPL, ki18n("Copyright 2012 Marco Martin"), KLocalizedString(), 0, "mart@kde.org");
|
||||
about.addAuthor( ki18n("Marco Martin"), KLocalizedString(), "mart@kde.org" );
|
||||
about.setProgramIconName("okular");
|
||||
|
||||
KCmdLineArgs::init(argc, argv, &about);
|
||||
|
||||
KCmdLineOptions options;
|
||||
options.add("+[url]", ki18n( "URL of the file to open" ));
|
||||
|
||||
KCmdLineArgs::addCmdLineOptions(options);
|
||||
KApplication app;
|
||||
|
||||
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
|
||||
|
||||
KGlobal::locale()->insertCatalog("org.kde.okular");
|
||||
//kDebug() << "ARGS:" << args << args->count();
|
||||
|
||||
KDeclarativeMainWindow *mainWindow = new KDeclarativeMainWindow();
|
||||
mainWindow->declarativeView()->setPackageName("org.kde.active.documentviewer");
|
||||
mainWindow->show();
|
||||
args->clear();
|
||||
return app.exec();
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
project(okular)
|
||||
|
||||
add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_BINARY_DIR}
|
||||
${KDE4_INCLUDES}
|
||||
${QIMAGEBLITZ_INCLUDES}
|
||||
)
|
||||
|
||||
set(okular_SRCS
|
||||
okularplugin.cpp
|
||||
${CMAKE_SOURCE_DIR}/ui/pagepainter.cpp
|
||||
${CMAKE_SOURCE_DIR}/ui/guiutils.cpp
|
||||
${CMAKE_SOURCE_DIR}/ui/tocmodel.cpp
|
||||
pageitem.cpp
|
||||
documentitem.cpp
|
||||
thumbnailitem.cpp
|
||||
)
|
||||
|
||||
kde4_add_kcfg_files(okular_SRCS ${CMAKE_SOURCE_DIR}/conf/settings.kcfgc )
|
||||
|
||||
qt4_automoc(${okular_SRCS})
|
||||
|
||||
kde4_add_library(okularplugin SHARED ${okular_SRCS})
|
||||
target_link_libraries(okularplugin
|
||||
${QT_QTCORE_LIBRARY}
|
||||
${QT_QTGUI_LIBRARY}
|
||||
${QT_QTDECLARATIVE_LIBRARY}
|
||||
${QT_QTXML_LIBRARY}
|
||||
${KDE4_KDECORE_LIBRARY}
|
||||
${KDE4_KDEUI_LIBRARY}
|
||||
${KDE4_KIO_LIBRARY}
|
||||
${QIMAGEBLITZ_LIBRARIES}
|
||||
okularcore
|
||||
)
|
||||
|
||||
install(TARGETS okularplugin DESTINATION ${IMPORTS_INSTALL_DIR}/org/kde/okular)
|
||||
install(FILES qmldir DESTINATION ${IMPORTS_INSTALL_DIR}/org/kde/okular)
|
||||
|
||||
#add_subdirectory(test)
|
|
@ -1,2 +0,0 @@
|
|||
plugin okularplugin
|
||||
|
72
autotests/CMakeLists.txt
Normal file
72
autotests/CMakeLists.txt
Normal file
|
@ -0,0 +1,72 @@
|
|||
add_definitions( -DKDESRCDIR="${CMAKE_CURRENT_SOURCE_DIR}/" )
|
||||
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}/..)
|
||||
|
||||
ecm_add_test(shelltest.cpp ../shell/shellutils.cpp
|
||||
TEST_NAME "shelltest"
|
||||
LINK_LIBRARIES Qt5::Test okularcore
|
||||
)
|
||||
|
||||
ecm_add_test(parttest.cpp
|
||||
TEST_NAME "parttest"
|
||||
LINK_LIBRARIES Qt5::Widgets Qt5::Test Qt5::Xml okularcore okularpart
|
||||
)
|
||||
|
||||
ecm_add_test(documenttest.cpp
|
||||
TEST_NAME "documenttest"
|
||||
LINK_LIBRARIES Qt5::Widgets Qt5::Test Qt5::Xml okularcore KF5::ThreadWeaver
|
||||
)
|
||||
|
||||
ecm_add_test(searchtest.cpp
|
||||
TEST_NAME "searchtest"
|
||||
LINK_LIBRARIES Qt5::Widgets Qt5::Test Qt5::Xml okularcore
|
||||
)
|
||||
|
||||
ecm_add_test(annotationstest.cpp
|
||||
TEST_NAME "annotationstest"
|
||||
LINK_LIBRARIES Qt5::Widgets Qt5::Test Qt5::Xml okularcore
|
||||
)
|
||||
|
||||
ecm_add_test(urldetecttest.cpp
|
||||
TEST_NAME "urldetecttest"
|
||||
LINK_LIBRARIES Qt5::Widgets Qt5::Test Qt5::Xml KF5::CoreAddons
|
||||
)
|
||||
|
||||
ecm_add_test(editannotationcontentstest.cpp testingutils.cpp
|
||||
TEST_NAME "editannotationcontentstest"
|
||||
LINK_LIBRARIES Qt5::Widgets Qt5::Test Qt5::Xml okularcore
|
||||
)
|
||||
|
||||
ecm_add_test(addremoveannotationtest.cpp testingutils.cpp
|
||||
TEST_NAME "addremoveannotationtest"
|
||||
LINK_LIBRARIES Qt5::Widgets Qt5::Test Qt5::Xml okularcore
|
||||
)
|
||||
|
||||
ecm_add_test(translateannotationtest.cpp testingutils.cpp
|
||||
TEST_NAME "translateannotationtest"
|
||||
LINK_LIBRARIES Qt5::Widgets Qt5::Test Qt5::Xml okularcore
|
||||
)
|
||||
|
||||
ecm_add_test(modifyannotationpropertiestest.cpp testingutils.cpp
|
||||
TEST_NAME "modifyannotationpropertiestest"
|
||||
LINK_LIBRARIES Qt5::Widgets Qt5::Test okularcore
|
||||
)
|
||||
|
||||
ecm_add_test(editformstest.cpp
|
||||
TEST_NAME "editformstest"
|
||||
LINK_LIBRARIES Qt5::Widgets Qt5::Test okularcore
|
||||
)
|
||||
|
||||
if(NOT WIN32)
|
||||
ecm_add_test(mainshelltest.cpp ../shell/okular_main.cpp ../shell/shellutils.cpp ../shell/shell.cpp
|
||||
TEST_NAME "mainshelltest"
|
||||
LINK_LIBRARIES Qt5::Test KF5::Activities okularpart okularcore
|
||||
)
|
||||
target_compile_definitions(mainshelltest PRIVATE OKULAR_BINARY="$<TARGET_FILE:okular>")
|
||||
endif()
|
||||
|
||||
ecm_add_test(generatorstest.cpp
|
||||
TEST_NAME "generatorstest"
|
||||
LINK_LIBRARIES Qt5::Test KF5::CoreAddons okularcore
|
||||
)
|
||||
target_compile_definitions(generatorstest PRIVATE GENERATORS_BUILD_DIR="${CMAKE_BINARY_DIR}/generators")
|
|
@ -7,7 +7,7 @@
|
|||
* (at your option) any later version. *
|
||||
***************************************************************************/
|
||||
|
||||
#include <qtest_kde.h>
|
||||
#include <QtTest>
|
||||
|
||||
#include "../core/document.h"
|
||||
#include "../core/page.h"
|
||||
|
@ -33,15 +33,16 @@ private:
|
|||
|
||||
void AddRemoveAnnotationTest::initTestCase()
|
||||
{
|
||||
Okular::SettingsCore::instance( "addannotationtest" );
|
||||
m_document = new Okular::Document( 0 );
|
||||
Okular::SettingsCore::instance( QStringLiteral("addannotationtest") );
|
||||
m_document = new Okular::Document( nullptr );
|
||||
}
|
||||
|
||||
void AddRemoveAnnotationTest::init()
|
||||
{
|
||||
const QString testFile = KDESRCDIR "data/file1.pdf";
|
||||
const KMimeType::Ptr mime = KMimeType::findByPath( testFile );
|
||||
m_document->openDocument(testFile, KUrl(), mime);
|
||||
const QString testFile = QStringLiteral(KDESRCDIR "data/file1.pdf");
|
||||
QMimeDatabase db;
|
||||
const QMimeType mime = db.mimeTypeForFile( testFile );
|
||||
QCOMPARE( m_document->openDocument(testFile, QUrl(), mime), Okular::Document::OpenSuccess );
|
||||
}
|
||||
|
||||
void AddRemoveAnnotationTest::cleanup()
|
||||
|
@ -58,11 +59,11 @@ void AddRemoveAnnotationTest::testAddAnnotations()
|
|||
// Create two distinct text annotations
|
||||
Okular::Annotation *annot1 = new Okular::TextAnnotation();
|
||||
annot1->setBoundingRectangle( Okular::NormalizedRect( 0.1, 0.1, 0.15, 0.15 ) );
|
||||
annot1->setContents( "annot contents" );
|
||||
annot1->setContents( QStringLiteral("annot contents") );
|
||||
|
||||
Okular::Annotation *annot2 = new Okular::TextAnnotation();
|
||||
annot2->setBoundingRectangle( Okular::NormalizedRect( 0.2, 0.2, 0.3, 0.4 ) );
|
||||
annot2->setContents( "annot contents" );
|
||||
annot2->setContents( QStringLiteral("annot contents") );
|
||||
|
||||
// The two annotations shold have different properties XML strings
|
||||
QVERIFY( TestingUtils::getAnnotationXml( annot1 ) != TestingUtils::getAnnotationXml( annot2 ) );
|
||||
|
@ -122,7 +123,7 @@ void AddRemoveAnnotationTest::testAddAnnotationUndoWithRotate_Bug318091()
|
|||
{
|
||||
Okular::Annotation *annot = new Okular::TextAnnotation();
|
||||
annot->setBoundingRectangle( Okular::NormalizedRect( 0.1, 0.1, 0.15, 0.15 ) );
|
||||
annot->setContents( "annot contents" );
|
||||
annot->setContents( QStringLiteral("annot contents") );
|
||||
|
||||
m_document->addPageAnnotation( 0, annot );
|
||||
QString origAnnotXml = TestingUtils::getAnnotationXml( annot );
|
||||
|
@ -148,11 +149,11 @@ void AddRemoveAnnotationTest::testRemoveAnnotations()
|
|||
// Create two distinct text annotations
|
||||
Okular::Annotation *annot1 = new Okular::TextAnnotation();
|
||||
annot1->setBoundingRectangle( Okular::NormalizedRect( 0.1, 0.1, 0.15, 0.15 ) );
|
||||
annot1->setContents( "annot contents" );
|
||||
annot1->setContents( QStringLiteral("annot contents") );
|
||||
|
||||
Okular::Annotation *annot2 = new Okular::TextAnnotation();
|
||||
annot2->setBoundingRectangle( Okular::NormalizedRect( 0.2, 0.2, 0.3, 0.4 ) );
|
||||
annot2->setContents( "annot contents" );
|
||||
annot2->setContents( QStringLiteral("annot contents") );
|
||||
|
||||
// Add annot1 and annot2 to document
|
||||
m_document->addPageAnnotation( 0, annot1 );
|
||||
|
@ -186,5 +187,5 @@ void AddRemoveAnnotationTest::testRemoveAnnotations()
|
|||
QVERIFY( TestingUtils::AnnotationDisposeWatcher::disposedAnnotationName() == annot1Name );
|
||||
}
|
||||
|
||||
QTEST_KDEMAIN( AddRemoveAnnotationTest, GUI )
|
||||
QTEST_MAIN( AddRemoveAnnotationTest )
|
||||
#include "addremoveannotationtest.moc"
|
|
@ -7,7 +7,7 @@
|
|||
* (at your option) any later version. *
|
||||
***************************************************************************/
|
||||
|
||||
#include <qtest_kde.h>
|
||||
#include <QtTest>
|
||||
|
||||
#include "../core/document.h"
|
||||
#include "../core/page.h"
|
||||
|
@ -38,17 +38,19 @@ private:
|
|||
|
||||
void AnnotationTest::initTestCase()
|
||||
{
|
||||
Okular::SettingsCore::instance( "annotationtest" );
|
||||
m_document = new Okular::Document( 0 );
|
||||
const QString testFile = KDESRCDIR "data/file1.pdf";
|
||||
const KMimeType::Ptr mime = KMimeType::findByPath( testFile );
|
||||
m_document->openDocument(testFile, KUrl(), mime);
|
||||
Okular::SettingsCore::instance( QStringLiteral("annotationtest") );
|
||||
m_document = new Okular::Document( nullptr );
|
||||
const QString testFile = QStringLiteral(KDESRCDIR "data/file1.pdf");
|
||||
QMimeDatabase db;
|
||||
const QMimeType mime = db.mimeTypeForFile( testFile );
|
||||
QCOMPARE( m_document->openDocument(testFile, QUrl(), mime), Okular::Document::OpenSuccess );
|
||||
}
|
||||
|
||||
void AnnotationTest::cleanupTestCase()
|
||||
{
|
||||
foreach ( Okular::Annotation* annotation, m_document->page( 0 )->annotations() )
|
||||
m_document->removePageAnnotation( 0, annotation );
|
||||
if ( m_document->isOpened() )
|
||||
foreach ( Okular::Annotation* annotation, m_document->page( 0 )->annotations() )
|
||||
m_document->removePageAnnotation( 0, annotation );
|
||||
}
|
||||
|
||||
|
||||
|
@ -139,6 +141,5 @@ void AnnotationTest::testDistance_data()
|
|||
}
|
||||
|
||||
|
||||
QTEST_KDEMAIN( AnnotationTest, GUI )
|
||||
|
||||
QTEST_MAIN( AnnotationTest )
|
||||
#include "annotationstest.moc"
|
BIN
autotests/data/file2.pdf
Normal file
BIN
autotests/data/file2.pdf
Normal file
Binary file not shown.
|
@ -7,9 +7,9 @@
|
|||
* (at your option) any later version. *
|
||||
***************************************************************************/
|
||||
|
||||
#include <qtest_kde.h>
|
||||
#include <QtTest>
|
||||
|
||||
#include <threadweaver/ThreadWeaver.h>
|
||||
#include <threadweaver/queue.h>
|
||||
|
||||
#include "../core/annotations.h"
|
||||
#include "../core/document.h"
|
||||
|
@ -34,19 +34,20 @@ class DocumentTest
|
|||
// is enqueued/running
|
||||
void DocumentTest::testCloseDuringRotationJob()
|
||||
{
|
||||
Okular::SettingsCore::instance( "documenttest" );
|
||||
Okular::Document *m_document = new Okular::Document( 0 );
|
||||
const QString testFile = KDESRCDIR "data/file1.pdf";
|
||||
const KMimeType::Ptr mime = KMimeType::findByPath( testFile );
|
||||
Okular::SettingsCore::instance( QStringLiteral("documenttest") );
|
||||
Okular::Document *m_document = new Okular::Document( nullptr );
|
||||
const QString testFile = QStringLiteral(KDESRCDIR "data/file1.pdf");
|
||||
QMimeDatabase db;
|
||||
const QMimeType mime = db.mimeTypeForFile( testFile );
|
||||
|
||||
Okular::DocumentObserver *dummyDocumentObserver = new Okular::DocumentObserver();
|
||||
m_document->addObserver( dummyDocumentObserver );
|
||||
|
||||
m_document->openDocument( testFile, KUrl(), mime );
|
||||
m_document->openDocument( testFile, QUrl(), mime );
|
||||
m_document->setRotation( 1 );
|
||||
|
||||
// Tell ThreadWeaver not to start any new job
|
||||
ThreadWeaver::Weaver::instance()->suspend();
|
||||
ThreadWeaver::Queue::instance()->suspend();
|
||||
|
||||
// Request a pixmap. A RotationJob will be enqueued but not started
|
||||
Okular::PixmapRequest *pixmapReq = new Okular::PixmapRequest(
|
||||
|
@ -57,8 +58,8 @@ void DocumentTest::testCloseDuringRotationJob()
|
|||
delete m_document;
|
||||
|
||||
// Resume job processing and wait for the RotationJob to finish
|
||||
ThreadWeaver::Weaver::instance()->resume();
|
||||
ThreadWeaver::Weaver::instance()->finish();
|
||||
ThreadWeaver::Queue::instance()->resume();
|
||||
ThreadWeaver::Queue::instance()->finish();
|
||||
qApp->processEvents();
|
||||
}
|
||||
|
||||
|
@ -69,7 +70,7 @@ void DocumentTest::testDocdataMigration()
|
|||
{
|
||||
Okular::SettingsCore::instance( "documenttest" );
|
||||
|
||||
const KUrl testFileUrl("file://" KDESRCDIR "data/file1.pdf");
|
||||
const QUrl testFileUrl = QUrl::fromLocalFile(KDESRCDIR "data/file1.pdf");
|
||||
const QString testFilePath = testFileUrl.toLocalFile();
|
||||
const qint64 testFileSize = QFileInfo(testFilePath).size();
|
||||
|
||||
|
@ -80,7 +81,8 @@ void DocumentTest::testDocdataMigration()
|
|||
|
||||
// Open our document
|
||||
Okular::Document *m_document = new Okular::Document( 0 );
|
||||
const KMimeType::Ptr mime = KMimeType::findByPath( testFilePath );
|
||||
QMimeDatabase db;
|
||||
const QMimeType mime = db.mimeTypeForFile( testFilePath );
|
||||
QCOMPARE( m_document->openDocument( testFilePath, testFileUrl, mime ), Okular::Document::OpenSuccess );
|
||||
|
||||
// Check that the annotation from file1-docdata.xml was loaded
|
||||
|
@ -110,5 +112,5 @@ void DocumentTest::testDocdataMigration()
|
|||
m_document->closeDocument();
|
||||
}
|
||||
|
||||
QTEST_KDEMAIN( DocumentTest, GUI )
|
||||
QTEST_MAIN( DocumentTest )
|
||||
#include "documenttest.moc"
|
|
@ -7,8 +7,10 @@
|
|||
* (at your option) any later version. *
|
||||
***************************************************************************/
|
||||
|
||||
#include <qtest_kde.h>
|
||||
#include <kmimetype.h>
|
||||
#include <QtTest>
|
||||
|
||||
#include <QMimeType>
|
||||
#include <QMimeDatabase>
|
||||
#include "../settings_core.h"
|
||||
#include "core/annotations.h"
|
||||
#include "core/document.h"
|
||||
|
@ -73,8 +75,8 @@ MockEditor::MockEditor( Okular::Annotation *annot, Okular::Document *doc )
|
|||
{
|
||||
m_annot = annot;
|
||||
m_document = doc;
|
||||
connect( m_document, SIGNAL(annotationContentsChangedByUndoRedo(Okular::Annotation*,QString,int,int)),
|
||||
this, SLOT(slotAnnotationContentsChangedByUndoRedo(Okular::Annotation*,QString,int,int)));
|
||||
connect( m_document, &Okular::Document::annotationContentsChangedByUndoRedo,
|
||||
this, &MockEditor::slotAnnotationContentsChangedByUndoRedo);
|
||||
m_cursorPos = 0;
|
||||
m_anchorPos = 0;
|
||||
m_contents = annot->contents();
|
||||
|
@ -92,8 +94,8 @@ void MockEditor::slotAnnotationContentsChangedByUndoRedo(Okular::Annotation* ann
|
|||
|
||||
void EditAnnotationContentsTest::initTestCase()
|
||||
{
|
||||
Okular::SettingsCore::instance( "editannotationcontentstest" );
|
||||
m_document = new Okular::Document( 0 );
|
||||
Okular::SettingsCore::instance( QStringLiteral("editannotationcontentstest") );
|
||||
m_document = new Okular::Document( nullptr );
|
||||
}
|
||||
|
||||
void EditAnnotationContentsTest::cleanupTestCase()
|
||||
|
@ -103,9 +105,10 @@ void EditAnnotationContentsTest::cleanupTestCase()
|
|||
|
||||
void EditAnnotationContentsTest::init()
|
||||
{
|
||||
const QString testFile = KDESRCDIR "data/file1.pdf";
|
||||
const KMimeType::Ptr mime = KMimeType::findByPath( testFile );
|
||||
m_document->openDocument(testFile, KUrl(), mime);
|
||||
const QString testFile = QStringLiteral(KDESRCDIR "data/file1.pdf");
|
||||
QMimeDatabase db;
|
||||
const QMimeType mime = db.mimeTypeForFile( testFile );
|
||||
QCOMPARE( m_document->openDocument(testFile, QUrl(), mime), Okular::Document::OpenSuccess );
|
||||
|
||||
// Undo and Redo should be unavailable when docuemnt is first opened.
|
||||
QVERIFY( !m_document->canUndo() );
|
||||
|
@ -114,12 +117,12 @@ void EditAnnotationContentsTest::init()
|
|||
// Create two distinct text annotations
|
||||
m_annot1 = new Okular::TextAnnotation();
|
||||
m_annot1->setBoundingRectangle( Okular::NormalizedRect( 0.1, 0.1, 0.15, 0.15 ) );
|
||||
m_annot1->setContents( QString( "Hello, World" ) );
|
||||
m_annot1->setContents( QStringLiteral( "Hello, World" ) );
|
||||
m_document->addPageAnnotation( 0, m_annot1 );
|
||||
|
||||
m_annot2 = new Okular::TextAnnotation();
|
||||
m_annot2->setBoundingRectangle( Okular::NormalizedRect( 0.1, 0.1, 0.15, 0.15 ) );
|
||||
m_annot2->setContents( QString( "Hello, World" ) );
|
||||
m_annot2->setContents( QStringLiteral( "Hello, World" ) );
|
||||
m_document->addPageAnnotation( 0, m_annot2 );
|
||||
|
||||
// setup editors
|
||||
|
@ -138,48 +141,48 @@ void EditAnnotationContentsTest::cleanup()
|
|||
void EditAnnotationContentsTest::testConsecutiveCharBackspacesMerged()
|
||||
{
|
||||
// Hello, World| -> Hello, Worl|
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "Hello, Worl" ), 11, 12, 12 );
|
||||
QCOMPARE( QString( "Hello, Worl" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "Hello, Worl" ), 11, 12, 12 );
|
||||
QCOMPARE( QStringLiteral( "Hello, Worl" ), m_annot1->contents() );
|
||||
|
||||
// Hello, Worl| -> Hello, Wor|
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "Hello, Wor" ), 10, 11, 11 );
|
||||
QCOMPARE( QString( "Hello, Wor" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "Hello, Wor" ), 10, 11, 11 );
|
||||
QCOMPARE( QStringLiteral( "Hello, Wor" ), m_annot1->contents() );
|
||||
|
||||
// undo and verify that consecutive backspace operations are merged together
|
||||
m_document->undo();
|
||||
QCOMPARE( QString( "Hello, World" ), m_annot1->contents() );
|
||||
QCOMPARE( QString( "Hello, World" ), m_editor1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, World" ), m_annot1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, World" ), m_editor1->contents() );
|
||||
QCOMPARE( 12, m_editor1->cursorPos() );
|
||||
QCOMPARE( 12, m_editor1->anchorPos() );
|
||||
|
||||
m_document->redo();
|
||||
QCOMPARE( QString( "Hello, Wor" ), m_annot1->contents() );
|
||||
QCOMPARE( QString( "Hello, Wor" ), m_editor1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, Wor" ), m_annot1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, Wor" ), m_editor1->contents() );
|
||||
QCOMPARE( 10, m_editor1->cursorPos() );
|
||||
QCOMPARE( 10, m_editor1->anchorPos() );
|
||||
|
||||
// Hello, Wor| -> Hello, Wo|
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "Hello, Wo" ), 9, 10, 10 );
|
||||
QCOMPARE( QString( "Hello, Wo" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "Hello, Wo" ), 9, 10, 10 );
|
||||
QCOMPARE( QStringLiteral( "Hello, Wo" ), m_annot1->contents() );
|
||||
|
||||
// Hello, Wo| -> Hello, W|
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "Hello, W" ), 8, 9, 9 );
|
||||
QCOMPARE( QString( "Hello, W" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "Hello, W" ), 8, 9, 9 );
|
||||
QCOMPARE( QStringLiteral( "Hello, W" ), m_annot1->contents() );
|
||||
|
||||
// Hello, W| -> Hello, |
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "Hello, " ), 7, 8, 8 );
|
||||
QCOMPARE( QString( "Hello, " ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "Hello, " ), 7, 8, 8 );
|
||||
QCOMPARE( QStringLiteral( "Hello, " ), m_annot1->contents() );
|
||||
|
||||
// undo and verify that consecutive backspace operations are merged together
|
||||
m_document->undo();
|
||||
QCOMPARE( QString( "Hello, World" ), m_annot1->contents() );
|
||||
QCOMPARE( QString( "Hello, World" ), m_editor1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, World" ), m_annot1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, World" ), m_editor1->contents() );
|
||||
QCOMPARE( 12, m_editor1->cursorPos() );
|
||||
QCOMPARE( 12, m_editor1->anchorPos() );
|
||||
|
||||
m_document->redo();
|
||||
QCOMPARE( QString( "Hello, " ), m_annot1->contents() );
|
||||
QCOMPARE( QString( "Hello, " ), m_editor1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, " ), m_annot1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, " ), m_editor1->contents() );
|
||||
QCOMPARE( 7, m_editor1->cursorPos() );
|
||||
QCOMPARE( 7, m_editor1->anchorPos() );
|
||||
}
|
||||
|
@ -187,42 +190,42 @@ void EditAnnotationContentsTest::testConsecutiveCharBackspacesMerged()
|
|||
void EditAnnotationContentsTest::testConsecutiveNewlineBackspacesNotMerged()
|
||||
{
|
||||
// Set contents to Hello, \n\n|World
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "Hello, \n\nWorld" ), 0, 0, 0 );
|
||||
QCOMPARE( QString( "Hello, \n\nWorld" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "Hello, \n\nWorld" ), 0, 0, 0 );
|
||||
QCOMPARE( QStringLiteral( "Hello, \n\nWorld" ), m_annot1->contents() );
|
||||
|
||||
// Hello, \n\n|World -> Hello, \n|World
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "Hello, \nWorld" ), 8, 9, 9 );
|
||||
QCOMPARE( QString( "Hello, \nWorld" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "Hello, \nWorld" ), 8, 9, 9 );
|
||||
QCOMPARE( QStringLiteral( "Hello, \nWorld" ), m_annot1->contents() );
|
||||
|
||||
// Hello, \n|World -> Hello, |World
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "Hello, World" ), 7, 8, 8 );
|
||||
QCOMPARE( QString( "Hello, World" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "Hello, World" ), 7, 8, 8 );
|
||||
QCOMPARE( QStringLiteral( "Hello, World" ), m_annot1->contents() );
|
||||
|
||||
// Hello, |World -> Hello,|World
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "Hello,World" ), 6, 7, 7 );
|
||||
QCOMPARE( QString( "Hello,World" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "Hello,World" ), 6, 7, 7 );
|
||||
QCOMPARE( QStringLiteral( "Hello,World" ), m_annot1->contents() );
|
||||
|
||||
// Hello,|World -> Hello|World
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "HelloWorld" ), 5, 6, 6 );
|
||||
QCOMPARE( QString( "HelloWorld" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "HelloWorld" ), 5, 6, 6 );
|
||||
QCOMPARE( QStringLiteral( "HelloWorld" ), m_annot1->contents() );
|
||||
|
||||
// Backspace operations of non-newline characters should be merged
|
||||
m_document->undo();
|
||||
QCOMPARE( QString( "Hello, World" ), m_annot1->contents() );
|
||||
QCOMPARE( QString( "Hello, World" ), m_editor1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, World" ), m_annot1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, World" ), m_editor1->contents() );
|
||||
QCOMPARE( 7, m_editor1->cursorPos() );
|
||||
QCOMPARE( 7, m_editor1->anchorPos() );
|
||||
|
||||
// Backspace operations on newline characters should not be merged
|
||||
m_document->undo();
|
||||
QCOMPARE( QString( "Hello, \nWorld" ), m_annot1->contents() );
|
||||
QCOMPARE( QString( "Hello, \nWorld" ), m_editor1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, \nWorld" ), m_annot1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, \nWorld" ), m_editor1->contents() );
|
||||
QCOMPARE( 8, m_editor1->cursorPos() );
|
||||
QCOMPARE( 8, m_editor1->anchorPos() );
|
||||
|
||||
m_document->undo();
|
||||
QCOMPARE( QString( "Hello, \n\nWorld" ), m_annot1->contents() );
|
||||
QCOMPARE( QString( "Hello, \n\nWorld" ), m_editor1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, \n\nWorld" ), m_annot1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, \n\nWorld" ), m_editor1->contents() );
|
||||
QCOMPARE( 9, m_editor1->cursorPos() );
|
||||
QCOMPARE( 9, m_editor1->anchorPos() );
|
||||
}
|
||||
|
@ -230,31 +233,31 @@ void EditAnnotationContentsTest::testConsecutiveNewlineBackspacesNotMerged()
|
|||
void EditAnnotationContentsTest::testConsecutiveCharInsertionsMerged()
|
||||
{
|
||||
// Hello, |World -> Hello, B|World
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "Hello, BWorld" ), 8, 7, 7 );
|
||||
QCOMPARE( QString( "Hello, BWorld" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "Hello, BWorld" ), 8, 7, 7 );
|
||||
QCOMPARE( QStringLiteral( "Hello, BWorld" ), m_annot1->contents() );
|
||||
|
||||
// Hello, l| -> Hello, li|
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "Hello, BiWorld" ), 9, 8, 8 );
|
||||
QCOMPARE( QString( "Hello, BiWorld" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "Hello, BiWorld" ), 9, 8, 8 );
|
||||
QCOMPARE( QStringLiteral( "Hello, BiWorld" ), m_annot1->contents() );
|
||||
|
||||
// Hello, li| -> Hello, lin|
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "Hello, BigWorld" ), 10, 9, 9 );
|
||||
QCOMPARE( QString( "Hello, BigWorld" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "Hello, BigWorld" ), 10, 9, 9 );
|
||||
QCOMPARE( QStringLiteral( "Hello, BigWorld" ), m_annot1->contents() );
|
||||
|
||||
// Hello, lin| -> Hello, line|
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "Hello, Big World" ), 11, 10, 10 );
|
||||
QCOMPARE( QString( "Hello, Big World" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "Hello, Big World" ), 11, 10, 10 );
|
||||
QCOMPARE( QStringLiteral( "Hello, Big World" ), m_annot1->contents() );
|
||||
|
||||
// Verify undo/redo operations merged
|
||||
m_document->undo();
|
||||
QCOMPARE( QString( "Hello, World" ), m_annot1->contents() );
|
||||
QCOMPARE( QString( "Hello, World" ), m_editor1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, World" ), m_annot1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, World" ), m_editor1->contents() );
|
||||
QCOMPARE( 7, m_editor1->cursorPos() );
|
||||
QCOMPARE( 7, m_editor1->anchorPos() );
|
||||
|
||||
m_document->redo();
|
||||
QCOMPARE( QString( "Hello, Big World" ), m_annot1->contents() );
|
||||
QCOMPARE( QString( "Hello, Big World" ), m_editor1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, Big World" ), m_annot1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, Big World" ), m_editor1->contents() );
|
||||
QCOMPARE( 11, m_editor1->cursorPos() );
|
||||
QCOMPARE( 11, m_editor1->anchorPos() );
|
||||
}
|
||||
|
@ -262,34 +265,34 @@ void EditAnnotationContentsTest::testConsecutiveCharInsertionsMerged()
|
|||
void EditAnnotationContentsTest::testConsecutiveNewlineInsertionsNotMerged()
|
||||
{
|
||||
// Hello, |World -> Hello, \n|World
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "Hello, \nWorld" ), 8, 7, 7 );
|
||||
QCOMPARE( QString( "Hello, \nWorld" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "Hello, \nWorld" ), 8, 7, 7 );
|
||||
QCOMPARE( QStringLiteral( "Hello, \nWorld" ), m_annot1->contents() );
|
||||
|
||||
// Hello, |World -> Hello, \n|World
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "Hello, \n\nWorld" ), 9, 8, 8 );
|
||||
QCOMPARE( QString( "Hello, \n\nWorld" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "Hello, \n\nWorld" ), 9, 8, 8 );
|
||||
QCOMPARE( QStringLiteral( "Hello, \n\nWorld" ), m_annot1->contents() );
|
||||
|
||||
m_document->undo();
|
||||
QCOMPARE( QString( "Hello, \nWorld" ), m_annot1->contents() );
|
||||
QCOMPARE( QString( "Hello, \nWorld" ), m_editor1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, \nWorld" ), m_annot1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, \nWorld" ), m_editor1->contents() );
|
||||
QCOMPARE( 8, m_editor1->cursorPos() );
|
||||
QCOMPARE( 8, m_editor1->anchorPos() );
|
||||
|
||||
m_document->undo();
|
||||
QCOMPARE( QString( "Hello, World" ), m_annot1->contents() );
|
||||
QCOMPARE( QString( "Hello, World" ), m_editor1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, World" ), m_annot1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, World" ), m_editor1->contents() );
|
||||
QCOMPARE( 7, m_editor1->cursorPos() );
|
||||
QCOMPARE( 7, m_editor1->anchorPos() );
|
||||
|
||||
m_document->redo();
|
||||
QCOMPARE( QString( "Hello, \nWorld" ), m_annot1->contents() );
|
||||
QCOMPARE( QString( "Hello, \nWorld" ), m_editor1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, \nWorld" ), m_annot1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, \nWorld" ), m_editor1->contents() );
|
||||
QCOMPARE( 8, m_editor1->cursorPos() );
|
||||
QCOMPARE( 8, m_editor1->anchorPos() );
|
||||
|
||||
m_document->redo();
|
||||
QCOMPARE( QString( "Hello, \n\nWorld" ), m_annot1->contents() );
|
||||
QCOMPARE( QString( "Hello, \n\nWorld" ), m_editor1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, \n\nWorld" ), m_annot1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, \n\nWorld" ), m_editor1->contents() );
|
||||
QCOMPARE( 9, m_editor1->cursorPos() );
|
||||
QCOMPARE( 9, m_editor1->anchorPos() );
|
||||
}
|
||||
|
@ -297,35 +300,35 @@ void EditAnnotationContentsTest::testConsecutiveNewlineInsertionsNotMerged()
|
|||
void EditAnnotationContentsTest::testConsecutiveCharDeletesMerged()
|
||||
{
|
||||
// Hello, |World -> Hello, |orld
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "Hello, orld" ), 7, 7, 7 );
|
||||
QCOMPARE( QString( "Hello, orld" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "Hello, orld" ), 7, 7, 7 );
|
||||
QCOMPARE( QStringLiteral( "Hello, orld" ), m_annot1->contents() );
|
||||
|
||||
// Hello, |orld -> Hello, |rld
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "Hello, rld" ), 7, 7, 7 );
|
||||
QCOMPARE( QString( "Hello, rld" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "Hello, rld" ), 7, 7, 7 );
|
||||
QCOMPARE( QStringLiteral( "Hello, rld" ), m_annot1->contents() );
|
||||
|
||||
// Hello, |rld -> Hello, |ld
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "Hello, ld" ), 7, 7, 7 );
|
||||
QCOMPARE( QString( "Hello, ld" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "Hello, ld" ), 7, 7, 7 );
|
||||
QCOMPARE( QStringLiteral( "Hello, ld" ), m_annot1->contents() );
|
||||
|
||||
// Hello, |ld -> Hello, |d
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "Hello, d" ), 7, 7, 7 );
|
||||
QCOMPARE( QString( "Hello, d" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "Hello, d" ), 7, 7, 7 );
|
||||
QCOMPARE( QStringLiteral( "Hello, d" ), m_annot1->contents() );
|
||||
|
||||
// Hello, | -> Hello, |
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "Hello, " ), 7, 7, 7 );
|
||||
QCOMPARE( QString( "Hello, " ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "Hello, " ), 7, 7, 7 );
|
||||
QCOMPARE( QStringLiteral( "Hello, " ), m_annot1->contents() );
|
||||
|
||||
// Verify undo/redo operations merged
|
||||
m_document->undo();
|
||||
QCOMPARE( QString( "Hello, World" ), m_annot1->contents() );
|
||||
QCOMPARE( QString( "Hello, World" ), m_editor1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, World" ), m_annot1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, World" ), m_editor1->contents() );
|
||||
QCOMPARE( 7, m_editor1->cursorPos() );
|
||||
QCOMPARE( 7, m_editor1->anchorPos() );
|
||||
|
||||
m_document->redo();
|
||||
QCOMPARE( QString( "Hello, " ), m_annot1->contents() );
|
||||
QCOMPARE( QString( "Hello, " ), m_editor1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, " ), m_annot1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, " ), m_editor1->contents() );
|
||||
QCOMPARE( 7, m_editor1->cursorPos() );
|
||||
QCOMPARE( 7, m_editor1->anchorPos() );
|
||||
}
|
||||
|
@ -333,53 +336,53 @@ void EditAnnotationContentsTest::testConsecutiveCharDeletesMerged()
|
|||
void EditAnnotationContentsTest::testConsecutiveNewlineDeletesNotMerged()
|
||||
{
|
||||
// Set contents to Hello, \n\n|World
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "Hello, \n\nWorld" ), 0, 0, 0 );
|
||||
QCOMPARE( QString( "Hello, \n\nWorld" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "Hello, \n\nWorld" ), 0, 0, 0 );
|
||||
QCOMPARE( QStringLiteral( "Hello, \n\nWorld" ), m_annot1->contents() );
|
||||
|
||||
// He|llo, \n\nWorld -> He|lo, \n\nWorld
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "Helo, \n\nWorld" ), 2, 2, 2 );
|
||||
QCOMPARE( QString( "Helo, \n\nWorld" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "Helo, \n\nWorld" ), 2, 2, 2 );
|
||||
QCOMPARE( QStringLiteral( "Helo, \n\nWorld" ), m_annot1->contents() );
|
||||
|
||||
// He|lo, \n\nWorld -> He|o, \n\nWorld
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "Heo, \n\nWorld" ), 2, 2, 2 );
|
||||
QCOMPARE( QString( "Heo, \n\nWorld" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "Heo, \n\nWorld" ), 2, 2, 2 );
|
||||
QCOMPARE( QStringLiteral( "Heo, \n\nWorld" ), m_annot1->contents() );
|
||||
|
||||
// He|o, \n\nWorld -> He|, \n\nWorld
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "He, \n\nWorld" ), 2, 2, 2 );
|
||||
QCOMPARE( QString( "He, \n\nWorld" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "He, \n\nWorld" ), 2, 2, 2 );
|
||||
QCOMPARE( QStringLiteral( "He, \n\nWorld" ), m_annot1->contents() );
|
||||
|
||||
// He|, \n\nWorld -> He| \n\nWorld
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "He \n\nWorld" ), 2, 2, 2 );
|
||||
QCOMPARE( QString( "He \n\nWorld" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "He \n\nWorld" ), 2, 2, 2 );
|
||||
QCOMPARE( QStringLiteral( "He \n\nWorld" ), m_annot1->contents() );
|
||||
|
||||
// He| \n\nWorld -> He|\n\nWorld
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "He\n\nWorld" ), 2, 2, 2 );
|
||||
QCOMPARE( QString( "He\n\nWorld" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "He\n\nWorld" ), 2, 2, 2 );
|
||||
QCOMPARE( QStringLiteral( "He\n\nWorld" ), m_annot1->contents() );
|
||||
|
||||
// He|\n\nWorld -> He|\nWorld
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "He\nWorld" ), 2, 2, 2 );
|
||||
QCOMPARE( QString( "He\nWorld" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "He\nWorld" ), 2, 2, 2 );
|
||||
QCOMPARE( QStringLiteral( "He\nWorld" ), m_annot1->contents() );
|
||||
|
||||
// He|\nWorld -> He|World
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "HeWorld" ), 2, 2, 2 );
|
||||
QCOMPARE( QString( "HeWorld" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "HeWorld" ), 2, 2, 2 );
|
||||
QCOMPARE( QStringLiteral( "HeWorld" ), m_annot1->contents() );
|
||||
|
||||
// Verify that deletions of newlines are not merged, but deletions of other characters are
|
||||
m_document->undo();
|
||||
QCOMPARE( QString( "He\nWorld" ), m_annot1->contents() );
|
||||
QCOMPARE( QString( "He\nWorld" ), m_editor1->contents() );
|
||||
QCOMPARE( QStringLiteral( "He\nWorld" ), m_annot1->contents() );
|
||||
QCOMPARE( QStringLiteral( "He\nWorld" ), m_editor1->contents() );
|
||||
QCOMPARE( 2, m_editor1->cursorPos() );
|
||||
QCOMPARE( 2, m_editor1->anchorPos() );
|
||||
|
||||
m_document->undo();
|
||||
QCOMPARE( QString( "He\n\nWorld" ), m_annot1->contents() );
|
||||
QCOMPARE( QString( "He\n\nWorld" ), m_editor1->contents() );
|
||||
QCOMPARE( QStringLiteral( "He\n\nWorld" ), m_annot1->contents() );
|
||||
QCOMPARE( QStringLiteral( "He\n\nWorld" ), m_editor1->contents() );
|
||||
QCOMPARE( 2, m_editor1->cursorPos() );
|
||||
QCOMPARE( 2, m_editor1->anchorPos() );
|
||||
|
||||
m_document->undo();
|
||||
QCOMPARE( QString( "Hello, \n\nWorld" ), m_annot1->contents() );
|
||||
QCOMPARE( QString( "Hello, \n\nWorld" ), m_editor1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, \n\nWorld" ), m_annot1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, \n\nWorld" ), m_editor1->contents() );
|
||||
QCOMPARE( 2, m_editor1->cursorPos() );
|
||||
QCOMPARE( 2, m_editor1->anchorPos() );
|
||||
}
|
||||
|
@ -387,70 +390,70 @@ void EditAnnotationContentsTest::testConsecutiveNewlineDeletesNotMerged()
|
|||
void EditAnnotationContentsTest::testConsecutiveEditsNotMergedAcrossDifferentAnnotations()
|
||||
{
|
||||
// Annot1: Hello, World| -> Hello, Worl|
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "Hello, Worl" ), 11, 12, 12 );
|
||||
QCOMPARE( QString( "Hello, Worl" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "Hello, Worl" ), 11, 12, 12 );
|
||||
QCOMPARE( QStringLiteral( "Hello, Worl" ), m_annot1->contents() );
|
||||
// Annot1: Hello, Worl| -> Hello, Wor|
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "Hello, Wor" ), 10, 11, 11 );
|
||||
QCOMPARE( QString( "Hello, Wor" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "Hello, Wor" ), 10, 11, 11 );
|
||||
QCOMPARE( QStringLiteral( "Hello, Wor" ), m_annot1->contents() );
|
||||
|
||||
// Annot2: Hello, World| -> Hello, Worl|
|
||||
m_document->editPageAnnotationContents( 0, m_annot2, QString( "Hello, Worl" ), 11, 12, 12 );
|
||||
QCOMPARE( QString( "Hello, Worl" ), m_annot2->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot2, QStringLiteral( "Hello, Worl" ), 11, 12, 12 );
|
||||
QCOMPARE( QStringLiteral( "Hello, Worl" ), m_annot2->contents() );
|
||||
// Annot2: Hello, Worl| -> Hello, Wor|
|
||||
m_document->editPageAnnotationContents( 0, m_annot2, QString( "Hello, Wor" ), 10, 11, 11 );
|
||||
QCOMPARE( QString( "Hello, Wor" ), m_annot2->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot2, QStringLiteral( "Hello, Wor" ), 10, 11, 11 );
|
||||
QCOMPARE( QStringLiteral( "Hello, Wor" ), m_annot2->contents() );
|
||||
|
||||
// Annot1: Hello, Wor| -> Hello, Wo|
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "Hello, Wo" ), 9, 10, 10 );
|
||||
QCOMPARE( QString( "Hello, Wo" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "Hello, Wo" ), 9, 10, 10 );
|
||||
QCOMPARE( QStringLiteral( "Hello, Wo" ), m_annot1->contents() );
|
||||
// Annot1: Hello, Wo| -> Hello, W|
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "Hello, W" ), 8, 9, 9 );
|
||||
QCOMPARE( QString( "Hello, W" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "Hello, W" ), 8, 9, 9 );
|
||||
QCOMPARE( QStringLiteral( "Hello, W" ), m_annot1->contents() );
|
||||
// Annot1: Hello, W| -> Hello, |
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "Hello, " ), 7, 8, 8 );
|
||||
QCOMPARE( QString( "Hello, " ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "Hello, " ), 7, 8, 8 );
|
||||
QCOMPARE( QStringLiteral( "Hello, " ), m_annot1->contents() );
|
||||
|
||||
// Annot2: Hello, Wor| -> Hello, Wo|
|
||||
m_document->editPageAnnotationContents( 0, m_annot2, QString( "Hello, Wo" ), 9, 10, 10 );
|
||||
QCOMPARE( QString( "Hello, Wo" ), m_annot2->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot2, QStringLiteral( "Hello, Wo" ), 9, 10, 10 );
|
||||
QCOMPARE( QStringLiteral( "Hello, Wo" ), m_annot2->contents() );
|
||||
// Annot2: Hello, Wo| -> Hello, W|
|
||||
m_document->editPageAnnotationContents( 0, m_annot2, QString( "Hello, W" ), 8, 9, 9 );
|
||||
QCOMPARE( QString( "Hello, W" ), m_annot2->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot2, QStringLiteral( "Hello, W" ), 8, 9, 9 );
|
||||
QCOMPARE( QStringLiteral( "Hello, W" ), m_annot2->contents() );
|
||||
// Annot2: Hello, W| -> Hello, |
|
||||
m_document->editPageAnnotationContents( 0, m_annot2, QString( "Hello, " ), 7, 8, 8 );
|
||||
QCOMPARE( QString( "Hello, " ), m_annot2->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot2, QStringLiteral( "Hello, " ), 7, 8, 8 );
|
||||
QCOMPARE( QStringLiteral( "Hello, " ), m_annot2->contents() );
|
||||
|
||||
|
||||
// undo and verify that consecutive backspace operations are merged together
|
||||
// m_annot2 -> "Hello, Wor|"
|
||||
m_document->undo();
|
||||
QCOMPARE( QString( "Hello, Wor" ), m_annot2->contents() );
|
||||
QCOMPARE( QString( "Hello, " ), m_editor1->contents() );
|
||||
QCOMPARE( QString( "Hello, Wor" ), m_editor2->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, Wor" ), m_annot2->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, " ), m_editor1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, Wor" ), m_editor2->contents() );
|
||||
QCOMPARE( 10, m_editor2->cursorPos() );
|
||||
QCOMPARE( 10, m_editor2->anchorPos() );
|
||||
|
||||
// m_annot1 -> "Hello, Wor|"
|
||||
m_document->undo();
|
||||
QCOMPARE( QString( "Hello, Wor" ), m_annot1->contents() );
|
||||
QCOMPARE( QString( "Hello, Wor" ), m_editor1->contents() );
|
||||
QCOMPARE( QString( "Hello, Wor" ), m_editor2->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, Wor" ), m_annot1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, Wor" ), m_editor1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, Wor" ), m_editor2->contents() );
|
||||
QCOMPARE( 10, m_editor1->cursorPos() );
|
||||
QCOMPARE( 10, m_editor1->anchorPos() );
|
||||
|
||||
// m_annot2 -> "Hello, World|"
|
||||
m_document->undo();
|
||||
QCOMPARE( QString( "Hello, World" ), m_annot2->contents() );
|
||||
QCOMPARE( QString( "Hello, Wor" ), m_editor1->contents() );
|
||||
QCOMPARE( QString( "Hello, World" ), m_editor2->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, World" ), m_annot2->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, Wor" ), m_editor1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, World" ), m_editor2->contents() );
|
||||
QCOMPARE( 12, m_editor2->cursorPos() );
|
||||
QCOMPARE( 12, m_editor2->anchorPos() );
|
||||
|
||||
// m_annot1 -> "Hello, World|"
|
||||
m_document->undo();
|
||||
QCOMPARE( QString( "Hello, World" ), m_annot1->contents() );
|
||||
QCOMPARE( QString( "Hello, World" ), m_editor1->contents() );
|
||||
QCOMPARE( QString( "Hello, World" ), m_editor2->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, World" ), m_annot1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, World" ), m_editor1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, World" ), m_editor2->contents() );
|
||||
QCOMPARE( 12, m_editor1->cursorPos() );
|
||||
QCOMPARE( 12, m_editor1->anchorPos() );
|
||||
}
|
||||
|
@ -458,22 +461,22 @@ void EditAnnotationContentsTest::testConsecutiveEditsNotMergedAcrossDifferentAnn
|
|||
void EditAnnotationContentsTest::testInsertWithSelection()
|
||||
{
|
||||
// Annot1: |Hello|, World -> H|, World
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "H, World" ), 1, 0, 5 );
|
||||
QCOMPARE( QString( "H, World" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "H, World" ), 1, 0, 5 );
|
||||
QCOMPARE( QStringLiteral( "H, World" ), m_annot1->contents() );
|
||||
|
||||
// Annot1: H|, World -> Hi|, World
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "Hi, World" ), 2, 1, 1 );
|
||||
QCOMPARE( QString( "Hi, World" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "Hi, World" ), 2, 1, 1 );
|
||||
QCOMPARE( QStringLiteral( "Hi, World" ), m_annot1->contents() );
|
||||
|
||||
m_document->undo();
|
||||
QCOMPARE( QString( "H, World" ), m_annot1->contents() );
|
||||
QCOMPARE( QString( "H, World" ), m_editor1->contents() );
|
||||
QCOMPARE( QStringLiteral( "H, World" ), m_annot1->contents() );
|
||||
QCOMPARE( QStringLiteral( "H, World" ), m_editor1->contents() );
|
||||
QCOMPARE( 1, m_editor1->cursorPos() );
|
||||
QCOMPARE( 1, m_editor1->anchorPos() );
|
||||
|
||||
m_document->undo();
|
||||
QCOMPARE( QString( "Hello, World" ), m_annot1->contents() );
|
||||
QCOMPARE( QString( "Hello, World" ), m_editor1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, World" ), m_annot1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, World" ), m_editor1->contents() );
|
||||
QCOMPARE( 0, m_editor1->cursorPos() );
|
||||
QCOMPARE( 5, m_editor1->anchorPos() );
|
||||
}
|
||||
|
@ -481,39 +484,39 @@ void EditAnnotationContentsTest::testInsertWithSelection()
|
|||
void EditAnnotationContentsTest::testCombinations()
|
||||
{
|
||||
// Annot1: Hello, World| -> Hello, Worl|
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "Hello, Worl" ), 11, 12, 12 );
|
||||
QCOMPARE( QString( "Hello, Worl" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "Hello, Worl" ), 11, 12, 12 );
|
||||
QCOMPARE( QStringLiteral( "Hello, Worl" ), m_annot1->contents() );
|
||||
|
||||
// Annot1: Hello, Worl| -> Hello, Wor|
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "Hello, Wor" ), 10, 11, 11 );
|
||||
QCOMPARE( QString( "Hello, Wor" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "Hello, Wor" ), 10, 11, 11 );
|
||||
QCOMPARE( QStringLiteral( "Hello, Wor" ), m_annot1->contents() );
|
||||
|
||||
// Annot1: |He|llo, Wor -> |llo, Wor
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "llo, Wor" ), 0, 2, 0 );
|
||||
QCOMPARE( QString( "llo, Wor" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "llo, Wor" ), 0, 2, 0 );
|
||||
QCOMPARE( QStringLiteral( "llo, Wor" ), m_annot1->contents() );
|
||||
|
||||
// Annot1: |llo, Wor -> |lo, Wor
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QString( "lo, Wor" ), 0, 0, 0 );
|
||||
QCOMPARE( QString( "lo, Wor" ), m_annot1->contents() );
|
||||
m_document->editPageAnnotationContents( 0, m_annot1, QStringLiteral( "lo, Wor" ), 0, 0, 0 );
|
||||
QCOMPARE( QStringLiteral( "lo, Wor" ), m_annot1->contents() );
|
||||
|
||||
m_document->undo();
|
||||
QCOMPARE( QString( "llo, Wor" ), m_annot1->contents() );
|
||||
QCOMPARE( QString( "llo, Wor" ), m_editor1->contents() );
|
||||
QCOMPARE( QStringLiteral( "llo, Wor" ), m_annot1->contents() );
|
||||
QCOMPARE( QStringLiteral( "llo, Wor" ), m_editor1->contents() );
|
||||
QCOMPARE( 0, m_editor1->cursorPos() );
|
||||
QCOMPARE( 0, m_editor1->anchorPos() );
|
||||
|
||||
m_document->undo();
|
||||
QCOMPARE( QString( "Hello, Wor" ), m_annot1->contents() );
|
||||
QCOMPARE( QString( "Hello, Wor" ), m_editor1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, Wor" ), m_annot1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, Wor" ), m_editor1->contents() );
|
||||
QCOMPARE( 2, m_editor1->cursorPos() );
|
||||
QCOMPARE( 0, m_editor1->anchorPos() );
|
||||
|
||||
m_document->undo();
|
||||
QCOMPARE( QString( "Hello, World" ), m_annot1->contents() );
|
||||
QCOMPARE( QString( "Hello, World" ), m_editor1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, World" ), m_annot1->contents() );
|
||||
QCOMPARE( QStringLiteral( "Hello, World" ), m_editor1->contents() );
|
||||
QCOMPARE( 12, m_editor1->cursorPos() );
|
||||
QCOMPARE( 12, m_editor1->anchorPos() );
|
||||
}
|
||||
|
||||
QTEST_KDEMAIN( EditAnnotationContentsTest, GUI )
|
||||
QTEST_MAIN( EditAnnotationContentsTest )
|
||||
#include "editannotationcontentstest.moc"
|
|
@ -7,8 +7,10 @@
|
|||
* (at your option) any later version. *
|
||||
***************************************************************************/
|
||||
|
||||
#include <qtest_kde.h>
|
||||
#include <kmimetype.h>
|
||||
#include <QtTest>
|
||||
|
||||
#include <QMimeType>
|
||||
#include <QMimeDatabase>
|
||||
#include "../settings_core.h"
|
||||
#include "core/document.h"
|
||||
#include <core/page.h>
|
||||
|
@ -52,8 +54,8 @@ private:
|
|||
|
||||
void EditFormsTest::initTestCase()
|
||||
{
|
||||
Okular::SettingsCore::instance( "editformstest" );
|
||||
m_document = new Okular::Document( 0 );
|
||||
Okular::SettingsCore::instance( QStringLiteral("editformstest") );
|
||||
m_document = new Okular::Document( nullptr );
|
||||
}
|
||||
|
||||
void EditFormsTest::cleanupTestCase()
|
||||
|
@ -63,9 +65,10 @@ void EditFormsTest::cleanupTestCase()
|
|||
|
||||
void EditFormsTest::init()
|
||||
{
|
||||
const QString testFile = KDESRCDIR "data/formSamples.pdf";
|
||||
const KMimeType::Ptr mime = KMimeType::findByPath( testFile );
|
||||
m_document->openDocument( testFile, KUrl(), mime );
|
||||
const QString testFile = QStringLiteral(KDESRCDIR "data/formSamples.pdf");
|
||||
QMimeDatabase db;
|
||||
const QMimeType mime = db.mimeTypeForFile( testFile );
|
||||
QCOMPARE( m_document->openDocument(testFile, QUrl(), mime), Okular::Document::OpenSuccess );
|
||||
|
||||
// Undo and Redo should be unavailable when docuemnt is first opened.
|
||||
QVERIFY( !m_document->canUndo() );
|
||||
|
@ -241,21 +244,21 @@ void EditFormsTest::testComboEditForm()
|
|||
|
||||
// Initially no choice is selected
|
||||
QCOMPARE( m_comboEdit->currentChoices().length(), 0 );
|
||||
QCOMPARE( m_comboEdit->editChoice(), QString( "" ) );
|
||||
QCOMPARE( m_comboEdit->editChoice(), QLatin1String( "" ) );
|
||||
|
||||
// Select first choice
|
||||
m_document->editFormCombo( 0, m_comboEdit, "combo1", 0, 0, 0);
|
||||
m_document->editFormCombo( 0, m_comboEdit, QStringLiteral("combo1"), 0, 0, 0);
|
||||
QCOMPARE( m_comboEdit->currentChoices().length(), 1 );
|
||||
QCOMPARE( m_comboEdit->currentChoices()[0], 0 );
|
||||
QCOMPARE( m_comboEdit->editChoice(), QString( "" ) );
|
||||
QCOMPARE( m_comboEdit->editChoice(), QLatin1String( "" ) );
|
||||
QVERIFY( m_document->canUndo() );
|
||||
QVERIFY( !m_document->canRedo() );
|
||||
|
||||
// Select third choice
|
||||
m_document->editFormCombo( 0, m_comboEdit, "combo3", 0, 0, 0);
|
||||
m_document->editFormCombo( 0, m_comboEdit, QStringLiteral("combo3"), 0, 0, 0);
|
||||
QCOMPARE( m_comboEdit->currentChoices().length(), 1 );
|
||||
QCOMPARE( m_comboEdit->currentChoices()[0], 2 );
|
||||
QCOMPARE( m_comboEdit->editChoice(), QString( "" ) );
|
||||
QCOMPARE( m_comboEdit->editChoice(), QLatin1String( "" ) );
|
||||
QVERIFY( m_document->canUndo() );
|
||||
QVERIFY( !m_document->canRedo() );
|
||||
|
||||
|
@ -274,9 +277,9 @@ void EditFormsTest::testComboEditForm()
|
|||
QVERIFY( !m_document->canRedo() );
|
||||
|
||||
// Select a custom choice and verify that no predefined choices are selected
|
||||
m_document->editFormCombo( 0, m_comboEdit, "comboEdit", 0, 0, 0);
|
||||
m_document->editFormCombo( 0, m_comboEdit, QStringLiteral("comboEdit"), 0, 0, 0);
|
||||
QCOMPARE( m_comboEdit->currentChoices().length(), 0 );
|
||||
QCOMPARE( m_comboEdit->editChoice(), QString( "comboEdit" ) );
|
||||
QCOMPARE( m_comboEdit->editChoice(), QStringLiteral( "comboEdit" ) );
|
||||
QVERIFY( m_document->canUndo() );
|
||||
QVERIFY( !m_document->canRedo() );
|
||||
|
||||
|
@ -386,46 +389,46 @@ void EditFormsTest::setRadioButtonStates( bool state1, bool state2, bool state3
|
|||
void EditFormsTest::verifyTextForm( Okular::FormFieldText* form )
|
||||
{
|
||||
// Text in form is initially empty
|
||||
QCOMPARE( form->text(), QString("") );
|
||||
QCOMPARE( form->text(), QLatin1String("") );
|
||||
|
||||
// Insert the string "Hello" into the form
|
||||
m_document->editFormText(0, form, QString("Hello"), 5, 0, 0);
|
||||
QCOMPARE( form->text(), QString("Hello") );
|
||||
m_document->editFormText(0, form, QStringLiteral("Hello"), 5, 0, 0);
|
||||
QCOMPARE( form->text(), QStringLiteral("Hello") );
|
||||
QVERIFY( m_document->canUndo() );
|
||||
QVERIFY( !m_document->canRedo() );
|
||||
|
||||
// Undo the insertion and verify that form is empty again
|
||||
m_document->undo();
|
||||
QCOMPARE( form->text(), QString("") );
|
||||
QCOMPARE( form->text(), QLatin1String("") );
|
||||
QVERIFY( !m_document->canUndo() );
|
||||
QVERIFY( m_document->canRedo() );
|
||||
|
||||
// Redo the insertion of "Hello"
|
||||
m_document->redo();
|
||||
QCOMPARE( form->text(), QString("Hello") );
|
||||
QCOMPARE( form->text(), QStringLiteral("Hello") );
|
||||
QVERIFY( m_document->canUndo() );
|
||||
QVERIFY( !m_document->canRedo() );
|
||||
|
||||
// Type "_World" after "Hello"
|
||||
m_document->editFormText(0, form, QString("Hello_"), 6, 5, 5);
|
||||
m_document->editFormText(0, form, QString("Hello_W"), 7, 6, 6);
|
||||
m_document->editFormText(0, form, QString("Hello_Wo"), 8, 7, 7);
|
||||
m_document->editFormText(0, form, QString("Hello_Wor"), 9, 8, 8);
|
||||
m_document->editFormText(0, form, QString("Hello_Worl"), 10, 9, 9);
|
||||
m_document->editFormText(0, form, QString("Hello_World"), 11, 10, 10);
|
||||
m_document->editFormText(0, form, QStringLiteral("Hello_"), 6, 5, 5);
|
||||
m_document->editFormText(0, form, QStringLiteral("Hello_W"), 7, 6, 6);
|
||||
m_document->editFormText(0, form, QStringLiteral("Hello_Wo"), 8, 7, 7);
|
||||
m_document->editFormText(0, form, QStringLiteral("Hello_Wor"), 9, 8, 8);
|
||||
m_document->editFormText(0, form, QStringLiteral("Hello_Worl"), 10, 9, 9);
|
||||
m_document->editFormText(0, form, QStringLiteral("Hello_World"), 11, 10, 10);
|
||||
|
||||
// Verify that character insertion operations were merged together into a single undo command
|
||||
m_document->undo();
|
||||
QCOMPARE( form->text(), QString("Hello") );
|
||||
QCOMPARE( form->text(), QStringLiteral("Hello") );
|
||||
QVERIFY( m_document->canUndo() );
|
||||
QVERIFY( m_document->canRedo() );
|
||||
|
||||
// Verify that one more undo gets us back to the original state (empty form)
|
||||
m_document->undo();
|
||||
QCOMPARE( form->text(), QString("") );
|
||||
QCOMPARE( form->text(), QLatin1String("") );
|
||||
QVERIFY( !m_document->canUndo() );
|
||||
QVERIFY( m_document->canRedo() );
|
||||
}
|
||||
|
||||
QTEST_KDEMAIN( EditFormsTest, GUI )
|
||||
QTEST_MAIN( EditFormsTest )
|
||||
#include "editformstest.moc"
|
75
autotests/generatorstest.cpp
Normal file
75
autotests/generatorstest.cpp
Normal file
|
@ -0,0 +1,75 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2015 by Alex Richardson <arichardson.kde@gmail.com> *
|
||||
* *
|
||||
* 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. *
|
||||
***************************************************************************/
|
||||
|
||||
#include <QtTest/QTest>
|
||||
#include <QDirIterator>
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
#include <KPluginFactory>
|
||||
#include <KPluginLoader>
|
||||
|
||||
#include "../generator.h"
|
||||
|
||||
class GeneratorsTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
void testLoadsCorrectly();
|
||||
};
|
||||
|
||||
void GeneratorsTest::testLoadsCorrectly()
|
||||
{
|
||||
QCoreApplication::setLibraryPaths(QStringList());
|
||||
QVERIFY2(QDir(QStringLiteral(GENERATORS_BUILD_DIR)).exists(), GENERATORS_BUILD_DIR);
|
||||
// find all possible generators in $CMAKE_BINARY_DIR/generators
|
||||
// We can't simply hardcore the list of generators since some might not be built
|
||||
// depending on which dependencies were found by CMake
|
||||
QStringList generatorLibs;
|
||||
QDirIterator it(QStringLiteral(GENERATORS_BUILD_DIR), QDir::Files | QDir::Executable, QDirIterator::Subdirectories);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
if (QLibrary::isLibrary(it.fileName())) {
|
||||
if (it.fileName().startsWith(QLatin1String("kio_"))) {
|
||||
continue; // don't check kio_msits.so
|
||||
}
|
||||
generatorLibs << it.fileInfo().absoluteFilePath();
|
||||
}
|
||||
}
|
||||
int failures = 0;
|
||||
int successful = 0;
|
||||
foreach (const QString& lib, generatorLibs) {
|
||||
KPluginLoader loader(lib);
|
||||
QVERIFY2(!loader.fileName().isEmpty(), qPrintable(lib));
|
||||
qDebug() << loader.fileName();
|
||||
auto factory = loader.factory();
|
||||
if (!factory) {
|
||||
qWarning() << "Could not get KPluginFactory for" << lib;
|
||||
failures++;
|
||||
continue;
|
||||
}
|
||||
Okular::Generator* generator = factory->create<Okular::Generator>();
|
||||
if (!generator) {
|
||||
qWarning() << "Failed to cast" << lib << "to Okular::Generator";
|
||||
// without the necessary Q_INTERFACES() qobject_cast fails!
|
||||
auto obj = factory->create<QObject>();
|
||||
qDebug() << "Object is of type " << obj->metaObject()->className();
|
||||
qDebug() << "dynamic_cast:" << dynamic_cast<Okular::Generator*>(obj);
|
||||
qDebug() << "qobject_cast:" << qobject_cast<Okular::Generator*>(obj);
|
||||
failures++;
|
||||
continue;
|
||||
}
|
||||
successful++;
|
||||
}
|
||||
qDebug() << "Successfully loaded" << successful << "generators";
|
||||
QCOMPARE(failures, 0);
|
||||
}
|
||||
|
||||
QTEST_MAIN(GeneratorsTest)
|
||||
|
||||
#include "generatorstest.moc"
|
|
@ -7,10 +7,13 @@
|
|||
* (at your option) any later version. *
|
||||
***************************************************************************/
|
||||
|
||||
#include <qtest_kde.h>
|
||||
#include <QtTest>
|
||||
|
||||
#include <qprintdialog.h>
|
||||
#include <qwidget.h>
|
||||
#include <ktabwidget.h>
|
||||
#include <qtabwidget.h>
|
||||
#include <QStandardPaths>
|
||||
#include <kconfiggroup.h>
|
||||
|
||||
#include "../shell/okular_main.h"
|
||||
#include "../shell/shell.h"
|
||||
|
@ -21,7 +24,11 @@
|
|||
#include "../settings.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#ifndef Q_OS_WIN
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#include <process.h>
|
||||
#endif
|
||||
|
||||
namespace Okular {
|
||||
class PartTest
|
||||
|
@ -56,7 +63,7 @@ class MainShellTest : public QObject, public Okular::PartTest
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static KTabWidget* tabWidget(Shell *s)
|
||||
static QTabWidget* tabWidget(Shell *s)
|
||||
{
|
||||
return s->m_tabWidget;
|
||||
}
|
||||
|
@ -73,11 +80,27 @@ private slots:
|
|||
void testFileRemembersPagePosition();
|
||||
void test2FilesError_data();
|
||||
void test2FilesError();
|
||||
void testSessionRestore_data();
|
||||
void testSessionRestore();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
Shell *findShell(Shell *ignore = 0)
|
||||
QList<Shell*> getShells()
|
||||
{
|
||||
QList<Shell*> shells;
|
||||
foreach( KMainWindow* kmw, KMainWindow::memberList() )
|
||||
{
|
||||
Shell* shell = qobject_cast<Shell*>( kmw );
|
||||
if( shell )
|
||||
{
|
||||
shells.append( shell );
|
||||
}
|
||||
}
|
||||
return shells;
|
||||
}
|
||||
|
||||
Shell *findShell(Shell *ignore = nullptr)
|
||||
{
|
||||
foreach (QWidget *widget, QApplication::topLevelWidgets())
|
||||
{
|
||||
|
@ -85,22 +108,23 @@ Shell *findShell(Shell *ignore = 0)
|
|||
if (s && s != ignore)
|
||||
return s;
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void MainShellTest::initTestCase()
|
||||
{
|
||||
QStandardPaths::setTestModeEnabled(true);
|
||||
// Don't pollute people's okular settings
|
||||
Okular::Settings::instance( "mainshelltest" );
|
||||
Okular::Settings::instance( QStringLiteral("mainshelltest") );
|
||||
|
||||
// Register in bus as okular
|
||||
QDBusConnectionInterface *bus = QDBusConnection::sessionBus().interface();
|
||||
const QString myPid = QString::number( getpid() );
|
||||
const QString serviceName = "org.kde.okular-"+ myPid;
|
||||
const QString serviceName = QStringLiteral("org.kde.okular-")+ myPid;
|
||||
QVERIFY( bus->registerService(serviceName) == QDBusConnectionInterface::ServiceRegistered );
|
||||
|
||||
// Tell the presentationWidget to not be annoying
|
||||
KSharedConfigPtr c = KGlobal::config();
|
||||
KSharedConfigPtr c = KSharedConfig::openConfig();
|
||||
KConfigGroup cg = c->group("Notification Messages");
|
||||
cg.writeEntry("presentationInfo", false);
|
||||
}
|
||||
|
@ -115,12 +139,12 @@ void MainShellTest::init()
|
|||
Okular::Settings::self()->setDefaults();
|
||||
|
||||
// Clean docdatas
|
||||
QList<KUrl> urls;
|
||||
urls << KUrl("file://" KDESRCDIR "data/file1.pdf");
|
||||
urls << KUrl("file://" KDESRCDIR "data/tocreload.pdf");
|
||||
urls << KUrl("file://" KDESRCDIR "data/contents.epub");
|
||||
QList<QUrl> urls;
|
||||
urls << QUrl::fromUserInput(QStringLiteral("file://" KDESRCDIR "data/file1.pdf"));
|
||||
urls << QUrl::fromUserInput(QStringLiteral("file://" KDESRCDIR "data/tocreload.pdf"));
|
||||
urls << QUrl::fromUserInput(QStringLiteral("file://" KDESRCDIR "data/contents.epub"));
|
||||
|
||||
foreach (const KUrl &url, urls)
|
||||
foreach (const QUrl &url, urls)
|
||||
{
|
||||
QFileInfo fileReadTest( url.toLocalFile() );
|
||||
const QString docDataPath = Okular::DocumentPrivate::docDataFileName(url, fileReadTest.size());
|
||||
|
@ -151,15 +175,15 @@ void MainShellTest::testShell_data()
|
|||
QTest::addColumn<bool>("externalProcessExpectPresentation");
|
||||
QTest::addColumn<bool>("externalProcessExpectPrintDialog");
|
||||
|
||||
const QStringList contentsEpub = QStringList(KDESRCDIR "data/contents.epub");
|
||||
const QStringList file1 = QStringList(KDESRCDIR "data/file1.pdf");
|
||||
const QStringList contentsEpub = QStringList(QStringLiteral(KDESRCDIR "data/contents.epub"));
|
||||
const QStringList file1 = QStringList(QStringLiteral(KDESRCDIR "data/file1.pdf"));
|
||||
QStringList file1AndToc;
|
||||
file1AndToc << KDESRCDIR "data/file1.pdf";
|
||||
file1AndToc << KDESRCDIR "data/tocreload.pdf";
|
||||
const QString tocReload = KDESRCDIR "data/tocreload.pdf";
|
||||
file1AndToc << QStringLiteral(KDESRCDIR "data/file1.pdf");
|
||||
file1AndToc << QStringLiteral(KDESRCDIR "data/tocreload.pdf");
|
||||
const QString tocReload = QStringLiteral(KDESRCDIR "data/tocreload.pdf");
|
||||
|
||||
const QString optionsPage2 = ShellUtils::serializeOptions(false, false, false, false, "2");
|
||||
const QString optionsPage2Presentation = ShellUtils::serializeOptions(true, false, false, false, "2");
|
||||
const QString optionsPage2 = ShellUtils::serializeOptions(false, false, false, false, QStringLiteral("2"));
|
||||
const QString optionsPage2Presentation = ShellUtils::serializeOptions(true, false, false, false, QStringLiteral("2"));
|
||||
const QString optionsPrint = ShellUtils::serializeOptions(false, true, false, false, QString());
|
||||
const QString optionsUnique = ShellUtils::serializeOptions(false, false, true, false, QString());
|
||||
|
||||
|
@ -219,7 +243,7 @@ void MainShellTest::testShell()
|
|||
QCOMPARE(s->m_tabs.count(), 1);
|
||||
Okular::Part *part = s->findChild<Okular::Part*>();
|
||||
QVERIFY(part);
|
||||
QCOMPARE(part->url().url(), QString("file://%1").arg(paths[0]));
|
||||
QCOMPARE(part->url().url(), QStringLiteral("file://%1").arg(paths[0]));
|
||||
QCOMPARE(partDocument(part)->currentPage(), expectedPage);
|
||||
}
|
||||
else if (paths.count() == 2)
|
||||
|
@ -232,8 +256,8 @@ void MainShellTest::testShell()
|
|||
Okular::Part *part = dynamic_cast<Okular::Part*>(s->m_tabs[0].part);
|
||||
Okular::Part *part2 = dynamic_cast<Okular::Part*>(s->m_tabs[1].part);
|
||||
QCOMPARE(s->m_tabs.count(), 2);
|
||||
QCOMPARE(part->url().url(), QString("file://%1").arg(paths[0]));
|
||||
QCOMPARE(part2->url().url(), QString("file://%1").arg(paths[1]));
|
||||
QCOMPARE(part->url().url(), QStringLiteral("file://%1").arg(paths[0]));
|
||||
QCOMPARE(part2->url().url(), QStringLiteral("file://%1").arg(paths[1]));
|
||||
QCOMPARE(partDocument(part)->currentPage(), expectedPage);
|
||||
QCOMPARE(partDocument(part2)->currentPage(), expectedPage);
|
||||
}
|
||||
|
@ -258,7 +282,7 @@ void MainShellTest::testShell()
|
|||
|
||||
foreach(const QString &path, paths)
|
||||
{
|
||||
QVERIFY(openUrls.contains(QString("file://%1").arg(path)));
|
||||
QVERIFY(openUrls.contains(QStringLiteral("file://%1").arg(path)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -268,26 +292,24 @@ void MainShellTest::testShell()
|
|||
Okular::Part *part = s->findChild<Okular::Part*>();
|
||||
|
||||
QProcess p;
|
||||
QString command = "okular " + externalProcessPath;
|
||||
QStringList args;
|
||||
args << externalProcessPath;
|
||||
if (unique)
|
||||
command += " -unique";
|
||||
args << QStringLiteral("-unique");
|
||||
if (externalProcessExpectedPage != 0)
|
||||
command += QString(" -page %1").arg(externalProcessExpectedPage + 1);
|
||||
args << QStringLiteral("-page") << QString::number(externalProcessExpectedPage + 1);
|
||||
if (externalProcessExpectPresentation)
|
||||
command += QString(" -presentation");
|
||||
args << QStringLiteral("-presentation");
|
||||
if (externalProcessExpectPrintDialog)
|
||||
command += QString(" -print");
|
||||
p.start(command);
|
||||
args << QStringLiteral("-print");
|
||||
p.start(QStringLiteral(OKULAR_BINARY), args);
|
||||
p.waitForStarted();
|
||||
QCOMPARE(p.state(), QProcess::Running);
|
||||
|
||||
if (useTabs || unique)
|
||||
{
|
||||
// It is attaching to us, so will eventually stop
|
||||
for (int i = 0; p.state() != QProcess::NotRunning && i < 20; ++i) {
|
||||
QTest::qWait(100);
|
||||
}
|
||||
QCOMPARE(p.state(), QProcess::NotRunning);
|
||||
QTRY_COMPARE_WITH_TIMEOUT(p.state(), QProcess::NotRunning, 20000);
|
||||
QCOMPARE(p.exitStatus(), QProcess::NormalExit);
|
||||
QCOMPARE(p.exitCode(), 0);
|
||||
|
||||
|
@ -295,7 +317,7 @@ void MainShellTest::testShell()
|
|||
{
|
||||
// It is unique so part got "overriten"
|
||||
QCOMPARE(s->m_tabs.count(), 1);
|
||||
QCOMPARE(part->url().url(), QString("file://%1").arg(externalProcessPath));
|
||||
QCOMPARE(part->url().url(), QStringLiteral("file://%1").arg(externalProcessPath));
|
||||
QCOMPARE(partDocument(part)->currentPage(), externalProcessExpectedPage);
|
||||
}
|
||||
else
|
||||
|
@ -303,7 +325,7 @@ void MainShellTest::testShell()
|
|||
// It is attaching to us so a second tab is there
|
||||
QCOMPARE(s->m_tabs.count(), 2);
|
||||
Okular::Part *part2 = dynamic_cast<Okular::Part*>(s->m_tabs[1].part);
|
||||
QCOMPARE(part2->url().url(), QString("file://%1").arg(externalProcessPath));
|
||||
QCOMPARE(part2->url().url(), QStringLiteral("file://%1").arg(externalProcessPath));
|
||||
QCOMPARE(partDocument(part2)->currentPage(), externalProcessExpectedPage);
|
||||
}
|
||||
}
|
||||
|
@ -315,11 +337,10 @@ void MainShellTest::testShell()
|
|||
QCOMPARE(p.state(), QProcess::Running);
|
||||
p.terminate();
|
||||
p.waitForFinished();
|
||||
QCOMPARE(p.exitCode(), 0);
|
||||
|
||||
QVERIFY(p.state() != QProcess::Running);
|
||||
// It opened on a new process, so no change for us
|
||||
QCOMPARE(s->m_tabs.count(), 1);
|
||||
QCOMPARE(part->url().url(), QString("file://%1").arg(paths[0]));
|
||||
QCOMPARE(part->url().url(), QStringLiteral("file://%1").arg(paths[0]));
|
||||
QCOMPARE(partDocument(part)->currentPage(), externalProcessExpectedPage);
|
||||
}
|
||||
}
|
||||
|
@ -328,12 +349,7 @@ void MainShellTest::testShell()
|
|||
{
|
||||
QCOMPARE(paths.count(), 1);
|
||||
Okular::Part *part = s->findChild<Okular::Part*>();
|
||||
|
||||
// Oh Qt5 i want your QTRY_VERIFY
|
||||
for (int i = 0; presentationWidget(part) == 0 && i < 20; ++i) {
|
||||
QTest::qWait(100);
|
||||
}
|
||||
QVERIFY(presentationWidget(part) != 0);
|
||||
QTRY_VERIFY(presentationWidget(part) != nullptr);
|
||||
}
|
||||
|
||||
if (externalProcessExpectPresentation)
|
||||
|
@ -350,10 +366,7 @@ void MainShellTest::testShell()
|
|||
part = dynamic_cast<Okular::Part*>(s->m_tabs[1].part);
|
||||
}
|
||||
|
||||
for (int i = 0; presentationWidget(part) == 0 && i < 20; ++i) {
|
||||
QTest::qWait(100);
|
||||
}
|
||||
QVERIFY(presentationWidget(part) != 0);
|
||||
QTRY_VERIFY(presentationWidget(part) != nullptr);
|
||||
}
|
||||
|
||||
if (helper)
|
||||
|
@ -367,7 +380,7 @@ void ClosePrintDialogHelper::closePrintDialog()
|
|||
Shell *s = findShell();
|
||||
QPrintDialog *dialog = s->findChild<QPrintDialog*>();
|
||||
if (!dialog) {
|
||||
QTimer::singleShot(0, this, SLOT(closePrintDialog()));
|
||||
QTimer::singleShot(0, this, &ClosePrintDialogHelper::closePrintDialog);
|
||||
return;
|
||||
}
|
||||
QVERIFY(dialog);
|
||||
|
@ -389,7 +402,7 @@ void MainShellTest::testFileRemembersPagePosition()
|
|||
{
|
||||
QFETCH(int, mode);
|
||||
|
||||
const QStringList paths = QStringList(KDESRCDIR "data/contents.epub");
|
||||
const QStringList paths = QStringList(QStringLiteral(KDESRCDIR "data/contents.epub"));
|
||||
QString serializedOptions;
|
||||
if (mode == 1 || mode == 3)
|
||||
serializedOptions = ShellUtils::serializeOptions(false, false, false, false, QString());
|
||||
|
@ -404,7 +417,7 @@ void MainShellTest::testFileRemembersPagePosition()
|
|||
QVERIFY(s);
|
||||
Okular::Part *part = s->findChild<Okular::Part*>();
|
||||
QVERIFY(part);
|
||||
QCOMPARE(part->url().url(), QString("file://%1").arg(paths[0]));
|
||||
QCOMPARE(part->url().url(), QStringLiteral("file://%1").arg(paths[0]));
|
||||
QCOMPARE(partDocument(part)->currentPage(), 0u);
|
||||
partDocument(part)->setViewportPage(3);
|
||||
QCOMPARE(partDocument(part)->currentPage(), 3u);
|
||||
|
@ -420,26 +433,24 @@ void MainShellTest::testFileRemembersPagePosition()
|
|||
else
|
||||
{
|
||||
QProcess p;
|
||||
QString command = "okular " + paths[0] ;
|
||||
QStringList args;
|
||||
args << paths[0];
|
||||
if (mode == 2)
|
||||
command += " -unique";
|
||||
p.start(command);
|
||||
args << QStringLiteral("-unique");
|
||||
p.start(QStringLiteral(OKULAR_BINARY), args);
|
||||
p.waitForStarted();
|
||||
QCOMPARE(p.state(), QProcess::Running);
|
||||
|
||||
// It is attaching to us, so will eventually stop
|
||||
for (int i = 0; p.state() != QProcess::NotRunning && i < 20; ++i) {
|
||||
QTest::qWait(100);
|
||||
}
|
||||
QCOMPARE(p.state(), QProcess::NotRunning);
|
||||
QCOMPARE(p.exitStatus(), QProcess::NormalExit);
|
||||
QTRY_COMPARE_WITH_TIMEOUT((int)p.state(), (int)QProcess::NotRunning, 20000);
|
||||
QCOMPARE((int)p.exitStatus(), (int)QProcess::NormalExit);
|
||||
QCOMPARE(p.exitCode(), 0);
|
||||
}
|
||||
s = findShell();
|
||||
QVERIFY(s);
|
||||
part = s->findChild<Okular::Part*>();
|
||||
QVERIFY(part);
|
||||
QCOMPARE(part->url().url(), QString("file://%1").arg(paths[0]));
|
||||
QCOMPARE(part->url().url(), QStringLiteral("file://%1").arg(paths[0]));
|
||||
QCOMPARE(partDocument(part)->currentPage(), 3u);
|
||||
}
|
||||
|
||||
|
@ -450,7 +461,7 @@ void MainShellTest::test2FilesError_data()
|
|||
QTest::newRow("startInPresentation") << ShellUtils::serializeOptions(true, false, false, false, QString());
|
||||
QTest::newRow("showPrintDialog") << ShellUtils::serializeOptions(false, true, false, false, QString());
|
||||
QTest::newRow("unique") << ShellUtils::serializeOptions(false, false, true, false, QString());
|
||||
QTest::newRow("pageNumger") << ShellUtils::serializeOptions(false, false, false, false, "3");
|
||||
QTest::newRow("pageNumger") << ShellUtils::serializeOptions(false, false, false, false, QStringLiteral("3"));
|
||||
}
|
||||
|
||||
void MainShellTest::test2FilesError()
|
||||
|
@ -458,7 +469,7 @@ void MainShellTest::test2FilesError()
|
|||
QFETCH(QString, serializedOptions);
|
||||
|
||||
QStringList paths;
|
||||
paths << KDESRCDIR "data/file1.pdf" << KDESRCDIR "data/tocreload.pdf";
|
||||
paths << QStringLiteral(KDESRCDIR "data/file1.pdf") << QStringLiteral(KDESRCDIR "data/tocreload.pdf");
|
||||
Okular::Status status = Okular::main(paths, serializedOptions);
|
||||
QCOMPARE(status, Okular::Error);
|
||||
|
||||
|
@ -467,6 +478,108 @@ void MainShellTest::test2FilesError()
|
|||
QVERIFY(!s);
|
||||
}
|
||||
|
||||
void MainShellTest::testSessionRestore_data()
|
||||
{
|
||||
QTest::addColumn<QStringList>("paths");
|
||||
QTest::addColumn<QString>("options");
|
||||
QTest::addColumn<bool>("useTabsOpen");
|
||||
QTest::addColumn<bool>("useTabsRestore");
|
||||
|
||||
QTEST_KDEMAIN( MainShellTest, GUI )
|
||||
QStringList oneDocPaths(QStringLiteral( KDESRCDIR "data/file1.pdf" ) );
|
||||
QStringList twoDocPaths( oneDocPaths );
|
||||
twoDocPaths << QStringLiteral(KDESRCDIR "data/formSamples.pdf");
|
||||
|
||||
const QString options = ShellUtils::serializeOptions(false, false, false, false, QString());
|
||||
|
||||
QTest::newRow("1 doc, 1 window, tabs") << oneDocPaths << options << true << true;
|
||||
QTest::newRow("2 docs, 1 window, tabs") << twoDocPaths << options << true << true;
|
||||
QTest::newRow("2 docs, 2 windows, tabs") << twoDocPaths << options << false << true;
|
||||
QTest::newRow("2 docs, 2 windows, no tabs") << twoDocPaths << options << false << false;
|
||||
QTest::newRow("2 docs, 1 window, no tabs") << twoDocPaths << options << true << false;
|
||||
}
|
||||
|
||||
void MainShellTest::testSessionRestore()
|
||||
{
|
||||
QFETCH( QStringList, paths );
|
||||
QFETCH( QString, options );
|
||||
QFETCH( bool, useTabsOpen );
|
||||
QFETCH( bool, useTabsRestore );
|
||||
|
||||
Okular::Settings::self()->setShellOpenFileInTabs( useTabsOpen );
|
||||
|
||||
Okular::Status status = Okular::main( paths, options );
|
||||
QCOMPARE( status, Okular::Success );
|
||||
|
||||
// Gather some information about the state
|
||||
// Verify that the correct number of windows/tabs were opened
|
||||
QList<Shell*> shells = getShells();
|
||||
QVERIFY( !shells.isEmpty() );
|
||||
int numDocs = 0;
|
||||
foreach( Shell* shell, shells )
|
||||
{
|
||||
QTest::qWaitForWindowExposed( shell );
|
||||
numDocs += shell->m_tabs.size();
|
||||
}
|
||||
|
||||
QCOMPARE( numDocs, paths.size() );
|
||||
QCOMPARE( shells.size(), useTabsOpen ? 1 : paths.size() );
|
||||
QTest::qWait( 100 );
|
||||
|
||||
// Simulate session shutdown. The actual shutdown path comes through
|
||||
// QSessionManager XSMP handlers, then KApplication::commitData/saveState,
|
||||
// then KMWSessionManager::commitData/saveState. Without simulating an X
|
||||
// session manager, the best we can do here is to make a temporary Config
|
||||
// and call KMainWindows save functions directly.
|
||||
QTemporaryFile configFile;
|
||||
QVERIFY( configFile.open() );
|
||||
|
||||
int numWindows = 0;
|
||||
{ // Scope for config so that we can reconstruct from file
|
||||
KConfig config( configFile.fileName(), KConfig::SimpleConfig );
|
||||
foreach( Shell* shell, shells )
|
||||
{
|
||||
shell->savePropertiesInternal( &config, ++numWindows );
|
||||
// Windows aren't necessarily closed on shutdown, but we'll use
|
||||
// this as a way to trigger the destructor code, which is normally
|
||||
// connected to the aboutToQuit signal
|
||||
shell->close();
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for shells to delete themselves. QTest::qWait doesn't do deferred
|
||||
// deletions so we'll set up a full event loop to do that.
|
||||
QEventLoop eventLoop;
|
||||
QTimer::singleShot( 100, &eventLoop, &QEventLoop::quit );
|
||||
eventLoop.exec( QEventLoop::AllEvents );
|
||||
shells = getShells();
|
||||
QVERIFY( shells.isEmpty() );
|
||||
|
||||
Okular::Settings::self()->setShellOpenFileInTabs( useTabsRestore );
|
||||
|
||||
// Simulate session restore. We can't call KMainWindow::restore() directly
|
||||
// because it asks for info from the session manager, which doesn't know
|
||||
// about our temporary config. But the logic here mostly mirrors restore().
|
||||
KConfig config( configFile.fileName(), KConfig::SimpleConfig );
|
||||
for( int i = 1; i <= numWindows; ++i )
|
||||
{
|
||||
Shell* shell = new Shell;
|
||||
shell->readPropertiesInternal( &config, i );
|
||||
shell->show();
|
||||
}
|
||||
|
||||
// Verify that the restore state is reasonable
|
||||
shells = getShells();
|
||||
QVERIFY( !shells.isEmpty() );
|
||||
numDocs = 0;
|
||||
foreach( Shell* shell, shells )
|
||||
{
|
||||
QTest::qWaitForWindowExposed( shell );
|
||||
numDocs += shell->m_tabs.size();
|
||||
}
|
||||
|
||||
QCOMPARE( numDocs, paths.size() );
|
||||
QCOMPARE( shells.size(), useTabsRestore ? numWindows : paths.size() );
|
||||
}
|
||||
|
||||
QTEST_MAIN( MainShellTest )
|
||||
#include "mainshelltest.moc"
|
|
@ -7,8 +7,10 @@
|
|||
* (at your option) any later version. *
|
||||
***************************************************************************/
|
||||
|
||||
#include <qtest_kde.h>
|
||||
#include <kmimetype.h>
|
||||
#include <QtTest>
|
||||
|
||||
#include <QMimeType>
|
||||
#include <QMimeDatabase>
|
||||
#include "../settings_core.h"
|
||||
#include <core/area.h>
|
||||
#include <core/annotations.h>
|
||||
|
@ -38,8 +40,8 @@ private:
|
|||
|
||||
void ModifyAnnotationPropertiesTest::initTestCase()
|
||||
{
|
||||
Okular::SettingsCore::instance( "editannotationcontentstest" );
|
||||
m_document = new Okular::Document( 0 );
|
||||
Okular::SettingsCore::instance( QStringLiteral("editannotationcontentstest") );
|
||||
m_document = new Okular::Document( nullptr );
|
||||
}
|
||||
|
||||
void ModifyAnnotationPropertiesTest::cleanupTestCase()
|
||||
|
@ -49,9 +51,10 @@ void ModifyAnnotationPropertiesTest::cleanupTestCase()
|
|||
|
||||
void ModifyAnnotationPropertiesTest::init()
|
||||
{
|
||||
const QString testFile = KDESRCDIR "data/file1.pdf";
|
||||
const KMimeType::Ptr mime = KMimeType::findByPath( testFile );
|
||||
m_document->openDocument(testFile, KUrl(), mime);
|
||||
const QString testFile = QStringLiteral(KDESRCDIR "data/file1.pdf");
|
||||
QMimeDatabase db;
|
||||
const QMimeType mime = db.mimeTypeForFile( testFile );
|
||||
QCOMPARE( m_document->openDocument(testFile, QUrl(), mime), Okular::Document::OpenSuccess );
|
||||
|
||||
// Undo and Redo should be unavailable when docuemnt is first opened.
|
||||
QVERIFY( !m_document->canUndo() );
|
||||
|
@ -60,8 +63,8 @@ void ModifyAnnotationPropertiesTest::init()
|
|||
// Create two distinct text annotations
|
||||
m_annot1 = new Okular::TextAnnotation();
|
||||
m_annot1->setBoundingRectangle( Okular::NormalizedRect( 0.1, 0.1, 0.15, 0.15 ) );
|
||||
m_annot1->setContents( QString( "Hello, World" ) );
|
||||
m_annot1->setAuthor( "Jon Mease" );
|
||||
m_annot1->setContents( QStringLiteral( "Hello, World" ) );
|
||||
m_annot1->setAuthor( QStringLiteral("Jon Mease") );
|
||||
m_annot1->style().setColor( RED );
|
||||
m_annot1->style().setWidth( 4.0 );
|
||||
m_document->addPageAnnotation( 0, m_annot1 );
|
||||
|
@ -164,5 +167,5 @@ void ModifyAnnotationPropertiesTest::testModifyAnnotationPropertiesWithRotation_
|
|||
QCOMPARE( transformedBoundingRect, m_annot1->transformedBoundingRectangle() );
|
||||
}
|
||||
|
||||
QTEST_KDEMAIN( ModifyAnnotationPropertiesTest, GUI )
|
||||
QTEST_MAIN( ModifyAnnotationPropertiesTest )
|
||||
#include "modifyannotationpropertiestest.moc"
|
|
@ -7,17 +7,19 @@
|
|||
* (at your option) any later version. *
|
||||
***************************************************************************/
|
||||
|
||||
#include <qtest_kde.h>
|
||||
#include <QtTest>
|
||||
|
||||
#include "../part.h"
|
||||
#include "../core/annotations.h"
|
||||
#include "../core/page.h"
|
||||
#include "../part.h"
|
||||
#include "../ui/toc.h"
|
||||
#include "../ui/pageview.h"
|
||||
|
||||
#include <KConfigDialog>
|
||||
#include <KStandardDirs>
|
||||
#include <KTempDir>
|
||||
|
||||
#include <QClipboard>
|
||||
#include <QScrollBar>
|
||||
#include <QTemporaryDir>
|
||||
#include <QTreeView>
|
||||
|
||||
namespace Okular
|
||||
|
@ -27,23 +29,27 @@ class PartTest
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
static bool openDocument(Okular::Part *part, const QString &filePath);
|
||||
|
||||
private slots:
|
||||
void testReload();
|
||||
void testCanceledReload();
|
||||
void testTOCReload();
|
||||
void testFowardPDF();
|
||||
void testFowardPDF_data();
|
||||
void testGeneratorPreferences();
|
||||
void testSelectText();
|
||||
void testClickInternalLink();
|
||||
void testSaveAs();
|
||||
void testSaveAs_data();
|
||||
void testGeneratorPreferences();
|
||||
};
|
||||
|
||||
class PartThatHijacksQueryClose : public Okular::Part
|
||||
{
|
||||
public:
|
||||
PartThatHijacksQueryClose(QWidget* parentWidget, QObject* parent,
|
||||
const QVariantList& args, KComponentData componentData)
|
||||
: Okular::Part(parentWidget, parent, args, componentData),
|
||||
const QVariantList& args)
|
||||
: Okular::Part(parentWidget, parent, args),
|
||||
behavior(PassThru)
|
||||
{}
|
||||
|
||||
|
@ -54,7 +60,7 @@ class PartThatHijacksQueryClose : public Okular::Part
|
|||
behavior = new_behavior;
|
||||
}
|
||||
|
||||
bool queryClose()
|
||||
bool queryClose() override
|
||||
{
|
||||
if (behavior == PassThru)
|
||||
return Okular::Part::queryClose();
|
||||
|
@ -65,12 +71,18 @@ class PartThatHijacksQueryClose : public Okular::Part
|
|||
Behavior behavior;
|
||||
};
|
||||
|
||||
bool PartTest::openDocument(Okular::Part *part, const QString &filePath)
|
||||
{
|
||||
part->openDocument( filePath );
|
||||
return part->m_document->isOpened();
|
||||
}
|
||||
|
||||
// Test that Okular doesn't crash after a successful reload
|
||||
void PartTest::testReload()
|
||||
{
|
||||
QVariantList dummyArgs;
|
||||
Okular::Part part(NULL, NULL, dummyArgs, KGlobal::mainComponent());
|
||||
part.openDocument(KDESRCDIR "data/file1.pdf");
|
||||
Okular::Part part(nullptr, nullptr, dummyArgs);
|
||||
QVERIFY( openDocument(&part, QStringLiteral(KDESRCDIR "data/file1.pdf")) );
|
||||
part.reload();
|
||||
qApp->processEvents();
|
||||
}
|
||||
|
@ -79,8 +91,8 @@ void PartTest::testReload()
|
|||
void PartTest::testCanceledReload()
|
||||
{
|
||||
QVariantList dummyArgs;
|
||||
PartThatHijacksQueryClose part(NULL, NULL, dummyArgs, KGlobal::mainComponent());
|
||||
part.openDocument(KDESRCDIR "data/file1.pdf");
|
||||
PartThatHijacksQueryClose part(nullptr, nullptr, dummyArgs);
|
||||
QVERIFY( openDocument(&part, QStringLiteral(KDESRCDIR "data/file1.pdf")) );
|
||||
|
||||
// When queryClose() returns false, the reload operation is canceled (as if
|
||||
// the user had chosen Cancel in the "Save changes?" message box)
|
||||
|
@ -94,8 +106,8 @@ void PartTest::testCanceledReload()
|
|||
void PartTest::testTOCReload()
|
||||
{
|
||||
QVariantList dummyArgs;
|
||||
Okular::Part part(NULL, NULL, dummyArgs, KGlobal::mainComponent());
|
||||
part.openDocument(KDESRCDIR "data/tocreload.pdf");
|
||||
Okular::Part part(nullptr, nullptr, dummyArgs);
|
||||
QVERIFY( openDocument(&part, QStringLiteral(KDESRCDIR "data/tocreload.pdf")) );
|
||||
QCOMPARE(part.m_toc->expandedNodes().count(), 0);
|
||||
part.m_toc->m_treeView->expandAll();
|
||||
QCOMPARE(part.m_toc->expandedNodes().count(), 3);
|
||||
|
@ -109,29 +121,45 @@ void PartTest::testFowardPDF()
|
|||
QFETCH(QString, dir);
|
||||
|
||||
QVariantList dummyArgs;
|
||||
Okular::Part part(NULL, NULL, dummyArgs, KGlobal::mainComponent());
|
||||
Okular::Part part(nullptr, nullptr, dummyArgs);
|
||||
|
||||
KTempDir tempDir(dir);
|
||||
QFile f(KDESRCDIR "data/synctextest.tex");
|
||||
const QString texDestination = tempDir.name() + "synctextest.tex";
|
||||
// Create temp dir named like this: ${system temp dir}/${random string}/${dir}
|
||||
const QTemporaryDir tempDir;
|
||||
const QDir workDir(QDir(tempDir.path()).filePath(dir));
|
||||
workDir.mkpath(QStringLiteral("."));
|
||||
|
||||
QFile f(QStringLiteral(KDESRCDIR "data/synctextest.tex"));
|
||||
const QString texDestination = workDir.path() + QStringLiteral("/synctextest.tex");
|
||||
QVERIFY(f.copy(texDestination));
|
||||
|
||||
QProcess process;
|
||||
process.setWorkingDirectory(tempDir.name());
|
||||
process.start("pdflatex", QStringList() << "-synctex=1" << "-interaction=nonstopmode" << texDestination);
|
||||
process.waitForFinished();
|
||||
process.setWorkingDirectory(workDir.path());
|
||||
process.start(QStringLiteral("pdflatex"), QStringList() << QStringLiteral("-synctex=1") << QStringLiteral("-interaction=nonstopmode") << texDestination);
|
||||
bool started = process.waitForStarted();
|
||||
if (!started) {
|
||||
qDebug() << "start error:" << process.error();
|
||||
qDebug() << "start stdout:" << process.readAllStandardOutput();
|
||||
qDebug() << "start stderr:" << process.readAllStandardError();
|
||||
}
|
||||
QVERIFY(started);
|
||||
|
||||
const QString pdfResult = tempDir.name() + "synctextest.pdf";
|
||||
process.waitForFinished();
|
||||
if (process.exitStatus() != QProcess::NormalExit || process.exitCode() != 0) {
|
||||
qDebug() << "exit error:" << process.error() << "status" << process.exitStatus() << "code" << process.exitCode();
|
||||
qDebug() << "exit stdout:" << process.readAllStandardOutput();
|
||||
qDebug() << "exit stderr:" << process.readAllStandardError();
|
||||
}
|
||||
|
||||
const QString pdfResult = workDir.path() + QStringLiteral("/synctextest.pdf");
|
||||
|
||||
QVERIFY(QFile::exists(pdfResult));
|
||||
|
||||
part.openDocument(pdfResult);
|
||||
QVERIFY( openDocument(&part, pdfResult) );
|
||||
part.m_document->setViewportPage(0);
|
||||
QCOMPARE(part.m_document->currentPage(), 0u);
|
||||
part.closeUrl();
|
||||
|
||||
KUrl u(pdfResult);
|
||||
u.setHTMLRef("src:100" + texDestination);
|
||||
QUrl u(QUrl::fromLocalFile(pdfResult));
|
||||
u.setFragment(QStringLiteral("src:100") + texDestination);
|
||||
part.openUrl(u);
|
||||
QCOMPARE(part.m_document->currentPage(), 1u);
|
||||
}
|
||||
|
@ -140,8 +168,90 @@ void PartTest::testFowardPDF_data()
|
|||
{
|
||||
QTest::addColumn<QString>("dir");
|
||||
|
||||
QTest::newRow("non-utf8") << QString(KGlobal::dirs()->resourceDirs("tmp")[0] + QString::fromUtf8("synctextest"));
|
||||
QTest::newRow("utf8") << QString(KGlobal::dirs()->resourceDirs("tmp")[0] + QString::fromUtf8("ßðđđŋßðđŋ"));
|
||||
QTest::newRow("non-utf8") << QString::fromUtf8("synctextest");
|
||||
QTest::newRow("utf8") << QString::fromUtf8("ßðđđŋßðđŋ");
|
||||
}
|
||||
|
||||
void PartTest::testGeneratorPreferences()
|
||||
{
|
||||
KConfigDialog * dialog;
|
||||
QVariantList dummyArgs;
|
||||
Okular::Part part(nullptr, nullptr, dummyArgs);
|
||||
|
||||
// Test that we don't crash while opening the dialog
|
||||
dialog = part.slotGeneratorPreferences();
|
||||
qApp->processEvents();
|
||||
delete dialog; // closes the dialog and recursively destroys all widgets
|
||||
|
||||
// Test that we don't crash while opening a new instance of the dialog
|
||||
// This catches attempts to reuse widgets that have been destroyed
|
||||
dialog = part.slotGeneratorPreferences();
|
||||
qApp->processEvents();
|
||||
delete dialog;
|
||||
}
|
||||
|
||||
void PartTest::testSelectText()
|
||||
{
|
||||
QVariantList dummyArgs;
|
||||
Okular::Part part(nullptr, nullptr, dummyArgs);
|
||||
QVERIFY(openDocument(&part, QStringLiteral(KDESRCDIR "data/file2.pdf")));
|
||||
part.widget()->show();
|
||||
QTest::qWaitForWindowExposed(part.widget());
|
||||
|
||||
const int width = part.m_pageView->horizontalScrollBar()->maximum() +
|
||||
part.m_pageView->viewport()->width();
|
||||
const int height = part.m_pageView->verticalScrollBar()->maximum() +
|
||||
part.m_pageView->viewport()->height();
|
||||
|
||||
part.m_document->setViewportPage(0);
|
||||
|
||||
// wait for pixmap
|
||||
QTRY_VERIFY(part.m_document->page(0)->hasPixmap(part.m_pageView));
|
||||
|
||||
QVERIFY(QMetaObject::invokeMethod(part.m_pageView, "slotSetMouseTextSelect"));
|
||||
|
||||
const int mouseY = height * 0.052;
|
||||
const int mouseStartX = width * 0.12;
|
||||
const int mouseEndX = width * 0.7;
|
||||
|
||||
QTest::mouseMove(part.m_pageView->viewport(), QPoint(mouseStartX, mouseY));
|
||||
QTest::mousePress(part.m_pageView->viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(mouseStartX, mouseY));
|
||||
QTest::mouseMove(part.m_pageView->viewport(), QPoint(mouseEndX, mouseY));
|
||||
// without this wait the test fails. 100ms were enough on my local system, but when running under valgrind
|
||||
// or on the CI server we need to wait longer.
|
||||
QTest::qWait(1000);
|
||||
QTest::mouseRelease(part.m_pageView->viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(mouseEndX, mouseY));
|
||||
|
||||
QApplication::clipboard()->clear();
|
||||
QVERIFY(QMetaObject::invokeMethod(part.m_pageView, "copyTextSelection"));
|
||||
|
||||
QCOMPARE(QApplication::clipboard()->text(), QStringLiteral("Hola que tal\n"));
|
||||
}
|
||||
|
||||
void PartTest::testClickInternalLink()
|
||||
{
|
||||
QVariantList dummyArgs;
|
||||
Okular::Part part(nullptr, nullptr, dummyArgs);
|
||||
QVERIFY(openDocument(&part, QStringLiteral(KDESRCDIR "data/file2.pdf")));
|
||||
part.widget()->show();
|
||||
QTest::qWaitForWindowExposed(part.widget());
|
||||
|
||||
const int width = part.m_pageView->horizontalScrollBar()->maximum() +
|
||||
part.m_pageView->viewport()->width();
|
||||
const int height = part.m_pageView->verticalScrollBar()->maximum() +
|
||||
part.m_pageView->viewport()->height();
|
||||
|
||||
part.m_document->setViewportPage(0);
|
||||
|
||||
// wait for pixmap
|
||||
while (!part.m_document->page(0)->hasPixmap(part.m_pageView))
|
||||
QTest::qWait(100);
|
||||
|
||||
QMetaObject::invokeMethod(part.m_pageView, "slotSetMouseNormal");
|
||||
|
||||
QCOMPARE(part.m_document->currentPage(), 0u);
|
||||
QTest::mouseClick(part.m_pageView->viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(width * 0.17, height * 0.05));
|
||||
QCOMPARE(part.m_document->currentPage(), 1u);
|
||||
}
|
||||
|
||||
void PartTest::testSaveAs()
|
||||
|
@ -168,7 +278,7 @@ void PartTest::testSaveAs()
|
|||
|
||||
qDebug() << "Open file, add annotation and save both natively and to .okular";
|
||||
{
|
||||
Okular::Part part(NULL, NULL, QVariantList(), KGlobal::mainComponent());
|
||||
Okular::Part part(nullptr, nullptr, QVariantList());
|
||||
part.openDocument( file );
|
||||
|
||||
Okular::Annotation *annot = new Okular::TextAnnotation();
|
||||
|
@ -177,21 +287,21 @@ void PartTest::testSaveAs()
|
|||
part.m_document->addPageAnnotation( 0, annot );
|
||||
annotName = annot->uniqueName();
|
||||
|
||||
QVERIFY( part.saveAs( KUrl( archiveSave.fileName() ), Part::SaveAsOkularArchive ) );
|
||||
QVERIFY( part.saveAs( KUrl( nativeDirectSave.fileName() ), saveAsNativeFlags ) );
|
||||
QVERIFY( part.saveAs( QUrl::fromLocalFile( archiveSave.fileName() ), Part::SaveAsOkularArchive ) );
|
||||
QVERIFY( part.saveAs( QUrl::fromLocalFile( nativeDirectSave.fileName() ), saveAsNativeFlags ) );
|
||||
|
||||
part.closeUrl();
|
||||
}
|
||||
|
||||
qDebug() << "Open the .okular, check that the annotation is present and save to native";
|
||||
{
|
||||
Okular::Part part(NULL, NULL, QVariantList(), KGlobal::mainComponent());
|
||||
Okular::Part part(nullptr, nullptr, QVariantList());
|
||||
part.openDocument( archiveSave.fileName() );
|
||||
|
||||
QCOMPARE( part.m_document->page( 0 )->annotations().size(), 1 );
|
||||
QCOMPARE( part.m_document->page( 0 )->annotations().first()->uniqueName(), annotName );
|
||||
|
||||
QVERIFY( part.saveAs( KUrl( nativeFromArchiveFile.fileName() ), saveAsNativeFlags ) );
|
||||
QVERIFY( part.saveAs( QUrl::fromLocalFile( nativeFromArchiveFile.fileName() ), saveAsNativeFlags ) );
|
||||
|
||||
part.closeUrl();
|
||||
}
|
||||
|
@ -199,7 +309,7 @@ void PartTest::testSaveAs()
|
|||
qDebug() << "Open the native file saved directly, and check that the annot"
|
||||
<< "is there iff we expect it";
|
||||
{
|
||||
Okular::Part part(NULL, NULL, QVariantList(), KGlobal::mainComponent());
|
||||
Okular::Part part(nullptr, nullptr, QVariantList());
|
||||
part.openDocument( nativeDirectSave.fileName() );
|
||||
|
||||
QCOMPARE( part.m_document->page( 0 )->annotations().size(), nativelySupportsAnnotations ? 1 : 0 );
|
||||
|
@ -212,7 +322,7 @@ void PartTest::testSaveAs()
|
|||
qDebug() << "Open the native file saved from the .okular, and check that the annot"
|
||||
<< "is there iff we expect it";
|
||||
{
|
||||
Okular::Part part(NULL, NULL, QVariantList(), KGlobal::mainComponent());
|
||||
Okular::Part part(nullptr, nullptr, QVariantList());
|
||||
part.openDocument( nativeFromArchiveFile.fileName() );
|
||||
|
||||
QCOMPARE( part.m_document->page( 0 )->annotations().size(), nativelySupportsAnnotations ? 1 : 0 );
|
||||
|
@ -233,45 +343,42 @@ void PartTest::testSaveAs_data()
|
|||
QTest::newRow("epub") << KDESRCDIR "data/contents.epub" << "epub" << false;
|
||||
}
|
||||
|
||||
void PartTest::testGeneratorPreferences()
|
||||
{
|
||||
KConfigDialog * dialog;
|
||||
QVariantList dummyArgs;
|
||||
Okular::Part part(NULL, NULL, dummyArgs, KGlobal::mainComponent());
|
||||
|
||||
// Test that we don't crash while opening the dialog
|
||||
dialog = part.slotGeneratorPreferences();
|
||||
qApp->processEvents();
|
||||
delete dialog; // closes the dialog and recursively destroys all widgets
|
||||
|
||||
// Test that we don't crash while opening a new instance of the dialog
|
||||
// This catches attempts to reuse widgets that have been destroyed
|
||||
dialog = part.slotGeneratorPreferences();
|
||||
qApp->processEvents();
|
||||
delete dialog;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// This is QTEST_KDEMAIN withouth the LC_ALL set
|
||||
setenv("LC_ALL", "en_US.UTF-8", 1);
|
||||
assert( !QDir::homePath().isEmpty() );
|
||||
setenv("KDEHOME", QFile::encodeName( QDir::homePath() + QString::fromLatin1("/.kde-unit-test") ), 1);
|
||||
setenv("XDG_DATA_HOME", QFile::encodeName( QDir::homePath() + QString::fromLatin1("/.kde-unit-test/xdg/local") ), 1);
|
||||
setenv("XDG_CONFIG_HOME", QFile::encodeName( QDir::homePath() + QString::fromLatin1("/.kde-unit-test/xdg/config") ), 1);
|
||||
setenv("KDE_SKIP_KDERC", "1", 1);
|
||||
unsetenv("KDE_COLOR_DEBUG");
|
||||
QFile::remove(QDir::homePath() + QString::fromLatin1("/.kde-unit-test/share/config/qttestrc"));
|
||||
KAboutData aboutData( QByteArray("qttest"), QByteArray(), ki18n("KDE Test Program"), QByteArray("version") );
|
||||
KComponentData cData(&aboutData);
|
||||
// Force consistent locale
|
||||
QLocale locale(QStringLiteral("en_US.UTF-8"));
|
||||
if (locale == QLocale::c()) { // This is the way to check if the above worked
|
||||
locale = QLocale(QLocale::English, QLocale::UnitedStates);
|
||||
}
|
||||
|
||||
QLocale::setDefault(locale);
|
||||
qputenv("LC_ALL", "en_US.UTF-8"); // For UNIX, third-party libraries
|
||||
|
||||
// Ensure consistent configs/caches
|
||||
QTemporaryDir homeDir; // QTemporaryDir automatically cleans up when it goes out of scope
|
||||
Q_ASSERT(homeDir.isValid());
|
||||
QByteArray homePath = QFile::encodeName(homeDir.path());
|
||||
qDebug() << homePath;
|
||||
qputenv("USERPROFILE", homePath);
|
||||
qputenv("HOME", homePath);
|
||||
qputenv("XDG_DATA_HOME", homePath + "/.local");
|
||||
qputenv("XDG_CONFIG_HOME", homePath + "/.kde-unit-test/xdg/config");
|
||||
|
||||
// Disable fancy debug output
|
||||
qunsetenv("QT_MESSAGE_PATTERN");
|
||||
|
||||
QApplication app( argc, argv );
|
||||
app.setApplicationName( QLatin1String("qttest") );
|
||||
qRegisterMetaType<KUrl>(); /*as done by kapplication*/
|
||||
qRegisterMetaType<KUrl::List>();
|
||||
app.setApplicationName(QLatin1String("okularparttest"));
|
||||
app.setOrganizationDomain(QLatin1String("kde.org"));
|
||||
app.setQuitOnLastWindowClosed(false);
|
||||
|
||||
qRegisterMetaType<QUrl>(); /*as done by kapplication*/
|
||||
qRegisterMetaType<QList<QUrl>>();
|
||||
|
||||
Okular::PartTest test;
|
||||
KGlobal::ref(); /* don't quit qeventloop after closing a mainwindow */
|
||||
|
||||
return QTest::qExec( &test, argc, argv );
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
* (at your option) any later version. *
|
||||
***************************************************************************/
|
||||
|
||||
#include <qtest_kde.h>
|
||||
#include <QtTest>
|
||||
|
||||
#include "../core/document.h"
|
||||
#include "../core/page.h"
|
||||
|
@ -53,7 +53,7 @@ class SearchTest : public QObject
|
|||
void SearchTest::initTestCase()
|
||||
{
|
||||
qRegisterMetaType<Okular::Document::SearchStatus>();
|
||||
Okular::SettingsCore::instance( "searchtest" );
|
||||
Okular::SettingsCore::instance( QStringLiteral("searchtest") );
|
||||
}
|
||||
|
||||
static void createTextPage(const QVector<QString>& text, const QVector<Okular::NormalizedRect>& rect,
|
||||
|
@ -121,17 +121,17 @@ void SearchTest::testNextAndPrevious()
|
|||
#define TEST_NEXT_PREV_SITUATION_COUNT 4
|
||||
|
||||
QVector<QString> texts[TEST_NEXT_PREV_SITUATION_COUNT] = {
|
||||
QVector<QString>() << "a" << "b" << "a" << "b" << "a",
|
||||
QVector<QString>() << "a" << "b" << "a" << "b",
|
||||
QVector<QString>() << "a" << "b" << "a" << "b" << "a" << "b" << "a" ,
|
||||
QVector<QString>() << "a" << " " << "ba" << " " << "b"
|
||||
QVector<QString>() << QStringLiteral("a") << QStringLiteral("b") << QStringLiteral("a" ) << QStringLiteral("b") << QStringLiteral("a"),
|
||||
QVector<QString>() << QStringLiteral("a") << QStringLiteral("b") << QStringLiteral("a" ) << QStringLiteral("b"),
|
||||
QVector<QString>() << QStringLiteral("a") << QStringLiteral("b") << QStringLiteral("a" ) << QStringLiteral("b") << QStringLiteral("a") << QStringLiteral("b") << QStringLiteral("a"),
|
||||
QVector<QString>() << QStringLiteral("a") << QStringLiteral(" ") << QStringLiteral("ba") << QStringLiteral(" ") << QStringLiteral("b")
|
||||
};
|
||||
|
||||
QString searchStrings[TEST_NEXT_PREV_SITUATION_COUNT] = {
|
||||
"b",
|
||||
"ab",
|
||||
"aba",
|
||||
"a b"
|
||||
QStringLiteral("b"),
|
||||
QStringLiteral("ab"),
|
||||
QStringLiteral("aba"),
|
||||
QStringLiteral("a b")
|
||||
};
|
||||
|
||||
for (int i = 0; i < TEST_NEXT_PREV_SITUATION_COUNT; i++) {
|
||||
|
@ -166,18 +166,19 @@ void SearchTest::testNextAndPrevious()
|
|||
|
||||
void SearchTest::test311232()
|
||||
{
|
||||
Okular::Document d(0);
|
||||
Okular::Document d(nullptr);
|
||||
SearchFinishedReceiver receiver;
|
||||
QSignalSpy spy(&d, SIGNAL(searchFinished(int,Okular::Document::SearchStatus)));
|
||||
|
||||
QObject::connect(&d, SIGNAL(searchFinished(int,Okular::Document::SearchStatus)), &receiver, SLOT(searchFinished(int,Okular::Document::SearchStatus)));
|
||||
|
||||
const QString testFile = KDESRCDIR "data/file1.pdf";
|
||||
const KMimeType::Ptr mime = KMimeType::findByPath( testFile );
|
||||
d.openDocument(testFile, KUrl(), mime);
|
||||
const QString testFile = QStringLiteral(KDESRCDIR "data/file1.pdf");
|
||||
QMimeDatabase db;
|
||||
const QMimeType mime = db.mimeTypeForFile( testFile );
|
||||
d.openDocument(testFile, QUrl(), mime);
|
||||
|
||||
const int searchId = 0;
|
||||
d.searchText(searchId, " i ", true, Qt::CaseSensitive, Okular::Document::NextMatch, false, QColor());
|
||||
d.searchText(searchId, QStringLiteral(" i "), true, Qt::CaseSensitive, Okular::Document::NextMatch, false, QColor());
|
||||
QTime t;
|
||||
t.start();
|
||||
while (spy.count() != 1 && t.elapsed() < 500)
|
||||
|
@ -199,14 +200,14 @@ void SearchTest::test311232()
|
|||
void SearchTest::test323262()
|
||||
{
|
||||
QVector<QString> text;
|
||||
text << "a\n";
|
||||
text << QStringLiteral("a\n");
|
||||
|
||||
QVector<Okular::NormalizedRect> rect;
|
||||
rect << Okular::NormalizedRect(1, 2, 3, 4);
|
||||
|
||||
CREATE_PAGE;
|
||||
|
||||
Okular::RegularAreaRect* result = tp->findText(0, "a", Okular::FromBottom, Qt::CaseSensitive, NULL);
|
||||
Okular::RegularAreaRect* result = tp->findText(0, QStringLiteral("a"), Okular::FromBottom, Qt::CaseSensitive, nullptr);
|
||||
QVERIFY(result);
|
||||
delete result;
|
||||
|
||||
|
@ -216,7 +217,7 @@ void SearchTest::test323262()
|
|||
void SearchTest::test323263()
|
||||
{
|
||||
QVector<QString> text;
|
||||
text << "a" << "a" << "b";
|
||||
text << QStringLiteral("a") << QStringLiteral("a") << QStringLiteral("b");
|
||||
|
||||
QVector<Okular::NormalizedRect> rect;
|
||||
rect << Okular::NormalizedRect(0, 0, 1, 1)
|
||||
|
@ -225,7 +226,7 @@ void SearchTest::test323263()
|
|||
|
||||
CREATE_PAGE;
|
||||
|
||||
Okular::RegularAreaRect* result = tp->findText(0, "ab", Okular::FromTop, Qt::CaseSensitive, NULL);
|
||||
Okular::RegularAreaRect* result = tp->findText(0, QStringLiteral("ab"), Okular::FromTop, Qt::CaseSensitive, nullptr);
|
||||
QVERIFY(result);
|
||||
Okular::RegularAreaRect expected;
|
||||
expected.append(rect[1]);
|
||||
|
@ -256,7 +257,7 @@ void SearchTest::testDottedI()
|
|||
|
||||
CREATE_PAGE;
|
||||
|
||||
Okular::RegularAreaRect* result = tp->findText(0, QString::fromUtf8("İ"), Okular::FromTop, Qt::CaseInsensitive, NULL);
|
||||
Okular::RegularAreaRect* result = tp->findText(0, QString::fromUtf8("İ"), Okular::FromTop, Qt::CaseInsensitive, nullptr);
|
||||
QVERIFY(result);
|
||||
delete result;
|
||||
|
||||
|
@ -266,11 +267,11 @@ void SearchTest::testDottedI()
|
|||
void SearchTest::testHyphenAtEndOfLineWithoutYOverlap()
|
||||
{
|
||||
QVector<QString> text;
|
||||
text << "super-"
|
||||
<< "cali-\n"
|
||||
<< "fragilistic" << "-"
|
||||
<< "expiali" << "-\n"
|
||||
<< "docious";
|
||||
text << QStringLiteral("super-")
|
||||
<< QStringLiteral("cali-\n")
|
||||
<< QStringLiteral("fragilistic") << QStringLiteral("-")
|
||||
<< QStringLiteral("expiali") << QStringLiteral("-\n")
|
||||
<< QStringLiteral("docious");
|
||||
|
||||
QVector<Okular::NormalizedRect> rect;
|
||||
rect << Okular::NormalizedRect(0.4, 0.0, 0.9, 0.1)
|
||||
|
@ -281,8 +282,8 @@ void SearchTest::testHyphenAtEndOfLineWithoutYOverlap()
|
|||
|
||||
CREATE_PAGE;
|
||||
|
||||
Okular::RegularAreaRect* result = tp->findText(0, "supercalifragilisticexpialidocious",
|
||||
Okular::FromTop, Qt::CaseSensitive, NULL);
|
||||
Okular::RegularAreaRect* result = tp->findText(0, QStringLiteral("supercalifragilisticexpialidocious"),
|
||||
Okular::FromTop, Qt::CaseSensitive, nullptr);
|
||||
QVERIFY(result);
|
||||
Okular::RegularAreaRect expected;
|
||||
for (int i = 0; i < text.size(); i++) {
|
||||
|
@ -299,7 +300,7 @@ void SearchTest::testHyphenAtEndOfLineWithoutYOverlap()
|
|||
{ \
|
||||
CREATE_PAGE; \
|
||||
\
|
||||
Okular::RegularAreaRect* result = tp->findText(0, searchString, \
|
||||
Okular::RegularAreaRect* result = tp->findText(0, QStringLiteral(searchString), \
|
||||
Okular::FromTop, Qt::CaseSensitive, NULL); \
|
||||
\
|
||||
QCOMPARE(!!result, matchExpected); \
|
||||
|
@ -311,8 +312,8 @@ void SearchTest::testHyphenAtEndOfLineWithoutYOverlap()
|
|||
void SearchTest::testHyphenWithYOverlap()
|
||||
{
|
||||
QVector<QString> text;
|
||||
text << "a-"
|
||||
<< "b";
|
||||
text << QStringLiteral("a-")
|
||||
<< QStringLiteral("b");
|
||||
|
||||
QVector<Okular::NormalizedRect> rect(2);
|
||||
|
||||
|
@ -346,7 +347,7 @@ void SearchTest::testHyphenAtEndOfPage()
|
|||
//next character is at the same line) at the end of the page.
|
||||
|
||||
QVector<QString> text;
|
||||
text << "a-";
|
||||
text << QStringLiteral("a-");
|
||||
|
||||
QVector<Okular::NormalizedRect> rect;
|
||||
rect << Okular::NormalizedRect(0, 0, 1, 1);
|
||||
|
@ -354,15 +355,15 @@ void SearchTest::testHyphenAtEndOfPage()
|
|||
CREATE_PAGE;
|
||||
|
||||
{
|
||||
Okular::RegularAreaRect* result = tp->findText(0, "a",
|
||||
Okular::FromTop, Qt::CaseSensitive, NULL);
|
||||
Okular::RegularAreaRect* result = tp->findText(0, QStringLiteral("a"),
|
||||
Okular::FromTop, Qt::CaseSensitive, nullptr);
|
||||
QVERIFY(result);
|
||||
delete result;
|
||||
}
|
||||
|
||||
{
|
||||
Okular::RegularAreaRect* result = tp->findText(0, "a",
|
||||
Okular::FromBottom, Qt::CaseSensitive, NULL);
|
||||
Okular::RegularAreaRect* result = tp->findText(0, QStringLiteral("a"),
|
||||
Okular::FromBottom, Qt::CaseSensitive, nullptr);
|
||||
QVERIFY(result);
|
||||
delete result;
|
||||
}
|
||||
|
@ -381,8 +382,8 @@ void SearchTest::testOneColumn()
|
|||
//and the horizontal spaces in the example are 0.1, so they are indeed both exactly 100 pixels.)
|
||||
|
||||
QVector<QString> text;
|
||||
text << "Only" << "one" << "column"
|
||||
<< "here";
|
||||
text << QStringLiteral("Only") << QStringLiteral("one") << QStringLiteral("column")
|
||||
<< QStringLiteral("here");
|
||||
|
||||
//characters and line breaks have length 0.05, word breaks 0.1
|
||||
QVector<Okular::NormalizedRect> rect;
|
||||
|
@ -393,8 +394,8 @@ void SearchTest::testOneColumn()
|
|||
|
||||
CREATE_PAGE;
|
||||
|
||||
Okular::RegularAreaRect* result = tp->findText(0, "Only one column",
|
||||
Okular::FromTop, Qt::CaseSensitive, NULL);
|
||||
Okular::RegularAreaRect* result = tp->findText(0, QStringLiteral("Only one column"),
|
||||
Okular::FromTop, Qt::CaseSensitive, nullptr);
|
||||
QVERIFY(result);
|
||||
delete result;
|
||||
|
||||
|
@ -406,8 +407,8 @@ void SearchTest::testTwoColumns()
|
|||
//Tests that the layout analysis algorithm can detect two columns.
|
||||
|
||||
QVector<QString> text;
|
||||
text << "This" << "text" << "in" << "two"
|
||||
<< "is" << "set" << "columns.";
|
||||
text << QStringLiteral("This") << QStringLiteral("text") << QStringLiteral("in") << QStringLiteral("two")
|
||||
<< QStringLiteral("is") << QStringLiteral("set") << QStringLiteral("columns.");
|
||||
|
||||
//characters, word breaks and line breaks have length 0.05
|
||||
QVector<Okular::NormalizedRect> rect;
|
||||
|
@ -421,14 +422,13 @@ void SearchTest::testTwoColumns()
|
|||
|
||||
CREATE_PAGE;
|
||||
|
||||
Okular::RegularAreaRect* result = tp->findText(0, "This text in",
|
||||
Okular::FromTop, Qt::CaseSensitive, NULL);
|
||||
Okular::RegularAreaRect* result = tp->findText(0, QStringLiteral("This text in"),
|
||||
Okular::FromTop, Qt::CaseSensitive, nullptr);
|
||||
QVERIFY(!result);
|
||||
delete result;
|
||||
|
||||
delete page;
|
||||
}
|
||||
|
||||
QTEST_KDEMAIN( SearchTest, GUI )
|
||||
|
||||
QTEST_MAIN( SearchTest )
|
||||
#include "searchtest.moc"
|
|
@ -7,27 +7,19 @@
|
|||
* (at your option) any later version. *
|
||||
***************************************************************************/
|
||||
|
||||
#include <qtest_kde.h>
|
||||
#include <qdir.h>
|
||||
#include <kurl.h>
|
||||
#include <QtTest>
|
||||
|
||||
#include <QDir>
|
||||
#include <QUrl>
|
||||
|
||||
#include "../shell/shellutils.h"
|
||||
|
||||
namespace QTest
|
||||
static const QUrl makeUrlFromCwd( const QString& u, const QString& ref = QString() )
|
||||
{
|
||||
template<>
|
||||
char* toString( const KUrl& url )
|
||||
{
|
||||
return qstrdup( url.url().toLocal8Bit() );
|
||||
}
|
||||
}
|
||||
|
||||
static const KUrl makeUrlFromCwd( const QString& u, const QString& ref = QString() )
|
||||
{
|
||||
KUrl url( KUrl( QDir::currentPath() + '/' ), u );
|
||||
QUrl url = QUrl::fromLocalFile( QDir::currentPath() + QLatin1Char('/') + u) ;
|
||||
if ( !ref.isEmpty() )
|
||||
url.setRef( ref );
|
||||
url.cleanPath();
|
||||
url.setFragment( ref );
|
||||
url.setPath(QDir::cleanPath( url.path() ) );
|
||||
return url;
|
||||
}
|
||||
|
||||
|
@ -54,68 +46,82 @@ class ShellTest
|
|||
|
||||
void ShellTest::initTestCase()
|
||||
{
|
||||
qRegisterMetaType<KUrl>();
|
||||
|
||||
KCmdLineArgs::setCwd( QDir::currentPath().toLocal8Bit() );
|
||||
qRegisterMetaType<QUrl>();
|
||||
}
|
||||
|
||||
void ShellTest::testUrlArgs_data()
|
||||
{
|
||||
QTest::addColumn<QString>( "arg" );
|
||||
QTest::addColumn<bool>( "exists" );
|
||||
QTest::addColumn<KUrl>( "resUrl" );
|
||||
QTest::addColumn<QUrl>( "resUrl" );
|
||||
|
||||
// local files
|
||||
QTest::newRow( "foo.pdf, exist" )
|
||||
<< "foo.pdf"
|
||||
<< true
|
||||
<< makeUrlFromCwd( "foo.pdf" );
|
||||
<< makeUrlFromCwd( QStringLiteral("foo.pdf") );
|
||||
QTest::newRow( "foo.pdf, !exist" )
|
||||
<< "foo.pdf"
|
||||
<< false
|
||||
<< makeUrlFromCwd( "foo.pdf" );
|
||||
<< makeUrlFromCwd( QStringLiteral("foo.pdf") );
|
||||
QTest::newRow( "foo#bar.pdf, exist" )
|
||||
<< "foo#bar.pdf"
|
||||
<< true
|
||||
<< makeUrlFromCwd( QStringLiteral("foo#bar.pdf") );
|
||||
QTest::newRow( "foo#bar.pdf, !exist" )
|
||||
<< "foo#bar.pdf"
|
||||
<< false
|
||||
<< makeUrlFromCwd( "foo#bar.pdf" );
|
||||
<< makeUrlFromCwd( QStringLiteral("foo"), QStringLiteral("bar.pdf") );
|
||||
QTest::newRow( "foo.pdf#anchor, !exist" )
|
||||
<< "foo.pdf#anchor"
|
||||
<< false
|
||||
<< makeUrlFromCwd( "foo.pdf", "anchor" );
|
||||
<< makeUrlFromCwd( QStringLiteral("foo.pdf"), QStringLiteral("anchor") );
|
||||
QTest::newRow( "#207461" )
|
||||
<< "file:///tmp/file%20with%20spaces.pdf"
|
||||
<< true
|
||||
<< KUrl( "file:///tmp/file%20with%20spaces.pdf" );
|
||||
<< QUrl( QStringLiteral("file:///tmp/file%20with%20spaces.pdf") );
|
||||
|
||||
// non-local files
|
||||
QTest::newRow( "http://kde.org/foo.pdf" )
|
||||
<< "http://kde.org/foo.pdf"
|
||||
<< true
|
||||
<< makeUrlFromCwd( "http://kde.org/foo.pdf" );
|
||||
<< QUrl( QStringLiteral("http://kde.org/foo.pdf") );
|
||||
// make sure we don't have a fragment
|
||||
QUrl hashInName( QStringLiteral("http://kde.org") );
|
||||
QVERIFY( hashInName.path().isEmpty() );
|
||||
hashInName.setPath( QStringLiteral("/foo#bar.pdf") );
|
||||
QVERIFY( hashInName.fragment().isEmpty() );
|
||||
QTest::newRow( "http://kde.org/foo#bar.pdf" )
|
||||
<< "http://kde.org/foo#bar.pdf"
|
||||
<< true
|
||||
<< makeUrlFromCwd( "http://kde.org/foo#bar.pdf" );
|
||||
<< hashInName;
|
||||
QUrl withAnchor( QStringLiteral("http://kde.org/foo.pdf") );
|
||||
withAnchor.setFragment( QStringLiteral("anchor") );
|
||||
QTest::newRow( "http://kde.org/foo.pdf#anchor" )
|
||||
<< "http://kde.org/foo.pdf#anchor"
|
||||
<< true
|
||||
<< makeUrlFromCwd( "http://kde.org/foo.pdf", "anchor" );
|
||||
<< withAnchor;
|
||||
QTest::newRow( "#207461" )
|
||||
<< "http://homepages.inf.ed.ac.uk/mef/file%20with%20spaces.pdf"
|
||||
<< true
|
||||
<< KUrl( "http://homepages.inf.ed.ac.uk/mef/file%20with%20spaces.pdf" );
|
||||
<< QUrl( QStringLiteral("http://homepages.inf.ed.ac.uk/mef/file%20with%20spaces.pdf") );
|
||||
QUrl openOnPage3 = QUrl( QStringLiteral("http://itzsimpl.info/lectures/CG/L2-transformations.pdf") );
|
||||
openOnPage3.setFragment( QStringLiteral("3") );
|
||||
QTest::newRow( "RR124738" )
|
||||
<< "http://itzsimpl.info/lectures/CG/L2-transformations.pdf#3"
|
||||
<< true
|
||||
<< openOnPage3;
|
||||
}
|
||||
|
||||
void ShellTest::testUrlArgs()
|
||||
{
|
||||
QFETCH( QString, arg );
|
||||
QFETCH( bool, exists );
|
||||
QFETCH( KUrl, resUrl );
|
||||
|
||||
KUrl url = ShellUtils::urlFromArg( arg, exists ? fileExist_always_Func : fileExist_never_Func );
|
||||
QFETCH( QUrl, resUrl );
|
||||
qDebug() << "Expected url:" << resUrl << "path =" << resUrl.path() << "fragment =" << resUrl.fragment();
|
||||
QUrl url = ShellUtils::urlFromArg( arg, exists ? fileExist_always_Func : fileExist_never_Func );
|
||||
QCOMPARE( url, resUrl );
|
||||
}
|
||||
|
||||
QTEST_KDEMAIN_CORE( ShellTest )
|
||||
|
||||
QTEST_GUILESS_MAIN( ShellTest )
|
||||
#include "shelltest.moc"
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include "testingutils.h"
|
||||
#include "core/annotations.h"
|
||||
#include <qtest_kde.h>
|
||||
#include <qtest.h>
|
||||
|
||||
namespace TestingUtils
|
||||
{
|
|
@ -7,8 +7,10 @@
|
|||
* (at your option) any later version. *
|
||||
***************************************************************************/
|
||||
|
||||
#include <qtest_kde.h>
|
||||
#include <kmimetype.h>
|
||||
#include <QtTest>
|
||||
|
||||
#include <QMimeType>
|
||||
#include <QMimeDatabase>
|
||||
#include "../settings_core.h"
|
||||
#include "core/annotations.h"
|
||||
#include "core/document.h"
|
||||
|
@ -64,8 +66,8 @@ private:
|
|||
|
||||
void TranslateAnnotationTest::initTestCase()
|
||||
{
|
||||
Okular::SettingsCore::instance( "editannotationcontentstest" );
|
||||
m_document = new Okular::Document( 0 );
|
||||
Okular::SettingsCore::instance( QStringLiteral("editannotationcontentstest") );
|
||||
m_document = new Okular::Document( nullptr );
|
||||
|
||||
// translate m_annot1
|
||||
m_deltaA = Okular::NormalizedPoint(0.05, 0.1);
|
||||
|
@ -105,9 +107,10 @@ void TranslateAnnotationTest::cleanupTestCase()
|
|||
|
||||
void TranslateAnnotationTest::init()
|
||||
{
|
||||
const QString testFile = KDESRCDIR "data/file1.pdf";
|
||||
const KMimeType::Ptr mime = KMimeType::findByPath( testFile );
|
||||
m_document->openDocument(testFile, KUrl(), mime);
|
||||
const QString testFile = QStringLiteral(KDESRCDIR "data/file1.pdf");
|
||||
QMimeDatabase db;
|
||||
const QMimeType mime = db.mimeTypeForFile( testFile );
|
||||
QCOMPARE( m_document->openDocument(testFile, QUrl(), mime), Okular::Document::OpenSuccess );
|
||||
|
||||
// Undo and Redo should be unavailable when docuemnt is first opened.
|
||||
QVERIFY( !m_document->canUndo() );
|
||||
|
@ -233,5 +236,5 @@ void TranslateAnnotationTest::testAlternateTranslationsNotMerged()
|
|||
|
||||
|
||||
|
||||
QTEST_KDEMAIN( TranslateAnnotationTest, GUI )
|
||||
QTEST_MAIN( TranslateAnnotationTest )
|
||||
#include "translateannotationtest.moc"
|
56
autotests/urldetecttest.cpp
Normal file
56
autotests/urldetecttest.cpp
Normal file
|
@ -0,0 +1,56 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2013 Jaydeep Solanki <jaydp17@gmail.com> *
|
||||
* *
|
||||
* 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. *
|
||||
***************************************************************************/
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
#include "../ui/url_utils.h"
|
||||
|
||||
namespace Okular
|
||||
{
|
||||
class UrlDetectTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private Q_SLOTS:
|
||||
void testURL();
|
||||
void testURL_data();
|
||||
};
|
||||
|
||||
void UrlDetectTest::testURL()
|
||||
{
|
||||
QFETCH( QString, selectedText );
|
||||
QFETCH( QString, url );
|
||||
QCOMPARE( UrlUtils::getUrl( selectedText ), url );
|
||||
}
|
||||
|
||||
void UrlDetectTest::testURL_data()
|
||||
{
|
||||
QTest::addColumn<QString>( "selectedText" );
|
||||
QTest::addColumn<QString>( "url" );
|
||||
QTest::newRow( "1" ) << QStringLiteral( "asdfhttp://okular.org" ) << QString();
|
||||
QTest::newRow( "2" ) << QStringLiteral( "google.com/index.php/" ) << QString();
|
||||
QTest::newRow( "3" ) << QStringLiteral( "http://google.com)" ) << QString();
|
||||
|
||||
QTest::newRow( "4" ) << QStringLiteral( "https://okular.org" ) << QStringLiteral( "https://okular.org" );
|
||||
QTest::newRow( "5" ) << QStringLiteral( "www.google.com" ) << QStringLiteral( "http://www.google.com" );
|
||||
QTest::newRow( "6" ) << QStringLiteral( "asdf http://okular.kde.org/" ) << QStringLiteral( "http://okular.kde.org/" );
|
||||
QTest::newRow( "7" ) << QStringLiteral( "http://www.example.com/wpstyle/?p=364" ) << QStringLiteral( "http://www.example.com/wpstyle/?p=364" );
|
||||
QTest::newRow( "8" ) << QStringLiteral( "asdf http://okular.org fdsa" ) << QStringLiteral( "http://okular.org" );
|
||||
QTest::newRow( "9" ) << QStringLiteral( "http://google.com/ø" ) << QStringLiteral( "http://google.com/ø" );
|
||||
QTest::newRow( "10" ) << QStringLiteral( "http://www.wolframalpha.com/input/?i=Plot[%281%2Be^%28-%282%29v%29%29^%28-2%29+%2B+%282%29+%281%2Be^v%29^%28-2%29%2C+{t%2C-0.5%2C+0.5}]" ) << QStringLiteral( "http://www.wolframalpha.com/input/?i=Plot[%281%2Be^%28-%282%29v%29%29^%28-2%29+%2B+%282%29+%281%2Be^v%29^%28-2%29%2C+{t%2C-0.5%2C+0.5}]" );
|
||||
QTest::newRow( "11" ) << QStringLiteral( "http://uid:pass@example.com:8080" ) << QStringLiteral( "http://uid:pass@example.com:8080" );
|
||||
QTest::newRow( "12" ) << QStringLiteral( "www.cs.princeton.edu/~rs/talks/LLRB/LLRB.pdf" ) << QStringLiteral( "http://www.cs.princeton.edu/~rs/talks/LLRB/LLRB.pdf" );
|
||||
QTest::newRow( "13" ) << QStringLiteral( "http://IISServer/nwind?template=<ROOTxmlns:sql=\"urn:schemas-microsoft-com:xml-sql\"><sql:query>SELECTTOP2*FROM[OrderDetails]WHEREUnitPrice%26lt;10FORXMLAUTO</sql:query></ROOT>" ) << QStringLiteral( "http://IISServer/nwind?template=<ROOTxmlns:sql=\"urn:schemas-microsoft-com:xml-sql\"><sql:query>SELECTTOP2*FROM[OrderDetails]WHEREUnitPrice%26lt;10FORXMLAUTO</sql:query></ROOT>" );
|
||||
QTest::newRow( "14" ) << QStringLiteral( "https://www.example.com/foo/?bar=baz&inga=42&quux" ) << QStringLiteral( "https://www.example.com/foo/?bar=baz&inga=42&quux" );
|
||||
QTest::newRow( "15" ) << QStringLiteral( "http://foo.bar/#tag" ) << QStringLiteral( "http://foo.bar/#tag" );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QTEST_MAIN( Okular::UrlDetectTest )
|
||||
#include "urldetecttest.moc"
|
36
cmake/modules/FindDiscount.cmake
Normal file
36
cmake/modules/FindDiscount.cmake
Normal file
|
@ -0,0 +1,36 @@
|
|||
# - Find Discount
|
||||
# Find the discount markdown library.
|
||||
#
|
||||
# This module defines
|
||||
# discount_FOUND - whether the discount library was found
|
||||
# discount_LIBRARIES - the discount library
|
||||
# discount_INCLUDE_DIR - the include path of the discount library
|
||||
|
||||
# Copyright (c) 2017, Julian Wolff, <wolff@julianwolff.de>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
|
||||
|
||||
if (discount_INCLUDE_DIR AND discount_LIBRARIES)
|
||||
|
||||
# Already in cache
|
||||
set (discount_FOUND TRUE)
|
||||
|
||||
else (discount_INCLUDE_DIR AND discount_LIBRARIES)
|
||||
|
||||
find_library (discount_LIBRARIES
|
||||
NAMES markdown libmarkdown
|
||||
)
|
||||
|
||||
find_path (discount_INCLUDE_DIR
|
||||
NAMES mkdio.h
|
||||
)
|
||||
|
||||
include (FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args (discount DEFAULT_MSG discount_LIBRARIES discount_INCLUDE_DIR)
|
||||
|
||||
endif (discount_INCLUDE_DIR AND discount_LIBRARIES)
|
||||
|
||||
mark_as_advanced(discount_INCLUDE_DIR discount_LIBRARIES)
|
||||
|
|
@ -12,50 +12,35 @@
|
|||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
|
||||
if(LIBSPECTRE_INCLUDE_DIR AND LIBSPECTRE_LIBRARY)
|
||||
|
||||
# in cache already
|
||||
set(LIBSPECTRE_INTERNAL_FOUND TRUE)
|
||||
|
||||
else(LIBSPECTRE_INCLUDE_DIR AND LIBSPECTRE_LIBRARY)
|
||||
|
||||
if(NOT WIN32)
|
||||
# use pkg-config to get the directories and then use these values
|
||||
# in the FIND_PATH() and FIND_LIBRARY() calls
|
||||
INCLUDE(UsePkgConfig)
|
||||
# use pkg-config to get the directories and then use these values
|
||||
# in the FIND_PATH() and FIND_LIBRARY() calls
|
||||
include(FindPkgConfig)
|
||||
|
||||
PKGCONFIG(libspectre _SpectreIncDir _SpectreLinkDir _SpectreLinkFlags _SpectreCflags)
|
||||
|
||||
if(_SpectreLinkFlags)
|
||||
# find again pkg-config, to query it about libspectre version
|
||||
FIND_PROGRAM(PKGCONFIG_EXECUTABLE NAMES pkg-config PATHS /usr/bin/ /usr/local/bin )
|
||||
|
||||
# query pkg-config asking for a libspectre >= LIBSPECTRE_MINIMUM_VERSION
|
||||
EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS --atleast-version=${LIBSPECTRE_MINIMUM_VERSION} libspectre RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _pkgconfigDevNull )
|
||||
if(_return_VALUE STREQUAL "0")
|
||||
set(LIBSPECTRE_INTERNAL_FOUND TRUE)
|
||||
endif(_return_VALUE STREQUAL "0")
|
||||
endif(_SpectreLinkFlags)
|
||||
if(LIBSPECTRE_MINIMUM_VERSION})
|
||||
pkg_check_modules(_pc_LIBSPECTRE libspectre>=${LIBSPECTRE_MINIMUM_VERSION})
|
||||
else(LIBSPECTRE_MINIMUM_VERSION})
|
||||
pkg_check_modules(_pc_LIBSPECTRE libspectre)
|
||||
endif(LIBSPECTRE_MINIMUM_VERSION})
|
||||
else(NOT WIN32)
|
||||
# do not use pkg-config on windows
|
||||
find_library(_SpectreLinkFlags NAMES libspectre spectre PATHS ${CMAKE_LIBRARY_PATH})
|
||||
|
||||
find_path(LIBSPECTRE_INCLUDE_DIR spectre.h PATH_SUFFIXES libspectre )
|
||||
|
||||
set(LIBSPECTRE_INTERNAL_FOUND TRUE)
|
||||
# do not use pkg-config on windows
|
||||
set(_pc_LIBSPECTRE_FOUND TRUE)
|
||||
endif(NOT WIN32)
|
||||
|
||||
if (LIBSPECTRE_INTERNAL_FOUND)
|
||||
set(LIBSPECTRE_LIBRARY ${_SpectreLinkFlags})
|
||||
|
||||
# the cflags for libspectre can contain more than one include path
|
||||
separate_arguments(_SpectreCflags)
|
||||
foreach(_includedir ${_SpectreCflags})
|
||||
string(REGEX REPLACE "-I(.+)" "\\1" _includedir "${_includedir}")
|
||||
set(LIBSPECTRE_INCLUDE_DIR ${LIBSPECTRE_INCLUDE_DIR} ${_includedir})
|
||||
endforeach(_includedir)
|
||||
if(_pc_LIBSPECTRE_FOUND)
|
||||
find_library(LIBSPECTRE_LIBRARY
|
||||
NAMES libspectre spectre
|
||||
HINTS ${_pc_LIBSPECTRE_LIBRARY_DIRS} ${CMAKE_LIBRARY_PATH}
|
||||
)
|
||||
|
||||
endif (LIBSPECTRE_INTERNAL_FOUND)
|
||||
find_path(LIBSPECTRE_INCLUDE_DIR spectre.h
|
||||
HINTS ${_pc_LIBSPECTRE_INCLUDE_DIRS}
|
||||
PATH_SUFFIXES libspectre
|
||||
)
|
||||
|
||||
set(LIBSPECTRE_INTERNAL_FOUND TRUE)
|
||||
endif(_pc_LIBSPECTRE_FOUND)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(LibSpectre DEFAULT_MSG LIBSPECTRE_LIBRARY LIBSPECTRE_INTERNAL_FOUND)
|
||||
|
@ -63,5 +48,3 @@ find_package_handle_standard_args(LibSpectre DEFAULT_MSG LIBSPECTRE_LIBRARY LIBS
|
|||
# ensure that they are cached
|
||||
set(LIBSPECTRE_INCLUDE_DIR ${LIBSPECTRE_INCLUDE_DIR} CACHE INTERNAL "The libspectre include path")
|
||||
set(LIBSPECTRE_LIBRARY ${LIBSPECTRE_LIBRARY} CACHE INTERNAL "The libspectre library")
|
||||
|
||||
endif(LIBSPECTRE_INCLUDE_DIR AND LIBSPECTRE_LIBRARY)
|
||||
|
|
|
@ -1,170 +0,0 @@
|
|||
# - Try to find the poppler PDF library
|
||||
# Once done this will define
|
||||
#
|
||||
# POPPLER_FOUND - system has poppler
|
||||
# POPPLER_INCLUDE_DIR - the poppler include directory
|
||||
# POPPLER_LIBRARY - Link this to use poppler
|
||||
#
|
||||
|
||||
# Copyright (c) 2006-2010, Pino Toscano, <pino@kde.org>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
|
||||
if(POPPLER_INCLUDE_DIR AND POPPLER_LIBRARY)
|
||||
|
||||
# in cache already
|
||||
set(POPPLER_FOUND TRUE)
|
||||
|
||||
else(POPPLER_INCLUDE_DIR AND POPPLER_LIBRARY)
|
||||
|
||||
set(_poppler_version_bad FALSE)
|
||||
|
||||
if(NOT WIN32)
|
||||
# use pkg-config to get the directories and then use these values
|
||||
# in the FIND_PATH() and FIND_LIBRARY() calls
|
||||
include(FindPkgConfig)
|
||||
pkg_check_modules(_pc_poppler poppler-qt4)
|
||||
if(_pc_poppler_FOUND)
|
||||
if(NOT "${_pc_poppler_VERSION}" VERSION_GREATER 0.5.3)
|
||||
set(_poppler_version_bad TRUE)
|
||||
endif(NOT "${_pc_poppler_VERSION}" VERSION_GREATER 0.5.3)
|
||||
endif(_pc_poppler_FOUND)
|
||||
endif(NOT WIN32)
|
||||
|
||||
if(NOT _poppler_version_bad)
|
||||
set(POPPLER_FOUND FALSE)
|
||||
|
||||
find_library(POPPLER_LIBRARY poppler-qt4
|
||||
HINTS ${_pc_poppler_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
find_path(POPPLER_INCLUDE_DIR poppler-qt4.h
|
||||
HINTS ${_pc_poppler_INCLUDE_DIRS}
|
||||
PATH_SUFFIXES poppler/qt4
|
||||
)
|
||||
find_path(POPPLER_INCLUDE_DIR_core qt4/poppler-qt4.h
|
||||
HINTS ${_pc_poppler_INCLUDE_DIRS}
|
||||
PATH_SUFFIXES poppler
|
||||
)
|
||||
|
||||
if(POPPLER_LIBRARY AND POPPLER_INCLUDE_DIR AND POPPLER_INCLUDE_DIR_core)
|
||||
list(APPEND POPPLER_INCLUDE_DIR "${POPPLER_INCLUDE_DIR_core}")
|
||||
set(POPPLER_FOUND TRUE)
|
||||
endif(POPPLER_LIBRARY AND POPPLER_INCLUDE_DIR AND POPPLER_INCLUDE_DIR_core)
|
||||
endif(NOT _poppler_version_bad)
|
||||
|
||||
if (POPPLER_FOUND)
|
||||
include(CheckCXXSourceCompiles)
|
||||
|
||||
# check whether we're using poppler 0.6
|
||||
set(CMAKE_REQUIRED_INCLUDES ${POPPLER_INCLUDE_DIR} ${QT_INCLUDE_DIR})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${POPPLER_LIBRARY} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTXML_LIBRARY})
|
||||
|
||||
check_cxx_source_compiles("
|
||||
#include <poppler-qt4.h>
|
||||
int main()
|
||||
{
|
||||
Poppler::Document::RenderHint hint = Poppler::Document::TextHinting;
|
||||
return 0;
|
||||
}
|
||||
" HAVE_POPPLER_0_12_1)
|
||||
|
||||
check_cxx_source_compiles("
|
||||
#include <poppler-qt4.h>
|
||||
|
||||
void debugFunction(const QString &message, const QVariant &closure)
|
||||
{
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
Poppler::setDebugErrorFunction(debugFunction, QVariant());
|
||||
return 0;
|
||||
}
|
||||
" HAVE_POPPLER_0_16)
|
||||
|
||||
check_cxx_source_compiles("
|
||||
#include <poppler-qt4.h>
|
||||
#include <poppler-media.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
Poppler::ScreenAnnotation *annot = 0;
|
||||
Poppler::LinkRendition *link = 0;
|
||||
const Poppler::LinkMovie::Operation operation = Poppler::LinkMovie::Play;
|
||||
return 0;
|
||||
}
|
||||
" HAVE_POPPLER_0_20)
|
||||
|
||||
check_cxx_source_compiles("
|
||||
#include <poppler-qt4.h>
|
||||
#include <poppler-annotation.h>
|
||||
#include <poppler-link.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
Poppler::MovieObject *movie = 0;
|
||||
Poppler::Document *doc = 0;
|
||||
movie->showPosterImage();
|
||||
|
||||
const Poppler::Annotation::AdditionalActionType type = Poppler::Annotation::PageOpeningAction;
|
||||
const Poppler::LinkRendition::RenditionAction action = Poppler::LinkRendition::NoRendition;
|
||||
const Poppler::Document::FormType formType = doc->formType();
|
||||
|
||||
return 0;
|
||||
}
|
||||
" HAVE_POPPLER_0_22)
|
||||
|
||||
check_cxx_source_compiles("
|
||||
#include <poppler-qt4.h>
|
||||
int main()
|
||||
{
|
||||
Poppler::Document::RenderHint hint = Poppler::Document::ThinLineSolid;
|
||||
return 0;
|
||||
}
|
||||
" HAVE_POPPLER_0_24)
|
||||
|
||||
check_cxx_source_compiles("
|
||||
#include <poppler-qt4.h>
|
||||
int main()
|
||||
{
|
||||
Poppler::Page *p = 0;
|
||||
p->annotations( QSet<Poppler::Annotation::SubType>() << Poppler::Annotation::ASound );
|
||||
return 0;
|
||||
}
|
||||
" HAVE_POPPLER_0_28)
|
||||
|
||||
set(CMAKE_REQUIRED_INCLUDES)
|
||||
set(CMAKE_REQUIRED_LIBRARIES)
|
||||
if (HAVE_POPPLER_0_28)
|
||||
set(popplerVersionMessage "0.28")
|
||||
elseif (HAVE_POPPLER_0_24)
|
||||
set(popplerVersionMessage "0.24")
|
||||
elseif (HAVE_POPPLER_0_22)
|
||||
set(popplerVersionMessage "0.22")
|
||||
elseif (HAVE_POPPLER_0_20)
|
||||
set(popplerVersionMessage "0.20")
|
||||
elseif (HAVE_POPPLER_0_16)
|
||||
set(popplerVersionMessage "0.16")
|
||||
elseif (HAVE_POPPLER_0_12_1)
|
||||
set(popplerVersionMessage "0.12.1")
|
||||
else (HAVE_POPPLER_0_28)
|
||||
set(popplerVersionMessage "0.5.4")
|
||||
endif (HAVE_POPPLER_0_28)
|
||||
if (NOT Poppler_FIND_QUIETLY)
|
||||
message(STATUS "Found Poppler-Qt4: ${POPPLER_LIBRARY}, (>= ${popplerVersionMessage})")
|
||||
endif (NOT Poppler_FIND_QUIETLY)
|
||||
else (POPPLER_FOUND)
|
||||
if (Poppler_FIND_REQUIRED)
|
||||
message(FATAL_ERROR "Could NOT find Poppler-Qt4")
|
||||
endif (Poppler_FIND_REQUIRED)
|
||||
message(STATUS "Could not find OPTIONAL package Poppler-Qt4")
|
||||
endif (POPPLER_FOUND)
|
||||
|
||||
# ensure that they are cached
|
||||
set(POPPLER_INCLUDE_DIR ${POPPLER_INCLUDE_DIR} CACHE INTERNAL "The Poppler-Qt4 include path")
|
||||
set(POPPLER_LIBRARY ${POPPLER_LIBRARY} CACHE INTERNAL "The Poppler-Qt4 library")
|
||||
set(HAVE_POPPLER_0_12_1 ${HAVE_POPPLER_0_12_1} CACHE INTERNAL "Whether the version of Poppler-Qt4 is >= 0.12.1")
|
||||
|
||||
endif(POPPLER_INCLUDE_DIR AND POPPLER_LIBRARY)
|
18
conf/autotests/CMakeLists.txt
Normal file
18
conf/autotests/CMakeLists.txt
Normal file
|
@ -0,0 +1,18 @@
|
|||
macro(add_conf_unittest _source)
|
||||
set(_test ${_source} ../editdrawingtooldialog.cpp)
|
||||
get_filename_component(_name ${_source} NAME_WE)
|
||||
add_executable( ${_name} ${_test} )
|
||||
add_test( ${_name} ${_name} )
|
||||
ecm_mark_as_test(${_name})
|
||||
target_link_libraries( ${_name}
|
||||
Qt5::Test
|
||||
Qt5::Widgets
|
||||
Qt5::Xml
|
||||
KF5::I18n
|
||||
KF5::Completion
|
||||
KF5::WidgetsAddons
|
||||
)
|
||||
endmacro ()
|
||||
|
||||
add_conf_unittest(editdrawingtooldialogtest.cpp)
|
||||
|
49
conf/autotests/editdrawingtooldialogtest.cpp
Normal file
49
conf/autotests/editdrawingtooldialogtest.cpp
Normal file
|
@ -0,0 +1,49 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2015 by Laurent Montel <montel@kde.org> *
|
||||
* *
|
||||
* 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. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "editdrawingtooldialogtest.h"
|
||||
#include "../editdrawingtooldialog.h"
|
||||
|
||||
#include <KColorButton>
|
||||
#include <KLineEdit>
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QSpinBox>
|
||||
#include <QTest>
|
||||
|
||||
EditDrawingToolDialogTest::EditDrawingToolDialogTest(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
EditDrawingToolDialogTest::~EditDrawingToolDialogTest()
|
||||
{
|
||||
}
|
||||
|
||||
void EditDrawingToolDialogTest::shouldHaveDefaultValues()
|
||||
{
|
||||
EditDrawingToolDialog dlg;
|
||||
|
||||
const QDialogButtonBox *buttonBox = dlg.findChild<QDialogButtonBox *>(QStringLiteral("buttonbox"));
|
||||
QVERIFY(buttonBox);
|
||||
|
||||
const KLineEdit *name = dlg.findChild<KLineEdit *>(QStringLiteral("name"));
|
||||
QVERIFY(name);
|
||||
|
||||
const KColorButton *colorButton = dlg.findChild<KColorButton *>(QStringLiteral("colorbutton"));
|
||||
QVERIFY(colorButton);
|
||||
|
||||
const QSpinBox *opacity = dlg.findChild<QSpinBox *>(QStringLiteral("opacity"));
|
||||
QVERIFY(opacity);
|
||||
|
||||
QVERIFY(name->text().isEmpty());
|
||||
}
|
||||
|
||||
QTEST_MAIN(EditDrawingToolDialogTest)
|
26
conf/autotests/editdrawingtooldialogtest.h
Normal file
26
conf/autotests/editdrawingtooldialogtest.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2015 by Laurent Montel <montel@kde.org> *
|
||||
* *
|
||||
* 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. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef EDITDRAWINGTOOLDIALOGTEST_H
|
||||
#define EDITDRAWINGTOOLDIALOGTEST_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class EditDrawingToolDialogTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit EditDrawingToolDialogTest(QObject *parent = nullptr);
|
||||
~EditDrawingToolDialogTest();
|
||||
|
||||
private Q_SLOTS:
|
||||
void shouldHaveDefaultValues();
|
||||
};
|
||||
|
||||
#endif // EDITDRAWINGTOOLDIALOGTEST_H
|
|
@ -28,7 +28,7 @@ DlgAccessibility::DlgAccessibility( QWidget * parent )
|
|||
page->hide();
|
||||
m_color_pages[ m_selected ]->show();
|
||||
|
||||
connect( m_dlg->kcfg_RenderMode, SIGNAL(currentIndexChanged(int)), this, SLOT(slotColorMode(int)) );
|
||||
connect(m_dlg->kcfg_RenderMode, static_cast<void (KComboBox::*)(int)>(&KComboBox::currentIndexChanged), this, &DlgAccessibility::slotColorMode);
|
||||
}
|
||||
|
||||
DlgAccessibility::~DlgAccessibility()
|
||||
|
@ -44,4 +44,4 @@ void DlgAccessibility::slotColorMode( int mode )
|
|||
m_selected = mode;
|
||||
}
|
||||
|
||||
#include "dlgaccessibility.moc"
|
||||
#include "moc_dlgaccessibility.cpp"
|
||||
|
|
|
@ -20,10 +20,10 @@ class DlgAccessibility : public QWidget
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DlgAccessibility( QWidget * parent = 0 );
|
||||
explicit DlgAccessibility( QWidget * parent = nullptr );
|
||||
~DlgAccessibility();
|
||||
|
||||
private slots:
|
||||
private Q_SLOTS:
|
||||
void slotColorMode( int mode );
|
||||
|
||||
private:
|
||||
|
|
|
@ -22,7 +22,7 @@ DlgAnnotations::DlgAnnotations( QWidget * parent )
|
|||
|
||||
WidgetAnnotTools * kcfg_AnnotationTools = new WidgetAnnotTools( dlg.annotToolsGroup );
|
||||
dlg.annotToolsPlaceholder->addWidget( kcfg_AnnotationTools );
|
||||
kcfg_AnnotationTools->setObjectName( "kcfg_AnnotationTools" );
|
||||
kcfg_AnnotationTools->setObjectName( QStringLiteral("kcfg_AnnotationTools") );
|
||||
|
||||
KConfigDialogManager::changedMap()->insert( "WidgetAnnotTools" , SIGNAL(changed()) );
|
||||
KConfigDialogManager::changedMap()->insert( QStringLiteral("WidgetAnnotTools") , SIGNAL(changed()) );
|
||||
}
|
||||
|
|
|
@ -15,8 +15,10 @@
|
|||
|
||||
class DlgAnnotations : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DlgAnnotations( QWidget * parent = 0 );
|
||||
explicit DlgAnnotations( QWidget * parent = nullptr );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
|
||||
#define DEBUG_SIMPLE_BOOL( cfgname, layout ) \
|
||||
{ \
|
||||
QCheckBox * foo = new QCheckBox( cfgname, this ); \
|
||||
foo->setObjectName( "kcfg_" cfgname ); \
|
||||
QCheckBox * foo = new QCheckBox( QStringLiteral(cfgname), this ); \
|
||||
foo->setObjectName( QStringLiteral("kcfg_" cfgname) ); \
|
||||
layout->addWidget( foo ); \
|
||||
}
|
||||
|
||||
|
|
|
@ -14,8 +14,10 @@
|
|||
|
||||
class DlgDebug : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DlgDebug( QWidget * parent = 0 );
|
||||
explicit DlgDebug( QWidget * parent = nullptr );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#include "core/texteditors_p.h"
|
||||
|
||||
#include <klocale.h>
|
||||
#include <klocalizedstring.h>
|
||||
|
||||
#include "ui_dlgeditorbase.h"
|
||||
|
||||
|
@ -23,7 +23,7 @@ DlgEditor::DlgEditor( QWidget * parent )
|
|||
|
||||
m_editors = Okular::buildEditorsMap();
|
||||
|
||||
connect( m_dlg->kcfg_ExternalEditor, SIGNAL(currentIndexChanged(int)), this, SLOT(editorChanged(int)) );
|
||||
connect(m_dlg->kcfg_ExternalEditor, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &DlgEditor::editorChanged);
|
||||
|
||||
m_dlg->kcfg_ExternalEditor->addItem( i18nc( "Text editor", "Custom Text Editor" ) );
|
||||
m_dlg->kcfg_ExternalEditor->addItem( i18nc( "Text editor", "Kate" ), 1 );
|
||||
|
@ -68,4 +68,4 @@ void DlgEditor::editorChanged( int which )
|
|||
}
|
||||
}
|
||||
|
||||
#include "dlgeditor.moc"
|
||||
#include "moc_dlgeditor.cpp"
|
||||
|
|
|
@ -20,10 +20,10 @@ class DlgEditor : public QWidget
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DlgEditor( QWidget * parent = 0 );
|
||||
explicit DlgEditor( QWidget * parent = nullptr );
|
||||
virtual ~DlgEditor();
|
||||
|
||||
private slots:
|
||||
private Q_SLOTS:
|
||||
void editorChanged( int which );
|
||||
|
||||
private:
|
||||
|
|
|
@ -26,6 +26,7 @@ DlgGeneral::DlgGeneral( QWidget * parent, Okular::EmbedMode embedMode )
|
|||
m_dlg->kcfg_SyncThumbnailsViewport->setVisible( false );
|
||||
m_dlg->kcfg_DisplayDocumentTitle->setVisible( false );
|
||||
m_dlg->kcfg_WatchFile->setVisible( false );
|
||||
m_dlg->kcfg_rtlReadingDirection->setVisible(false);
|
||||
}
|
||||
m_dlg->kcfg_ShellOpenFileInTabs->setVisible( embedMode == Okular::NativeShellMode );
|
||||
}
|
||||
|
@ -40,7 +41,7 @@ void DlgGeneral::showEvent( QShowEvent * )
|
|||
#if OKULAR_FORCE_DRM
|
||||
m_dlg->kcfg_ObeyDRM->hide();
|
||||
#else
|
||||
if ( KAuthorized::authorize( "skip_drm" ) )
|
||||
if ( KAuthorized::authorize( QStringLiteral("skip_drm") ) )
|
||||
m_dlg->kcfg_ObeyDRM->show();
|
||||
else
|
||||
m_dlg->kcfg_ObeyDRM->hide();
|
||||
|
|
|
@ -18,12 +18,14 @@ class Ui_DlgGeneralBase;
|
|||
|
||||
class DlgGeneral : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DlgGeneral( QWidget * parent, Okular::EmbedMode embedMode );
|
||||
explicit DlgGeneral( QWidget * parent, Okular::EmbedMode embedMode );
|
||||
virtual ~DlgGeneral();
|
||||
|
||||
protected:
|
||||
virtual void showEvent( QShowEvent * );
|
||||
void showEvent( QShowEvent * ) override;
|
||||
|
||||
Ui_DlgGeneralBase * m_dlg;
|
||||
};
|
||||
|
|
113
conf/dlggeneralbase.ui
Executable file → Normal file
113
conf/dlggeneralbase.ui
Executable file → Normal file
|
@ -11,7 +11,16 @@
|
|||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout">
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
|
@ -23,7 +32,16 @@
|
|||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
|
@ -31,7 +49,16 @@
|
|||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
|
@ -73,16 +100,13 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KButtonGroup" name="kcfg_DisplayDocumentNameOrPath">
|
||||
<widget class="QGroupBox" name="kcfg_DisplayDocumentNameOrPath">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">KButtonGroup {border:0; }</string>
|
||||
<string notr="true">QGroupBox {border:0; }</string>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="current" stdset="0">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>8</number>
|
||||
|
@ -133,7 +157,16 @@
|
|||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
|
@ -176,7 +209,16 @@
|
|||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
|
@ -184,7 +226,16 @@
|
|||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
|
@ -222,16 +273,22 @@
|
|||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="pixmapLabel1_2_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
<widget class="QCheckBox" name="kcfg_rtlReadingDirection">
|
||||
<property name="text">
|
||||
<string>Right to left reading direction</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -240,9 +297,6 @@
|
|||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
|
@ -276,7 +330,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="KIntSpinBox" name="kcfg_ViewColumns">
|
||||
<widget class="QSpinBox" name="kcfg_ViewColumns">
|
||||
<property name="minimum">
|
||||
<number>3</number>
|
||||
</property>
|
||||
|
@ -302,7 +356,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="KIntSpinBox" name="kcfg_ScrollOverlap">
|
||||
<widget class="QSpinBox" name="kcfg_ScrollOverlap">
|
||||
<property name="suffix">
|
||||
<string>%</string>
|
||||
</property>
|
||||
|
@ -385,19 +439,6 @@ For files which were opened before the previous zoom is applied.</string>
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>KButtonGroup</class>
|
||||
<extends>QGroupBox</extends>
|
||||
<header>kbuttongroup.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>KIntSpinBox</class>
|
||||
<extends>QSpinBox</extends>
|
||||
<header>knuminput.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<includes>
|
||||
<include location="global">kiconloader.h</include>
|
||||
</includes>
|
||||
|
|
|
@ -9,14 +9,19 @@
|
|||
|
||||
#include "dlgperformance.h"
|
||||
|
||||
#include <qfont.h>
|
||||
#include <kiconloader.h>
|
||||
#include <QButtonGroup>
|
||||
#include <QFont>
|
||||
|
||||
#include <KConfigDialogManager>
|
||||
#include <KIconLoader>
|
||||
|
||||
#include "settings_core.h"
|
||||
#include "ui_dlgperformancebase.h"
|
||||
|
||||
DlgPerformance::DlgPerformance( QWidget * parent )
|
||||
: QWidget( parent )
|
||||
{
|
||||
Q_PROPERTY( QButtonGroup checkedId READ checkedId USER true );
|
||||
m_dlg = new Ui_DlgPerformanceBase();
|
||||
m_dlg->setupUi( this );
|
||||
|
||||
|
@ -24,10 +29,17 @@ DlgPerformance::DlgPerformance( QWidget * parent )
|
|||
labelFont.setBold( true );
|
||||
m_dlg->descLabel->setFont( labelFont );
|
||||
|
||||
m_dlg->cpuLabel->setPixmap( BarIcon( "cpu", 32 ) );
|
||||
// m_dlg->memoryLabel->setPixmap( BarIcon( "kcmmemory", 32 ) ); // TODO: enable again when proper icon is available
|
||||
m_dlg->cpuLabel->setPixmap( BarIcon( QStringLiteral("cpu"), 32 ) );
|
||||
// m_dlg->memoryLabel->setPixmap( BarIcon( "kcmmemory", 32 ) ); // TODO: enable again when proper icon is available
|
||||
|
||||
connect( m_dlg->kcfg_MemoryLevel, SIGNAL(changed(int)), this, SLOT(radioGroup_changed(int)) );
|
||||
m_dlg->memoryLevelGroup->setId(m_dlg->lowRadio, 0);
|
||||
m_dlg->memoryLevelGroup->setId(m_dlg->normalRadio, 1);
|
||||
m_dlg->memoryLevelGroup->setId(m_dlg->aggressiveRadio, 2);
|
||||
m_dlg->memoryLevelGroup->setId(m_dlg->greedyRadio, 3);
|
||||
|
||||
|
||||
connect(m_dlg->memoryLevelGroup, static_cast<void(QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked),
|
||||
this, &DlgPerformance::radioGroup_changed);
|
||||
}
|
||||
|
||||
DlgPerformance::~DlgPerformance()
|
||||
|
@ -43,10 +55,10 @@ void DlgPerformance::radioGroup_changed( int which )
|
|||
m_dlg->descLabel->setText( i18n("Keeps used memory as low as possible. Do not reuse anything. (For systems with low memory.)") );
|
||||
break;
|
||||
case 1:
|
||||
m_dlg->descLabel->setText( i18n("A good compromise between memory usage and speed gain. Preload next page and boost searches. (For systems with 256MB of memory, typically.)") );
|
||||
m_dlg->descLabel->setText( i18n("A good compromise between memory usage and speed gain. Preload next page and boost searches. (For systems with 2GB of memory, typically.)") );
|
||||
break;
|
||||
case 2:
|
||||
m_dlg->descLabel->setText( i18n("Keeps everything in memory. Preload next pages. Boost searches. (For systems with more than 512MB of memory.)") );
|
||||
m_dlg->descLabel->setText( i18n("Keeps everything in memory. Preload next pages. Boost searches. (For systems with more than 4GB of memory.)") );
|
||||
break;
|
||||
case 3:
|
||||
// xgettext: no-c-format
|
||||
|
@ -55,4 +67,4 @@ void DlgPerformance::radioGroup_changed( int which )
|
|||
}
|
||||
}
|
||||
|
||||
#include "dlgperformance.moc"
|
||||
#include "moc_dlgperformance.cpp"
|
||||
|
|
|
@ -10,19 +10,20 @@
|
|||
#ifndef _DLGPERFORMANCE_H
|
||||
#define _DLGPERFORMANCE_H
|
||||
|
||||
#include <qwidget.h>
|
||||
#include <QWidget>
|
||||
|
||||
class Ui_DlgPerformanceBase;
|
||||
class QButtonGroup;
|
||||
|
||||
class DlgPerformance : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DlgPerformance( QWidget * parent = 0 );
|
||||
explicit DlgPerformance( QWidget * parent = nullptr );
|
||||
virtual ~DlgPerformance();
|
||||
|
||||
protected slots:
|
||||
protected Q_SLOTS:
|
||||
void radioGroup_changed( int which );
|
||||
|
||||
protected:
|
||||
|
|
|
@ -7,14 +7,23 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>316</width>
|
||||
<height>344</height>
|
||||
<height>397</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
|
@ -26,7 +35,16 @@
|
|||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
|
@ -34,7 +52,16 @@
|
|||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
|
@ -42,7 +69,16 @@
|
|||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
|
@ -59,7 +95,16 @@
|
|||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
|
@ -96,7 +141,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KButtonGroup" name="kcfg_MemoryLevel">
|
||||
<widget class="QGroupBox" name="groupbox">
|
||||
<property name="title">
|
||||
<string>Memory Usage</string>
|
||||
</property>
|
||||
|
@ -104,7 +149,16 @@
|
|||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
|
@ -112,53 +166,85 @@
|
|||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QVBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
<widget class="QGroupBox" name="kcfg_MemoryLevel">
|
||||
<property name="title">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="lowRadio">
|
||||
<property name="text">
|
||||
<string>&Low</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="normalRadio">
|
||||
<property name="text">
|
||||
<string>&Normal (default)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="aggressiveRadio">
|
||||
<property name="text">
|
||||
<string>&Aggressive</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="greedyRadio">
|
||||
<property name="text">
|
||||
<string>&Greedy</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="lowRadio">
|
||||
<property name="text">
|
||||
<string>&Low</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">memoryLevelGroup</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="normalRadio">
|
||||
<property name="text">
|
||||
<string>Nor&mal (default)</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">memoryLevelGroup</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="aggressiveRadio">
|
||||
<property name="text">
|
||||
<string>Aggr&essive</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">memoryLevelGroup</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="greedyRadio">
|
||||
<property name="text">
|
||||
<string>G&reedy</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">memoryLevelGroup</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
|
@ -258,17 +344,12 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>KButtonGroup</class>
|
||||
<extends>QGroupBox</extends>
|
||||
<header>kbuttongroup.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<includes>
|
||||
<include location="global">kiconloader.h</include>
|
||||
</includes>
|
||||
<resources/>
|
||||
<connections/>
|
||||
<buttongroups>
|
||||
<buttongroup name="memoryLevelGroup"/>
|
||||
</buttongroups>
|
||||
</ui>
|
||||
|
|
|
@ -10,11 +10,12 @@
|
|||
#include "dlgpresentation.h"
|
||||
|
||||
#include "ui_dlgpresentationbase.h"
|
||||
#include "widgetdrawingtools.h"
|
||||
|
||||
#include <qapplication.h>
|
||||
#include <qdesktopwidget.h>
|
||||
|
||||
#include <klocale.h>
|
||||
#include <KConfigDialogManager>
|
||||
#include <KLocalizedString>
|
||||
|
||||
#include "settings.h"
|
||||
|
||||
|
@ -24,6 +25,12 @@ DlgPresentation::DlgPresentation( QWidget * parent )
|
|||
m_dlg = new Ui_DlgPresentationBase();
|
||||
m_dlg->setupUi( this );
|
||||
|
||||
WidgetDrawingTools * kcfg_DrawingTools = new WidgetDrawingTools( m_dlg->annotationToolsGroupBox );
|
||||
m_dlg->verticalLayout_4->addWidget( kcfg_DrawingTools );
|
||||
kcfg_DrawingTools->setObjectName( QStringLiteral("kcfg_DrawingTools") );
|
||||
|
||||
KConfigDialogManager::changedMap()->insert( QStringLiteral("WidgetDrawingTools"), SIGNAL(changed()) );
|
||||
|
||||
QStringList choices;
|
||||
choices.append( i18nc( "@label:listbox The current screen, for the presentation mode", "Current Screen" ) );
|
||||
choices.append( i18nc( "@label:listbox The default screen for the presentation mode", "Default Screen" ) );
|
||||
|
@ -47,7 +54,7 @@ DlgPresentation::DlgPresentation( QWidget * parent )
|
|||
|
||||
m_dlg->kcfg_SlidesAdvanceTime->setSuffix(ki18ncp("Advance every %1 seconds", " second", " seconds"));
|
||||
|
||||
connect( m_dlg->screenCombo, SIGNAL(activated(int)), this, SLOT(screenComboChanged(int)) );
|
||||
connect(m_dlg->screenCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this, &DlgPresentation::screenComboChanged);
|
||||
}
|
||||
|
||||
DlgPresentation::~DlgPresentation()
|
||||
|
@ -60,4 +67,4 @@ void DlgPresentation::screenComboChanged( int which )
|
|||
Okular::Settings::setSlidesScreen( which - 2 );
|
||||
}
|
||||
|
||||
#include "dlgpresentation.moc"
|
||||
#include "moc_dlgpresentation.cpp"
|
||||
|
|
|
@ -19,10 +19,10 @@ class DlgPresentation : public QWidget
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DlgPresentation( QWidget * parent = 0 );
|
||||
explicit DlgPresentation( QWidget * parent = nullptr );
|
||||
virtual ~DlgPresentation();
|
||||
|
||||
protected slots:
|
||||
protected Q_SLOTS:
|
||||
void screenComboChanged( int which );
|
||||
|
||||
protected:
|
||||
|
|
|
@ -1,54 +1,79 @@
|
|||
<ui version="4.0" >
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DlgPresentationBase</class>
|
||||
<widget class="QWidget" name="DlgPresentationBase" >
|
||||
<property name="geometry" >
|
||||
<widget class="QWidget" name="DlgPresentationBase">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>446</height>
|
||||
<height>525</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2" >
|
||||
<property name="margin" >
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox" >
|
||||
<property name="title" >
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Navigation</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="spacing" >
|
||||
<layout class="QVBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin" >
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="spacing" >
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin" >
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="kcfg_SlidesAdvance" >
|
||||
<property name="text" >
|
||||
<widget class="QCheckBox" name="kcfg_SlidesAdvance">
|
||||
<property name="text">
|
||||
<string>Advance every:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KIntSpinBox" name="kcfg_SlidesAdvanceTime" >
|
||||
<property name="enabled" >
|
||||
<widget class="KPluralHandlingSpinBox" name="kcfg_SlidesAdvanceTime">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="suffix" >
|
||||
<string> sec.</string>
|
||||
</property>
|
||||
<property name="value" >
|
||||
<property name="value">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
|
@ -56,8 +81,8 @@
|
|||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="kcfg_SlidesLoop" >
|
||||
<property name="text" >
|
||||
<widget class="QCheckBox" name="kcfg_SlidesLoop">
|
||||
<property name="text">
|
||||
<string>Loop after last page</string>
|
||||
</property>
|
||||
</widget>
|
||||
|
@ -66,63 +91,50 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2" >
|
||||
<property name="title" >
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Appearance</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" >
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_3" >
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="textLabel3" >
|
||||
<property name="text" >
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="textLabel3">
|
||||
<property name="text">
|
||||
<string>Background color:</string>
|
||||
</property>
|
||||
<property name="alignment" >
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="KColorButton" name="kcfg_SlidesBackgroundColor" />
|
||||
<item row="0" column="1">
|
||||
<widget class="KColorButton" name="kcfg_SlidesBackgroundColor"/>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="text" >
|
||||
<string>Pencil color:</string>
|
||||
</property>
|
||||
<property name="alignment" >
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="KColorButton" name="kcfg_SlidesPencilColor" />
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<widget class="QLabel" name="textLabel2" >
|
||||
<property name="text" >
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="textLabel2">
|
||||
<property name="text">
|
||||
<string>Mouse cursor:</string>
|
||||
</property>
|
||||
<property name="alignment" >
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" >
|
||||
<widget class="QComboBox" name="kcfg_SlidesCursor" >
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="kcfg_SlidesCursor">
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Hidden After Delay</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Always Visible</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Always Hidden</string>
|
||||
</property>
|
||||
</item>
|
||||
|
@ -131,15 +143,15 @@
|
|||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="kcfg_SlidesShowProgress" >
|
||||
<property name="text" >
|
||||
<widget class="QCheckBox" name="kcfg_SlidesShowProgress">
|
||||
<property name="text">
|
||||
<string>Show &progress indicator</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="kcfg_SlidesShowSummary" >
|
||||
<property name="text" >
|
||||
<widget class="QCheckBox" name="kcfg_SlidesShowSummary">
|
||||
<property name="text">
|
||||
<string>Show s&ummary page</string>
|
||||
</property>
|
||||
</widget>
|
||||
|
@ -148,116 +160,121 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="kcfg_SlidesTransitionsEnabled" >
|
||||
<property name="title" >
|
||||
<widget class="QGroupBox" name="kcfg_SlidesTransitionsEnabled">
|
||||
<property name="title">
|
||||
<string>Enable transitions</string>
|
||||
</property>
|
||||
<property name="checkable" >
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked" >
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout" >
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="textLabel1" >
|
||||
<property name="text" >
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="textLabel1">
|
||||
<property name="text">
|
||||
<string>Default transition:</string>
|
||||
</property>
|
||||
<property name="alignment" >
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QComboBox" name="kcfg_SlidesTransition" >
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="kcfg_SlidesTransition">
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Blinds Vertical</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Blinds Horizontal</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Box In</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Box Out</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Dissolve</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Fade</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Glitter Down</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Glitter Right</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Glitter Right-Down</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Random Transition</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Replace</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Split Horizontal In</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Split Horizontal Out</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Split Vertical In</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Split Vertical Out</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Wipe Down</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Wipe Right</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Wipe Left</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Wipe Up</string>
|
||||
</property>
|
||||
</item>
|
||||
|
@ -267,55 +284,47 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_4" >
|
||||
<property name="title" >
|
||||
<widget class="QGroupBox" name="groupBox_4">
|
||||
<property name="title">
|
||||
<string>Placement</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2" >
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="label_2" >
|
||||
<property name="text" >
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Screen:</string>
|
||||
</property>
|
||||
<property name="alignment" >
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QComboBox" name="screenCombo" />
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="screenCombo"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
<widget class="QGroupBox" name="annotationToolsGroupBox">
|
||||
<property name="title">
|
||||
<string>Drawing Tool Configuration</string>
|
||||
</property>
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>4</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4"/>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>KColorButton</class>
|
||||
<extends>QPushButton</extends>
|
||||
<header>kcolorbutton.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>KIntSpinBox</class>
|
||||
<extends>KIntSpinBox</extends>
|
||||
<header>knuminput.h</header>
|
||||
<class>KPluralHandlingSpinBox</class>
|
||||
<extends>QSpinBox</extends>
|
||||
<header>KPluralHandlingSpinBox</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
|
@ -326,11 +335,11 @@
|
|||
<receiver>kcfg_SlidesAdvanceTime</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<hint type="sourcelabel">
|
||||
<x>88</x>
|
||||
<y>43</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<hint type="destinationlabel">
|
||||
<x>280</x>
|
||||
<y>49</y>
|
||||
</hint>
|
||||
|
|
493
conf/editannottooldialog.cpp
Normal file
493
conf/editannottooldialog.cpp
Normal file
|
@ -0,0 +1,493 @@
|
|||
|
||||
#include "editannottooldialog.h"
|
||||
|
||||
#include <kcolorbutton.h>
|
||||
#include <kcombobox.h>
|
||||
#include <klocalizedstring.h>
|
||||
#include <klineedit.h>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QLabel>
|
||||
#include <QListWidget>
|
||||
#include <QListWidgetItem>
|
||||
#include <QPushButton>
|
||||
#include <QStackedWidget>
|
||||
#include <QtXml/QDomDocument>
|
||||
#include <QtXml/QDomElement>
|
||||
#include <KConfigGroup>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "core/annotations.h"
|
||||
#include "ui/annotationwidgets.h"
|
||||
#include "ui/pageviewannotator.h"
|
||||
|
||||
|
||||
EditAnnotToolDialog::EditAnnotToolDialog( QWidget *parent, const QDomElement &initialState )
|
||||
: QDialog( parent ), m_stubann( nullptr ), m_annotationWidget( nullptr )
|
||||
{
|
||||
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
setLayout(mainLayout);
|
||||
QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
|
||||
okButton->setDefault(true);
|
||||
okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
|
||||
connect(buttonBox, &QDialogButtonBox::accepted, this, &EditAnnotToolDialog::accept);
|
||||
connect(buttonBox, &QDialogButtonBox::rejected, this, &EditAnnotToolDialog::reject);
|
||||
okButton->setDefault(true);
|
||||
|
||||
QLabel * tmplabel;
|
||||
QWidget *widget = new QWidget( this );
|
||||
QGridLayout * widgetLayout = new QGridLayout( widget );
|
||||
|
||||
mainLayout->addWidget(widget);
|
||||
mainLayout->addWidget(buttonBox);
|
||||
|
||||
|
||||
m_name = new KLineEdit( widget );
|
||||
mainLayout->addWidget(m_name);
|
||||
tmplabel = new QLabel( i18n( "&Name:" ), widget );
|
||||
mainLayout->addWidget(tmplabel);
|
||||
tmplabel->setBuddy( m_name );
|
||||
widgetLayout->addWidget( tmplabel, 0, 0, Qt::AlignRight );
|
||||
widgetLayout->addWidget( m_name, 0, 1 );
|
||||
|
||||
m_type = new KComboBox( false, widget );
|
||||
mainLayout->addWidget(m_type);
|
||||
connect(m_type, static_cast<void (KComboBox::*)(int)>(&KComboBox::currentIndexChanged), this, &EditAnnotToolDialog::slotTypeChanged);
|
||||
tmplabel = new QLabel( i18n( "&Type:" ), widget );
|
||||
mainLayout->addWidget(tmplabel);
|
||||
tmplabel->setBuddy( m_type );
|
||||
widgetLayout->addWidget( tmplabel, 1, 0, Qt::AlignRight );
|
||||
widgetLayout->addWidget( m_type, 1, 1 );
|
||||
|
||||
m_toolIcon = new QLabel( widget );
|
||||
mainLayout->addWidget(m_toolIcon);
|
||||
m_toolIcon->setAlignment( Qt::AlignRight | Qt::AlignTop );
|
||||
m_toolIcon->setMinimumSize( 40, 32 );
|
||||
widgetLayout->addWidget( m_toolIcon, 0, 2, 2, 1 );
|
||||
|
||||
m_appearanceBox = new QGroupBox( i18n( "Appearance" ), widget );
|
||||
mainLayout->addWidget(m_appearanceBox);
|
||||
m_appearanceBox->setLayout( new QVBoxLayout( m_appearanceBox ) );
|
||||
widgetLayout->addWidget( m_appearanceBox, 2, 0, 1, 3 );
|
||||
|
||||
// Populate combobox with annotation types
|
||||
m_type->addItem( i18n("Pop-up Note"), qVariantFromValue( ToolNoteLinked ) );
|
||||
m_type->addItem( i18n("Inline Note"), qVariantFromValue( ToolNoteInline ) );
|
||||
m_type->addItem( i18n("Freehand Line"), qVariantFromValue( ToolInk ) );
|
||||
m_type->addItem( i18n("Straight Line"), qVariantFromValue( ToolStraightLine ) );
|
||||
m_type->addItem( i18n("Polygon"), qVariantFromValue( ToolPolygon ) );
|
||||
m_type->addItem( i18n("Text markup"), qVariantFromValue( ToolTextMarkup ) );
|
||||
m_type->addItem( i18n("Geometrical shape"), qVariantFromValue( ToolGeometricalShape ) );
|
||||
m_type->addItem( i18n("Stamp"), qVariantFromValue( ToolStamp ) );
|
||||
|
||||
createStubAnnotation();
|
||||
|
||||
if ( initialState.isNull() )
|
||||
{
|
||||
setWindowTitle( i18n("Create annotation tool") );
|
||||
}
|
||||
else
|
||||
{
|
||||
setWindowTitle( i18n("Edit annotation tool") );
|
||||
loadTool( initialState );
|
||||
}
|
||||
|
||||
rebuildAppearanceBox();
|
||||
updateDefaultNameAndIcon();
|
||||
}
|
||||
|
||||
EditAnnotToolDialog::~EditAnnotToolDialog()
|
||||
{
|
||||
delete m_annotationWidget;
|
||||
}
|
||||
|
||||
QString EditAnnotToolDialog::name() const
|
||||
{
|
||||
return m_name->text();
|
||||
}
|
||||
|
||||
QDomDocument EditAnnotToolDialog::toolXml() const
|
||||
{
|
||||
const ToolType toolType = m_type->itemData( m_type->currentIndex() ).value<ToolType>();
|
||||
|
||||
QDomDocument doc;
|
||||
QDomElement toolElement = doc.createElement( QStringLiteral("tool") );
|
||||
QDomElement engineElement = doc.createElement( QStringLiteral("engine") );
|
||||
QDomElement annotationElement = doc.createElement( QStringLiteral("annotation") );
|
||||
doc.appendChild( toolElement );
|
||||
toolElement.appendChild( engineElement );
|
||||
engineElement.appendChild( annotationElement );
|
||||
|
||||
const QString color = m_stubann->style().color().name();
|
||||
const QString opacity = QString::number( m_stubann->style().opacity() );
|
||||
const QString width = QString::number( m_stubann->style().width() );
|
||||
|
||||
if ( toolType == ToolNoteLinked )
|
||||
{
|
||||
Okular::TextAnnotation * ta = static_cast<Okular::TextAnnotation*>( m_stubann );
|
||||
toolElement.setAttribute( QStringLiteral("type"), QStringLiteral("note-linked") );
|
||||
engineElement.setAttribute( QStringLiteral("type"), QStringLiteral("PickPoint") );
|
||||
engineElement.setAttribute( QStringLiteral("color"), color );
|
||||
engineElement.setAttribute( QStringLiteral("hoverIcon"), QStringLiteral("tool-note") );
|
||||
annotationElement.setAttribute( QStringLiteral("type"), QStringLiteral("Text") );
|
||||
annotationElement.setAttribute( QStringLiteral("color"), color );
|
||||
annotationElement.setAttribute( QStringLiteral("icon"), ta->textIcon() );
|
||||
}
|
||||
else if ( toolType == ToolNoteInline )
|
||||
{
|
||||
Okular::TextAnnotation * ta = static_cast<Okular::TextAnnotation*>( m_stubann );
|
||||
toolElement.setAttribute( QStringLiteral("type"), QStringLiteral("note-inline") );
|
||||
engineElement.setAttribute( QStringLiteral("type"), QStringLiteral("PickPoint") );
|
||||
engineElement.setAttribute( QStringLiteral("color"), color );
|
||||
engineElement.setAttribute( QStringLiteral("hoverIcon"), QStringLiteral("tool-note-inline") );
|
||||
engineElement.setAttribute( QStringLiteral("block"), QStringLiteral("true") );
|
||||
annotationElement.setAttribute( QStringLiteral("type"), QStringLiteral("FreeText") );
|
||||
annotationElement.setAttribute( QStringLiteral("color"), color );
|
||||
annotationElement.setAttribute( QStringLiteral("width"), width );
|
||||
if ( ta->inplaceAlignment() != 0 )
|
||||
annotationElement.setAttribute( QStringLiteral("align"), ta->inplaceAlignment() );
|
||||
if ( ta->textFont() != QApplication::font() )
|
||||
annotationElement.setAttribute( QStringLiteral("font"), ta->textFont().toString() );
|
||||
}
|
||||
else if ( toolType == ToolInk )
|
||||
{
|
||||
toolElement.setAttribute( QStringLiteral("type"), QStringLiteral("ink") );
|
||||
engineElement.setAttribute( QStringLiteral("type"), QStringLiteral("SmoothLine") );
|
||||
engineElement.setAttribute( QStringLiteral("color"), color );
|
||||
annotationElement.setAttribute( QStringLiteral("type"), QStringLiteral("Ink") );
|
||||
annotationElement.setAttribute( QStringLiteral("color"), color );
|
||||
annotationElement.setAttribute( QStringLiteral("width"), width );
|
||||
}
|
||||
else if ( toolType == ToolStraightLine )
|
||||
{
|
||||
Okular::LineAnnotation * la = static_cast<Okular::LineAnnotation*>( m_stubann );
|
||||
toolElement.setAttribute( QStringLiteral("type"), QStringLiteral("straight-line") );
|
||||
engineElement.setAttribute( QStringLiteral("type"), QStringLiteral("PolyLine") );
|
||||
engineElement.setAttribute( QStringLiteral("color"), color );
|
||||
engineElement.setAttribute( QStringLiteral("points"), QStringLiteral("2") );
|
||||
annotationElement.setAttribute( QStringLiteral("type"), QStringLiteral("Line") );
|
||||
annotationElement.setAttribute( QStringLiteral("color"), color );
|
||||
annotationElement.setAttribute( QStringLiteral("width"), width );
|
||||
if ( la->lineLeadingForwardPoint() != 0 || la->lineLeadingBackwardPoint() != 0 )
|
||||
{
|
||||
annotationElement.setAttribute( QStringLiteral("leadFwd"), QString::number( la->lineLeadingForwardPoint() ) );
|
||||
annotationElement.setAttribute( QStringLiteral("leadBack"), QString::number( la->lineLeadingBackwardPoint() ) );
|
||||
}
|
||||
}
|
||||
else if ( toolType == ToolPolygon )
|
||||
{
|
||||
Okular::LineAnnotation * la = static_cast<Okular::LineAnnotation*>( m_stubann );
|
||||
toolElement.setAttribute( QStringLiteral("type"), QStringLiteral("polygon") );
|
||||
engineElement.setAttribute( QStringLiteral("type"), QStringLiteral("PolyLine") );
|
||||
engineElement.setAttribute( QStringLiteral("color"), color );
|
||||
engineElement.setAttribute( QStringLiteral("points"), QStringLiteral("-1") );
|
||||
annotationElement.setAttribute( QStringLiteral("type"), QStringLiteral("Line") );
|
||||
annotationElement.setAttribute( QStringLiteral("color"), color );
|
||||
annotationElement.setAttribute( QStringLiteral("width"), width );
|
||||
if ( la->lineInnerColor().isValid() )
|
||||
{
|
||||
annotationElement.setAttribute( QStringLiteral("innerColor"), la->lineInnerColor().name() );
|
||||
}
|
||||
}
|
||||
else if ( toolType == ToolTextMarkup )
|
||||
{
|
||||
Okular::HighlightAnnotation * ha = static_cast<Okular::HighlightAnnotation*>( m_stubann );
|
||||
|
||||
switch ( ha->highlightType() )
|
||||
{
|
||||
case Okular::HighlightAnnotation::Highlight:
|
||||
toolElement.setAttribute( QStringLiteral("type"), QStringLiteral("highlight") );
|
||||
annotationElement.setAttribute( QStringLiteral("type"), QStringLiteral("Highlight") );
|
||||
break;
|
||||
case Okular::HighlightAnnotation::Squiggly:
|
||||
toolElement.setAttribute( QStringLiteral("type"), QStringLiteral("squiggly") );
|
||||
annotationElement.setAttribute( QStringLiteral("type"), QStringLiteral("Squiggly") );
|
||||
break;
|
||||
case Okular::HighlightAnnotation::Underline:
|
||||
toolElement.setAttribute( QStringLiteral("type"), QStringLiteral("underline") );
|
||||
annotationElement.setAttribute( QStringLiteral("type"), QStringLiteral("Underline") );
|
||||
break;
|
||||
case Okular::HighlightAnnotation::StrikeOut:
|
||||
toolElement.setAttribute( QStringLiteral("type"), QStringLiteral("strikeout") );
|
||||
annotationElement.setAttribute( QStringLiteral("type"), QStringLiteral("StrikeOut") );
|
||||
break;
|
||||
}
|
||||
|
||||
engineElement.setAttribute( QStringLiteral("type"), QStringLiteral("TextSelector") );
|
||||
engineElement.setAttribute( QStringLiteral("color"), color );
|
||||
annotationElement.setAttribute( QStringLiteral("color"), color );
|
||||
}
|
||||
else if ( toolType == ToolGeometricalShape )
|
||||
{
|
||||
Okular::GeomAnnotation * ga = static_cast<Okular::GeomAnnotation*>( m_stubann );
|
||||
|
||||
if ( ga->geometricalType() == Okular::GeomAnnotation::InscribedCircle )
|
||||
{
|
||||
toolElement.setAttribute( QStringLiteral("type"), QStringLiteral("ellipse") );
|
||||
annotationElement.setAttribute( QStringLiteral("type"), QStringLiteral("GeomCircle") );
|
||||
}
|
||||
else
|
||||
{
|
||||
toolElement.setAttribute( QStringLiteral("type"), QStringLiteral("rectangle") );
|
||||
annotationElement.setAttribute( QStringLiteral("type"), QStringLiteral("GeomSquare") );
|
||||
}
|
||||
|
||||
engineElement.setAttribute( QStringLiteral("type"), QStringLiteral("PickPoint") );
|
||||
engineElement.setAttribute( QStringLiteral("color"), color );
|
||||
engineElement.setAttribute( QStringLiteral("block"), QStringLiteral("true") );
|
||||
annotationElement.setAttribute( QStringLiteral("color"), color );
|
||||
annotationElement.setAttribute( QStringLiteral("width"), width );
|
||||
|
||||
if ( ga->geometricalInnerColor().isValid() )
|
||||
annotationElement.setAttribute( QStringLiteral("innerColor"), ga->geometricalInnerColor().name() );
|
||||
}
|
||||
else if ( toolType == ToolStamp )
|
||||
{
|
||||
Okular::StampAnnotation * sa = static_cast<Okular::StampAnnotation*>( m_stubann );
|
||||
toolElement.setAttribute( QStringLiteral("type"), QStringLiteral("stamp") );
|
||||
engineElement.setAttribute( QStringLiteral("type"), QStringLiteral("PickPoint") );
|
||||
engineElement.setAttribute( QStringLiteral("hoverIcon"), sa->stampIconName() );
|
||||
engineElement.setAttribute( QStringLiteral("size"), QStringLiteral("64") );
|
||||
engineElement.setAttribute( QStringLiteral("block"), QStringLiteral("true") );
|
||||
annotationElement.setAttribute( QStringLiteral("type"), QStringLiteral("Stamp") );
|
||||
annotationElement.setAttribute( QStringLiteral("icon"), sa->stampIconName() );
|
||||
}
|
||||
|
||||
if ( opacity != QStringLiteral("1") )
|
||||
annotationElement.setAttribute( QStringLiteral("opacity"), opacity );
|
||||
|
||||
return doc;
|
||||
}
|
||||
|
||||
void EditAnnotToolDialog::createStubAnnotation()
|
||||
{
|
||||
const ToolType toolType = m_type->itemData( m_type->currentIndex() ).value<ToolType>();
|
||||
|
||||
// Delete previous stub annotation, if any
|
||||
delete m_stubann;
|
||||
|
||||
// Create stub annotation
|
||||
if ( toolType == ToolNoteLinked )
|
||||
{
|
||||
Okular::TextAnnotation * ta = new Okular::TextAnnotation();
|
||||
ta->setTextType( Okular::TextAnnotation::Linked );
|
||||
ta->setTextIcon( QStringLiteral("Note") );
|
||||
ta->style().setColor( Qt::yellow );
|
||||
m_stubann = ta;
|
||||
}
|
||||
else if ( toolType == ToolNoteInline )
|
||||
{
|
||||
Okular::TextAnnotation * ta = new Okular::TextAnnotation();
|
||||
ta->setTextType( Okular::TextAnnotation::InPlace );
|
||||
ta->style().setWidth( 1.0 );
|
||||
ta->style().setColor( Qt::yellow );
|
||||
m_stubann = ta;
|
||||
}
|
||||
else if ( toolType == ToolInk )
|
||||
{
|
||||
m_stubann = new Okular::InkAnnotation();
|
||||
m_stubann->style().setWidth( 2.0 );
|
||||
m_stubann->style().setColor( Qt::green );
|
||||
}
|
||||
else if ( toolType == ToolStraightLine )
|
||||
{
|
||||
Okular::LineAnnotation * la = new Okular::LineAnnotation();
|
||||
la->setLinePoints( QLinkedList<Okular::NormalizedPoint>() <<
|
||||
Okular::NormalizedPoint(0,0) <<
|
||||
Okular::NormalizedPoint(1,0) );
|
||||
la->style().setColor( QColor( 0xff, 0xe0, 0x00 ) );
|
||||
m_stubann = la;
|
||||
}
|
||||
else if ( toolType == ToolPolygon )
|
||||
{
|
||||
Okular::LineAnnotation * la = new Okular::LineAnnotation();
|
||||
la->setLinePoints( QLinkedList<Okular::NormalizedPoint>() <<
|
||||
Okular::NormalizedPoint(0,0) <<
|
||||
Okular::NormalizedPoint(1,0) <<
|
||||
Okular::NormalizedPoint(1,1) );
|
||||
la->setLineClosed( true );
|
||||
la->style().setColor( QColor( 0x00, 0x7e, 0xee ) );
|
||||
m_stubann = la;
|
||||
}
|
||||
else if ( toolType == ToolTextMarkup )
|
||||
{
|
||||
m_stubann = new Okular::HighlightAnnotation();
|
||||
m_stubann->style().setColor( Qt::yellow );
|
||||
}
|
||||
else if ( toolType == ToolGeometricalShape )
|
||||
{
|
||||
Okular::GeomAnnotation * ga = new Okular::GeomAnnotation();
|
||||
ga->setGeometricalType( Okular::GeomAnnotation::InscribedCircle );
|
||||
ga->style().setWidth( 5.0 );
|
||||
ga->style().setColor( Qt::cyan );
|
||||
m_stubann = ga;
|
||||
}
|
||||
else if ( toolType == ToolStamp )
|
||||
{
|
||||
Okular::StampAnnotation * sa = new Okular::StampAnnotation();
|
||||
sa->setStampIconName( QStringLiteral("okular") );
|
||||
m_stubann = sa;
|
||||
}
|
||||
}
|
||||
|
||||
void EditAnnotToolDialog::rebuildAppearanceBox()
|
||||
{
|
||||
// Remove previous widget (if any)
|
||||
if ( m_annotationWidget )
|
||||
{
|
||||
delete m_annotationWidget->appearanceWidget();
|
||||
delete m_annotationWidget;
|
||||
}
|
||||
|
||||
m_annotationWidget = AnnotationWidgetFactory::widgetFor( m_stubann );
|
||||
m_appearanceBox->layout()->addWidget( m_annotationWidget->appearanceWidget() );
|
||||
|
||||
connect(m_annotationWidget, &AnnotationWidget::dataChanged, this, &EditAnnotToolDialog::slotDataChanged);
|
||||
}
|
||||
|
||||
void EditAnnotToolDialog::updateDefaultNameAndIcon()
|
||||
{
|
||||
QDomDocument doc = toolXml();
|
||||
QDomElement toolElement = doc.documentElement();
|
||||
m_name->setPlaceholderText( PageViewAnnotator::defaultToolName( toolElement ) );
|
||||
m_toolIcon->setPixmap( PageViewAnnotator::makeToolPixmap( toolElement ) );
|
||||
}
|
||||
|
||||
void EditAnnotToolDialog::setToolType( ToolType newType )
|
||||
{
|
||||
int idx = -1;
|
||||
|
||||
for ( int i = 0; idx == -1 && i < m_type->count(); ++i )
|
||||
{
|
||||
if ( m_type->itemData( i ).value<ToolType>() == newType )
|
||||
idx = i;
|
||||
}
|
||||
|
||||
// The following call also results in createStubAnnotation being called
|
||||
m_type->setCurrentIndex( idx );
|
||||
}
|
||||
|
||||
void EditAnnotToolDialog::loadTool( const QDomElement &toolElement )
|
||||
{
|
||||
const QDomElement engineElement = toolElement.elementsByTagName( QStringLiteral("engine") ).item( 0 ).toElement();
|
||||
const QDomElement annotationElement = engineElement.elementsByTagName( QStringLiteral("annotation") ).item( 0 ).toElement();
|
||||
const QString annotType = toolElement.attribute( QStringLiteral("type") );
|
||||
|
||||
if ( annotType == QLatin1String("ellipse") )
|
||||
{
|
||||
setToolType( ToolGeometricalShape );
|
||||
Okular::GeomAnnotation * ga = static_cast<Okular::GeomAnnotation*>( m_stubann );
|
||||
ga->setGeometricalType( Okular::GeomAnnotation::InscribedCircle );
|
||||
if ( annotationElement.hasAttribute( QStringLiteral("innerColor") ) )
|
||||
ga->setGeometricalInnerColor( QColor( annotationElement.attribute( QStringLiteral("innerColor") ) ) );
|
||||
}
|
||||
else if ( annotType == QLatin1String("highlight") )
|
||||
{
|
||||
setToolType( ToolTextMarkup );
|
||||
Okular::HighlightAnnotation * ha = static_cast<Okular::HighlightAnnotation*>( m_stubann );
|
||||
ha->setHighlightType( Okular::HighlightAnnotation::Highlight );
|
||||
}
|
||||
else if ( annotType == QLatin1String("ink") )
|
||||
{
|
||||
setToolType( ToolInk );
|
||||
}
|
||||
else if ( annotType == QLatin1String("note-inline") )
|
||||
{
|
||||
setToolType( ToolNoteInline );
|
||||
Okular::TextAnnotation * ta = static_cast<Okular::TextAnnotation*>( m_stubann );
|
||||
if ( annotationElement.hasAttribute( QStringLiteral("align") ) )
|
||||
ta->setInplaceAlignment( annotationElement.attribute( QStringLiteral("align") ).toInt() );
|
||||
if ( annotationElement.hasAttribute( QStringLiteral("font") ) )
|
||||
{
|
||||
QFont f;
|
||||
f.fromString( annotationElement.attribute( QStringLiteral("font") ) );
|
||||
ta->setTextFont( f );
|
||||
}
|
||||
}
|
||||
else if ( annotType == QLatin1String("note-linked") )
|
||||
{
|
||||
setToolType( ToolNoteLinked );
|
||||
Okular::TextAnnotation * ta = static_cast<Okular::TextAnnotation*>( m_stubann );
|
||||
ta->setTextIcon( annotationElement.attribute( QStringLiteral("icon") ) );
|
||||
}
|
||||
else if ( annotType == QLatin1String("polygon") )
|
||||
{
|
||||
setToolType( ToolPolygon );
|
||||
Okular::LineAnnotation * la = static_cast<Okular::LineAnnotation*>( m_stubann );
|
||||
if ( annotationElement.hasAttribute( QStringLiteral("innerColor") ) )
|
||||
la->setLineInnerColor( QColor( annotationElement.attribute( QStringLiteral("innerColor") ) ) );
|
||||
}
|
||||
else if ( annotType == QLatin1String("rectangle") )
|
||||
{
|
||||
setToolType( ToolGeometricalShape );
|
||||
Okular::GeomAnnotation * ga = static_cast<Okular::GeomAnnotation*>( m_stubann );
|
||||
ga->setGeometricalType( Okular::GeomAnnotation::InscribedSquare );
|
||||
if ( annotationElement.hasAttribute( QStringLiteral("innerColor") ) )
|
||||
ga->setGeometricalInnerColor( QColor( annotationElement.attribute( QStringLiteral("innerColor") ) ) );
|
||||
}
|
||||
else if ( annotType == QLatin1String("squiggly") )
|
||||
{
|
||||
setToolType( ToolTextMarkup );
|
||||
Okular::HighlightAnnotation * ha = static_cast<Okular::HighlightAnnotation*>( m_stubann );
|
||||
ha->setHighlightType( Okular::HighlightAnnotation::Squiggly );
|
||||
}
|
||||
else if ( annotType == QLatin1String("stamp") )
|
||||
{
|
||||
setToolType( ToolStamp );
|
||||
Okular::StampAnnotation * sa = static_cast<Okular::StampAnnotation*>( m_stubann );
|
||||
sa->setStampIconName( annotationElement.attribute( QStringLiteral("icon") ) );
|
||||
}
|
||||
else if ( annotType == QLatin1String("straight-line") )
|
||||
{
|
||||
setToolType( ToolStraightLine );
|
||||
Okular::LineAnnotation * la = static_cast<Okular::LineAnnotation*>( m_stubann );
|
||||
if ( annotationElement.hasAttribute( QStringLiteral("leadFwd") ) )
|
||||
la->setLineLeadingForwardPoint( annotationElement.attribute( QStringLiteral("leadFwd") ).toDouble() );
|
||||
if ( annotationElement.hasAttribute( QStringLiteral("leadBack") ) )
|
||||
la->setLineLeadingBackwardPoint( annotationElement.attribute( QStringLiteral("leadBack") ).toDouble() );
|
||||
}
|
||||
else if ( annotType == QLatin1String("strikeout") )
|
||||
{
|
||||
setToolType( ToolTextMarkup );
|
||||
Okular::HighlightAnnotation * ha = static_cast<Okular::HighlightAnnotation*>( m_stubann );
|
||||
ha->setHighlightType( Okular::HighlightAnnotation::StrikeOut );
|
||||
}
|
||||
else if ( annotType == QLatin1String("underline") )
|
||||
{
|
||||
setToolType( ToolTextMarkup );
|
||||
Okular::HighlightAnnotation * ha = static_cast<Okular::HighlightAnnotation*>( m_stubann );
|
||||
ha->setHighlightType( Okular::HighlightAnnotation::Underline );
|
||||
}
|
||||
|
||||
// Common properties
|
||||
if ( annotationElement.hasAttribute( QStringLiteral("color") ) )
|
||||
m_stubann->style().setColor( QColor( annotationElement.attribute( QStringLiteral("color") ) ) );
|
||||
if ( annotationElement.hasAttribute( QStringLiteral("opacity") ) )
|
||||
m_stubann->style().setOpacity( annotationElement.attribute( QStringLiteral("opacity") ).toDouble() );
|
||||
if ( annotationElement.hasAttribute( QStringLiteral("width") ) )
|
||||
m_stubann->style().setWidth( annotationElement.attribute( QStringLiteral("width") ).toDouble() );
|
||||
|
||||
if ( toolElement.hasAttribute( QStringLiteral("name") ) )
|
||||
m_name->setText( toolElement.attribute( QStringLiteral("name") ) );
|
||||
}
|
||||
|
||||
void EditAnnotToolDialog::slotTypeChanged()
|
||||
{
|
||||
createStubAnnotation();
|
||||
rebuildAppearanceBox();
|
||||
updateDefaultNameAndIcon();
|
||||
}
|
||||
|
||||
void EditAnnotToolDialog::slotDataChanged()
|
||||
{
|
||||
// Mirror changes back in the stub annotation
|
||||
m_annotationWidget->applyChanges();
|
||||
|
||||
updateDefaultNameAndIcon();
|
||||
}
|
73
conf/editannottooldialog.h
Normal file
73
conf/editannottooldialog.h
Normal file
|
@ -0,0 +1,73 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2012 by Fabio D'Urso <fabiodurso@hotmail.it> *
|
||||
* *
|
||||
* 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. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef EDITANNOTTOOLDIALOG_H
|
||||
#define EDITANNOTTOOLDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QDomElement>
|
||||
class KLineEdit;
|
||||
class KComboBox;
|
||||
class QLabel;
|
||||
class QListWidget;
|
||||
class QListWidgetItem;
|
||||
class QGroupBox;
|
||||
class AnnotationWidget;
|
||||
|
||||
namespace Okular
|
||||
{
|
||||
class Annotation;
|
||||
}
|
||||
|
||||
|
||||
class EditAnnotToolDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum ToolType
|
||||
{
|
||||
ToolNoteLinked,
|
||||
ToolNoteInline,
|
||||
ToolInk,
|
||||
ToolStraightLine,
|
||||
ToolPolygon,
|
||||
ToolTextMarkup,
|
||||
ToolGeometricalShape,
|
||||
ToolStamp
|
||||
};
|
||||
|
||||
EditAnnotToolDialog( QWidget *parent = nullptr, const QDomElement &initialState = QDomElement() );
|
||||
~EditAnnotToolDialog();
|
||||
QString name() const;
|
||||
QDomDocument toolXml() const;
|
||||
|
||||
private:
|
||||
void createStubAnnotation();
|
||||
void rebuildAppearanceBox();
|
||||
void updateDefaultNameAndIcon();
|
||||
void setToolType( ToolType newType );
|
||||
void loadTool( const QDomElement &toolElement );
|
||||
|
||||
KLineEdit *m_name;
|
||||
KComboBox *m_type;
|
||||
QLabel *m_toolIcon;
|
||||
QGroupBox *m_appearanceBox;
|
||||
|
||||
Okular::Annotation *m_stubann;
|
||||
AnnotationWidget *m_annotationWidget;
|
||||
|
||||
private Q_SLOTS:
|
||||
void slotTypeChanged();
|
||||
void slotDataChanged();
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE( EditAnnotToolDialog::ToolType )
|
||||
|
||||
#endif // EDITANNOTTOOLDIALOG_H
|
145
conf/editdrawingtooldialog.cpp
Normal file
145
conf/editdrawingtooldialog.cpp
Normal file
|
@ -0,0 +1,145 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2015 by Laurent Montel <montel@kde.org> *
|
||||
* *
|
||||
* 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. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "editdrawingtooldialog.h"
|
||||
|
||||
#include <KColorButton>
|
||||
#include <KLineEdit>
|
||||
#include <KLocalizedString>
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QSpinBox>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
EditDrawingToolDialog::EditDrawingToolDialog( const QDomElement &initialState, QWidget *parent )
|
||||
: QDialog(parent)
|
||||
{
|
||||
QDialogButtonBox *buttonBox = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel );
|
||||
buttonBox->setObjectName( QStringLiteral("buttonbox") );
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout(this);
|
||||
|
||||
QPushButton *okButton = buttonBox->button( QDialogButtonBox::Ok );
|
||||
okButton->setDefault( true );
|
||||
okButton->setShortcut( Qt::CTRL | Qt::Key_Return );
|
||||
connect( buttonBox, &QDialogButtonBox::accepted, this, &EditDrawingToolDialog::accept );
|
||||
connect( buttonBox, &QDialogButtonBox::rejected, this, &EditDrawingToolDialog::reject );
|
||||
okButton->setDefault( true );
|
||||
|
||||
QWidget *widget = new QWidget( this );
|
||||
QGridLayout * widgetLayout = new QGridLayout( widget );
|
||||
|
||||
mainLayout->addWidget( widget );
|
||||
mainLayout->addWidget( buttonBox );
|
||||
|
||||
m_name = new KLineEdit( widget );
|
||||
m_name->setObjectName( QStringLiteral("name") );
|
||||
mainLayout->addWidget( m_name );
|
||||
|
||||
QLabel *tmplabel = new QLabel( i18n( "&Name:" ), widget );
|
||||
mainLayout->addWidget( tmplabel );
|
||||
tmplabel->setBuddy( m_name );
|
||||
|
||||
widgetLayout->addWidget( tmplabel, 0, 0, Qt::AlignRight );
|
||||
widgetLayout->addWidget( m_name, 0, 1 );
|
||||
|
||||
tmplabel = new QLabel( i18n( "Color:" ), widget );
|
||||
widgetLayout->addWidget( tmplabel, 1, 0, Qt::AlignRight );
|
||||
|
||||
m_colorBn = new KColorButton( this );
|
||||
m_colorBn->setObjectName( QStringLiteral("colorbutton") );
|
||||
widgetLayout->addWidget( m_colorBn, 1, 1, Qt::AlignRight );
|
||||
|
||||
tmplabel = new QLabel( i18n( "&Pen Width:" ), widget );
|
||||
widgetLayout->addWidget( tmplabel, 2, 0, Qt::AlignRight );
|
||||
|
||||
m_penWidth = new QSpinBox( widget );
|
||||
m_penWidth->setObjectName( QStringLiteral("penWidth") );
|
||||
m_penWidth->setRange( 0, 50 );
|
||||
m_penWidth->setSuffix( i18nc( "Suffix for the pen width, eg '10 px'", " px" ) );
|
||||
tmplabel->setBuddy( m_penWidth );
|
||||
widgetLayout->addWidget( m_penWidth, 2, 1 );
|
||||
|
||||
tmplabel = new QLabel( i18n( "&Opacity:" ), widget );
|
||||
widgetLayout->addWidget( tmplabel, 3, 0, Qt::AlignRight );
|
||||
|
||||
m_opacity = new QSpinBox( widget );
|
||||
m_opacity->setObjectName( QStringLiteral("opacity") );
|
||||
m_opacity->setRange( 0, 100 );
|
||||
m_opacity->setSuffix( i18nc( "Suffix for the opacity level, eg '80 %'", " %" ) );
|
||||
tmplabel->setBuddy( m_opacity );
|
||||
widgetLayout->addWidget( m_opacity, 3, 1 );
|
||||
|
||||
if ( initialState.isNull() )
|
||||
{
|
||||
setWindowTitle( i18n("Create drawing tool") );
|
||||
m_colorBn->setColor( Qt::black );
|
||||
m_penWidth->setValue( 2 );
|
||||
m_opacity->setValue( 100 );
|
||||
}
|
||||
else
|
||||
{
|
||||
setWindowTitle( i18n("Edit drawing tool") );
|
||||
loadTool( initialState );
|
||||
}
|
||||
|
||||
m_name->setFocus();
|
||||
}
|
||||
|
||||
EditDrawingToolDialog::~EditDrawingToolDialog()
|
||||
{
|
||||
}
|
||||
|
||||
QString EditDrawingToolDialog::name() const
|
||||
{
|
||||
return m_name->text();
|
||||
}
|
||||
|
||||
QDomDocument EditDrawingToolDialog::toolXml() const
|
||||
{
|
||||
QDomDocument doc;
|
||||
QDomElement toolElement = doc.createElement( QStringLiteral("tool") );
|
||||
QDomElement engineElement = doc.createElement( QStringLiteral("engine") );
|
||||
QDomElement annotationElement = doc.createElement( QStringLiteral("annotation") );
|
||||
doc.appendChild( toolElement );
|
||||
toolElement.appendChild( engineElement );
|
||||
engineElement.appendChild( annotationElement );
|
||||
|
||||
const QString color = m_colorBn->color().name();
|
||||
const double opacity = m_opacity->value() / 100.0;
|
||||
|
||||
engineElement.setAttribute( QStringLiteral("color"), color );
|
||||
|
||||
annotationElement.setAttribute( QStringLiteral("type"), QStringLiteral("Ink") );
|
||||
annotationElement.setAttribute( QStringLiteral("color"), color );
|
||||
annotationElement.setAttribute( QStringLiteral("width"), QString::number( m_penWidth->value() ) );
|
||||
|
||||
if ( opacity != 1.0 )
|
||||
annotationElement.setAttribute( QStringLiteral("opacity"), QString::number( opacity ) );
|
||||
|
||||
return doc;
|
||||
}
|
||||
|
||||
void EditDrawingToolDialog::loadTool( const QDomElement &toolElement )
|
||||
{
|
||||
const QDomElement engineElement = toolElement.elementsByTagName( QStringLiteral("engine") ).item( 0 ).toElement();
|
||||
const QDomElement annotationElement = engineElement.elementsByTagName( QStringLiteral("annotation") ).item( 0 ).toElement();
|
||||
|
||||
if ( annotationElement.hasAttribute( QStringLiteral("color") ) )
|
||||
m_colorBn->setColor( QColor( annotationElement.attribute( QStringLiteral("color") ) ) );
|
||||
|
||||
m_penWidth->setValue( annotationElement.attribute( QStringLiteral("width"), QStringLiteral("2") ).toInt() );
|
||||
m_opacity->setValue( annotationElement.attribute( QStringLiteral("opacity"), QStringLiteral("1.0") ).toDouble() * 100 );
|
||||
|
||||
if ( toolElement.attribute( QStringLiteral("default"), QStringLiteral("false") ) == QLatin1String("true") )
|
||||
m_name->setText( i18n( toolElement.attribute( QStringLiteral("name") ).toLatin1().constData() ) );
|
||||
else
|
||||
m_name->setText( toolElement.attribute( QStringLiteral("name") ) );
|
||||
}
|
41
conf/editdrawingtooldialog.h
Normal file
41
conf/editdrawingtooldialog.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2015 by Laurent Montel <montel@kde.org> *
|
||||
* *
|
||||
* 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. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef EDITDRAWINGTOOLDIALOG_H
|
||||
#define EDITDRAWINGTOOLDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QDomElement>
|
||||
|
||||
class KColorButton;
|
||||
class KLineEdit;
|
||||
|
||||
class QSpinBox;
|
||||
|
||||
class EditDrawingToolDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit EditDrawingToolDialog( const QDomElement &initialState = QDomElement(), QWidget *parent = nullptr );
|
||||
~EditDrawingToolDialog();
|
||||
|
||||
QDomDocument toolXml() const;
|
||||
|
||||
QString name() const;
|
||||
|
||||
private:
|
||||
void loadTool( const QDomElement &toolElement );
|
||||
|
||||
KLineEdit *m_name;
|
||||
KColorButton *m_colorBn;
|
||||
QSpinBox *m_penWidth;
|
||||
QSpinBox *m_opacity;
|
||||
};
|
||||
|
||||
#endif // EDITDRAWINGTOOLDIALOG_H
|
|
@ -26,6 +26,14 @@
|
|||
<default>false</default>
|
||||
</entry>
|
||||
</group>
|
||||
<group name="Layers" >
|
||||
<entry key="LayersSearchCaseSensitive" type="Bool">
|
||||
<default>false</default>
|
||||
</entry>
|
||||
<entry key="LayersSearchRegularExpression" type="Bool">
|
||||
<default>false</default>
|
||||
</entry>
|
||||
</group>
|
||||
<group name="Reviews" >
|
||||
<entry key="ReviewsSearchCaseSensitive" type="Bool">
|
||||
<default>false</default>
|
||||
|
@ -33,11 +41,49 @@
|
|||
<entry key="ReviewsSearchRegularExpression" type="Bool">
|
||||
<default>false</default>
|
||||
</entry>
|
||||
<entry key="DrawingTools" type="StringList">
|
||||
<code>
|
||||
QStringList drawingTools;
|
||||
// load the default tool list from the 'xml tools definition' file
|
||||
QFile infoDrawingFile( QStandardPaths::locate(QStandardPaths::GenericDataLocation, "okular/drawingtools.xml") );
|
||||
if ( infoDrawingFile.exists() && infoDrawingFile.open( QIODevice::ReadOnly ) )
|
||||
{
|
||||
QDomDocument doc;
|
||||
if ( doc.setContent( &infoDrawingFile ) )
|
||||
{
|
||||
const QDomElement toolsDefinition = doc.elementsByTagName("drawingTools").item( 0 ).toElement();
|
||||
// create the annotationTools list from the XML dom tree
|
||||
QDomNode toolDescription = toolsDefinition.firstChild();
|
||||
while ( toolDescription.isElement() )
|
||||
{
|
||||
const QDomElement toolElement = toolDescription.toElement();
|
||||
if ( toolElement.tagName() == "tool" )
|
||||
{
|
||||
QDomDocument temp;
|
||||
temp.appendChild( temp.importNode( toolElement, true) );
|
||||
// add each <tool>...</tool> as XML string
|
||||
drawingTools << temp.toString(-1);
|
||||
}
|
||||
toolDescription = toolDescription.nextSibling();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning() << "DrawingTools XML file seems to be damaged";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning() << "Unable to open DrawingTools XML definition";
|
||||
}
|
||||
</code>
|
||||
<default code="true">drawingTools</default>
|
||||
</entry>
|
||||
<entry key="AnnotationTools" type="StringList">
|
||||
<code>
|
||||
QStringList annotationTools;
|
||||
// load the default tool list from the 'xml tools definition' file
|
||||
QFile infoFile( KStandardDirs::locate("data", "okular/tools.xml") );
|
||||
QFile infoFile( QStandardPaths::locate(QStandardPaths::GenericDataLocation, "okular/tools.xml") );
|
||||
if ( infoFile.exists() && infoFile.open( QIODevice::ReadOnly ) )
|
||||
{
|
||||
QDomDocument doc;
|
||||
|
@ -61,12 +107,12 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
kWarning() << "AnnotatingTools XML file seems to be damaged";
|
||||
qWarning() << "AnnotatingTools XML file seems to be damaged";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
kWarning() << "Unable to open AnnotatingTools XML definition";
|
||||
qWarning() << "Unable to open AnnotatingTools XML definition";
|
||||
}
|
||||
</code>
|
||||
<default code="true">annotationTools</default>
|
||||
|
@ -88,6 +134,9 @@
|
|||
<entry key="DisplayDocumentTitle" type="Bool" >
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry key="rtlReadingDirection" type="Bool" >
|
||||
<default>false</default>
|
||||
</entry>
|
||||
<entry key="DisplayDocumentNameOrPath" type="Enum" >
|
||||
<default>Name</default>
|
||||
<choices>
|
||||
|
@ -95,7 +144,7 @@
|
|||
<choice name="Path" />
|
||||
</choices>
|
||||
</entry>
|
||||
<entry key="UseKTTSD" type="Bool" />
|
||||
<entry key="UseTTS" type="Bool" />
|
||||
<entry key="WatchFile" type="Bool" >
|
||||
<default>true</default>
|
||||
</entry>
|
||||
|
@ -112,6 +161,7 @@
|
|||
<choice name="BoxIn" />
|
||||
<choice name="BoxOut" />
|
||||
<choice name="Dissolve" />
|
||||
<choice name="Fade" />
|
||||
<choice name="GlitterDown" />
|
||||
<choice name="GlitterRight" />
|
||||
<choice name="GlitterRightDown" />
|
||||
|
@ -141,9 +191,6 @@
|
|||
<entry key="SlidesShowSummary" type="Bool" >
|
||||
<default>false</default>
|
||||
</entry>
|
||||
<entry key="SlidesPencilColor" type="Color" >
|
||||
<default code="true" >Qt::red</default>
|
||||
</entry>
|
||||
<entry key="SlidesTransitionsEnabled" type="Bool" >
|
||||
<default>true</default>
|
||||
</entry>
|
||||
|
@ -220,6 +267,14 @@
|
|||
<choice name="Summary" />
|
||||
</choices>
|
||||
</entry>
|
||||
<entry key="TrimMode" type="Enum" >
|
||||
<default>None</default>
|
||||
<choices>
|
||||
<choice name="None" />
|
||||
<choice name="Margins" />
|
||||
<choice name="Selection" />
|
||||
</choices>
|
||||
</entry>
|
||||
<entry key="MouseMode" type="Enum" >
|
||||
<default>Browse</default>
|
||||
<choices>
|
||||
|
@ -229,6 +284,7 @@
|
|||
<choice name="TextSelect" />
|
||||
<choice name="TableSelect" />
|
||||
<choice name="Magnifier" />
|
||||
<choice name="TrimSelect" />
|
||||
</choices>
|
||||
</entry>
|
||||
<entry key="ShowSourceLocationsGraphically" type="Bool" >
|
||||
|
@ -242,6 +298,9 @@
|
|||
<entry key="SearchFromCurrentPage" type="Bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry key="FindAsYouType" type="Bool">
|
||||
<default>true</default>
|
||||
</entry>
|
||||
</group>
|
||||
<group name="Dlg Accessibility" >
|
||||
<entry key="HighlightImages" type="Bool" >
|
||||
|
|
|
@ -76,7 +76,7 @@
|
|||
</choices>
|
||||
</entry>
|
||||
<entry key="ExternalEditorCommand" type="String">
|
||||
<default>kate --use --line %l --column %c</default>
|
||||
<default>kate --line %l --column %c</default>
|
||||
</entry>
|
||||
</group>
|
||||
<group name="Core Presentation" >
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
// reimplementing this
|
||||
#include "preferencesdialog.h"
|
||||
|
||||
#include <klocale.h>
|
||||
#include <KLocalizedString>
|
||||
|
||||
// single config pages
|
||||
#include "dlggeneral.h"
|
||||
|
@ -22,43 +22,43 @@
|
|||
#include "dlgdebug.h"
|
||||
|
||||
PreferencesDialog::PreferencesDialog( QWidget * parent, KConfigSkeleton * skeleton, Okular::EmbedMode embedMode )
|
||||
: KConfigDialog( parent, "preferences", skeleton )
|
||||
: KConfigDialog( parent, QStringLiteral("preferences"), skeleton )
|
||||
{
|
||||
setWindowModality( Qt::ApplicationModal );
|
||||
|
||||
m_general = new DlgGeneral( this, embedMode );
|
||||
m_performance = new DlgPerformance( this );
|
||||
m_accessibility = new DlgAccessibility( this );
|
||||
m_presentation = 0;
|
||||
m_annotations = 0;
|
||||
m_annotationsPage = 0;
|
||||
m_editor = 0;
|
||||
m_presentation = nullptr;
|
||||
m_annotations = nullptr;
|
||||
m_annotationsPage = nullptr;
|
||||
m_editor = nullptr;
|
||||
#ifdef OKULAR_DEBUG_CONFIGPAGE
|
||||
m_debug = new DlgDebug( this );
|
||||
#endif
|
||||
|
||||
addPage( m_general, i18n("General"), "okular", i18n("General Options") );
|
||||
addPage( m_accessibility, i18n("Accessibility"), "preferences-desktop-accessibility", i18n("Accessibility Reading Aids") );
|
||||
addPage( m_performance, i18n("Performance"), "preferences-system-performance", i18n("Performance Tuning") );
|
||||
addPage( m_general, i18n("General"), QStringLiteral("okular"), i18n("General Options") );
|
||||
addPage( m_accessibility, i18n("Accessibility"), QStringLiteral("preferences-desktop-accessibility"), i18n("Accessibility Reading Aids") );
|
||||
addPage( m_performance, i18n("Performance"), QStringLiteral("preferences-system-performance"), i18n("Performance Tuning") );
|
||||
if( embedMode == Okular::ViewerWidgetMode )
|
||||
{
|
||||
setCaption( i18n("Configure Viewer") );
|
||||
setWindowTitle( i18n("Configure Viewer") );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_presentation = new DlgPresentation( this );
|
||||
m_annotations = new DlgAnnotations( this );
|
||||
m_editor = new DlgEditor( this );
|
||||
addPage( m_presentation, i18n("Presentation"), "view-presentation",
|
||||
addPage( m_presentation, i18n("Presentation"), QStringLiteral("view-presentation"),
|
||||
i18n("Options for Presentation Mode") );
|
||||
m_annotationsPage = addPage( m_annotations, i18n("Annotations"),
|
||||
"draw-freehand", i18n("Annotation Options") );
|
||||
addPage( m_editor, i18n("Editor"), "accessories-text-editor", i18n("Editor Options") );
|
||||
QStringLiteral("draw-freehand"), i18n("Annotation Options") );
|
||||
addPage( m_editor, i18n("Editor"), QStringLiteral("accessories-text-editor"), i18n("Editor Options") );
|
||||
}
|
||||
#ifdef OKULAR_DEBUG_CONFIGPAGE
|
||||
addPage( m_debug, "Debug", "system-run", "Debug options" );
|
||||
#endif
|
||||
setHelp("configure", "okular");
|
||||
setHelp(QStringLiteral("configure"), QStringLiteral("okular"));
|
||||
}
|
||||
|
||||
void PreferencesDialog::switchToAnnotationsPage()
|
||||
|
|
|
@ -27,6 +27,7 @@ class DlgDebug;
|
|||
|
||||
class PreferencesDialog : public KConfigDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PreferencesDialog( QWidget * parent, KConfigSkeleton * config, Okular::EmbedMode embedMode );
|
||||
|
@ -47,7 +48,9 @@ class PreferencesDialog : public KConfigDialog
|
|||
DlgPresentation * m_presentation;
|
||||
DlgAnnotations * m_annotations;
|
||||
DlgEditor * m_editor;
|
||||
#ifdef OKULAR_DEBUG_CONFIGPAGE
|
||||
DlgDebug * m_debug;
|
||||
#endif
|
||||
|
||||
KPageWidgetItem * m_annotationsPage;
|
||||
};
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
ClassName=Settings
|
||||
Namespace=Okular
|
||||
NameSpace=Okular
|
||||
File=okular.kcfg
|
||||
Inherits=SettingsCore
|
||||
Mutators=true
|
||||
Singleton=true
|
||||
Visibility=OKULAR_PART_EXPORT
|
||||
IncludeFiles=settings_core.h,okular_part_export.h
|
||||
SourceIncludeFiles=kstandarddirs.h,qdom.h
|
||||
Visibility=OKULARPART_EXPORT
|
||||
IncludeFiles=settings_core.h,okularpart_export.h
|
||||
SourceIncludeFiles=qdom.h,QStandardPaths
|
||||
MemberVariables=dpointer
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
ClassName=SettingsCore
|
||||
Namespace=Okular
|
||||
NameSpace=Okular
|
||||
File=okular_core.kcfg
|
||||
Mutators=true
|
||||
Singleton=true
|
||||
Visibility=OKULAR_EXPORT
|
||||
IncludeFiles=core/okular_export.h
|
||||
Visibility=OKULARCORE_EXPORT
|
||||
IncludeFiles=okularcore_export.h
|
||||
MemberVariables=dpointer
|
||||
|
|
|
@ -8,72 +8,32 @@
|
|||
***************************************************************************/
|
||||
|
||||
#include "widgetannottools.h"
|
||||
#include "editannottooldialog.h"
|
||||
|
||||
#include <kcolorbutton.h>
|
||||
#include <kcombobox.h>
|
||||
#include <kdebug.h>
|
||||
#include <kicon.h>
|
||||
#include <QIcon>
|
||||
#include <klocalizedstring.h>
|
||||
#include <klineedit.h>
|
||||
#include <knuminput.h>
|
||||
#include <kpushbutton.h>
|
||||
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QHBoxLayout>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QGroupBox>
|
||||
#include <QtGui/QLabel>
|
||||
#include <QtGui/QListWidget>
|
||||
#include <QtGui/QListWidgetItem>
|
||||
#include <QtGui/QStackedWidget>
|
||||
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QHBoxLayout>
|
||||
#include <QListWidget>
|
||||
#include <QListWidgetItem>
|
||||
#include <QtXml/QDomDocument>
|
||||
#include <QtXml/QDomElement>
|
||||
#include <KConfigGroup>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "core/annotations.h"
|
||||
#include "ui/annotationwidgets.h"
|
||||
#include "ui/pageviewannotator.h"
|
||||
|
||||
// Used to store tools' XML description in m_list's items
|
||||
static const int ToolXmlRole = Qt::UserRole;
|
||||
|
||||
WidgetAnnotTools::WidgetAnnotTools( QWidget * parent )
|
||||
: QWidget( parent )
|
||||
: WidgetConfigurationToolsBase( parent )
|
||||
{
|
||||
QHBoxLayout *hBoxLayout = new QHBoxLayout( this );
|
||||
m_list = new QListWidget( this );
|
||||
m_list->setIconSize( QSize( 64, 64 ) );
|
||||
hBoxLayout->addWidget( m_list );
|
||||
|
||||
QVBoxLayout *vBoxLayout = new QVBoxLayout();
|
||||
m_btnAdd = new KPushButton( i18n("&Add..."), this );
|
||||
m_btnAdd->setIcon( KIcon("list-add") );
|
||||
vBoxLayout->addWidget( m_btnAdd );
|
||||
m_btnEdit = new KPushButton( i18n("&Edit..."), this );
|
||||
m_btnEdit->setIcon( KIcon("edit-rename") );
|
||||
m_btnEdit->setEnabled( false );
|
||||
vBoxLayout->addWidget( m_btnEdit );
|
||||
m_btnRemove = new KPushButton( i18n("&Remove"), this );
|
||||
m_btnRemove->setIcon( KIcon("list-remove") );
|
||||
m_btnRemove->setEnabled( false );
|
||||
vBoxLayout->addWidget( m_btnRemove );
|
||||
m_btnMoveUp = new KPushButton( i18n("Move &Up"), this );
|
||||
m_btnMoveUp->setIcon( KIcon("arrow-up") );
|
||||
m_btnMoveUp->setEnabled( false );
|
||||
vBoxLayout->addWidget( m_btnMoveUp );
|
||||
m_btnMoveDown = new KPushButton( i18n("Move &Down"), this );
|
||||
m_btnMoveDown->setIcon( KIcon("arrow-down") );
|
||||
m_btnMoveDown->setEnabled( false );
|
||||
vBoxLayout->addWidget( m_btnMoveDown );
|
||||
vBoxLayout->addStretch();
|
||||
hBoxLayout->addLayout( vBoxLayout );
|
||||
|
||||
connect( m_list, SIGNAL( itemDoubleClicked(QListWidgetItem*) ), this, SLOT( slotEdit() ) );
|
||||
connect( m_list, SIGNAL( currentRowChanged(int) ), this, SLOT( updateButtons() ) );
|
||||
connect( m_btnAdd, SIGNAL( clicked(bool) ), this, SLOT( slotAdd() ) );
|
||||
connect( m_btnEdit, SIGNAL( clicked(bool) ), this, SLOT( slotEdit() ) );
|
||||
connect( m_btnRemove, SIGNAL( clicked(bool) ), this, SLOT( slotRemove() ) );
|
||||
connect( m_btnMoveUp, SIGNAL( clicked(bool) ), this, SLOT( slotMoveUp() ) );
|
||||
connect( m_btnMoveDown, SIGNAL( clicked(bool) ), this, SLOT( slotMoveDown() ) );
|
||||
}
|
||||
|
||||
WidgetAnnotTools::~WidgetAnnotTools()
|
||||
|
@ -98,17 +58,17 @@ QStringList WidgetAnnotTools::tools() const
|
|||
|
||||
// Set id
|
||||
QDomElement toolElement = doc.documentElement();
|
||||
toolElement.setAttribute( "id", i+1 );
|
||||
toolElement.setAttribute( QStringLiteral("id"), i+1 );
|
||||
|
||||
// Remove old shortcut, if any
|
||||
QDomNode oldShortcut = toolElement.elementsByTagName( "shortcut" ).item( 0 );
|
||||
QDomNode oldShortcut = toolElement.elementsByTagName( QStringLiteral("shortcut") ).item( 0 );
|
||||
if ( oldShortcut.isElement() )
|
||||
toolElement.removeChild( oldShortcut );
|
||||
|
||||
// Create new shortcut element (only the first 9 tools are assigned a shortcut key)
|
||||
if ( i < 9 )
|
||||
{
|
||||
QDomElement newShortcut = doc.createElement( "shortcut" );
|
||||
QDomElement newShortcut = doc.createElement( QStringLiteral("shortcut") );
|
||||
newShortcut.appendChild( doc.createTextNode(QString::number( i+1 )) );
|
||||
toolElement.appendChild( newShortcut );
|
||||
}
|
||||
|
@ -130,15 +90,15 @@ void WidgetAnnotTools::setTools(const QStringList& items)
|
|||
QDomDocument entryParser;
|
||||
if ( !entryParser.setContent( toolXml ) )
|
||||
{
|
||||
kWarning() << "Skipping malformed tool XML string";
|
||||
qWarning() << "Skipping malformed tool XML string";
|
||||
break;
|
||||
}
|
||||
|
||||
QDomElement toolElement = entryParser.documentElement();
|
||||
if ( toolElement.tagName() == "tool" )
|
||||
if ( toolElement.tagName() == QLatin1String("tool") )
|
||||
{
|
||||
// Create list item and attach the source XML string as data
|
||||
QString itemText = toolElement.attribute( "name" );
|
||||
QString itemText = toolElement.attribute( QStringLiteral("name") );
|
||||
if ( itemText.isEmpty() )
|
||||
itemText = PageViewAnnotator::defaultToolName( toolElement );
|
||||
QListWidgetItem * listEntry = new QListWidgetItem( itemText, m_list );
|
||||
|
@ -150,17 +110,6 @@ void WidgetAnnotTools::setTools(const QStringList& items)
|
|||
updateButtons();
|
||||
}
|
||||
|
||||
void WidgetAnnotTools::updateButtons()
|
||||
{
|
||||
const int row = m_list->currentRow();
|
||||
const int last = m_list->count() - 1;
|
||||
|
||||
m_btnEdit->setEnabled( row != -1 );
|
||||
m_btnRemove->setEnabled( row != -1 );
|
||||
m_btnMoveUp->setEnabled( row > 0 );
|
||||
m_btnMoveDown->setEnabled( row != -1 && row != last );
|
||||
}
|
||||
|
||||
void WidgetAnnotTools::slotEdit()
|
||||
{
|
||||
QListWidgetItem *listEntry = m_list->currentItem();
|
||||
|
@ -181,7 +130,7 @@ void WidgetAnnotTools::slotEdit()
|
|||
|
||||
// Store name attribute only if the user specified a customized name
|
||||
if ( !itemText.isEmpty() )
|
||||
toolElement.setAttribute( "name", itemText );
|
||||
toolElement.setAttribute( QStringLiteral("name"), itemText );
|
||||
else
|
||||
itemText = PageViewAnnotator::defaultToolName( toolElement );
|
||||
|
||||
|
@ -211,7 +160,7 @@ void WidgetAnnotTools::slotAdd()
|
|||
|
||||
// Store name attribute only if the user specified a customized name
|
||||
if ( !itemText.isEmpty() )
|
||||
toolElement.setAttribute( "name", itemText );
|
||||
toolElement.setAttribute( QStringLiteral("name"), itemText );
|
||||
else
|
||||
itemText = PageViewAnnotator::defaultToolName( toolElement );
|
||||
|
||||
|
@ -226,479 +175,3 @@ void WidgetAnnotTools::slotAdd()
|
|||
updateButtons();
|
||||
emit changed();
|
||||
}
|
||||
|
||||
void WidgetAnnotTools::slotRemove()
|
||||
{
|
||||
const int row = m_list->currentRow();
|
||||
delete m_list->takeItem(row);
|
||||
updateButtons();
|
||||
emit changed();
|
||||
}
|
||||
|
||||
void WidgetAnnotTools::slotMoveUp()
|
||||
{
|
||||
const int row = m_list->currentRow();
|
||||
m_list->insertItem( row, m_list->takeItem(row-1) );
|
||||
m_list->scrollToItem( m_list->currentItem() );
|
||||
updateButtons();
|
||||
emit changed();
|
||||
}
|
||||
|
||||
void WidgetAnnotTools::slotMoveDown()
|
||||
{
|
||||
const int row = m_list->currentRow();
|
||||
m_list->insertItem( row, m_list->takeItem(row+1) );
|
||||
m_list->scrollToItem( m_list->currentItem() );
|
||||
updateButtons();
|
||||
emit changed();
|
||||
}
|
||||
|
||||
EditAnnotToolDialog::EditAnnotToolDialog( QWidget *parent, const QDomElement &initialState )
|
||||
: KDialog( parent ), m_stubann( 0 ), m_annotationWidget( 0 )
|
||||
{
|
||||
setButtons( Ok | Cancel );
|
||||
setDefaultButton( Ok );
|
||||
|
||||
QLabel * tmplabel;
|
||||
QWidget *widget = new QWidget( this );
|
||||
QGridLayout * widgetLayout = new QGridLayout( widget );
|
||||
|
||||
setMainWidget(widget);
|
||||
|
||||
m_name = new KLineEdit( widget );
|
||||
tmplabel = new QLabel( i18n( "&Name:" ), widget );
|
||||
tmplabel->setBuddy( m_name );
|
||||
widgetLayout->addWidget( tmplabel, 0, 0, Qt::AlignRight );
|
||||
widgetLayout->addWidget( m_name, 0, 1 );
|
||||
|
||||
m_type = new KComboBox( false, widget );
|
||||
connect( m_type, SIGNAL( currentIndexChanged(int) ), this, SLOT( slotTypeChanged() ) );
|
||||
tmplabel = new QLabel( i18n( "&Type:" ), widget );
|
||||
tmplabel->setBuddy( m_type );
|
||||
widgetLayout->addWidget( tmplabel, 1, 0, Qt::AlignRight );
|
||||
widgetLayout->addWidget( m_type, 1, 1 );
|
||||
|
||||
m_toolIcon = new QLabel( widget );
|
||||
m_toolIcon->setAlignment( Qt::AlignRight | Qt::AlignTop );
|
||||
m_toolIcon->setMinimumSize( 40, 32 );
|
||||
widgetLayout->addWidget( m_toolIcon, 0, 2, 2, 1 );
|
||||
|
||||
m_appearanceBox = new QGroupBox( i18n( "Appearance" ), widget );
|
||||
m_appearanceBox->setLayout( new QVBoxLayout( m_appearanceBox ) );
|
||||
widgetLayout->addWidget( m_appearanceBox, 2, 0, 1, 3 );
|
||||
|
||||
// Populate combobox with annotation types
|
||||
m_type->addItem( i18n("Pop-up Note"), qVariantFromValue( ToolNoteLinked ) );
|
||||
m_type->addItem( i18n("Inline Note"), qVariantFromValue( ToolNoteInline ) );
|
||||
m_type->addItem( i18n("Freehand Line"), qVariantFromValue( ToolInk ) );
|
||||
m_type->addItem( i18n("Straight Line"), qVariantFromValue( ToolStraightLine ) );
|
||||
m_type->addItem( i18n("Polygon"), qVariantFromValue( ToolPolygon ) );
|
||||
m_type->addItem( i18n("Text markup"), qVariantFromValue( ToolTextMarkup ) );
|
||||
m_type->addItem( i18n("Geometrical shape"), qVariantFromValue( ToolGeometricalShape ) );
|
||||
m_type->addItem( i18n("Stamp"), qVariantFromValue( ToolStamp ) );
|
||||
|
||||
createStubAnnotation();
|
||||
|
||||
if ( initialState.isNull() )
|
||||
{
|
||||
setCaption( i18n("Create annotation tool") );
|
||||
}
|
||||
else
|
||||
{
|
||||
setCaption( i18n("Edit annotation tool") );
|
||||
loadTool( initialState );
|
||||
}
|
||||
|
||||
rebuildAppearanceBox();
|
||||
updateDefaultNameAndIcon();
|
||||
}
|
||||
|
||||
EditAnnotToolDialog::~EditAnnotToolDialog()
|
||||
{
|
||||
delete m_annotationWidget;
|
||||
}
|
||||
|
||||
QString EditAnnotToolDialog::name() const
|
||||
{
|
||||
return m_name->text();
|
||||
}
|
||||
|
||||
QDomDocument EditAnnotToolDialog::toolXml() const
|
||||
{
|
||||
const ToolType toolType = m_type->itemData( m_type->currentIndex() ).value<ToolType>();
|
||||
|
||||
QDomDocument doc;
|
||||
QDomElement toolElement = doc.createElement( "tool" );
|
||||
QDomElement engineElement = doc.createElement( "engine" );
|
||||
QDomElement annotationElement = doc.createElement( "annotation" );
|
||||
doc.appendChild( toolElement );
|
||||
toolElement.appendChild( engineElement );
|
||||
engineElement.appendChild( annotationElement );
|
||||
|
||||
const QString color = m_stubann->style().color().name();
|
||||
const double opacity = m_stubann->style().opacity();
|
||||
const double width = m_stubann->style().width();
|
||||
|
||||
if ( toolType == ToolNoteLinked )
|
||||
{
|
||||
Okular::TextAnnotation * ta = static_cast<Okular::TextAnnotation*>( m_stubann );
|
||||
toolElement.setAttribute( "type", "note-linked" );
|
||||
engineElement.setAttribute( "type", "PickPoint" );
|
||||
engineElement.setAttribute( "color", color );
|
||||
engineElement.setAttribute( "hoverIcon", "tool-note" );
|
||||
annotationElement.setAttribute( "type", "Text" );
|
||||
annotationElement.setAttribute( "color", color );
|
||||
annotationElement.setAttribute( "icon", ta->textIcon() );
|
||||
}
|
||||
else if ( toolType == ToolNoteInline )
|
||||
{
|
||||
Okular::TextAnnotation * ta = static_cast<Okular::TextAnnotation*>( m_stubann );
|
||||
toolElement.setAttribute( "type", "note-inline" );
|
||||
engineElement.setAttribute( "type", "PickPoint" );
|
||||
engineElement.setAttribute( "color", color );
|
||||
engineElement.setAttribute( "hoverIcon", "tool-note-inline" );
|
||||
engineElement.setAttribute( "block", "true" );
|
||||
annotationElement.setAttribute( "type", "FreeText" );
|
||||
annotationElement.setAttribute( "color", color );
|
||||
if ( ta->inplaceAlignment() != 0 )
|
||||
annotationElement.setAttribute( "align", ta->inplaceAlignment() );
|
||||
if ( ta->textFont() != QApplication::font() )
|
||||
annotationElement.setAttribute( "font", ta->textFont().toString() );
|
||||
}
|
||||
else if ( toolType == ToolInk )
|
||||
{
|
||||
toolElement.setAttribute( "type", "ink" );
|
||||
engineElement.setAttribute( "type", "SmoothLine" );
|
||||
engineElement.setAttribute( "color", color );
|
||||
annotationElement.setAttribute( "type", "Ink" );
|
||||
annotationElement.setAttribute( "color", color );
|
||||
annotationElement.setAttribute( "width", width );
|
||||
}
|
||||
else if ( toolType == ToolStraightLine )
|
||||
{
|
||||
Okular::LineAnnotation * la = static_cast<Okular::LineAnnotation*>( m_stubann );
|
||||
toolElement.setAttribute( "type", "straight-line" );
|
||||
engineElement.setAttribute( "type", "PolyLine" );
|
||||
engineElement.setAttribute( "color", color );
|
||||
engineElement.setAttribute( "points", "2" );
|
||||
annotationElement.setAttribute( "type", "Line" );
|
||||
annotationElement.setAttribute( "color", color );
|
||||
annotationElement.setAttribute( "width", width );
|
||||
if ( la->lineLeadingForwardPoint() != 0 || la->lineLeadingBackwardPoint() != 0 )
|
||||
{
|
||||
annotationElement.setAttribute( "leadFwd", la->lineLeadingForwardPoint() );
|
||||
annotationElement.setAttribute( "leadBack", la->lineLeadingBackwardPoint() );
|
||||
}
|
||||
}
|
||||
else if ( toolType == ToolPolygon )
|
||||
{
|
||||
Okular::LineAnnotation * la = static_cast<Okular::LineAnnotation*>( m_stubann );
|
||||
toolElement.setAttribute( "type", "polygon" );
|
||||
engineElement.setAttribute( "type", "PolyLine" );
|
||||
engineElement.setAttribute( "color", color );
|
||||
engineElement.setAttribute( "points", "-1" );
|
||||
annotationElement.setAttribute( "type", "Line" );
|
||||
annotationElement.setAttribute( "color", color );
|
||||
annotationElement.setAttribute( "width", width );
|
||||
if ( la->lineInnerColor().isValid() )
|
||||
{
|
||||
annotationElement.setAttribute( "innerColor", la->lineInnerColor().name() );
|
||||
}
|
||||
}
|
||||
else if ( toolType == ToolTextMarkup )
|
||||
{
|
||||
Okular::HighlightAnnotation * ha = static_cast<Okular::HighlightAnnotation*>( m_stubann );
|
||||
|
||||
switch ( ha->highlightType() )
|
||||
{
|
||||
case Okular::HighlightAnnotation::Highlight:
|
||||
toolElement.setAttribute( "type", "highlight" );
|
||||
annotationElement.setAttribute( "type", "Highlight" );
|
||||
break;
|
||||
case Okular::HighlightAnnotation::Squiggly:
|
||||
toolElement.setAttribute( "type", "squiggly" );
|
||||
annotationElement.setAttribute( "type", "Squiggly" );
|
||||
break;
|
||||
case Okular::HighlightAnnotation::Underline:
|
||||
toolElement.setAttribute( "type", "underline" );
|
||||
annotationElement.setAttribute( "type", "Underline" );
|
||||
break;
|
||||
case Okular::HighlightAnnotation::StrikeOut:
|
||||
toolElement.setAttribute( "type", "strikeout" );
|
||||
annotationElement.setAttribute( "type", "StrikeOut" );
|
||||
break;
|
||||
}
|
||||
|
||||
engineElement.setAttribute( "type", "TextSelector" );
|
||||
engineElement.setAttribute( "color", color );
|
||||
annotationElement.setAttribute( "color", color );
|
||||
}
|
||||
else if ( toolType == ToolGeometricalShape )
|
||||
{
|
||||
Okular::GeomAnnotation * ga = static_cast<Okular::GeomAnnotation*>( m_stubann );
|
||||
|
||||
if ( ga->geometricalType() == Okular::GeomAnnotation::InscribedCircle )
|
||||
{
|
||||
toolElement.setAttribute( "type", "ellipse" );
|
||||
annotationElement.setAttribute( "type", "GeomCircle" );
|
||||
}
|
||||
else
|
||||
{
|
||||
toolElement.setAttribute( "type", "rectangle" );
|
||||
annotationElement.setAttribute( "type", "GeomSquare" );
|
||||
}
|
||||
|
||||
engineElement.setAttribute( "type", "PickPoint" );
|
||||
engineElement.setAttribute( "color", color );
|
||||
engineElement.setAttribute( "block", "true" );
|
||||
annotationElement.setAttribute( "color", color );
|
||||
annotationElement.setAttribute( "width", width );
|
||||
|
||||
if ( ga->geometricalInnerColor().isValid() )
|
||||
annotationElement.setAttribute( "innerColor", ga->geometricalInnerColor().name() );
|
||||
}
|
||||
else if ( toolType == ToolStamp )
|
||||
{
|
||||
Okular::StampAnnotation * sa = static_cast<Okular::StampAnnotation*>( m_stubann );
|
||||
toolElement.setAttribute( "type", "stamp" );
|
||||
engineElement.setAttribute( "type", "PickPoint" );
|
||||
engineElement.setAttribute( "hoverIcon", sa->stampIconName() );
|
||||
engineElement.setAttribute( "size", "64" );
|
||||
engineElement.setAttribute( "block", "true" );
|
||||
annotationElement.setAttribute( "type", "Stamp" );
|
||||
annotationElement.setAttribute( "icon", sa->stampIconName() );
|
||||
}
|
||||
|
||||
if ( opacity != 1 )
|
||||
annotationElement.setAttribute( "opacity", opacity );
|
||||
|
||||
return doc;
|
||||
}
|
||||
|
||||
void EditAnnotToolDialog::createStubAnnotation()
|
||||
{
|
||||
const ToolType toolType = m_type->itemData( m_type->currentIndex() ).value<ToolType>();
|
||||
|
||||
// Delete previous stub annotation, if any
|
||||
delete m_stubann;
|
||||
|
||||
// Create stub annotation
|
||||
if ( toolType == ToolNoteLinked )
|
||||
{
|
||||
Okular::TextAnnotation * ta = new Okular::TextAnnotation();
|
||||
ta->setTextType( Okular::TextAnnotation::Linked );
|
||||
ta->setTextIcon( "Note" );
|
||||
ta->style().setColor( Qt::yellow );
|
||||
m_stubann = ta;
|
||||
}
|
||||
else if ( toolType == ToolNoteInline )
|
||||
{
|
||||
Okular::TextAnnotation * ta = new Okular::TextAnnotation();
|
||||
ta->setTextType( Okular::TextAnnotation::InPlace );
|
||||
ta->style().setColor( Qt::yellow );
|
||||
m_stubann = ta;
|
||||
}
|
||||
else if ( toolType == ToolInk )
|
||||
{
|
||||
m_stubann = new Okular::InkAnnotation();
|
||||
m_stubann->style().setWidth( 2.0 );
|
||||
m_stubann->style().setColor( Qt::green );
|
||||
}
|
||||
else if ( toolType == ToolStraightLine )
|
||||
{
|
||||
Okular::LineAnnotation * la = new Okular::LineAnnotation();
|
||||
la->setLinePoints( QLinkedList<Okular::NormalizedPoint>() <<
|
||||
Okular::NormalizedPoint(0,0) <<
|
||||
Okular::NormalizedPoint(1,0) );
|
||||
la->style().setColor( QColor( 0xff, 0xe0, 0x00 ) );
|
||||
m_stubann = la;
|
||||
}
|
||||
else if ( toolType == ToolPolygon )
|
||||
{
|
||||
Okular::LineAnnotation * la = new Okular::LineAnnotation();
|
||||
la->setLinePoints( QLinkedList<Okular::NormalizedPoint>() <<
|
||||
Okular::NormalizedPoint(0,0) <<
|
||||
Okular::NormalizedPoint(1,0) <<
|
||||
Okular::NormalizedPoint(1,1) );
|
||||
la->setLineClosed( true );
|
||||
la->style().setColor( QColor( 0x00, 0x7e, 0xee ) );
|
||||
m_stubann = la;
|
||||
}
|
||||
else if ( toolType == ToolTextMarkup )
|
||||
{
|
||||
m_stubann = new Okular::HighlightAnnotation();
|
||||
m_stubann->style().setColor( Qt::yellow );
|
||||
}
|
||||
else if ( toolType == ToolGeometricalShape )
|
||||
{
|
||||
Okular::GeomAnnotation * ga = new Okular::GeomAnnotation();
|
||||
ga->setGeometricalType( Okular::GeomAnnotation::InscribedCircle );
|
||||
ga->style().setWidth( 5.0 );
|
||||
ga->style().setColor( Qt::cyan );
|
||||
m_stubann = ga;
|
||||
}
|
||||
else if ( toolType == ToolStamp )
|
||||
{
|
||||
Okular::StampAnnotation * sa = new Okular::StampAnnotation();
|
||||
sa->setStampIconName( "okular" );
|
||||
m_stubann = sa;
|
||||
}
|
||||
}
|
||||
|
||||
void EditAnnotToolDialog::rebuildAppearanceBox()
|
||||
{
|
||||
// Remove previous widget (if any)
|
||||
if ( m_annotationWidget )
|
||||
{
|
||||
delete m_annotationWidget->appearanceWidget();
|
||||
delete m_annotationWidget;
|
||||
}
|
||||
|
||||
m_annotationWidget = AnnotationWidgetFactory::widgetFor( m_stubann );
|
||||
m_appearanceBox->layout()->addWidget( m_annotationWidget->appearanceWidget() );
|
||||
|
||||
connect( m_annotationWidget, SIGNAL(dataChanged()), this, SLOT(slotDataChanged()) );
|
||||
}
|
||||
|
||||
void EditAnnotToolDialog::updateDefaultNameAndIcon()
|
||||
{
|
||||
QDomDocument doc = toolXml();
|
||||
QDomElement toolElement = doc.documentElement();
|
||||
m_name->setPlaceholderText( PageViewAnnotator::defaultToolName( toolElement ) );
|
||||
m_toolIcon->setPixmap( PageViewAnnotator::makeToolPixmap( toolElement ) );
|
||||
}
|
||||
|
||||
void EditAnnotToolDialog::setToolType( ToolType newType )
|
||||
{
|
||||
int idx = -1;
|
||||
|
||||
for ( int i = 0; idx == -1 && i < m_type->count(); ++i )
|
||||
{
|
||||
if ( m_type->itemData( i ).value<ToolType>() == newType )
|
||||
idx = i;
|
||||
}
|
||||
|
||||
// The following call also results in createStubAnnotation being called
|
||||
m_type->setCurrentIndex( idx );
|
||||
}
|
||||
|
||||
void EditAnnotToolDialog::loadTool( const QDomElement &toolElement )
|
||||
{
|
||||
const QDomElement engineElement = toolElement.elementsByTagName( "engine" ).item( 0 ).toElement();
|
||||
const QDomElement annotationElement = engineElement.elementsByTagName( "annotation" ).item( 0 ).toElement();
|
||||
const QString annotType = toolElement.attribute( "type" );
|
||||
|
||||
if ( annotType == "ellipse" )
|
||||
{
|
||||
setToolType( ToolGeometricalShape );
|
||||
Okular::GeomAnnotation * ga = static_cast<Okular::GeomAnnotation*>( m_stubann );
|
||||
ga->setGeometricalType( Okular::GeomAnnotation::InscribedCircle );
|
||||
if ( annotationElement.hasAttribute( "innerColor" ) )
|
||||
ga->setGeometricalInnerColor( QColor( annotationElement.attribute( "innerColor" ) ) );
|
||||
}
|
||||
else if ( annotType == "highlight" )
|
||||
{
|
||||
setToolType( ToolTextMarkup );
|
||||
Okular::HighlightAnnotation * ha = static_cast<Okular::HighlightAnnotation*>( m_stubann );
|
||||
ha->setHighlightType( Okular::HighlightAnnotation::Highlight );
|
||||
}
|
||||
else if ( annotType == "ink" )
|
||||
{
|
||||
setToolType( ToolInk );
|
||||
}
|
||||
else if ( annotType == "note-inline" )
|
||||
{
|
||||
setToolType( ToolNoteInline );
|
||||
Okular::TextAnnotation * ta = static_cast<Okular::TextAnnotation*>( m_stubann );
|
||||
if ( annotationElement.hasAttribute( "align" ) )
|
||||
ta->setInplaceAlignment( annotationElement.attribute( "align" ).toInt() );
|
||||
if ( annotationElement.hasAttribute( "font" ) )
|
||||
{
|
||||
QFont f;
|
||||
f.fromString( annotationElement.attribute( "font" ) );
|
||||
ta->setTextFont( f );
|
||||
}
|
||||
}
|
||||
else if ( annotType == "note-linked" )
|
||||
{
|
||||
setToolType( ToolNoteLinked );
|
||||
Okular::TextAnnotation * ta = static_cast<Okular::TextAnnotation*>( m_stubann );
|
||||
ta->setTextIcon( annotationElement.attribute( "icon" ) );
|
||||
}
|
||||
else if ( annotType == "polygon" )
|
||||
{
|
||||
setToolType( ToolPolygon );
|
||||
Okular::LineAnnotation * la = static_cast<Okular::LineAnnotation*>( m_stubann );
|
||||
if ( annotationElement.hasAttribute( "innerColor" ) )
|
||||
la->setLineInnerColor( QColor( annotationElement.attribute( "innerColor" ) ) );
|
||||
}
|
||||
else if ( annotType == "rectangle" )
|
||||
{
|
||||
setToolType( ToolGeometricalShape );
|
||||
Okular::GeomAnnotation * ga = static_cast<Okular::GeomAnnotation*>( m_stubann );
|
||||
ga->setGeometricalType( Okular::GeomAnnotation::InscribedSquare );
|
||||
if ( annotationElement.hasAttribute( "innerColor" ) )
|
||||
ga->setGeometricalInnerColor( QColor( annotationElement.attribute( "innerColor" ) ) );
|
||||
}
|
||||
else if ( annotType == "squiggly" )
|
||||
{
|
||||
setToolType( ToolTextMarkup );
|
||||
Okular::HighlightAnnotation * ha = static_cast<Okular::HighlightAnnotation*>( m_stubann );
|
||||
ha->setHighlightType( Okular::HighlightAnnotation::Squiggly );
|
||||
}
|
||||
else if ( annotType == "stamp" )
|
||||
{
|
||||
setToolType( ToolStamp );
|
||||
Okular::StampAnnotation * sa = static_cast<Okular::StampAnnotation*>( m_stubann );
|
||||
sa->setStampIconName( annotationElement.attribute( "icon" ) );
|
||||
}
|
||||
else if ( annotType == "straight-line" )
|
||||
{
|
||||
setToolType( ToolStraightLine );
|
||||
Okular::LineAnnotation * la = static_cast<Okular::LineAnnotation*>( m_stubann );
|
||||
if ( annotationElement.hasAttribute( "leadFwd" ) )
|
||||
la->setLineLeadingForwardPoint( annotationElement.attribute( "leadFwd" ).toDouble() );
|
||||
if ( annotationElement.hasAttribute( "leadBack" ) )
|
||||
la->setLineLeadingBackwardPoint( annotationElement.attribute( "leadBack" ).toDouble() );
|
||||
}
|
||||
else if ( annotType == "strikeout" )
|
||||
{
|
||||
setToolType( ToolTextMarkup );
|
||||
Okular::HighlightAnnotation * ha = static_cast<Okular::HighlightAnnotation*>( m_stubann );
|
||||
ha->setHighlightType( Okular::HighlightAnnotation::StrikeOut );
|
||||
}
|
||||
else if ( annotType == "underline" )
|
||||
{
|
||||
setToolType( ToolTextMarkup );
|
||||
Okular::HighlightAnnotation * ha = static_cast<Okular::HighlightAnnotation*>( m_stubann );
|
||||
ha->setHighlightType( Okular::HighlightAnnotation::Underline );
|
||||
}
|
||||
|
||||
// Common properties
|
||||
if ( annotationElement.hasAttribute( "color" ) )
|
||||
m_stubann->style().setColor( QColor( annotationElement.attribute( "color" ) ) );
|
||||
if ( annotationElement.hasAttribute( "opacity" ) )
|
||||
m_stubann->style().setOpacity( annotationElement.attribute( "opacity" ).toDouble() );
|
||||
if ( annotationElement.hasAttribute( "width" ) )
|
||||
m_stubann->style().setWidth( annotationElement.attribute( "width" ).toDouble() );
|
||||
|
||||
if ( toolElement.hasAttribute( "name" ) )
|
||||
m_name->setText( toolElement.attribute( "name" ) );
|
||||
}
|
||||
|
||||
void EditAnnotToolDialog::slotTypeChanged()
|
||||
{
|
||||
createStubAnnotation();
|
||||
rebuildAppearanceBox();
|
||||
updateDefaultNameAndIcon();
|
||||
}
|
||||
|
||||
void EditAnnotToolDialog::slotDataChanged()
|
||||
{
|
||||
// Mirror changes back in the stub annotation
|
||||
m_annotationWidget->applyChanges();
|
||||
|
||||
updateDefaultNameAndIcon();
|
||||
}
|
||||
|
||||
#include "moc_widgetannottools.cpp"
|
||||
|
|
|
@ -10,99 +10,29 @@
|
|||
#ifndef _WIDGETANNOTTOOLS_H_
|
||||
#define _WIDGETANNOTTOOLS_H_
|
||||
|
||||
#include <kdialog.h>
|
||||
#include "widgetconfigurationtoolsbase.h"
|
||||
|
||||
#include <qdom.h>
|
||||
#include <qwidget.h>
|
||||
|
||||
class KLineEdit;
|
||||
class KComboBox;
|
||||
class KPushButton;
|
||||
class QLabel;
|
||||
class QListWidget;
|
||||
class QListWidgetItem;
|
||||
class QGroupBox;
|
||||
class AnnotationWidget;
|
||||
|
||||
namespace Okular
|
||||
{
|
||||
class Annotation;
|
||||
}
|
||||
|
||||
class WidgetAnnotTools : public QWidget
|
||||
class WidgetAnnotTools : public WidgetConfigurationToolsBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY( QStringList tools READ tools WRITE setTools NOTIFY changed USER true )
|
||||
|
||||
public:
|
||||
WidgetAnnotTools( QWidget * parent = 0 );
|
||||
explicit WidgetAnnotTools( QWidget * parent = nullptr );
|
||||
~WidgetAnnotTools();
|
||||
|
||||
QStringList tools() const;
|
||||
void setTools(const QStringList& items);
|
||||
QStringList tools() const override;
|
||||
void setTools(const QStringList& items) override;
|
||||
|
||||
Q_SIGNALS:
|
||||
void changed();
|
||||
|
||||
private:
|
||||
QListWidget *m_list;
|
||||
KPushButton *m_btnAdd;
|
||||
KPushButton *m_btnEdit;
|
||||
KPushButton *m_btnRemove;
|
||||
KPushButton *m_btnMoveUp;
|
||||
KPushButton *m_btnMoveDown;
|
||||
|
||||
private slots:
|
||||
void updateButtons();
|
||||
void slotAdd();
|
||||
void slotEdit();
|
||||
void slotRemove();
|
||||
void slotMoveUp();
|
||||
void slotMoveDown();
|
||||
protected Q_SLOTS:
|
||||
void slotAdd() override;
|
||||
void slotEdit() override;
|
||||
};
|
||||
|
||||
class EditAnnotToolDialog : public KDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum ToolType
|
||||
{
|
||||
ToolNoteLinked,
|
||||
ToolNoteInline,
|
||||
ToolInk,
|
||||
ToolStraightLine,
|
||||
ToolPolygon,
|
||||
ToolTextMarkup,
|
||||
ToolGeometricalShape,
|
||||
ToolStamp
|
||||
};
|
||||
|
||||
EditAnnotToolDialog( QWidget *parent = 0, const QDomElement &initialState = QDomElement() );
|
||||
~EditAnnotToolDialog();
|
||||
QString name() const;
|
||||
QDomDocument toolXml() const;
|
||||
|
||||
private:
|
||||
void createStubAnnotation();
|
||||
void rebuildAppearanceBox();
|
||||
void updateDefaultNameAndIcon();
|
||||
void setToolType( ToolType newType );
|
||||
void loadTool( const QDomElement &toolElement );
|
||||
|
||||
KLineEdit *m_name;
|
||||
KComboBox *m_type;
|
||||
QLabel *m_toolIcon;
|
||||
QGroupBox *m_appearanceBox;
|
||||
|
||||
Okular::Annotation *m_stubann;
|
||||
AnnotationWidget *m_annotationWidget;
|
||||
|
||||
private slots:
|
||||
void slotTypeChanged();
|
||||
void slotDataChanged();
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE( EditAnnotToolDialog::ToolType )
|
||||
|
||||
#endif
|
||||
|
|
104
conf/widgetconfigurationtoolsbase.cpp
Normal file
104
conf/widgetconfigurationtoolsbase.cpp
Normal file
|
@ -0,0 +1,104 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2015 by Laurent Montel <montel@kde.org> *
|
||||
* *
|
||||
* 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. *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "widgetconfigurationtoolsbase.h"
|
||||
|
||||
|
||||
#include <QIcon>
|
||||
#include <KLocalizedString>
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QListWidget>
|
||||
#include <QListWidgetItem>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
WidgetConfigurationToolsBase::WidgetConfigurationToolsBase( QWidget * parent )
|
||||
: QWidget( parent )
|
||||
{
|
||||
QHBoxLayout *hBoxLayout = new QHBoxLayout( this );
|
||||
m_list = new QListWidget( this );
|
||||
m_list->setIconSize( QSize( 64, 64 ) );
|
||||
hBoxLayout->addWidget( m_list );
|
||||
|
||||
QVBoxLayout *vBoxLayout = new QVBoxLayout();
|
||||
m_btnAdd = new QPushButton( i18n("&Add..."), this );
|
||||
m_btnAdd->setIcon( QIcon::fromTheme(QStringLiteral("list-add")) );
|
||||
vBoxLayout->addWidget( m_btnAdd );
|
||||
m_btnEdit = new QPushButton( i18n("&Edit..."), this );
|
||||
m_btnEdit->setIcon( QIcon::fromTheme(QStringLiteral("edit-rename")) );
|
||||
m_btnEdit->setEnabled( false );
|
||||
vBoxLayout->addWidget( m_btnEdit );
|
||||
m_btnRemove = new QPushButton( i18n("&Remove"), this );
|
||||
m_btnRemove->setIcon( QIcon::fromTheme(QStringLiteral("list-remove")) );
|
||||
m_btnRemove->setEnabled( false );
|
||||
vBoxLayout->addWidget( m_btnRemove );
|
||||
m_btnMoveUp = new QPushButton( i18n("Move &Up"), this );
|
||||
m_btnMoveUp->setIcon( QIcon::fromTheme(QStringLiteral("arrow-up")) );
|
||||
m_btnMoveUp->setEnabled( false );
|
||||
vBoxLayout->addWidget( m_btnMoveUp );
|
||||
m_btnMoveDown = new QPushButton( i18n("Move &Down"), this );
|
||||
m_btnMoveDown->setIcon( QIcon::fromTheme(QStringLiteral("arrow-down")) );
|
||||
m_btnMoveDown->setEnabled( false );
|
||||
vBoxLayout->addWidget( m_btnMoveDown );
|
||||
vBoxLayout->addStretch();
|
||||
hBoxLayout->addLayout( vBoxLayout );
|
||||
|
||||
connect(m_list, &QListWidget::itemDoubleClicked, this, &WidgetConfigurationToolsBase::slotEdit);
|
||||
connect(m_list, &QListWidget::currentRowChanged, this, &WidgetConfigurationToolsBase::updateButtons);
|
||||
connect(m_btnAdd, &QPushButton::clicked, this, &WidgetConfigurationToolsBase::slotAdd);
|
||||
connect(m_btnEdit, &QPushButton::clicked, this, &WidgetConfigurationToolsBase::slotEdit);
|
||||
connect(m_btnRemove, &QPushButton::clicked, this, &WidgetConfigurationToolsBase::slotRemove);
|
||||
connect(m_btnMoveUp, &QPushButton::clicked, this, &WidgetConfigurationToolsBase::slotMoveUp);
|
||||
connect(m_btnMoveDown, &QPushButton::clicked, this, &WidgetConfigurationToolsBase::slotMoveDown);
|
||||
}
|
||||
|
||||
WidgetConfigurationToolsBase::~WidgetConfigurationToolsBase()
|
||||
{
|
||||
}
|
||||
|
||||
void WidgetConfigurationToolsBase::updateButtons()
|
||||
{
|
||||
const int row = m_list->currentRow();
|
||||
const int last = m_list->count() - 1;
|
||||
|
||||
m_btnEdit->setEnabled( row != -1 );
|
||||
m_btnRemove->setEnabled( row != -1 );
|
||||
m_btnMoveUp->setEnabled( row > 0 );
|
||||
m_btnMoveDown->setEnabled( row != -1 && row != last );
|
||||
}
|
||||
|
||||
|
||||
void WidgetConfigurationToolsBase::slotRemove()
|
||||
{
|
||||
const int row = m_list->currentRow();
|
||||
delete m_list->takeItem(row);
|
||||
updateButtons();
|
||||
emit changed();
|
||||
}
|
||||
|
||||
void WidgetConfigurationToolsBase::slotMoveUp()
|
||||
{
|
||||
const int row = m_list->currentRow();
|
||||
m_list->insertItem( row, m_list->takeItem(row-1) );
|
||||
m_list->scrollToItem( m_list->currentItem() );
|
||||
updateButtons();
|
||||
emit changed();
|
||||
}
|
||||
|
||||
void WidgetConfigurationToolsBase::slotMoveDown()
|
||||
{
|
||||
const int row = m_list->currentRow();
|
||||
m_list->insertItem( row, m_list->takeItem(row+1) );
|
||||
m_list->scrollToItem( m_list->currentItem() );
|
||||
updateButtons();
|
||||
emit changed();
|
||||
}
|
51
conf/widgetconfigurationtoolsbase.h
Normal file
51
conf/widgetconfigurationtoolsbase.h
Normal file
|
@ -0,0 +1,51 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2015 by Laurent Montel <montel@kde.org> *
|
||||
* *
|
||||
* 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. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef WIDGETCONFIGURATIONTOOLSBASE_H
|
||||
#define WIDGETCONFIGURATIONTOOLSBASE_H
|
||||
|
||||
#include <QWidget>
|
||||
class QListWidget;
|
||||
class QPushButton;
|
||||
|
||||
class WidgetConfigurationToolsBase : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY( QStringList tools READ tools WRITE setTools NOTIFY changed USER true )
|
||||
|
||||
public:
|
||||
explicit WidgetConfigurationToolsBase( QWidget * parent = nullptr );
|
||||
~WidgetConfigurationToolsBase();
|
||||
|
||||
virtual QStringList tools() const = 0;
|
||||
virtual void setTools(const QStringList& items) = 0;
|
||||
|
||||
Q_SIGNALS:
|
||||
void changed();
|
||||
|
||||
protected:
|
||||
QListWidget *m_list;
|
||||
private:
|
||||
QPushButton *m_btnAdd;
|
||||
QPushButton *m_btnEdit;
|
||||
QPushButton *m_btnRemove;
|
||||
QPushButton *m_btnMoveUp;
|
||||
QPushButton *m_btnMoveDown;
|
||||
|
||||
protected Q_SLOTS:
|
||||
virtual void slotAdd() = 0;
|
||||
virtual void slotEdit() = 0;
|
||||
void updateButtons();
|
||||
void slotRemove();
|
||||
void slotMoveUp();
|
||||
void slotMoveDown();
|
||||
};
|
||||
|
||||
#endif // WIDGETCONFIGURATIONTOOLSBASE_H
|
212
conf/widgetdrawingtools.cpp
Normal file
212
conf/widgetdrawingtools.cpp
Normal file
|
@ -0,0 +1,212 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2015 by Laurent Montel <montel@kde.org> *
|
||||
* *
|
||||
* 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. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "widgetdrawingtools.h"
|
||||
|
||||
#include "editdrawingtooldialog.h"
|
||||
|
||||
#include <KLocalizedString>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDomElement>
|
||||
#include <QListWidgetItem>
|
||||
#include <QMessageBox>
|
||||
#include <QPainter>
|
||||
|
||||
// Used to store tools' XML description in m_list's items
|
||||
static const int ToolXmlRole = Qt::UserRole;
|
||||
|
||||
static QPixmap colorDecorationFromToolDescription( const QString &toolDescription )
|
||||
{
|
||||
QDomDocument doc;
|
||||
doc.setContent( toolDescription, true );
|
||||
const QDomElement toolElement = doc.documentElement();
|
||||
const QDomElement engineElement = toolElement.elementsByTagName( QStringLiteral( "engine" ) ).at( 0 ).toElement();
|
||||
const QDomElement annotationElement = engineElement.elementsByTagName( QStringLiteral( "annotation" ) ).at( 0 ).toElement();
|
||||
|
||||
QPixmap pm( 50, 20 );
|
||||
pm.fill( QColor( annotationElement.attribute( QStringLiteral( "color" ) ) ) );
|
||||
|
||||
QPainter p( &pm );
|
||||
p.setPen( Qt::black );
|
||||
p.drawRect( QRect( 0, 0, pm.width() - 1, pm.height() - 1 ) );
|
||||
|
||||
return pm;
|
||||
}
|
||||
|
||||
WidgetDrawingTools::WidgetDrawingTools( QWidget *parent )
|
||||
: WidgetConfigurationToolsBase( parent )
|
||||
{
|
||||
}
|
||||
|
||||
WidgetDrawingTools::~WidgetDrawingTools()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QStringList WidgetDrawingTools::tools() const
|
||||
{
|
||||
QStringList res;
|
||||
|
||||
const int count = m_list->count();
|
||||
for ( int i = 0; i < count; ++i )
|
||||
{
|
||||
QListWidgetItem * listEntry = m_list->item( i );
|
||||
|
||||
// Parse associated DOM data
|
||||
QDomDocument doc;
|
||||
doc.setContent( listEntry->data( ToolXmlRole ).value<QString>() );
|
||||
|
||||
// Append to output
|
||||
res << doc.toString( -1 );
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void WidgetDrawingTools::setTools( const QStringList &items )
|
||||
{
|
||||
m_list->clear();
|
||||
|
||||
// Parse each string and populate the list widget
|
||||
foreach ( const QString &toolXml, items )
|
||||
{
|
||||
QDomDocument entryParser;
|
||||
if ( !entryParser.setContent( toolXml ) )
|
||||
{
|
||||
qWarning() << "Skipping malformed tool XML string";
|
||||
break;
|
||||
}
|
||||
|
||||
const QDomElement toolElement = entryParser.documentElement();
|
||||
if ( toolElement.tagName() == QLatin1String("tool") )
|
||||
{
|
||||
const QString name = toolElement.attribute( QStringLiteral("name") );
|
||||
QString itemText;
|
||||
if ( toolElement.attribute( QStringLiteral("default"), QStringLiteral("false") ) == QLatin1String("true") )
|
||||
itemText = i18n( name.toLatin1().constData() );
|
||||
else
|
||||
itemText = name;
|
||||
|
||||
QListWidgetItem * listEntry = new QListWidgetItem( itemText, m_list );
|
||||
listEntry->setData( ToolXmlRole, qVariantFromValue( toolXml ) );
|
||||
listEntry->setData( Qt::DecorationRole, colorDecorationFromToolDescription( toolXml ) );
|
||||
}
|
||||
}
|
||||
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
QString WidgetDrawingTools::defaultName() const
|
||||
{
|
||||
int nameIndex = 1;
|
||||
bool freeNameFound = false;
|
||||
QString candidateName;
|
||||
while (!freeNameFound)
|
||||
{
|
||||
candidateName = i18n("Default Drawing Tool #%1", nameIndex);
|
||||
int i = 0;
|
||||
for ( ; i < m_list->count(); ++i )
|
||||
{
|
||||
QListWidgetItem * listEntry = m_list->item( i );
|
||||
if (candidateName == listEntry->text()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
freeNameFound = i == m_list->count();
|
||||
++nameIndex;
|
||||
}
|
||||
return candidateName;
|
||||
}
|
||||
|
||||
void WidgetDrawingTools::slotAdd()
|
||||
{
|
||||
EditDrawingToolDialog dlg( QDomElement(), this );
|
||||
|
||||
if ( dlg.exec() != QDialog::Accepted )
|
||||
return;
|
||||
|
||||
const QDomDocument rootDoc = dlg.toolXml();
|
||||
QDomElement toolElement = rootDoc.documentElement();
|
||||
|
||||
QString itemText = dlg.name().trimmed();
|
||||
|
||||
if (itemText.isEmpty()) {
|
||||
itemText = defaultName();
|
||||
}
|
||||
|
||||
for ( int i = 0; i < m_list->count(); ++i )
|
||||
{
|
||||
QListWidgetItem * listEntry = m_list->item( i );
|
||||
if (itemText == listEntry->text()) {
|
||||
QMessageBox::information( this, i18n("Duplicated Name"), i18n("There's already a tool with that name. Using a default one") );
|
||||
itemText = defaultName();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Store name attribute only if the user specified a customized name
|
||||
toolElement.setAttribute( QStringLiteral("name"), itemText );
|
||||
|
||||
// Create list entry and attach XML string as data
|
||||
const QString toolXml = rootDoc.toString( -1 );
|
||||
QListWidgetItem * listEntry = new QListWidgetItem( itemText, m_list );
|
||||
listEntry->setData( ToolXmlRole, qVariantFromValue( toolXml ) );
|
||||
listEntry->setData( Qt::DecorationRole, colorDecorationFromToolDescription( toolXml ) );
|
||||
|
||||
// Select and scroll
|
||||
m_list->setCurrentItem( listEntry );
|
||||
m_list->scrollToItem( listEntry );
|
||||
updateButtons();
|
||||
emit changed();
|
||||
}
|
||||
|
||||
void WidgetDrawingTools::slotEdit()
|
||||
{
|
||||
QListWidgetItem *listEntry = m_list->currentItem();
|
||||
|
||||
QDomDocument doc;
|
||||
doc.setContent( listEntry->data( ToolXmlRole ).value<QString>() );
|
||||
QDomElement toolElement = doc.documentElement();
|
||||
|
||||
EditDrawingToolDialog dlg( toolElement, this );
|
||||
|
||||
if ( dlg.exec() != QDialog::Accepted )
|
||||
return;
|
||||
|
||||
doc = dlg.toolXml();
|
||||
toolElement = doc.documentElement();
|
||||
|
||||
QString itemText = dlg.name();
|
||||
|
||||
for ( int i = 0; i < m_list->count(); ++i )
|
||||
{
|
||||
QListWidgetItem * auxListEntry = m_list->item( i );
|
||||
if (itemText == auxListEntry->text() && auxListEntry != listEntry) {
|
||||
QMessageBox::information( this, i18n("Duplicated Name"), i18n("There's already a tool with that name. Using a default one") );
|
||||
itemText = defaultName();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Store name attribute only if the user specified a customized name
|
||||
toolElement.setAttribute( QStringLiteral("name"), itemText );
|
||||
|
||||
// Edit list entry and attach XML string as data
|
||||
const QString toolXml = doc.toString( -1 );
|
||||
listEntry->setText( itemText );
|
||||
listEntry->setData( ToolXmlRole, qVariantFromValue( toolXml ) );
|
||||
listEntry->setData( Qt::DecorationRole, colorDecorationFromToolDescription( toolXml ) );
|
||||
|
||||
// Select and scroll
|
||||
m_list->setCurrentItem( listEntry );
|
||||
m_list->scrollToItem( listEntry );
|
||||
updateButtons();
|
||||
emit changed();
|
||||
}
|
33
conf/widgetdrawingtools.h
Normal file
33
conf/widgetdrawingtools.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2015 by Laurent Montel <montel@kde.org> *
|
||||
* *
|
||||
* 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. *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef WIDGETDRAWINGTOOLS_H
|
||||
#define WIDGETDRAWINGTOOLS_H
|
||||
|
||||
#include "widgetconfigurationtoolsbase.h"
|
||||
|
||||
class WidgetDrawingTools : public WidgetConfigurationToolsBase
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit WidgetDrawingTools( QWidget * parent = nullptr );
|
||||
~WidgetDrawingTools();
|
||||
|
||||
QStringList tools() const override;
|
||||
void setTools( const QStringList& items ) override;
|
||||
|
||||
QString defaultName() const;
|
||||
|
||||
protected Q_SLOTS:
|
||||
void slotAdd() override;
|
||||
void slotEdit() override;
|
||||
};
|
||||
|
||||
#endif // WIDGETDRAWINGTOOLS_H
|
|
@ -1,5 +1,3 @@
|
|||
/* Defines if force the use DRM in okular */
|
||||
#define OKULAR_FORCE_DRM ${_OKULAR_FORCE_DRM}
|
||||
|
||||
/* Defines if LibKScreen is present */
|
||||
#define HAVE_LIBKSCREEN ${LibKScreen_FOUND}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "action.h"
|
||||
|
||||
// kde includes
|
||||
#include <klocale.h>
|
||||
#include <KLocalizedString>
|
||||
|
||||
// local includes
|
||||
#include "document.h"
|
||||
|
@ -46,7 +46,7 @@ Action::~Action()
|
|||
|
||||
QString Action::actionTip() const
|
||||
{
|
||||
return "";
|
||||
return QLatin1String("");
|
||||
}
|
||||
|
||||
void Action::setNativeId( const QVariant &id )
|
||||
|
@ -103,7 +103,7 @@ Action::ActionType GotoAction::actionType() const
|
|||
QString GotoAction::actionTip() const
|
||||
{
|
||||
Q_D( const GotoAction );
|
||||
return d->m_extFileName.isEmpty() ? ( d->m_vp.isValid() ? i18n( "Go to page %1", d->m_vp.pageNumber + 1 ) : "" ) :
|
||||
return d->m_extFileName.isEmpty() ? ( d->m_vp.isValid() ? i18n( "Go to page %1", d->m_vp.pageNumber + 1 ) : QLatin1String("") ) :
|
||||
i18n("Open external file");
|
||||
}
|
||||
|
||||
|
@ -182,15 +182,15 @@ QString ExecuteAction::parameters() const
|
|||
class Okular::BrowseActionPrivate : public Okular::ActionPrivate
|
||||
{
|
||||
public:
|
||||
BrowseActionPrivate( const QString &url )
|
||||
BrowseActionPrivate( const QUrl &url )
|
||||
: ActionPrivate(), m_url( url )
|
||||
{
|
||||
}
|
||||
|
||||
QString m_url;
|
||||
QUrl m_url;
|
||||
};
|
||||
|
||||
BrowseAction::BrowseAction( const QString &url )
|
||||
BrowseAction::BrowseAction(const QUrl &url )
|
||||
: Action( *new BrowseActionPrivate( url ) )
|
||||
{
|
||||
}
|
||||
|
@ -213,10 +213,10 @@ QString BrowseAction::actionTip() const
|
|||
{
|
||||
return sourceReferenceToolTip( source, row, col );
|
||||
}
|
||||
return d->m_url;
|
||||
return d->m_url.toDisplayString();
|
||||
}
|
||||
|
||||
QString BrowseAction::url() const
|
||||
QUrl BrowseAction::url() const
|
||||
{
|
||||
Q_D( const Okular::BrowseAction );
|
||||
return d->m_url;
|
||||
|
@ -300,7 +300,7 @@ class Okular::SoundActionPrivate : public Okular::ActionPrivate
|
|||
{
|
||||
}
|
||||
|
||||
~SoundActionPrivate()
|
||||
~SoundActionPrivate() override
|
||||
{
|
||||
delete m_sound;
|
||||
}
|
||||
|
@ -419,7 +419,7 @@ class Okular::MovieActionPrivate : public Okular::ActionPrivate
|
|||
{
|
||||
public:
|
||||
MovieActionPrivate( MovieAction::OperationType operation )
|
||||
: ActionPrivate(), m_operation( operation ), m_annotation( 0 )
|
||||
: ActionPrivate(), m_operation( operation ), m_annotation( nullptr )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -471,7 +471,7 @@ class Okular::RenditionActionPrivate : public Okular::ActionPrivate
|
|||
public:
|
||||
RenditionActionPrivate( RenditionAction::OperationType operation, Okular::Movie *movie, enum ScriptType scriptType, const QString &script )
|
||||
: ActionPrivate(), m_operation( operation ), m_movie( movie ), m_scriptType( scriptType ),
|
||||
m_script( script ), m_annotation( 0 )
|
||||
m_script( script ), m_annotation( nullptr )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -558,3 +558,13 @@ ScreenAnnotation* RenditionAction::annotation() const
|
|||
Q_D( const Okular::RenditionAction );
|
||||
return d->m_annotation;
|
||||
}
|
||||
|
||||
BackendOpaqueAction::BackendOpaqueAction()
|
||||
: Action( *new ActionPrivate() )
|
||||
{
|
||||
}
|
||||
|
||||
Action::ActionType BackendOpaqueAction::actionType() const
|
||||
{
|
||||
return BackendOpaque;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#define _OKULAR_ACTION_H_
|
||||
|
||||
#include "global.h"
|
||||
#include "okular_export.h"
|
||||
#include "okularcore_export.h"
|
||||
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QVariant>
|
||||
|
@ -40,7 +40,7 @@ class DocumentViewport;
|
|||
* widgets to reimplement the 'actionType' method and return the type of
|
||||
* the action described by the reimplemented class.
|
||||
*/
|
||||
class OKULAR_EXPORT Action
|
||||
class OKULARCORE_EXPORT Action
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -54,7 +54,8 @@ class OKULAR_EXPORT Action
|
|||
Sound, ///< Play a sound
|
||||
Movie, ///< Play a movie
|
||||
Script, ///< Executes a Script code
|
||||
Rendition ///< Play a movie and/or execute a Script code @since 0.16 (KDE 4.10)
|
||||
Rendition, ///< Play a movie and/or execute a Script code @since 0.16 (KDE 4.10)
|
||||
BackendOpaque ///< Calls back to the backend with the action @since 1.1
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -112,7 +113,7 @@ class OKULAR_EXPORT Action
|
|||
* The Goto action changes the viewport to another page
|
||||
* or loads an external document.
|
||||
*/
|
||||
class OKULAR_EXPORT GotoAction : public Action
|
||||
class OKULARCORE_EXPORT GotoAction : public Action
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -141,12 +142,12 @@ class OKULAR_EXPORT GotoAction : public Action
|
|||
/**
|
||||
* Returns the action type.
|
||||
*/
|
||||
ActionType actionType() const;
|
||||
ActionType actionType() const override;
|
||||
|
||||
/**
|
||||
* Returns the action tip.
|
||||
*/
|
||||
QString actionTip() const;
|
||||
QString actionTip() const override;
|
||||
|
||||
/**
|
||||
* Returns whether the goto action points to an external document.
|
||||
|
@ -178,7 +179,7 @@ class OKULAR_EXPORT GotoAction : public Action
|
|||
/**
|
||||
* The Execute action executes an external application.
|
||||
*/
|
||||
class OKULAR_EXPORT ExecuteAction : public Action
|
||||
class OKULARCORE_EXPORT ExecuteAction : public Action
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -197,12 +198,12 @@ class OKULAR_EXPORT ExecuteAction : public Action
|
|||
/**
|
||||
* Returns the action type.
|
||||
*/
|
||||
ActionType actionType() const;
|
||||
ActionType actionType() const override;
|
||||
|
||||
/**
|
||||
* Returns the action tip.
|
||||
*/
|
||||
QString actionTip() const;
|
||||
QString actionTip() const override;
|
||||
|
||||
/**
|
||||
* Returns the file name of the application to execute.
|
||||
|
@ -223,7 +224,7 @@ class OKULAR_EXPORT ExecuteAction : public Action
|
|||
* The Browse action browses an url by opening a web browser or
|
||||
* email client, depedning on the url protocol (e.g. http, mailto, etc.).
|
||||
*/
|
||||
class OKULAR_EXPORT BrowseAction : public Action
|
||||
class OKULARCORE_EXPORT BrowseAction : public Action
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -231,7 +232,7 @@ class OKULAR_EXPORT BrowseAction : public Action
|
|||
*
|
||||
* @param url The url to browse.
|
||||
*/
|
||||
BrowseAction( const QString &url );
|
||||
BrowseAction( const QUrl &url );
|
||||
|
||||
/**
|
||||
* Destroys the browse action.
|
||||
|
@ -241,17 +242,17 @@ class OKULAR_EXPORT BrowseAction : public Action
|
|||
/**
|
||||
* Returns the action type.
|
||||
*/
|
||||
ActionType actionType() const;
|
||||
ActionType actionType() const override;
|
||||
|
||||
/**
|
||||
* Returns the action tip.
|
||||
*/
|
||||
QString actionTip() const;
|
||||
QString actionTip() const override;
|
||||
|
||||
/**
|
||||
* Returns the url to browse.
|
||||
*/
|
||||
QString url() const;
|
||||
QUrl url() const;
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE( BrowseAction )
|
||||
|
@ -262,7 +263,7 @@ class OKULAR_EXPORT BrowseAction : public Action
|
|||
* The DocumentAction action contains an action that is performed on
|
||||
* the current document.
|
||||
*/
|
||||
class OKULAR_EXPORT DocumentAction : public Action
|
||||
class OKULARCORE_EXPORT DocumentAction : public Action
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -300,12 +301,12 @@ class OKULAR_EXPORT DocumentAction : public Action
|
|||
/**
|
||||
* Returns the action type.
|
||||
*/
|
||||
ActionType actionType() const;
|
||||
ActionType actionType() const override;
|
||||
|
||||
/**
|
||||
* Returns the action tip.
|
||||
*/
|
||||
QString actionTip() const;
|
||||
QString actionTip() const override;
|
||||
|
||||
/**
|
||||
* Returns the type of action.
|
||||
|
@ -320,7 +321,7 @@ class OKULAR_EXPORT DocumentAction : public Action
|
|||
/**
|
||||
* The Sound action plays a sound on activation.
|
||||
*/
|
||||
class OKULAR_EXPORT SoundAction : public Action
|
||||
class OKULARCORE_EXPORT SoundAction : public Action
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -342,12 +343,12 @@ class OKULAR_EXPORT SoundAction : public Action
|
|||
/**
|
||||
* Returns the action type.
|
||||
*/
|
||||
ActionType actionType() const;
|
||||
ActionType actionType() const override;
|
||||
|
||||
/**
|
||||
* Returns the action tip.
|
||||
*/
|
||||
QString actionTip() const;
|
||||
QString actionTip() const override;
|
||||
|
||||
/**
|
||||
* Returns the volume of the sound.
|
||||
|
@ -384,7 +385,7 @@ class OKULAR_EXPORT SoundAction : public Action
|
|||
*
|
||||
* @since 0.7 (KDE 4.1)
|
||||
*/
|
||||
class OKULAR_EXPORT ScriptAction : public Action
|
||||
class OKULARCORE_EXPORT ScriptAction : public Action
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -402,12 +403,12 @@ class OKULAR_EXPORT ScriptAction : public Action
|
|||
/**
|
||||
* Returns the action type.
|
||||
*/
|
||||
ActionType actionType() const;
|
||||
ActionType actionType() const override;
|
||||
|
||||
/**
|
||||
* Returns the action tip.
|
||||
*/
|
||||
QString actionTip() const;
|
||||
QString actionTip() const override;
|
||||
|
||||
/**
|
||||
* Returns the type of action.
|
||||
|
@ -429,7 +430,7 @@ class OKULAR_EXPORT ScriptAction : public Action
|
|||
*
|
||||
* @since 0.15 (KDE 4.9)
|
||||
*/
|
||||
class OKULAR_EXPORT MovieAction : public Action
|
||||
class OKULARCORE_EXPORT MovieAction : public Action
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -455,12 +456,12 @@ class OKULAR_EXPORT MovieAction : public Action
|
|||
/**
|
||||
* Returns the action type.
|
||||
*/
|
||||
ActionType actionType() const;
|
||||
ActionType actionType() const override;
|
||||
|
||||
/**
|
||||
* Returns the action tip.
|
||||
*/
|
||||
QString actionTip() const;
|
||||
QString actionTip() const override;
|
||||
|
||||
/**
|
||||
* Returns the operation type.
|
||||
|
@ -488,7 +489,7 @@ class OKULAR_EXPORT MovieAction : public Action
|
|||
*
|
||||
* @since 0.16 (KDE 4.10)
|
||||
*/
|
||||
class OKULAR_EXPORT RenditionAction : public Action
|
||||
class OKULARCORE_EXPORT RenditionAction : public Action
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -520,12 +521,12 @@ class OKULAR_EXPORT RenditionAction : public Action
|
|||
/**
|
||||
* Returns the action type.
|
||||
*/
|
||||
ActionType actionType() const;
|
||||
ActionType actionType() const override;
|
||||
|
||||
/**
|
||||
* Returns the action tip.
|
||||
*/
|
||||
QString actionTip() const;
|
||||
QString actionTip() const override;
|
||||
|
||||
/**
|
||||
* Returns the operation type.
|
||||
|
@ -562,6 +563,20 @@ class OKULAR_EXPORT RenditionAction : public Action
|
|||
Q_DISABLE_COPY( RenditionAction )
|
||||
};
|
||||
|
||||
class OKULARCORE_EXPORT BackendOpaqueAction : public Action
|
||||
{
|
||||
public:
|
||||
BackendOpaqueAction();
|
||||
|
||||
/**
|
||||
* Returns the action type.
|
||||
*/
|
||||
ActionType actionType() const override;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY( BackendOpaqueAction )
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -18,7 +18,7 @@
|
|||
#include <QtXml/QDomDocument>
|
||||
#include <QtXml/QDomElement>
|
||||
|
||||
#include "okular_export.h"
|
||||
#include "okularcore_export.h"
|
||||
#include "area.h"
|
||||
|
||||
namespace Okular {
|
||||
|
@ -45,11 +45,12 @@ class SoundAnnotationPrivate;
|
|||
class MovieAnnotationPrivate;
|
||||
class ScreenAnnotationPrivate;
|
||||
class WidgetAnnotationPrivate;
|
||||
class RichMediaAnnotationPrivate;
|
||||
|
||||
/**
|
||||
* @short Helper class for (recursive) annotation retrieval/storage.
|
||||
*/
|
||||
class OKULAR_EXPORT AnnotationUtils
|
||||
class OKULARCORE_EXPORT AnnotationUtils
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -87,7 +88,7 @@ class OKULAR_EXPORT AnnotationUtils
|
|||
* An Annotation is an object (text note, highlight, sound, popup window, ..)
|
||||
* contained by a Page in the document.
|
||||
*/
|
||||
class OKULAR_EXPORT Annotation
|
||||
class OKULARCORE_EXPORT Annotation
|
||||
{
|
||||
/// @cond PRIVATE
|
||||
friend class AnnotationObjectRect;
|
||||
|
@ -116,6 +117,7 @@ class OKULAR_EXPORT Annotation
|
|||
AMovie = 11, ///< A movie annotation
|
||||
AScreen = 12, ///< A screen annotation
|
||||
AWidget = 13, ///< A widget annotation
|
||||
ARichMedia = 14,///< A rich media annotation
|
||||
A_BASE = 0 ///< The annotation base class
|
||||
};
|
||||
|
||||
|
@ -133,7 +135,8 @@ class OKULAR_EXPORT Annotation
|
|||
ToggleHidingOnMouse = 64, ///< Can be hidden/shown by mouse click
|
||||
External = 128, ///< Is stored external
|
||||
ExternallyDrawn = 256, ///< Is drawn externally (by the generator which provided it) @since 0.10 (KDE 4.4)
|
||||
BeingMoved = 512 ///< Is being moved (mouse drag and drop). If ExternallyDrawn, the generator must not draw it @since 0.15 (KDE 4.9)
|
||||
BeingMoved = 512, ///< Is being moved (mouse drag and drop). If ExternallyDrawn, the generator must not draw it @since 0.15 (KDE 4.9)
|
||||
BeingResized = 1024 ///< Is being resized (mouse drag and drop). If ExternallyDrawn, the generator must not draw it @since 1.1.0
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -298,11 +301,20 @@ class OKULAR_EXPORT Annotation
|
|||
*/
|
||||
void translate( const NormalizedPoint &coord );
|
||||
|
||||
/**
|
||||
* Adjust the annotation by the specified coordinates.
|
||||
* Adds coordinates of @p deltaCoord1 to annotations top left corner,
|
||||
* and @p deltaCoord2 to the bottom right.
|
||||
*
|
||||
* @see canBeResized()
|
||||
*/
|
||||
void adjust( const NormalizedPoint & deltaCoord1, const NormalizedPoint & deltaCoord2 );
|
||||
|
||||
/**
|
||||
* The Style class contains all information about style of the
|
||||
* annotation.
|
||||
*/
|
||||
class OKULAR_EXPORT Style
|
||||
class OKULARCORE_EXPORT Style
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -437,7 +449,7 @@ class OKULAR_EXPORT Annotation
|
|||
* The Window class contains all information about the popup window
|
||||
* of the annotation that is used to edit the content and properties.
|
||||
*/
|
||||
class OKULAR_EXPORT Window
|
||||
class OKULARCORE_EXPORT Window
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -632,6 +644,11 @@ class OKULAR_EXPORT Annotation
|
|||
*/
|
||||
bool canBeMoved() const;
|
||||
|
||||
/**
|
||||
* Returns whether the annotation can be resized.
|
||||
*/
|
||||
bool canBeResized() const;
|
||||
|
||||
/**
|
||||
* Returns whether the annotation dialog should be open after creation of the annotation or not
|
||||
*
|
||||
|
@ -683,7 +700,7 @@ class OKULAR_EXPORT Annotation
|
|||
*
|
||||
* @since 0.15 (KDE 4.9)
|
||||
*/
|
||||
class OKULAR_EXPORT AnnotationProxy
|
||||
class OKULARCORE_EXPORT AnnotationProxy
|
||||
{
|
||||
public:
|
||||
enum Capability
|
||||
|
@ -728,7 +745,7 @@ class OKULAR_EXPORT AnnotationProxy
|
|||
virtual void notifyRemoval( Annotation *annotation, int page ) = 0;
|
||||
};
|
||||
|
||||
class OKULAR_EXPORT TextAnnotation : public Annotation
|
||||
class OKULARCORE_EXPORT TextAnnotation : public Annotation
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -841,19 +858,19 @@ class OKULAR_EXPORT TextAnnotation : public Annotation
|
|||
/**
|
||||
* Returns the sub type of the text annotation.
|
||||
*/
|
||||
SubType subType() const;
|
||||
SubType subType() const override;
|
||||
|
||||
/**
|
||||
* Stores the text annotation as xml in @p document under the given parent @p node.
|
||||
*/
|
||||
void store( QDomNode &node, QDomDocument &document ) const;
|
||||
void store( QDomNode &node, QDomDocument &document ) const override;
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE( TextAnnotation )
|
||||
Q_DISABLE_COPY( TextAnnotation )
|
||||
};
|
||||
|
||||
class OKULAR_EXPORT LineAnnotation : public Annotation
|
||||
class OKULARCORE_EXPORT LineAnnotation : public Annotation
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -1001,19 +1018,19 @@ class OKULAR_EXPORT LineAnnotation : public Annotation
|
|||
/**
|
||||
* Returns the sub type of the line annotation.
|
||||
*/
|
||||
SubType subType() const;
|
||||
SubType subType() const override;
|
||||
|
||||
/**
|
||||
* Stores the line annotation as xml in @p document under the given parent @p node.
|
||||
*/
|
||||
void store( QDomNode &node, QDomDocument &document ) const;
|
||||
void store( QDomNode &node, QDomDocument &document ) const override;
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE( LineAnnotation )
|
||||
Q_DISABLE_COPY( LineAnnotation )
|
||||
};
|
||||
|
||||
class OKULAR_EXPORT GeomAnnotation : public Annotation
|
||||
class OKULARCORE_EXPORT GeomAnnotation : public Annotation
|
||||
{
|
||||
public:
|
||||
// common enums
|
||||
|
@ -1062,20 +1079,20 @@ class OKULAR_EXPORT GeomAnnotation : public Annotation
|
|||
/**
|
||||
* Returns the sub type of the geometrical annotation.
|
||||
*/
|
||||
SubType subType() const;
|
||||
SubType subType() const override;
|
||||
|
||||
/**
|
||||
* Stores the geometrical annotation as xml in @p document
|
||||
* under the given parent @p node.
|
||||
*/
|
||||
void store( QDomNode &node, QDomDocument &document ) const;
|
||||
void store( QDomNode &node, QDomDocument &document ) const override;
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE( GeomAnnotation )
|
||||
Q_DISABLE_COPY( GeomAnnotation )
|
||||
};
|
||||
|
||||
class OKULAR_EXPORT HighlightAnnotation : public Annotation
|
||||
class OKULARCORE_EXPORT HighlightAnnotation : public Annotation
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -1119,7 +1136,7 @@ class OKULAR_EXPORT HighlightAnnotation : public Annotation
|
|||
* The Quad class contains 8 coordinates and style definitions
|
||||
* which describe a line part of the whole highlight annotation.
|
||||
*/
|
||||
class OKULAR_EXPORT Quad
|
||||
class OKULARCORE_EXPORT Quad
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -1205,20 +1222,20 @@ class OKULAR_EXPORT HighlightAnnotation : public Annotation
|
|||
/**
|
||||
* Returns the sub type of the highlight annotation.
|
||||
*/
|
||||
SubType subType() const;
|
||||
SubType subType() const override;
|
||||
|
||||
/**
|
||||
* Stores the highlight annotation as xml in @p document
|
||||
* under the given parent @p node.
|
||||
*/
|
||||
void store( QDomNode &node, QDomDocument &document ) const;
|
||||
void store( QDomNode &node, QDomDocument &document ) const override;
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE( HighlightAnnotation )
|
||||
Q_DISABLE_COPY( HighlightAnnotation )
|
||||
};
|
||||
|
||||
class OKULAR_EXPORT StampAnnotation : public Annotation
|
||||
class OKULARCORE_EXPORT StampAnnotation : public Annotation
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -1249,20 +1266,20 @@ class OKULAR_EXPORT StampAnnotation : public Annotation
|
|||
/**
|
||||
* Returns the sub type of the stamp annotation.
|
||||
*/
|
||||
SubType subType() const;
|
||||
SubType subType() const override;
|
||||
|
||||
/**
|
||||
* Stores the stamp annotation as xml in @p document
|
||||
* under the given parent @p node.
|
||||
*/
|
||||
void store( QDomNode &node, QDomDocument &document ) const;
|
||||
void store( QDomNode &node, QDomDocument &document ) const override;
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE( StampAnnotation )
|
||||
Q_DISABLE_COPY( StampAnnotation )
|
||||
};
|
||||
|
||||
class OKULAR_EXPORT InkAnnotation : public Annotation
|
||||
class OKULARCORE_EXPORT InkAnnotation : public Annotation
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -1299,20 +1316,20 @@ class OKULAR_EXPORT InkAnnotation : public Annotation
|
|||
/**
|
||||
* Returns the sub type of the ink annotation.
|
||||
*/
|
||||
SubType subType() const;
|
||||
SubType subType() const override;
|
||||
|
||||
/**
|
||||
* Stores the ink annotation as xml in @p document
|
||||
* under the given parent @p node.
|
||||
*/
|
||||
void store( QDomNode &node, QDomDocument &document ) const;
|
||||
void store( QDomNode &node, QDomDocument &document ) const override;
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE( InkAnnotation )
|
||||
Q_DISABLE_COPY( InkAnnotation )
|
||||
};
|
||||
|
||||
class OKULAR_EXPORT CaretAnnotation : public Annotation
|
||||
class OKULARCORE_EXPORT CaretAnnotation : public Annotation
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -1352,20 +1369,20 @@ class OKULAR_EXPORT CaretAnnotation : public Annotation
|
|||
/**
|
||||
* Returns the sub type of the caret annotation.
|
||||
*/
|
||||
SubType subType() const;
|
||||
SubType subType() const override;
|
||||
|
||||
/**
|
||||
* Stores the caret annotation as xml in @p document
|
||||
* under the given parent @p node.
|
||||
*/
|
||||
void store( QDomNode &node, QDomDocument &document ) const;
|
||||
void store( QDomNode &node, QDomDocument &document ) const override;
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE( CaretAnnotation )
|
||||
Q_DISABLE_COPY( CaretAnnotation )
|
||||
};
|
||||
|
||||
class OKULAR_EXPORT FileAttachmentAnnotation : public Annotation
|
||||
class OKULARCORE_EXPORT FileAttachmentAnnotation : public Annotation
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -1405,13 +1422,13 @@ class OKULAR_EXPORT FileAttachmentAnnotation : public Annotation
|
|||
/**
|
||||
* Returns the sub type of the file attachment annotation.
|
||||
*/
|
||||
SubType subType() const;
|
||||
SubType subType() const override;
|
||||
|
||||
/**
|
||||
* Stores the file attachment annotation as xml in @p document
|
||||
* under the given parent @p node.
|
||||
*/
|
||||
void store( QDomNode &node, QDomDocument &document ) const;
|
||||
void store( QDomNode &node, QDomDocument &document ) const override;
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE( FileAttachmentAnnotation )
|
||||
|
@ -1425,7 +1442,7 @@ class OKULAR_EXPORT FileAttachmentAnnotation : public Annotation
|
|||
*
|
||||
* @since 0.7 (KDE 4.1)
|
||||
*/
|
||||
class OKULAR_EXPORT SoundAnnotation : public Annotation
|
||||
class OKULARCORE_EXPORT SoundAnnotation : public Annotation
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -1465,13 +1482,13 @@ class OKULAR_EXPORT SoundAnnotation : public Annotation
|
|||
/**
|
||||
* Returns the sub type of the sound annotation.
|
||||
*/
|
||||
SubType subType() const;
|
||||
SubType subType() const override;
|
||||
|
||||
/**
|
||||
* Stores the sound annotation as xml in @p document
|
||||
* under the given parent @p node.
|
||||
*/
|
||||
void store( QDomNode &node, QDomDocument &document ) const;
|
||||
void store( QDomNode &node, QDomDocument &document ) const override;
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE( SoundAnnotation )
|
||||
|
@ -1485,7 +1502,7 @@ class OKULAR_EXPORT SoundAnnotation : public Annotation
|
|||
*
|
||||
* @since 0.8 (KDE 4.2)
|
||||
*/
|
||||
class OKULAR_EXPORT MovieAnnotation : public Annotation
|
||||
class OKULARCORE_EXPORT MovieAnnotation : public Annotation
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -1511,12 +1528,12 @@ class OKULAR_EXPORT MovieAnnotation : public Annotation
|
|||
/**
|
||||
* Returns the sub type of the movie annotation.
|
||||
*/
|
||||
SubType subType() const;
|
||||
SubType subType() const override;
|
||||
/**
|
||||
* Stores the movie annotation as xml in @p document
|
||||
* under the given @p parentNode.
|
||||
*/
|
||||
void store( QDomNode &parentNode, QDomDocument &document ) const;
|
||||
void store( QDomNode &parentNode, QDomDocument &document ) const override;
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE( MovieAnnotation )
|
||||
|
@ -1531,7 +1548,7 @@ class OKULAR_EXPORT MovieAnnotation : public Annotation
|
|||
*
|
||||
* @since 0.16 (KDE 4.10)
|
||||
*/
|
||||
class OKULAR_EXPORT ScreenAnnotation : public Annotation
|
||||
class OKULARCORE_EXPORT ScreenAnnotation : public Annotation
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -1552,13 +1569,13 @@ class OKULAR_EXPORT ScreenAnnotation : public Annotation
|
|||
/**
|
||||
* Returns the sub type of the screen annotation.
|
||||
*/
|
||||
SubType subType() const;
|
||||
SubType subType() const override;
|
||||
|
||||
/**
|
||||
* Stores the screen annotation as xml in @p document
|
||||
* under the given @p parentNode.
|
||||
*/
|
||||
void store( QDomNode &parentNode, QDomDocument &document ) const;
|
||||
void store( QDomNode &parentNode, QDomDocument &document ) const override;
|
||||
|
||||
/**
|
||||
* Sets the @p action that is executed when the annotation is triggered.
|
||||
|
@ -1600,7 +1617,7 @@ class OKULAR_EXPORT ScreenAnnotation : public Annotation
|
|||
*
|
||||
* @since 0.16 (KDE 4.10)
|
||||
*/
|
||||
class OKULAR_EXPORT WidgetAnnotation : public Annotation
|
||||
class OKULARCORE_EXPORT WidgetAnnotation : public Annotation
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -1621,13 +1638,13 @@ class OKULAR_EXPORT WidgetAnnotation : public Annotation
|
|||
/**
|
||||
* Returns the sub type of the widget annotation.
|
||||
*/
|
||||
SubType subType() const;
|
||||
SubType subType() const override;
|
||||
|
||||
/**
|
||||
* Stores the widget annotation as xml in @p document
|
||||
* under the given @p parentNode.
|
||||
*/
|
||||
void store( QDomNode &parentNode, QDomDocument &document ) const;
|
||||
void store( QDomNode &parentNode, QDomDocument &document ) const override;
|
||||
|
||||
/**
|
||||
* Sets the additional @p action of the given @p type.
|
||||
|
@ -1648,6 +1665,67 @@ class OKULAR_EXPORT WidgetAnnotation : public Annotation
|
|||
Q_DISABLE_COPY( WidgetAnnotation )
|
||||
};
|
||||
|
||||
/**
|
||||
* \short RichMedia annotation.
|
||||
*
|
||||
* The rich media annotation represents an video or sound on a page.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class OKULARCORE_EXPORT RichMediaAnnotation : public Annotation
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Creates a new rich media annotation.
|
||||
*/
|
||||
RichMediaAnnotation();
|
||||
|
||||
/**
|
||||
* Creates a new rich media annotation from the xml @p description
|
||||
*/
|
||||
RichMediaAnnotation( const QDomNode &description );
|
||||
|
||||
/**
|
||||
* Destroys the rich media annotation.
|
||||
*/
|
||||
virtual ~RichMediaAnnotation();
|
||||
|
||||
/**
|
||||
* Returns the sub type of the rich media annotation.
|
||||
*/
|
||||
SubType subType() const override;
|
||||
|
||||
/**
|
||||
* Stores the rich media annotation as xml in @p document
|
||||
* under the given @p parentNode.
|
||||
*/
|
||||
void store( QDomNode &parentNode, QDomDocument &document ) const override;
|
||||
|
||||
/**
|
||||
* Gets the movie object.
|
||||
*/
|
||||
Movie* movie() const;
|
||||
|
||||
/**
|
||||
* Sets the new @p movie object.
|
||||
*/
|
||||
void setMovie( Movie *movie );
|
||||
|
||||
/**
|
||||
* Sets the @p object representing the embedded file.
|
||||
*/
|
||||
void setEmbeddedFile( EmbeddedFile *object );
|
||||
|
||||
/**
|
||||
* Gets the embedded file object.
|
||||
*/
|
||||
EmbeddedFile* embeddedFile() const;
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE( RichMediaAnnotation )
|
||||
Q_DISABLE_COPY( RichMediaAnnotation )
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -42,8 +42,10 @@ class AnnotationPrivate
|
|||
virtual void baseTransform( const QTransform &matrix );
|
||||
virtual void resetTransformation();
|
||||
virtual void translate( const NormalizedPoint &coord );
|
||||
virtual void adjust( const NormalizedPoint & deltaCoord1, const NormalizedPoint & deltaCoord2 );
|
||||
virtual bool openDialogAfterCreation() const;
|
||||
virtual void setAnnotationProperties( const QDomNode& node );
|
||||
virtual bool canBeResized() const;
|
||||
virtual AnnotationPrivate* getNewAnnotationPrivate() = 0;
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#include <QtCore/QRect>
|
||||
#include <QtGui/QPolygonF>
|
||||
#include <kdebug.h>
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
#include <math.h>
|
||||
|
||||
|
@ -267,6 +267,11 @@ void NormalizedRect::transform( const QTransform &matrix )
|
|||
bottom = rect.bottom();
|
||||
}
|
||||
|
||||
uint qHash( const NormalizedRect& r, uint seed )
|
||||
{
|
||||
return qHash(r.bottom, qHash(r.right, qHash(r.top, qHash(r.left, seed))));
|
||||
}
|
||||
|
||||
QDebug operator<<( QDebug str, const Okular::NormalizedRect& r )
|
||||
{
|
||||
str.nospace() << "NormRect(" << r.left << "," << r.top << " x " << ( r.right - r.left ) << "+" << ( r.bottom - r.top ) << ")";
|
||||
|
@ -274,12 +279,12 @@ QDebug operator<<( QDebug str, const Okular::NormalizedRect& r )
|
|||
}
|
||||
|
||||
RegularAreaRect::RegularAreaRect()
|
||||
: RegularArea< NormalizedRect, QRect >(), d( 0 )
|
||||
: RegularArea< NormalizedRect, QRect >(), d( nullptr )
|
||||
{
|
||||
}
|
||||
|
||||
RegularAreaRect::RegularAreaRect( const RegularAreaRect& rar )
|
||||
: RegularArea< NormalizedRect, QRect >( rar ), d( 0 )
|
||||
: RegularArea< NormalizedRect, QRect >( rar ), d( nullptr )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -421,7 +426,7 @@ ObjectRect::~ObjectRect()
|
|||
else if ( m_objectType == SourceRef )
|
||||
delete static_cast<Okular::SourceReference*>( m_object );
|
||||
else
|
||||
kDebug(OkularDebug).nospace() << "Object deletion not implemented for type '" << m_objectType << "'.";
|
||||
qCDebug(OkularCoreDebug).nospace() << "Object deletion not implemented for type '" << m_objectType << "'.";
|
||||
}
|
||||
|
||||
/** class AnnotationObjectRect **/
|
||||
|
@ -458,7 +463,7 @@ AnnotationObjectRect::~AnnotationObjectRect()
|
|||
{
|
||||
// the annotation pointer is kept elsewehere (in Page, most probably),
|
||||
// so just release its pointer
|
||||
m_object = 0;
|
||||
m_object = nullptr;
|
||||
}
|
||||
|
||||
void AnnotationObjectRect::transform( const QTransform &matrix )
|
||||
|
|
67
core/area.h
67
core/area.h
|
@ -10,15 +10,16 @@
|
|||
#ifndef _OKULAR_AREA_H_
|
||||
#define _OKULAR_AREA_H_
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <QtCore/QList>
|
||||
#include <QtGui/QColor>
|
||||
#include <QtGui/QPainterPath>
|
||||
#include <QtGui/QTransform>
|
||||
#include <kdebug.h>
|
||||
#include <math.h>
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
#include "global.h"
|
||||
#include "okular_export.h"
|
||||
#include "okularcore_export.h"
|
||||
|
||||
class QPolygonF;
|
||||
class QRect;
|
||||
|
@ -44,7 +45,7 @@ class NormalizedShape;
|
|||
* That allows you to zoom the page by just multiplying the normalized points with the
|
||||
* zoomed page size.
|
||||
*/
|
||||
class OKULAR_EXPORT NormalizedPoint
|
||||
class OKULARCORE_EXPORT NormalizedPoint
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -102,7 +103,7 @@ class OKULAR_EXPORT NormalizedPoint
|
|||
* NormalizedRect is a helper class which stores the coordinates
|
||||
* of a normalized rect, which is a rectangle of @see NormalizedPoints.
|
||||
*/
|
||||
class OKULAR_EXPORT NormalizedRect
|
||||
class OKULARCORE_EXPORT NormalizedRect
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -319,7 +320,7 @@ class OKULAR_EXPORT NormalizedRect
|
|||
*/
|
||||
double bottom;
|
||||
};
|
||||
KDE_DUMMY_QHASH_FUNCTION(NormalizedRect)
|
||||
//KDE_DUMMY_QHASH_FUNCTION(NormalizedRect)
|
||||
|
||||
/**
|
||||
* @short NormalizedRect that contains a reference to an object.
|
||||
|
@ -334,7 +335,7 @@ KDE_DUMMY_QHASH_FUNCTION(NormalizedRect)
|
|||
* - Image : class Image : description of an image (n/a)
|
||||
* - Annotation: class Annotation: description of an annotation
|
||||
*/
|
||||
class OKULAR_EXPORT ObjectRect
|
||||
class OKULARCORE_EXPORT ObjectRect
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -428,7 +429,7 @@ class OKULAR_EXPORT ObjectRect
|
|||
/**
|
||||
* This class describes the object rectangle for an annotation.
|
||||
*/
|
||||
class OKULAR_EXPORT AnnotationObjectRect : public ObjectRect
|
||||
class OKULARCORE_EXPORT AnnotationObjectRect : public ObjectRect
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -451,18 +452,18 @@ class OKULAR_EXPORT AnnotationObjectRect : public ObjectRect
|
|||
* Returns the bounding rect of the annotation object rectangle for the
|
||||
* scaling factor @p xScale and @p yScale.
|
||||
*/
|
||||
virtual QRect boundingRect( double xScale, double yScale ) const;
|
||||
QRect boundingRect( double xScale, double yScale ) const override;
|
||||
|
||||
/**
|
||||
* Returns whether the annotation object rectangle contains the point @p x, @p y for the
|
||||
* scaling factor @p xScale and @p yScale.
|
||||
*/
|
||||
virtual bool contains( double x, double y, double xScale, double yScale ) const;
|
||||
bool contains( double x, double y, double xScale, double yScale ) const override;
|
||||
|
||||
/**
|
||||
* Transforms the annotation object rectangle with the operations defined by @p matrix.
|
||||
*/
|
||||
virtual void transform( const QTransform &matrix );
|
||||
void transform( const QTransform &matrix ) override;
|
||||
|
||||
private:
|
||||
Annotation * m_annotation;
|
||||
|
@ -471,7 +472,7 @@ class OKULAR_EXPORT AnnotationObjectRect : public ObjectRect
|
|||
/**
|
||||
* This class describes the object rectangle for a source reference.
|
||||
*/
|
||||
class OKULAR_EXPORT SourceRefObjectRect : public ObjectRect
|
||||
class OKULARCORE_EXPORT SourceRefObjectRect : public ObjectRect
|
||||
{
|
||||
friend class ObjectRect;
|
||||
|
||||
|
@ -488,13 +489,13 @@ class OKULAR_EXPORT SourceRefObjectRect : public ObjectRect
|
|||
* Returns the bounding rect of the source reference object rectangle for the
|
||||
* scaling factor @p xScale and @p yScale.
|
||||
*/
|
||||
virtual QRect boundingRect( double xScale, double yScale ) const;
|
||||
QRect boundingRect( double xScale, double yScale ) const override;
|
||||
|
||||
/**
|
||||
* Returns whether the source reference object rectangle contains the point @p x, @p y for the
|
||||
* scaling factor @p xScale and @p yScale.
|
||||
*/
|
||||
virtual bool contains( double x, double y, double xScale, double yScale ) const;
|
||||
bool contains( double x, double y, double xScale, double yScale ) const override;
|
||||
|
||||
private:
|
||||
NormalizedPoint m_point;
|
||||
|
@ -648,16 +649,13 @@ void RegularArea<NormalizedShape, Shape>::simplify()
|
|||
}
|
||||
}
|
||||
#ifdef DEBUG_REGULARAREA
|
||||
kDebug() << "from" << prev_end << "to" << this->count();
|
||||
qCDebug(OkularCoreDebug) << "from" << prev_end << "to" << this->count();
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class NormalizedShape, class Shape>
|
||||
bool RegularArea<NormalizedShape, Shape>::isNull() const
|
||||
{
|
||||
if ( !this )
|
||||
return false;
|
||||
|
||||
if ( this->isEmpty() )
|
||||
return false;
|
||||
|
||||
|
@ -672,9 +670,6 @@ bool RegularArea<NormalizedShape, Shape>::isNull() const
|
|||
template <class NormalizedShape, class Shape>
|
||||
bool RegularArea<NormalizedShape, Shape>::intersects( const NormalizedShape& rect ) const
|
||||
{
|
||||
if ( !this )
|
||||
return false;
|
||||
|
||||
if ( this->isEmpty() )
|
||||
return false;
|
||||
|
||||
|
@ -689,9 +684,6 @@ bool RegularArea<NormalizedShape, Shape>::intersects( const NormalizedShape& rec
|
|||
template <class NormalizedShape, class Shape>
|
||||
bool RegularArea<NormalizedShape, Shape>::intersects( const RegularArea<NormalizedShape,Shape> *area ) const
|
||||
{
|
||||
if ( !this )
|
||||
return false;
|
||||
|
||||
if ( this->isEmpty() )
|
||||
return false;
|
||||
|
||||
|
@ -712,9 +704,6 @@ bool RegularArea<NormalizedShape, Shape>::intersects( const RegularArea<Normaliz
|
|||
template <class NormalizedShape, class Shape>
|
||||
void RegularArea<NormalizedShape, Shape>::appendArea( const RegularArea<NormalizedShape, Shape> *area )
|
||||
{
|
||||
if ( !this )
|
||||
return;
|
||||
|
||||
typename QList<NormalizedShape>::const_iterator areaIt = area->begin(), areaItEnd = area->end();
|
||||
for ( ; areaIt != areaItEnd; ++areaIt )
|
||||
this->append( *areaIt );
|
||||
|
@ -724,9 +713,6 @@ void RegularArea<NormalizedShape, Shape>::appendArea( const RegularArea<Normaliz
|
|||
template <class NormalizedShape, class Shape>
|
||||
void RegularArea<NormalizedShape, Shape>::appendShape( const NormalizedShape& shape, MergeSide side )
|
||||
{
|
||||
if ( !this )
|
||||
return;
|
||||
|
||||
int size = this->count();
|
||||
// if the list is empty, adds the shape normally
|
||||
if ( size == 0 )
|
||||
|
@ -799,9 +785,6 @@ void RegularArea<NormalizedShape, Shape>::appendShape( const NormalizedShape& sh
|
|||
template <class NormalizedShape, class Shape>
|
||||
bool RegularArea<NormalizedShape, Shape>::contains( double x, double y ) const
|
||||
{
|
||||
if ( !this )
|
||||
return false;
|
||||
|
||||
if ( this->isEmpty() )
|
||||
return false;
|
||||
|
||||
|
@ -816,9 +799,6 @@ bool RegularArea<NormalizedShape, Shape>::contains( double x, double y ) const
|
|||
template <class NormalizedShape, class Shape>
|
||||
bool RegularArea<NormalizedShape, Shape>::contains( const NormalizedShape& shape ) const
|
||||
{
|
||||
if ( !this )
|
||||
return false;
|
||||
|
||||
if ( this->isEmpty() )
|
||||
return false;
|
||||
|
||||
|
@ -828,7 +808,7 @@ bool RegularArea<NormalizedShape, Shape>::contains( const NormalizedShape& shape
|
|||
template <class NormalizedShape, class Shape>
|
||||
QList<Shape> RegularArea<NormalizedShape, Shape>::geometry( int xScale, int yScale, int dx, int dy ) const
|
||||
{
|
||||
if ( !this || this->isEmpty() )
|
||||
if ( this->isEmpty() )
|
||||
return QList<Shape>();
|
||||
|
||||
QList<Shape> ret;
|
||||
|
@ -847,9 +827,6 @@ QList<Shape> RegularArea<NormalizedShape, Shape>::geometry( int xScale, int ySca
|
|||
template <class NormalizedShape, class Shape>
|
||||
void RegularArea<NormalizedShape, Shape>::transform( const QTransform &matrix )
|
||||
{
|
||||
if ( !this )
|
||||
return;
|
||||
|
||||
if ( this->isEmpty() )
|
||||
return;
|
||||
|
||||
|
@ -857,7 +834,7 @@ void RegularArea<NormalizedShape, Shape>::transform( const QTransform &matrix )
|
|||
givePtr( (*this)[i] )->transform( matrix );
|
||||
}
|
||||
|
||||
class OKULAR_EXPORT RegularAreaRect : public RegularArea< NormalizedRect, QRect >
|
||||
class OKULARCORE_EXPORT RegularAreaRect : public RegularArea< NormalizedRect, QRect >
|
||||
{
|
||||
public:
|
||||
RegularAreaRect();
|
||||
|
@ -882,7 +859,7 @@ class HighlightAreaRect : public RegularAreaRect
|
|||
* Creates a new highlight area rect with the coordinates of
|
||||
* the given @p area.
|
||||
*/
|
||||
HighlightAreaRect( const RegularAreaRect *area = 0 );
|
||||
HighlightAreaRect( const RegularAreaRect *area = nullptr );
|
||||
|
||||
/**
|
||||
* The search ID of the highlight owner.
|
||||
|
@ -897,16 +874,18 @@ class HighlightAreaRect : public RegularAreaRect
|
|||
|
||||
}
|
||||
|
||||
uint qHash(const Okular::NormalizedRect& r, uint seed = 0);
|
||||
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
/**
|
||||
* Debug operator for normalized @p point.
|
||||
*/
|
||||
OKULAR_EXPORT QDebug operator<<( QDebug str, const Okular::NormalizedPoint &point );
|
||||
OKULARCORE_EXPORT QDebug operator<<( QDebug str, const Okular::NormalizedPoint &point );
|
||||
|
||||
/**
|
||||
* Debug operator for normalized @p rect.
|
||||
*/
|
||||
OKULAR_EXPORT QDebug operator<<( QDebug str, const Okular::NormalizedRect &rect );
|
||||
OKULARCORE_EXPORT QDebug operator<<( QDebug str, const Okular::NormalizedRect &rect );
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
// qt/kde includes
|
||||
#include <qbuffer.h>
|
||||
#include <qdir.h>
|
||||
#include <kdebug.h>
|
||||
#include <QtCore/QDebug>
|
||||
#include <krandom.h>
|
||||
#include <Phonon/Path>
|
||||
#include <phonon/path.h>
|
||||
#include <phonon/audiooutput.h>
|
||||
#include <phonon/abstractmediastream.h>
|
||||
#include <phonon/mediaobject.h>
|
||||
|
@ -31,7 +31,7 @@ using namespace Okular;
|
|||
class SoundInfo
|
||||
{
|
||||
public:
|
||||
explicit SoundInfo( const Sound * s = 0, const SoundAction * ls = 0 )
|
||||
explicit SoundInfo( const Sound * s = nullptr, const SoundAction * ls = nullptr )
|
||||
: sound( s ), volume( 0.5 ), synchronous( false ), repeat( false ),
|
||||
mix( false )
|
||||
{
|
||||
|
@ -56,7 +56,7 @@ class PlayData
|
|||
{
|
||||
public:
|
||||
PlayData()
|
||||
: m_mediaobject( 0 ), m_output( 0 ), m_buffer( 0 )
|
||||
: m_mediaobject( nullptr ), m_output( nullptr ), m_buffer( nullptr )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ int AudioPlayerPrivate::newId() const
|
|||
|
||||
bool AudioPlayerPrivate::play( const SoundInfo& si )
|
||||
{
|
||||
kDebug() ;
|
||||
qCDebug(OkularCoreDebug) ;
|
||||
PlayData * data = new PlayData();
|
||||
data->m_output = new Phonon::AudioOutput( Phonon::NotificationCategory );
|
||||
data->m_output->setVolume( si.volume );
|
||||
|
@ -124,20 +124,20 @@ bool AudioPlayerPrivate::play( const SoundInfo& si )
|
|||
case Sound::External:
|
||||
{
|
||||
QString url = si.sound->url();
|
||||
kDebug(OkularDebug) << "External," << url;
|
||||
qCDebug(OkularCoreDebug) << "External," << url;
|
||||
if ( !url.isEmpty() )
|
||||
{
|
||||
int newid = newId();
|
||||
m_mapper.setMapping( data->m_mediaobject, newid );
|
||||
KUrl newurl;
|
||||
if ( KUrl::isRelativeUrl( url ) )
|
||||
QUrl newurl;
|
||||
if ( QUrl::fromUserInput(url).isRelative() )
|
||||
{
|
||||
newurl = m_currentDocument;
|
||||
newurl.setFileName( url );
|
||||
newurl = m_currentDocument.adjusted(QUrl::RemoveFilename);
|
||||
newurl.setPath(newurl.path() + url );
|
||||
}
|
||||
else
|
||||
{
|
||||
newurl = url;
|
||||
newurl = QUrl::fromLocalFile(url);
|
||||
}
|
||||
data->m_mediaobject->setCurrentSource( newurl );
|
||||
m_playing.insert( newid, data );
|
||||
|
@ -148,10 +148,10 @@ bool AudioPlayerPrivate::play( const SoundInfo& si )
|
|||
case Sound::Embedded:
|
||||
{
|
||||
QByteArray filedata = si.sound->data();
|
||||
kDebug(OkularDebug) << "Embedded," << filedata.length();
|
||||
qCDebug(OkularCoreDebug) << "Embedded," << filedata.length();
|
||||
if ( !filedata.isEmpty() )
|
||||
{
|
||||
kDebug(OkularDebug) << "Mediaobject:" << data->m_mediaobject;
|
||||
qCDebug(OkularCoreDebug) << "Mediaobject:" << data->m_mediaobject;
|
||||
int newid = newId();
|
||||
m_mapper.setMapping( data->m_mediaobject, newid );
|
||||
data->m_buffer = new QBuffer();
|
||||
|
@ -166,12 +166,12 @@ bool AudioPlayerPrivate::play( const SoundInfo& si )
|
|||
if ( !valid )
|
||||
{
|
||||
delete data;
|
||||
data = 0;
|
||||
data = nullptr;
|
||||
}
|
||||
if ( data )
|
||||
{
|
||||
QObject::connect( data->m_mediaobject, SIGNAL(finished()), &m_mapper, SLOT(map()) );
|
||||
kDebug(OkularDebug) << "PLAY";
|
||||
qCDebug(OkularCoreDebug) << "PLAY";
|
||||
data->play();
|
||||
m_state = AudioPlayer::PlayingState;
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ void AudioPlayerPrivate::finished( int id )
|
|||
m_playing.erase( it );
|
||||
m_state = AudioPlayer::StoppedState;
|
||||
}
|
||||
kDebug(OkularDebug) << "finished," << m_playing.count();
|
||||
qCDebug(OkularCoreDebug) << "finished," << m_playing.count();
|
||||
}
|
||||
|
||||
|
||||
|
@ -235,7 +235,7 @@ void AudioPlayer::playSound( const Sound * sound, const SoundAction * linksound
|
|||
if ( sound->soundType() == Sound::External && !d->m_currentDocument.isLocalFile() )
|
||||
return;
|
||||
|
||||
kDebug() ;
|
||||
qCDebug(OkularCoreDebug) ;
|
||||
SoundInfo si( sound, linksound );
|
||||
|
||||
// if the mix flag of the new sound is false, then the currently playing
|
||||
|
@ -256,4 +256,4 @@ AudioPlayer::State AudioPlayer::state() const
|
|||
return d->m_state;
|
||||
}
|
||||
|
||||
#include "audioplayer.moc"
|
||||
#include "moc_audioplayer.cpp"
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#ifndef _OKULAR_AUDIOPLAYER_H_
|
||||
#define _OKULAR_AUDIOPLAYER_H_
|
||||
|
||||
#include "okular_export.h"
|
||||
#include "okularcore_export.h"
|
||||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
|
@ -27,7 +27,7 @@ class SoundAction;
|
|||
* Singleton utility class to play sounds in documents using the KDE sound
|
||||
* system.
|
||||
*/
|
||||
class OKULAR_EXPORT AudioPlayer : public QObject
|
||||
class OKULARCORE_EXPORT AudioPlayer : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -60,7 +60,7 @@ class OKULAR_EXPORT AudioPlayer : public QObject
|
|||
* Enqueue the specified @p sound for playing, optionally taking more
|
||||
* information about the playing from the @p soundlink .
|
||||
*/
|
||||
void playSound( const Sound * sound, const SoundAction * linksound = 0 );
|
||||
void playSound( const Sound * sound, const SoundAction * linksound = nullptr );
|
||||
|
||||
/**
|
||||
* Tell the AudioPlayer to stop all the playbacks.
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// qt/kde includes
|
||||
#include <qhash.h>
|
||||
#include <qsignalmapper.h>
|
||||
#include <kurl.h>
|
||||
#include <QUrl>
|
||||
|
||||
class QBuffer;
|
||||
class PlayData;
|
||||
|
@ -41,7 +41,7 @@ public:
|
|||
|
||||
QHash< int, PlayData * > m_playing;
|
||||
QSignalMapper m_mapper;
|
||||
KUrl m_currentDocument;
|
||||
QUrl m_currentDocument;
|
||||
AudioPlayer::State m_state;
|
||||
};
|
||||
|
||||
|
|
|
@ -12,11 +12,13 @@
|
|||
// qt/kde includes
|
||||
#include <qhash.h>
|
||||
#include <qset.h>
|
||||
#include <kbookmarkaction.h>
|
||||
#include <kbookmarkmanager.h>
|
||||
#include <kbookmarkmenu.h>
|
||||
#include <kdebug.h>
|
||||
#include <kglobal.h>
|
||||
#include <kstandarddirs.h>
|
||||
#include <QDebug>
|
||||
#include <QGuiApplication>
|
||||
#include <QUrl>
|
||||
#include <QStandardPaths>
|
||||
|
||||
// local includes
|
||||
#include "document_p.h"
|
||||
|
@ -39,9 +41,9 @@ class OkularBookmarkAction : public KBookmarkAction
|
|||
: KBookmarkAction( bk, owner, parent )
|
||||
{
|
||||
if ( vp.isValid() )
|
||||
setText( QString::number( vp.pageNumber + 1 ) + " - " + text() );
|
||||
setText( QString::number( vp.pageNumber + 1 ) + QStringLiteral(" - ") + text() );
|
||||
setProperty("pageNumber", vp.pageNumber + 1);
|
||||
setProperty("htmlRef", bk.url().htmlRef());
|
||||
setProperty("htmlRef", bk.url().fragment(QUrl::FullyDecoded));
|
||||
}
|
||||
|
||||
inline int pageNumber() const
|
||||
|
@ -75,8 +77,8 @@ static inline bool documentViewportFuzzyCompare( const DocumentViewport &vp1, co
|
|||
|
||||
static inline bool bookmarkLessThan( const KBookmark &b1, const KBookmark &b2 )
|
||||
{
|
||||
DocumentViewport vp1( b1.url().htmlRef() );
|
||||
DocumentViewport vp2( b2.url().htmlRef() );
|
||||
DocumentViewport vp1( b1.url().fragment(QUrl::FullyDecoded) );
|
||||
DocumentViewport vp2( b2.url().fragment(QUrl::FullyDecoded) );
|
||||
|
||||
return vp1 < vp2;
|
||||
}
|
||||
|
@ -93,53 +95,55 @@ class BookmarkManager::Private : public KBookmarkOwner
|
|||
{
|
||||
public:
|
||||
Private( BookmarkManager * qq )
|
||||
: KBookmarkOwner(), q( qq ), document( 0 ), manager( 0 )
|
||||
: KBookmarkOwner(), q( qq ), document( nullptr ), manager( nullptr )
|
||||
{
|
||||
}
|
||||
|
||||
~Private()
|
||||
~Private() override
|
||||
{
|
||||
knownFiles.clear();
|
||||
// no need to delete the manager, it's automatically done by KBookmarkManager
|
||||
// delete manager;
|
||||
}
|
||||
|
||||
virtual QString currentUrl() const;
|
||||
virtual QString currentTitle() const;
|
||||
virtual bool enableOption(BookmarkOption option) const;
|
||||
virtual void openBookmark( const KBookmark & bm, Qt::MouseButtons, Qt::KeyboardModifiers );
|
||||
QUrl currentUrl() const override;
|
||||
QString currentTitle() const override;
|
||||
bool enableOption(BookmarkOption option) const override;
|
||||
void openBookmark( const KBookmark & bm, Qt::MouseButtons, Qt::KeyboardModifiers ) override;
|
||||
|
||||
QHash<KUrl, QString>::iterator bookmarkFind( const KUrl& url, bool doCreate, KBookmarkGroup *result = 0);
|
||||
QHash<QUrl, QString>::iterator bookmarkFind( const QUrl& url, bool doCreate, KBookmarkGroup *result = nullptr);
|
||||
|
||||
// slots
|
||||
void _o_changed( const QString & groupAddress, const QString & caller );
|
||||
|
||||
BookmarkManager * q;
|
||||
KUrl url;
|
||||
QUrl url;
|
||||
QHash<int,int> urlBookmarks;
|
||||
DocumentPrivate * document;
|
||||
QString file;
|
||||
KBookmarkManager * manager;
|
||||
QHash<KUrl, QString> knownFiles;
|
||||
QHash<QUrl, QString> knownFiles;
|
||||
};
|
||||
|
||||
static inline KUrl urlForGroup(const KBookmark &group)
|
||||
static inline QUrl urlForGroup(const KBookmark &group)
|
||||
{
|
||||
if ( group.url().isValid() ) return group.url();
|
||||
else return KUrl( group.fullText() );
|
||||
if ( group.url().isValid() )
|
||||
return group.url();
|
||||
else
|
||||
return QUrl::fromUserInput( group.fullText() );
|
||||
}
|
||||
|
||||
BookmarkManager::BookmarkManager( DocumentPrivate * document )
|
||||
: QObject( document->m_parent ), d( new Private( this ) )
|
||||
{
|
||||
setObjectName( QLatin1String( "Okular::BookmarkManager" ) );
|
||||
setObjectName( QStringLiteral( "Okular::BookmarkManager" ) );
|
||||
|
||||
d->document = document;
|
||||
|
||||
d->file = KStandardDirs::locateLocal( "data", "okular/bookmarks.xml" );
|
||||
d->file = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/okular/bookmarks.xml");
|
||||
|
||||
d->manager = KBookmarkManager::managerForFile( d->file, "okular" );
|
||||
d->manager->setEditorOptions( KGlobal::caption(), false );
|
||||
d->manager = KBookmarkManager::managerForFile( d->file, QStringLiteral("okular") );
|
||||
d->manager->setEditorOptions( QGuiApplication::applicationDisplayName(), false );
|
||||
d->manager->setUpdate( true );
|
||||
connect( d->manager, SIGNAL(changed(QString,QString)),
|
||||
this, SLOT(_o_changed(QString,QString)) );
|
||||
|
@ -151,14 +155,14 @@ BookmarkManager::~BookmarkManager()
|
|||
}
|
||||
|
||||
//BEGIN Reimplementations from KBookmarkOwner
|
||||
QString BookmarkManager::Private::currentUrl() const
|
||||
QUrl BookmarkManager::Private::currentUrl() const
|
||||
{
|
||||
return url.prettyUrl();
|
||||
return url;
|
||||
}
|
||||
|
||||
QString BookmarkManager::Private::currentTitle() const
|
||||
{
|
||||
return url.isLocalFile() ? url.toLocalFile() : url.prettyUrl();
|
||||
return url.toDisplayString();
|
||||
}
|
||||
|
||||
bool BookmarkManager::Private::enableOption(BookmarkOption option) const
|
||||
|
@ -179,9 +183,9 @@ void BookmarkManager::Private::_o_changed( const QString & groupAddress, const Q
|
|||
if ( groupAddress.isEmpty() )
|
||||
return;
|
||||
|
||||
KUrl referurl;
|
||||
QUrl referurl;
|
||||
// first, try to find the bookmark group whom change notification was just received
|
||||
QHash<KUrl, QString>::iterator it = knownFiles.begin(), itEnd = knownFiles.end();
|
||||
QHash<QUrl, QString>::iterator it = knownFiles.begin(), itEnd = knownFiles.end();
|
||||
for ( ; it != itEnd; ++it )
|
||||
{
|
||||
if ( it.value() == groupAddress )
|
||||
|
@ -231,9 +235,9 @@ void BookmarkManager::Private::_o_changed( const QString & groupAddress, const Q
|
|||
emit q->saved();
|
||||
}
|
||||
|
||||
KUrl::List BookmarkManager::files() const
|
||||
QList<QUrl> BookmarkManager::files() const
|
||||
{
|
||||
KUrl::List ret;
|
||||
QList<QUrl> ret;
|
||||
KBookmarkGroup group = d->manager->root();
|
||||
for ( KBookmark bm = group.first(); !bm.isNull(); bm = group.next( bm ) )
|
||||
{
|
||||
|
@ -245,7 +249,7 @@ KUrl::List BookmarkManager::files() const
|
|||
return ret;
|
||||
}
|
||||
|
||||
KBookmark::List BookmarkManager::bookmarks( const KUrl& url ) const
|
||||
KBookmark::List BookmarkManager::bookmarks(const QUrl &url ) const
|
||||
{
|
||||
KBookmark::List ret;
|
||||
KBookmarkGroup group = d->manager->root();
|
||||
|
@ -279,7 +283,7 @@ KBookmark::List BookmarkManager::bookmarks( int page ) const
|
|||
KBookmark::List ret;
|
||||
foreach( const KBookmark &bm, bmarks )
|
||||
{
|
||||
DocumentViewport vp( bm.url().htmlRef() );
|
||||
DocumentViewport vp( bm.url().fragment(QUrl::FullyDecoded) );
|
||||
if ( vp.isValid() && vp.pageNumber == page )
|
||||
{
|
||||
ret.append(bm);
|
||||
|
@ -294,7 +298,7 @@ KBookmark BookmarkManager::bookmark( int page ) const
|
|||
const KBookmark::List bmarks = bookmarks();
|
||||
foreach( const KBookmark &bm, bmarks )
|
||||
{
|
||||
DocumentViewport vp( bm.url().htmlRef() );
|
||||
DocumentViewport vp( bm.url().fragment(QUrl::FullyDecoded) );
|
||||
if ( vp.isValid() && vp.pageNumber == page )
|
||||
{
|
||||
return bm;
|
||||
|
@ -309,7 +313,7 @@ KBookmark BookmarkManager::bookmark( const DocumentViewport &viewport ) const
|
|||
return KBookmark();
|
||||
|
||||
KBookmarkGroup thebg;
|
||||
QHash<KUrl, QString>::iterator it = d->bookmarkFind( d->url, false, &thebg );
|
||||
QHash<QUrl, QString>::iterator it = d->bookmarkFind( d->url, false, &thebg );
|
||||
if ( it == d->knownFiles.end() )
|
||||
return KBookmark();
|
||||
|
||||
|
@ -318,7 +322,7 @@ KBookmark BookmarkManager::bookmark( const DocumentViewport &viewport ) const
|
|||
if ( bm.isSeparator() || bm.isGroup() )
|
||||
continue;
|
||||
|
||||
DocumentViewport vp( bm.url().htmlRef() );
|
||||
DocumentViewport vp( bm.url().fragment(QUrl::FullyDecoded) );
|
||||
if ( documentViewportFuzzyCompare( vp, viewport ) )
|
||||
{
|
||||
return bm;
|
||||
|
@ -334,9 +338,9 @@ void BookmarkManager::save() const
|
|||
emit const_cast<BookmarkManager*>( this )->saved();
|
||||
}
|
||||
|
||||
QHash<KUrl, QString>::iterator BookmarkManager::Private::bookmarkFind( const KUrl& url, bool doCreate, KBookmarkGroup *result )
|
||||
QHash<QUrl, QString>::iterator BookmarkManager::Private::bookmarkFind( const QUrl& url, bool doCreate, KBookmarkGroup *result )
|
||||
{
|
||||
QHash<KUrl, QString>::iterator it = knownFiles.find( url );
|
||||
QHash<QUrl, QString>::iterator it = knownFiles.find( url );
|
||||
if ( it == knownFiles.end() )
|
||||
{
|
||||
// if the url we want to add a new entry for is not in the hash of the
|
||||
|
@ -349,7 +353,7 @@ QHash<KUrl, QString>::iterator BookmarkManager::Private::bookmarkFind( const KUr
|
|||
if ( bm.isSeparator() || !bm.isGroup() )
|
||||
continue;
|
||||
|
||||
KUrl tmpurl( urlForGroup( bm ) );
|
||||
QUrl tmpurl( urlForGroup( bm ) );
|
||||
if ( tmpurl == url )
|
||||
{
|
||||
// got it! place it the hash of known files
|
||||
|
@ -365,7 +369,7 @@ QHash<KUrl, QString>::iterator BookmarkManager::Private::bookmarkFind( const KUr
|
|||
{
|
||||
// folder not found :(
|
||||
// then, in a single step create a new folder and add it in our cache :)
|
||||
QString purl = url.isLocalFile() ? url.toLocalFile() : url.prettyUrl();
|
||||
QString purl = url.isLocalFile() ? url.toLocalFile() : url.toDisplayString();
|
||||
KBookmarkGroup newbg = root.createNewFolder( purl );
|
||||
newbg.setUrl( url );
|
||||
it = knownFiles.insert( url, newbg.address() );
|
||||
|
@ -396,7 +400,7 @@ void BookmarkManager::addBookmark( const DocumentViewport &vp )
|
|||
addBookmark( d->url, vp );
|
||||
}
|
||||
|
||||
bool BookmarkManager::addBookmark( const KUrl& referurl, const Okular::DocumentViewport& vp, const QString& title )
|
||||
bool BookmarkManager::addBookmark(const QUrl &referurl, const Okular::DocumentViewport& vp, const QString& title )
|
||||
{
|
||||
if ( !referurl.isValid() || !vp.isValid() )
|
||||
return false;
|
||||
|
@ -405,7 +409,7 @@ bool BookmarkManager::addBookmark( const KUrl& referurl, const Okular::DocumentV
|
|||
return false;
|
||||
|
||||
KBookmarkGroup thebg;
|
||||
QHash<KUrl, QString>::iterator it = d->bookmarkFind( referurl, true, &thebg );
|
||||
QHash<QUrl, QString>::iterator it = d->bookmarkFind( referurl, true, &thebg );
|
||||
Q_ASSERT( it != d->knownFiles.end() );
|
||||
|
||||
int count = 0; // Number of bookmarks in the current page
|
||||
|
@ -416,7 +420,7 @@ bool BookmarkManager::addBookmark( const KUrl& referurl, const Okular::DocumentV
|
|||
if ( bm.isSeparator() || bm.isGroup() )
|
||||
continue;
|
||||
|
||||
DocumentViewport bmViewport( bm.url().htmlRef() );
|
||||
DocumentViewport bmViewport( bm.url().fragment(QUrl::FullyDecoded) );
|
||||
if ( bmViewport.isValid() && bmViewport.pageNumber == vp.pageNumber )
|
||||
{
|
||||
++count;
|
||||
|
@ -437,15 +441,15 @@ bool BookmarkManager::addBookmark( const KUrl& referurl, const Okular::DocumentV
|
|||
// if there's more than one bookmark per page, give the name '#p-n'
|
||||
// where n is the index of this bookmark among the ones of its page.
|
||||
if ( count > 0 )
|
||||
newtitle = QString( "#%1-%2" ).arg( vp.pageNumber + 1 ).arg( count );
|
||||
newtitle = QStringLiteral( "#%1-%2" ).arg( vp.pageNumber + 1 ).arg( count );
|
||||
else
|
||||
newtitle = QString( "#%1" ).arg( vp.pageNumber + 1 );
|
||||
newtitle = QStringLiteral( "#%1" ).arg( vp.pageNumber + 1 );
|
||||
}
|
||||
else
|
||||
newtitle = title;
|
||||
|
||||
KUrl newurl = referurl;
|
||||
newurl.setHTMLRef( vp.toString() );
|
||||
QUrl newurl = referurl;
|
||||
newurl.setFragment(vp.toString(), QUrl::DecodedMode);
|
||||
thebg.addBookmark( newtitle, newurl, QString() );
|
||||
if ( referurl == d->document->m_url )
|
||||
{
|
||||
|
@ -477,7 +481,7 @@ void BookmarkManager::removeBookmark( const DocumentViewport &vp )
|
|||
void BookmarkManager::renameBookmark( KBookmark* bm, const QString& newName)
|
||||
{
|
||||
KBookmarkGroup thebg;
|
||||
QHash<KUrl, QString>::iterator it = d->bookmarkFind( d->url, false, &thebg );
|
||||
QHash<QUrl, QString>::iterator it = d->bookmarkFind( d->url, false, &thebg );
|
||||
Q_ASSERT ( it != d->knownFiles.end() );
|
||||
if ( it == d->knownFiles.end() )
|
||||
return;
|
||||
|
@ -486,13 +490,13 @@ void BookmarkManager::renameBookmark( KBookmark* bm, const QString& newName)
|
|||
d->manager->emitChanged( thebg );
|
||||
}
|
||||
|
||||
void BookmarkManager::renameBookmark( const KUrl& referurl, const QString& newName )
|
||||
void BookmarkManager::renameBookmark(const QUrl &referurl, const QString& newName )
|
||||
{
|
||||
if ( !referurl.isValid() )
|
||||
return;
|
||||
|
||||
KBookmarkGroup thebg;
|
||||
QHash<KUrl, QString>::iterator it = d->bookmarkFind( referurl, false, &thebg );
|
||||
QHash<QUrl, QString>::iterator it = d->bookmarkFind( referurl, false, &thebg );
|
||||
Q_ASSERT ( it != d->knownFiles.end() );
|
||||
if ( it == d->knownFiles.end() )
|
||||
return;
|
||||
|
@ -501,26 +505,26 @@ void BookmarkManager::renameBookmark( const KUrl& referurl, const QString& newNa
|
|||
d->manager->emitChanged( thebg );
|
||||
}
|
||||
|
||||
QString BookmarkManager::titleForUrl( const KUrl& referurl ) const
|
||||
QString BookmarkManager::titleForUrl(const QUrl &referurl ) const
|
||||
{
|
||||
KBookmarkGroup thebg;
|
||||
QHash<KUrl, QString>::iterator it = d->bookmarkFind( referurl, false, &thebg );
|
||||
QHash<QUrl, QString>::iterator it = d->bookmarkFind( referurl, false, &thebg );
|
||||
Q_ASSERT( it != d->knownFiles.end() );
|
||||
|
||||
return thebg.fullText();
|
||||
}
|
||||
|
||||
int BookmarkManager::removeBookmark( const KUrl& referurl, const KBookmark& bm )
|
||||
int BookmarkManager::removeBookmark(const QUrl &referurl, const KBookmark& bm )
|
||||
{
|
||||
if ( !referurl.isValid() || bm.isNull() || bm.isGroup() || bm.isSeparator() )
|
||||
return -1;
|
||||
|
||||
DocumentViewport vp( bm.url().htmlRef() );
|
||||
DocumentViewport vp( bm.url().fragment(QUrl::FullyDecoded) );
|
||||
if ( !vp.isValid() )
|
||||
return -1;
|
||||
|
||||
KBookmarkGroup thebg;
|
||||
QHash<KUrl, QString>::iterator it = d->bookmarkFind( referurl, false, &thebg );
|
||||
QHash<QUrl, QString>::iterator it = d->bookmarkFind( referurl, false, &thebg );
|
||||
if ( it == d->knownFiles.end() )
|
||||
return -1;
|
||||
|
||||
|
@ -536,13 +540,13 @@ int BookmarkManager::removeBookmark( const KUrl& referurl, const KBookmark& bm )
|
|||
return vp.pageNumber;
|
||||
}
|
||||
|
||||
void BookmarkManager::removeBookmarks( const KUrl& referurl, const KBookmark::List& list )
|
||||
void BookmarkManager::removeBookmarks(const QUrl &referurl, const KBookmark::List& list )
|
||||
{
|
||||
if ( !referurl.isValid() || list.isEmpty() )
|
||||
return;
|
||||
|
||||
KBookmarkGroup thebg;
|
||||
QHash<KUrl, QString>::iterator it = d->bookmarkFind( referurl, false, &thebg );
|
||||
QHash<QUrl, QString>::iterator it = d->bookmarkFind( referurl, false, &thebg );
|
||||
if ( it == d->knownFiles.end() )
|
||||
return;
|
||||
|
||||
|
@ -555,7 +559,7 @@ void BookmarkManager::removeBookmarks( const KUrl& referurl, const KBookmark::Li
|
|||
thebg.deleteBookmark( bm );
|
||||
deletedAny = true;
|
||||
|
||||
DocumentViewport vp( bm.url().htmlRef() );
|
||||
DocumentViewport vp( bm.url().fragment(QUrl::FullyDecoded) );
|
||||
if ( referurl == d->document->m_url )
|
||||
{
|
||||
d->urlBookmarks[ vp.pageNumber ]--;
|
||||
|
@ -584,7 +588,7 @@ void BookmarkManager::removeBookmarks( const KUrl& referurl, const KBookmark::Li
|
|||
d->manager->emitChanged( thebg );
|
||||
}
|
||||
|
||||
QList< QAction * > BookmarkManager::actionsForUrl( const KUrl& url ) const
|
||||
QList< QAction * > BookmarkManager::actionsForUrl(const QUrl &url ) const
|
||||
{
|
||||
QList< QAction * > ret;
|
||||
KBookmarkGroup group = d->manager->root();
|
||||
|
@ -599,7 +603,7 @@ QList< QAction * > BookmarkManager::actionsForUrl( const KUrl& url ) const
|
|||
if ( b.isSeparator() || b.isGroup() )
|
||||
continue;
|
||||
|
||||
ret.append( new OkularBookmarkAction( DocumentViewport( b.url().htmlRef() ), b, d, 0 ) );
|
||||
ret.append( new OkularBookmarkAction( DocumentViewport( b.url().fragment(QUrl::FullyDecoded) ), b, d, nullptr ) );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -607,12 +611,12 @@ QList< QAction * > BookmarkManager::actionsForUrl( const KUrl& url ) const
|
|||
return ret;
|
||||
}
|
||||
|
||||
void BookmarkManager::setUrl( const KUrl& url )
|
||||
void BookmarkManager::setUrl(const QUrl &url )
|
||||
{
|
||||
d->url = url;
|
||||
d->urlBookmarks.clear();
|
||||
KBookmarkGroup thebg;
|
||||
QHash<KUrl, QString>::iterator it = d->bookmarkFind( url, false, &thebg );
|
||||
QHash<QUrl, QString>::iterator it = d->bookmarkFind( url, false, &thebg );
|
||||
if ( it != d->knownFiles.end() )
|
||||
{
|
||||
for ( KBookmark bm = thebg.first(); !bm.isNull(); bm = thebg.next( bm ) )
|
||||
|
@ -620,7 +624,7 @@ void BookmarkManager::setUrl( const KUrl& url )
|
|||
if ( bm.isSeparator() || bm.isGroup() )
|
||||
continue;
|
||||
|
||||
DocumentViewport vp( bm.url().htmlRef() );
|
||||
DocumentViewport vp( bm.url().fragment(QUrl::FullyDecoded) );
|
||||
if ( !vp.isValid() )
|
||||
continue;
|
||||
|
||||
|
@ -632,7 +636,7 @@ void BookmarkManager::setUrl( const KUrl& url )
|
|||
bool BookmarkManager::setPageBookmark( int page )
|
||||
{
|
||||
KBookmarkGroup thebg;
|
||||
QHash<KUrl, QString>::iterator it = d->bookmarkFind( d->url, true, &thebg );
|
||||
QHash<QUrl, QString>::iterator it = d->bookmarkFind( d->url, true, &thebg );
|
||||
Q_ASSERT( it != d->knownFiles.end() );
|
||||
|
||||
bool found = false;
|
||||
|
@ -642,7 +646,7 @@ bool BookmarkManager::setPageBookmark( int page )
|
|||
if ( bm.isSeparator() || bm.isGroup() )
|
||||
continue;
|
||||
|
||||
DocumentViewport vp( bm.url().htmlRef() );
|
||||
DocumentViewport vp( bm.url().fragment(QUrl::FullyDecoded) );
|
||||
if ( vp.isValid() && vp.pageNumber == page )
|
||||
found = true;
|
||||
|
||||
|
@ -652,9 +656,9 @@ bool BookmarkManager::setPageBookmark( int page )
|
|||
d->urlBookmarks[ page ]++;
|
||||
DocumentViewport vp;
|
||||
vp.pageNumber = page;
|
||||
KUrl newurl = d->url;
|
||||
newurl.setHTMLRef( vp.toString() );
|
||||
thebg.addBookmark( QString::fromLatin1( "#" ) + QString::number( vp.pageNumber + 1 ), newurl, QString() );
|
||||
QUrl newurl = d->url;
|
||||
newurl.setFragment(vp.toString(), QUrl::DecodedMode);
|
||||
thebg.addBookmark( QLatin1String( "#" ) + QString::number( vp.pageNumber + 1 ), newurl, QString() );
|
||||
added = true;
|
||||
d->manager->emitChanged( thebg );
|
||||
}
|
||||
|
@ -664,7 +668,7 @@ bool BookmarkManager::setPageBookmark( int page )
|
|||
bool BookmarkManager::removePageBookmark( int page )
|
||||
{
|
||||
KBookmarkGroup thebg;
|
||||
QHash<KUrl, QString>::iterator it = d->bookmarkFind( d->url, false, &thebg );
|
||||
QHash<QUrl, QString>::iterator it = d->bookmarkFind( d->url, false, &thebg );
|
||||
if ( it == d->knownFiles.end() )
|
||||
return false;
|
||||
|
||||
|
@ -674,7 +678,7 @@ bool BookmarkManager::removePageBookmark( int page )
|
|||
if ( bm.isSeparator() || bm.isGroup() )
|
||||
continue;
|
||||
|
||||
DocumentViewport vp( bm.url().htmlRef() );
|
||||
DocumentViewport vp( bm.url().fragment(QUrl::FullyDecoded) );
|
||||
if ( vp.isValid() && vp.pageNumber == page )
|
||||
{
|
||||
found = true;
|
||||
|
@ -706,7 +710,7 @@ KBookmark BookmarkManager::nextBookmark( const DocumentViewport &viewport) const
|
|||
KBookmark bookmark;
|
||||
foreach ( const KBookmark &bm, bmarks )
|
||||
{
|
||||
DocumentViewport vp( bm.url().htmlRef() );
|
||||
DocumentViewport vp( bm.url().fragment(QUrl::FullyDecoded) );
|
||||
if ( viewport < vp )
|
||||
{
|
||||
bookmark = bm;
|
||||
|
@ -726,7 +730,7 @@ KBookmark BookmarkManager::previousBookmark( const DocumentViewport &viewport )
|
|||
for ( KBookmark::List::const_iterator it = bmarks.constEnd(); it != bmarks.constBegin(); --it )
|
||||
{
|
||||
KBookmark bm = *(it-1);
|
||||
DocumentViewport vp( bm.url().htmlRef() );
|
||||
DocumentViewport vp( bm.url().fragment(QUrl::FullyDecoded) );
|
||||
if ( vp < viewport )
|
||||
{
|
||||
bookmark = bm;
|
||||
|
@ -740,6 +744,6 @@ KBookmark BookmarkManager::previousBookmark( const DocumentViewport &viewport )
|
|||
#undef foreachObserver
|
||||
#undef foreachObserverD
|
||||
|
||||
#include "bookmarkmanager.moc"
|
||||
#include "moc_bookmarkmanager.cpp"
|
||||
|
||||
/* kate: replace-tabs on; indent-width 4; */
|
||||
|
|
|
@ -12,10 +12,11 @@
|
|||
|
||||
#include <kbookmark.h>
|
||||
|
||||
#include "okular_export.h"
|
||||
#include "okularcore_export.h"
|
||||
#include <QObject>
|
||||
#include <QUrl>
|
||||
|
||||
class QAction;
|
||||
class KUrl;
|
||||
|
||||
namespace Okular {
|
||||
|
||||
|
@ -29,7 +30,7 @@ class DocumentViewport;
|
|||
* This class is responsible for loading and saving the bookmarks using the
|
||||
* proper format, and for working with them (eg querying, adding, removing).
|
||||
*/
|
||||
class OKULAR_EXPORT BookmarkManager : public QObject
|
||||
class OKULARCORE_EXPORT BookmarkManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -39,12 +40,12 @@ class OKULAR_EXPORT BookmarkManager : public QObject
|
|||
/**
|
||||
* Returns the list of documents with bookmarks.
|
||||
*/
|
||||
KUrl::List files() const;
|
||||
QList<QUrl> files() const;
|
||||
|
||||
/**
|
||||
* Returns the list of bookmarks for the specified @p url.
|
||||
*/
|
||||
KBookmark::List bookmarks( const KUrl& url ) const;
|
||||
KBookmark::List bookmarks( const QUrl& url ) const;
|
||||
|
||||
/**
|
||||
* Returns the list of bookmarks for document
|
||||
|
@ -92,7 +93,7 @@ class OKULAR_EXPORT BookmarkManager : public QObject
|
|||
*
|
||||
* If no @p title is specified, then \em #n will be used.
|
||||
*/
|
||||
bool addBookmark( const KUrl& referurl, const Okular::DocumentViewport& vp, const QString& title = QString() );
|
||||
bool addBookmark( const QUrl& referurl, const Okular::DocumentViewport& vp, const QString& title = QString() );
|
||||
|
||||
/**
|
||||
* Remove a bookmark for the given @p page.
|
||||
|
@ -108,7 +109,7 @@ class OKULAR_EXPORT BookmarkManager : public QObject
|
|||
/**
|
||||
* Removes the bookmark @p bm for the @p referurl specified.
|
||||
*/
|
||||
int removeBookmark( const KUrl& referurl, const KBookmark& bm );
|
||||
int removeBookmark( const QUrl& referurl, const KBookmark& bm );
|
||||
|
||||
/**
|
||||
* Removes the bookmarks in @p list for the @p referurl specified.
|
||||
|
@ -117,7 +118,7 @@ class OKULAR_EXPORT BookmarkManager : public QObject
|
|||
*
|
||||
* @since 0.11 (KDE 4.5)
|
||||
*/
|
||||
void removeBookmarks( const KUrl& referurl, const KBookmark::List& list );
|
||||
void removeBookmarks( const QUrl& referurl, const KBookmark::List& list );
|
||||
|
||||
/**
|
||||
* Returns the bookmark given bookmark of the document
|
||||
|
@ -130,13 +131,13 @@ class OKULAR_EXPORT BookmarkManager : public QObject
|
|||
* the @p newName specified.
|
||||
* @since 0.15 (KDE 4.9)
|
||||
*/
|
||||
void renameBookmark( const KUrl& referurl, const QString& newName );
|
||||
void renameBookmark( const QUrl& referurl, const QString& newName );
|
||||
|
||||
/**
|
||||
* Returns title for the @p referurl
|
||||
* @since 0.15 (KDE 4.9)
|
||||
*/
|
||||
QString titleForUrl( const KUrl& referurl ) const;
|
||||
QString titleForUrl( const QUrl& referurl ) const;
|
||||
|
||||
/**
|
||||
* Returns whether the given @p page is bookmarked.
|
||||
|
@ -167,13 +168,13 @@ class OKULAR_EXPORT BookmarkManager : public QObject
|
|||
* @note the actions will have no parents, so you have to delete them
|
||||
* yourself
|
||||
*/
|
||||
QList< QAction* > actionsForUrl( const KUrl& url ) const;
|
||||
QList< QAction* > actionsForUrl( const QUrl& url ) const;
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* The bookmark manager is requesting to open the specified @p url.
|
||||
*/
|
||||
void openUrl( const KUrl& url );
|
||||
void openUrl( const QUrl& url );
|
||||
|
||||
/**
|
||||
* This signal is emitted whenever bookmarks have been saved.
|
||||
|
@ -185,7 +186,7 @@ class OKULAR_EXPORT BookmarkManager : public QObject
|
|||
*
|
||||
* @since 0.7 (KDE 4.1)
|
||||
*/
|
||||
void bookmarksChanged( const KUrl& url );
|
||||
void bookmarksChanged( const QUrl& url );
|
||||
|
||||
private:
|
||||
class Private;
|
||||
|
@ -198,7 +199,7 @@ class OKULAR_EXPORT BookmarkManager : public QObject
|
|||
|
||||
BookmarkManager( DocumentPrivate * document );
|
||||
|
||||
void setUrl( const KUrl& url );
|
||||
void setUrl( const QUrl& url );
|
||||
bool setPageBookmark( int page );
|
||||
bool removePageBookmark( int page );
|
||||
|
||||
|
|
|
@ -9,30 +9,40 @@
|
|||
|
||||
#include "chooseenginedialog_p.h"
|
||||
|
||||
#include <QtGui/QComboBox>
|
||||
#include <QtGui/QLabel>
|
||||
#include <QtWidgets/QComboBox>
|
||||
#include <QtWidgets/QLabel>
|
||||
|
||||
#include <klocale.h>
|
||||
#include <KLocalizedString>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "ui_chooseenginewidget.h"
|
||||
|
||||
ChooseEngineDialog::ChooseEngineDialog( const QStringList &generators, const KMimeType::Ptr &mime, QWidget * parent )
|
||||
: KDialog( parent )
|
||||
ChooseEngineDialog::ChooseEngineDialog( const QStringList &generators, const QMimeType &mime, QWidget * parent )
|
||||
: QDialog( parent )
|
||||
{
|
||||
setCaption( i18n( "Backend Selection" ) );
|
||||
setButtons( Ok | Cancel );
|
||||
setDefaultButton( Ok );
|
||||
setWindowTitle( i18n( "Backend Selection" ) );
|
||||
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
setLayout(mainLayout);
|
||||
QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
|
||||
okButton->setDefault(true);
|
||||
okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
|
||||
connect(buttonBox, &QDialogButtonBox::accepted, this, &ChooseEngineDialog::accept);
|
||||
connect(buttonBox, &QDialogButtonBox::rejected, this, &ChooseEngineDialog::reject);
|
||||
okButton->setDefault(true);
|
||||
QWidget *main = new QWidget( this );
|
||||
setMainWidget( main );
|
||||
m_widget = new Ui_ChooseEngineWidget();
|
||||
m_widget->setupUi( main );
|
||||
|
||||
mainLayout->addWidget(main);
|
||||
mainLayout->addWidget(buttonBox);
|
||||
m_widget->engineList->addItems(generators);
|
||||
|
||||
m_widget->description->setText(
|
||||
i18n( "<qt>More than one backend found for the MIME type:<br />"
|
||||
"<b>%1</b> (%2).<br /><br />"
|
||||
"Please select which one to use:</qt>", mime->comment(), mime->name() ) );
|
||||
"Please select which one to use:</qt>", mime.comment(), mime.name() ) );
|
||||
}
|
||||
|
||||
ChooseEngineDialog::~ChooseEngineDialog()
|
||||
|
|
|
@ -12,15 +12,17 @@
|
|||
|
||||
#include <QtCore/QStringList>
|
||||
|
||||
#include <kdialog.h>
|
||||
#include <kmimetype.h>
|
||||
#include <QDialog>
|
||||
#include <QMimeType>
|
||||
|
||||
class Ui_ChooseEngineWidget;
|
||||
|
||||
class ChooseEngineDialog : public KDialog
|
||||
class ChooseEngineDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ChooseEngineDialog( const QStringList &generators, const KMimeType::Ptr &mime, QWidget * parent = 0 );
|
||||
ChooseEngineDialog( const QStringList &generators, const QMimeType &mime, QWidget * parent = nullptr );
|
||||
~ChooseEngineDialog();
|
||||
|
||||
int selectedGenerator() const;
|
||||
|
|
12
core/debug.cpp
Normal file
12
core/debug.cpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2014 by Frederik Gladhorn <gladhorn@kde.org> *
|
||||
* *
|
||||
* 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. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "debug_p.h"
|
||||
|
||||
Q_LOGGING_CATEGORY(OkularCoreDebug, "org.kde.okular.core", QtWarningMsg)
|
|
@ -1,5 +1,6 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2007 by Pino Toscano <pino@kde.org> *
|
||||
* Copyright (C) 2014 by Frederik Gladhorn <gladhorn@kde.org> *
|
||||
* *
|
||||
* 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 *
|
||||
|
@ -7,9 +8,11 @@
|
|||
* (at your option) any later version. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef _OKUAR_DEBUG_P_H_
|
||||
#define _OKUAR_DEBUG_P_H_
|
||||
#ifndef OKULAR_DEBUG_P_H
|
||||
#define OKULAR_DEBUG_P_H
|
||||
|
||||
#define OkularDebug 4700
|
||||
#include <QtCore/qloggingcategory.h>
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(OkularCoreDebug)
|
||||
|
||||
#endif
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue