Development/Tutorials/Plasma4/ContainmentAction: Difference between revisions

From KDE TechBase
(compilation)
(test it)
Line 48: Line 48:
Compile, link and install it using the command
Compile, link and install it using the command
  cmake -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` . && make -j8 && make install
  cmake -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` . && make -j8 && make install
== Test it ==
To test it, right-click onto your desktop and select "Folder View Settings". Then select the context menu:
[[File:Snapshot-kde-contextmenu-1.png]]


= Debugging =
= Debugging =

Revision as of 00:22, 1 March 2013

You can use Plasma ContainmentAction e.g. for Context Menus on your Plasma Desktop. They will run as plugins meaning you can add and remove them after compilation. If they exist, their name will be stored in .desktop files.

Example

A simple example for Plasma ContainmentAction plugins can be found at https://github.com/tstaerk/kde-contextmenu/tree/0.1. Let's look at it here:

kde-contextmenu.desktop

[Desktop Entry]
Name=KDE Context Menu
Type=Service
Icon=favorites
Comment=Simple application launcher

ServiceTypes=Plasma/ContainmentActions

X-KDE-Library=kde-contextmenu
X-KDE-PluginInfo-Author=R. Hacker
[email protected]
X-KDE-PluginInfo-Name=kde-contextmenu
X-KDE-PluginInfo-Version=pre0.1
X-KDE-PluginInfo-Website=http://techbase.kde.org
X-KDE-PluginInfo-EnabledByDefault=true

CMakeLists.txt

project(kde-contextmenu)

set(KDE_MIN_VERSION "4.3.85") # for the < 4.2 macro
find_package(KDE4 4.3.85 REQUIRED)

include(MacroLibrary)
include(KDE4Defaults)

add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES})

set(contextmenu_SRCS
    launch.cpp
)

kde4_add_plugin(kde-contextmenu ${contextmenu_SRCS})
target_link_libraries(kde-contextmenu ${KDE4_PLASMA_LIBS} ${KDE4_KIO_LIBS})

install(TARGETS kde-contextmenu DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES kde-contextmenu.desktop DESTINATION ${SERVICES_INSTALL_DIR})

Install it

Compile, link and install it using the command

cmake -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` . && make -j8 && make install

Test it

To test it, right-click onto your desktop and select "Folder View Settings". Then select the context menu:

Debugging

To debug your Plasma ContainmentAction call

kdebugdialog --fullmode

search for "plasma" and direct kDebug's output to /tmp/whatever.txt

See also