Activities support for Okular

REVIEW: 106685
This commit is contained in:
Ivan Čukić 2012-10-04 20:17:13 +02:00 committed by Albert Astals Cid
parent ec7b2e763d
commit 09a2fdab8c
3 changed files with 34 additions and 1 deletions

View file

@ -3,6 +3,16 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/..
)
# checking whether we should enable activities support
macro_optional_find_package(KActivities 6.1.0)
macro_log_feature(KActivities_FOUND "KActivities" "Activities interface library" "https://projects.kde.org/projects/kde/kdelibs/kactivities" FALSE "6.1.0" "Required for Activities integration.")
if(KActivities_FOUND)
add_definitions(-DKActivities_FOUND)
include_directories(${KACTIVITIES_INCLUDE_DIRS})
endif(KActivities_FOUND)
# okular
set(okular_SRCS
@ -15,7 +25,7 @@ kde4_add_app_icon(okular_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/../ui/data/icons/hi*-
kde4_add_executable(okular ${okular_SRCS})
target_link_libraries(okular ${KDE4_KPARTS_LIBS} )
target_link_libraries(okular ${KDE4_KPARTS_LIBS} ${KACTIVITIES_LIBRARY})
install(TARGETS okular ${INSTALL_TARGETS_DEFAULT_ARGS})

View file

@ -44,6 +44,10 @@
#include <kactioncollection.h>
#include <kwindowsystem.h>
#ifdef KActivities_FOUND
#include <KActivities/ResourceInstance>
#endif
// local includes
#include "kdocumentviewer.h"
#include "shellutils.h"
@ -53,6 +57,9 @@ static const char *shouldShowToolBarComingFromFullScreen = "shouldShowToolBarCom
Shell::Shell(KCmdLineArgs* args, int argIndex)
: KParts::MainWindow(), m_args(args), m_menuBarWasShown(true), m_toolBarWasShown(true)
#ifdef KActivities_FOUND
, m_activityResource(0)
#endif
{
if (m_args && argIndex != -1)
{
@ -167,7 +174,15 @@ void Shell::openUrl( const KUrl & url )
if ( !isstdin )
{
if ( openOk )
{
#ifdef KActivities_FOUND
if ( !m_activityResource )
m_activityResource = new KActivities::ResourceInstance( window()->winId(), this );
m_activityResource->setUri( url );
#endif
m_recent->addUrl( url );
}
else
m_recent->removeUrl( url );
}

View file

@ -27,6 +27,10 @@ class KToggleAction;
class KDocumentViewer;
class Part;
#ifdef KActivities_FOUND
namespace KActivities { class ResourceInstance; }
#endif
/**
* This is the application "Shell". It has a menubar and a toolbar
* but relies on the "Part" to do all the real work.
@ -112,6 +116,10 @@ private:
bool m_menuBarWasShown, m_toolBarWasShown;
bool m_unique;
KUrl m_openUrl;
#ifdef KActivities_FOUND
KActivities::ResourceInstance* m_activityResource;
#endif
};
#endif