project(LancelotMenu)

# Moved up level
# add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})

include(PlasmaUIMacros)

include_directories(
   ${CMAKE_SOURCE_DIR}
   ${CMAKE_BINARY_DIR}
   ${CMAKE_CURRENT_SOURCE_DIR}
   ${CMAKE_CURRENT_BINARY_DIR}
   ${KDE4_INCLUDES}
   ${PLASMA_INCLUDE_DIR}
   ${LANCELOT_INCLUDE_DIR}
)

# Lancelot data models files
set(plasma_lancelot_models_SRCS
  models/BaseModel.cpp
  models/FolderModel.cpp

  models/FavoriteApplications.cpp
  models/Applications.cpp

  models/Devices.cpp
  models/Places.cpp
  models/SystemServices.cpp

  models/RecentDocuments.cpp
  models/OpenDocuments.cpp
  models/NewDocuments.cpp

  models/Runner.cpp
)

# Lancelot application files
set(plasma_lancelot_application_SRCS
  LancelotApplication.cpp
  LancelotWindow.cpp
  QtDisplay.cpp
)

plasmaui_add_ui_files(plasma_lancelot_application_SRCS
  "ui/LancelotWindowBase.xml"
)

# Lancelot client files
set(plasma_lancelot_client_SRCS
)

# Lancelot D-Bus connections
#set(plasma_lancelot_dbus_SRCS)

set(screensaver_xml ${DBUS_INTERFACES_INSTALL_DIR}/org.freedesktop.ScreenSaver.xml)
qt4_add_dbus_interface(plasma_lancelot_application_SRCS ${screensaver_xml} screensaver_interface)

set(krunner_xml ${DBUS_INTERFACES_INSTALL_DIR}/org.kde.krunner.Interface.xml)
qt4_add_dbus_interface(plasma_lancelot_application_SRCS ${krunner_xml} krunner_interface)

set(ksmserver_xml ${DBUS_INTERFACES_INSTALL_DIR}/org.kde.KSMServerInterface.xml)
qt4_add_dbus_interface(plasma_lancelot_application_SRCS ${ksmserver_xml} ksmserver_interface)

set(kmail_xml ${DBUS_INTERFACES_INSTALL_DIR}/org.kde.kmail.kmail.xml)
qt4_add_dbus_interface(plasma_lancelot_application_SRCS ${kmail_xml} kmail_interface)

set(kopete_xml ${DBUS_INTERFACES_INSTALL_DIR}/org.kde.Kopete.xml)
qt4_add_dbus_interface(plasma_lancelot_application_SRCS ${kopete_xml} kopete_interface)

set(lancelot_xml org.kde.lancelot.xml)
qt4_add_dbus_interface(plasma_lancelot_client_SRCS ${lancelot_xml} lancelot_interface)

qt4_add_dbus_adaptor(plasma_lancelot_application_SRCS org.kde.lancelot.xml
     LancelotApplication.h LancelotApplication)

# Lancelot Menu
set(
  plasma_lancelot_SRCS
  main.cpp

  ${plasma_lancelot_widgets_SRCS}
  ${plasma_lancelot_models_SRCS}
  ${plasma_lancelot_application_SRCS}
)

kde4_add_executable(lancelot-menu ${plasma_lancelot_SRCS})

target_link_libraries(lancelot-menu ${KDE4_KDEUI_LIBS} ${PLASMA_LIBS} ${LANCELOT_LIBS} taskmanager)
set_target_properties(lancelot-menu PROPERTIES OUTPUT_NAME lancelot)

## DBUS service

configure_file(org.kde.lancelot.service.in
  ${CMAKE_CURRENT_BINARY_DIR}/org.kde.lancelot.service)

# To regenerate .xml file:
# qdbuscpp2xml -M -s LancelotApplication.h -o org.kde.lancelot.xml.new
# And make the needed changes
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.kde.lancelot.service DESTINATION ${DBUS_SERVICES_INSTALL_DIR}) # ${CMAKE_INSTALL_PREFIX}/share/dbus-1/services )

########### install applicaiton ###############
install(TARGETS lancelot-menu ${INSTALL_TARGETS_DEFAULT_ARGS} )

# Lancelot Part Applet

# set(plasma_applet_lancelot_part_SRCS
#   ${plasma_lancelot_widgets_SRCS}
#   ${plasma_lancelot_models_SRCS}
#   ${plasma_lancelot_application_SRCS}
#   parts/LancelotPart.cpp
# )
#
# kde4_add_plugin(plasma_applet_lancelot_part ${plasma_applet_lancelot_part_SRCS})
#
# target_link_libraries(plasma_applet_lancelot_part ${PLASMA_LIBS} ${LANCELOT_LIBS} ${KDE4_KIO_LIBS} taskmanager)
#
# install(
#   TARGETS plasma_applet_lancelot_part
#   DESTINATION ${PLUGIN_INSTALL_DIR}
# )
#
# install(
#   FILES parts/plasma-applet-lancelot-part.desktop
#   DESTINATION ${SERVICES_INSTALL_DIR}
# )

# Lancelot Main Applet

set(plasma_applet_lancelot_launcher_SRCS
  ${plasma_lancelot_widgets_SRCS}
  ${plasma_lancelot_client_SRCS}
  launcher/LancelotApplet.cpp
  launcher/LancelotAppletConfig.cpp
)

kde4_add_ui_files(
  plasma_applet_lancelot_launcher_SRCS
  launcher/LancelotAppletConfigBase.ui
)

kde4_add_plugin(plasma_applet_lancelot_launcher ${plasma_applet_lancelot_launcher_SRCS})

target_link_libraries(
   plasma_applet_lancelot_launcher
   ${PLASMA_LIBS}
   ${LANCELOT_LIBS}
   ${KDE4_KIO_LIBS}
)

install(
  TARGETS plasma_applet_lancelot_launcher
  DESTINATION ${PLUGIN_INSTALL_DIR}
)

install(
  FILES launcher/plasma-applet-lancelot-launcher.desktop
  DESTINATION ${SERVICES_INSTALL_DIR}
)
