From fbfb374b9cdca346126ab19c522ffd7aa38ca3a7 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Thu, 19 Oct 2023 17:12:38 +0300 Subject: [PATCH] generic: drop scripting and tray support after changes to multiple sub-projects (Katie, kdelibs, kde-workspace and kde-extraapps) that finally happened, can write lots about it but I will keep it short - by rewriting parts that were using js/qml (e.g. the plasma applets) the desktop startup was reduced to half, also the legacy tray thing shall be no more (anything that needs tray icon shall be a plasma applet now) thus some applications and features will be dropped aswell. see all repositories for the changes done Signed-off-by: Ivailo Monev --- CMakeLists.txt | 1 - cmake/modules/CMakeLists.txt | 3 - cmake/modules/FindGMP.cmake | 27 - cmake/modules/FindLibVNCServer.cmake | 44 - cmake/modules/FindMPFR.cmake | 37 - includes/CMakeLists.txt | 9 - includes/KDBusMenuExporter | 1 - includes/KDBusMenuImporter | 1 - includes/KPasteTextAction | 1 - includes/KStatusNotifierItem | 1 - includes/KSystemTrayIcon | 1 - includes/Plasma/AppletScript | 1 - includes/Plasma/ConfigLoader | 1 - includes/Plasma/DeclarativeWidget | 1 - includes/Plasma/ScriptEngine | 1 - kdeclarative/CMakeLists.txt | 60 -- kdeclarative/bindings/backportglobal.h | 38 - kdeclarative/bindings/i18n.cpp | 125 --- kdeclarative/bindings/i18n_p.h | 34 - kdeclarative/bindings/icon.cpp | 112 --- kdeclarative/bindings/image.cpp | 101 -- kdeclarative/bindings/locale.cpp | 116 --- .../bindings/qscriptnonguibookkeeping.cpp | 114 --- kdeclarative/bindings/url.cpp | 117 --- kdeclarative/config-kdeclarative.h.cmake | 2 - kdeclarative/kdeclarative.cpp | 213 ---- kdeclarative/kdeclarative.h | 65 -- kdeclarative/private/engineaccess.cpp | 41 - kdeclarative/private/engineaccess_p.h | 45 - kdeclarative/private/kdeclarative_p.h | 36 - kdeclarative/private/kiconprovider.cpp | 73 -- kdeclarative/private/kiconprovider_p.h | 34 - kdecore/kdebug.areas | 1 - kdecore/kernel/kcmdlineargs.cpp | 1 - kdecore/tests/kautostarttest.cpp | 2 - kdeui/CMakeLists.txt | 25 - kdeui/actions/kpastetextaction.cpp | 141 --- kdeui/actions/kpastetextaction.h | 89 -- kdeui/actions/kstandardaction.cpp | 9 - kdeui/actions/kstandardaction.h | 8 - kdeui/actions/kstandardaction_p.h | 1 - kdeui/kernel/kapplication.cpp | 190 ---- kdeui/notifications/kdbusmenu_p.cpp | 73 -- kdeui/notifications/kdbusmenu_p.h | 148 --- kdeui/notifications/kdbusmenuexporter.cpp | 225 ----- kdeui/notifications/kdbusmenuexporter.h | 67 -- kdeui/notifications/kdbusmenuimporter.cpp | 158 --- kdeui/notifications/kdbusmenuimporter.h | 89 -- kdeui/notifications/kstatusnotifieritem.cpp | 921 ------------------ kdeui/notifications/kstatusnotifieritem.h | 445 --------- .../kstatusnotifieritemdbus_p.cpp | 308 ------ .../notifications/kstatusnotifieritemdbus_p.h | 242 ----- .../kstatusnotifieritemprivate_p.h | 131 --- kdeui/notifications/ksystemtrayicon.cpp | 334 ------- kdeui/notifications/ksystemtrayicon.h | 164 ---- .../org.kde.StatusNotifierItem.xml | 93 -- .../org.kde.StatusNotifierWatcher.xml | 42 - kdeui/widgets/kmainwindow.cpp | 8 - kio/application.desktop | 3 - kio/kfile/kpropertiesdesktopadvbase.ui | 10 - kio/kfile/kpropertiesdialog.cpp | 22 +- plasma/CMakeLists.txt | 27 - plasma/abstractrunner.h | 3 +- plasma/applet.cpp | 319 +----- plasma/applet.h | 65 +- plasma/config-plasma.h.cmake | 1 - plasma/configloader.cpp | 432 -------- plasma/configloader.h | 149 --- plasma/containment.cpp | 10 - plasma/containment.h | 12 - .../data/servicetypes/plasma-applet.desktop | 3 - .../servicetypes/plasma-scriptengine.desktop | 86 -- plasma/dataenginemanager.cpp | 1 - plasma/extenders/extenderitem.cpp | 1 - plasma/packagemetadata.cpp | 13 - plasma/packagemetadata.h | 6 - plasma/packagestructure.cpp | 15 +- plasma/plasma.cpp | 15 - plasma/plasma.h | 33 - plasma/pluginloader.cpp | 25 +- plasma/popupapplet.cpp | 34 +- plasma/popupapplet.h | 10 - plasma/private/applet_p.h | 26 +- plasma/private/configloader_p.h | 221 ----- plasma/private/dataenginebindings.cpp | 66 -- plasma/private/dataenginebindings_p.h | 83 -- plasma/private/packages.cpp | 53 - plasma/private/packages_p.h | 15 - plasma/runnermanager.cpp | 19 +- plasma/scripting/appletscript.cpp | 259 ----- plasma/scripting/appletscript.h | 268 ----- plasma/scripting/scriptengine.cpp | 199 ---- plasma/scripting/scriptengine.h | 118 --- plasma/svg.cpp | 19 +- plasma/tests/CMakeLists.txt | 3 - plasma/tests/configloadertest.cpp | 213 ---- plasma/tests/configloadertest.h | 67 -- plasma/tests/configloadertest.xml | 71 -- plasma/tests/packagestructuretest.cpp | 215 ---- plasma/tests/plasmoidpackagerc | 38 - plasma/tests/plasmoidpackagetest.cpp | 294 ------ plasma/tests/plasmoidpackagetest.h | 52 - plasma/widgets/declarativewidget.cpp | 328 ------- plasma/widgets/declarativewidget.h | 142 --- 104 files changed, 59 insertions(+), 9376 deletions(-) delete mode 100644 cmake/modules/FindGMP.cmake delete mode 100644 cmake/modules/FindLibVNCServer.cmake delete mode 100644 cmake/modules/FindMPFR.cmake delete mode 100644 includes/KDBusMenuExporter delete mode 100644 includes/KDBusMenuImporter delete mode 100644 includes/KPasteTextAction delete mode 100644 includes/KStatusNotifierItem delete mode 100644 includes/KSystemTrayIcon delete mode 100644 includes/Plasma/AppletScript delete mode 100644 includes/Plasma/ConfigLoader delete mode 100644 includes/Plasma/DeclarativeWidget delete mode 100644 includes/Plasma/ScriptEngine delete mode 100644 kdeclarative/CMakeLists.txt delete mode 100644 kdeclarative/bindings/backportglobal.h delete mode 100644 kdeclarative/bindings/i18n.cpp delete mode 100644 kdeclarative/bindings/i18n_p.h delete mode 100644 kdeclarative/bindings/icon.cpp delete mode 100644 kdeclarative/bindings/image.cpp delete mode 100644 kdeclarative/bindings/locale.cpp delete mode 100644 kdeclarative/bindings/qscriptnonguibookkeeping.cpp delete mode 100644 kdeclarative/bindings/url.cpp delete mode 100644 kdeclarative/config-kdeclarative.h.cmake delete mode 100644 kdeclarative/kdeclarative.cpp delete mode 100644 kdeclarative/kdeclarative.h delete mode 100644 kdeclarative/private/engineaccess.cpp delete mode 100644 kdeclarative/private/engineaccess_p.h delete mode 100644 kdeclarative/private/kdeclarative_p.h delete mode 100644 kdeclarative/private/kiconprovider.cpp delete mode 100644 kdeclarative/private/kiconprovider_p.h delete mode 100644 kdeui/actions/kpastetextaction.cpp delete mode 100644 kdeui/actions/kpastetextaction.h delete mode 100644 kdeui/notifications/kdbusmenu_p.cpp delete mode 100644 kdeui/notifications/kdbusmenu_p.h delete mode 100644 kdeui/notifications/kdbusmenuexporter.cpp delete mode 100644 kdeui/notifications/kdbusmenuexporter.h delete mode 100644 kdeui/notifications/kdbusmenuimporter.cpp delete mode 100644 kdeui/notifications/kdbusmenuimporter.h delete mode 100644 kdeui/notifications/kstatusnotifieritem.cpp delete mode 100644 kdeui/notifications/kstatusnotifieritem.h delete mode 100644 kdeui/notifications/kstatusnotifieritemdbus_p.cpp delete mode 100644 kdeui/notifications/kstatusnotifieritemdbus_p.h delete mode 100644 kdeui/notifications/kstatusnotifieritemprivate_p.h delete mode 100644 kdeui/notifications/ksystemtrayicon.cpp delete mode 100644 kdeui/notifications/ksystemtrayicon.h delete mode 100644 kdeui/notifications/org.kde.StatusNotifierItem.xml delete mode 100644 kdeui/notifications/org.kde.StatusNotifierWatcher.xml delete mode 100644 plasma/configloader.cpp delete mode 100644 plasma/configloader.h delete mode 100644 plasma/data/servicetypes/plasma-scriptengine.desktop delete mode 100644 plasma/private/configloader_p.h delete mode 100644 plasma/private/dataenginebindings.cpp delete mode 100644 plasma/private/dataenginebindings_p.h delete mode 100644 plasma/scripting/appletscript.cpp delete mode 100644 plasma/scripting/appletscript.h delete mode 100644 plasma/scripting/scriptengine.cpp delete mode 100644 plasma/scripting/scriptengine.h delete mode 100644 plasma/tests/configloadertest.cpp delete mode 100644 plasma/tests/configloadertest.h delete mode 100644 plasma/tests/configloadertest.xml delete mode 100644 plasma/tests/packagestructuretest.cpp delete mode 100644 plasma/tests/plasmoidpackagerc delete mode 100644 plasma/tests/plasmoidpackagetest.cpp delete mode 100644 plasma/tests/plasmoidpackagetest.h delete mode 100644 plasma/widgets/declarativewidget.cpp delete mode 100644 plasma/widgets/declarativewidget.h diff --git a/CMakeLists.txt b/CMakeLists.txt index c456ddc8..da840940 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -457,7 +457,6 @@ add_subdirectory( cmake ) add_subdirectory( includes ) add_subdirectory( interfaces ) -add_subdirectory( kdeclarative ) add_subdirectory( kdecore ) add_subdirectory( kded ) add_subdirectory( kdeui ) diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt index c6cc0128..7a62d81e 100644 --- a/cmake/modules/CMakeLists.txt +++ b/cmake/modules/CMakeLists.txt @@ -32,7 +32,6 @@ set(cmakeFiles FindFontconfig.cmake FindGettextPO.cmake FindGLIB2.cmake - FindGMP.cmake FindGphoto2.cmake FindKmod.cmake FindLibATASmart.cmake @@ -44,10 +43,8 @@ set(cmakeFiles FindLibSSH.cmake FindLibTorrent.cmake FindLibUSB.cmake - FindLibVNCServer.cmake FindLightDM.cmake FindLibGit2.cmake - FindMPFR.cmake FindMtp.cmake FindPCIUTILS.cmake FindPoppler.cmake diff --git a/cmake/modules/FindGMP.cmake b/cmake/modules/FindGMP.cmake deleted file mode 100644 index d8f6a69a..00000000 --- a/cmake/modules/FindGMP.cmake +++ /dev/null @@ -1,27 +0,0 @@ -# Try to find GMP, once done this will define: -# -# GMP_FOUND - system has GMP -# GMP_INCLUDE_DIR - the GMP include directory -# GMP_LIBRARIES - the libraries needed to use GMP -# -# Copyright (c) 2020 Ivailo Monev -# -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. - -find_path(GMP_INCLUDE_DIR - NAMES gmp.h - HINTS $ENV{GMPDIR}/include -) - -find_library(GMP_LIBRARIES - NAMES gmp - HINTS $ENV{GMPDIR}/lib -) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(GMP - REQUIRED_VARS GMP_LIBRARIES GMP_INCLUDE_DIR -) - -mark_as_advanced(GMP_INCLUDE_DIR GMP_LIBRARIES) diff --git a/cmake/modules/FindLibVNCServer.cmake b/cmake/modules/FindLibVNCServer.cmake deleted file mode 100644 index c50eb8f2..00000000 --- a/cmake/modules/FindLibVNCServer.cmake +++ /dev/null @@ -1,44 +0,0 @@ -# cmake macro to test LIBVNCSERVER LIB - -# Copyright (c) 2006, Alessandro Praduroux -# Copyright (c) 2007, Urs Wolfer -# -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. - -INCLUDE(CheckStructHasMember) -INCLUDE(CMakePushCheckState) - -IF (LIBVNCSERVER_INCLUDE_DIR AND LIBVNCSERVER_LIBRARIES) - # Already in cache, be silent - SET(LIBVNCSERVER_FIND_QUIETLY TRUE) -ENDIF (LIBVNCSERVER_INCLUDE_DIR AND LIBVNCSERVER_LIBRARIES) - -FIND_PATH(LIBVNCSERVER_INCLUDE_DIR rfb/rfb.h) - -FIND_LIBRARY(LIBVNCSERVER_LIBRARIES NAMES vncserver libvncserver) - -# libvncserver and libvncclient are in the same package, so it does -# not make sense to add a new cmake script for finding libvncclient. -# instead just find the libvncclient also in this file. -FIND_PATH(LIBVNCCLIENT_INCLUDE_DIR rfb/rfbclient.h) -FIND_LIBRARY(LIBVNCCLIENT_LIBRARIES NAMES vncclient libvncclient) - -IF (LIBVNCSERVER_INCLUDE_DIR AND LIBVNCSERVER_LIBRARIES) - cmake_reset_check_state() - SET(CMAKE_REQUIRED_INCLUDES "${LIBVNCSERVER_INCLUDE_DIR}") - CHECK_STRUCT_HAS_MEMBER(rfbClient GotXCutText rfb/rfbclient.h LIBVNCSERVER_FOUND) - cmake_reset_check_state() -ENDIF (LIBVNCSERVER_INCLUDE_DIR AND LIBVNCSERVER_LIBRARIES) - -IF (LIBVNCSERVER_FOUND) - IF (NOT LIBVNCSERVER_FIND_QUIETLY) - MESSAGE(STATUS "Found LibVNCServer: ${LIBVNCSERVER_LIBRARIES}") - ENDIF (NOT LIBVNCSERVER_FIND_QUIETLY) -ELSE (LIBVNCSERVER_FOUND) - IF (LIBVNCSERVER_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Could NOT find acceptable version of LibVNCServer (version 0.9 or later required).") - ENDIF (LIBVNCSERVER_FIND_REQUIRED) -ENDIF (LIBVNCSERVER_FOUND) - -MARK_AS_ADVANCED(LIBVNCSERVER_INCLUDE_DIR LIBVNCSERVER_LIBRARIES) diff --git a/cmake/modules/FindMPFR.cmake b/cmake/modules/FindMPFR.cmake deleted file mode 100644 index df3d2cf7..00000000 --- a/cmake/modules/FindMPFR.cmake +++ /dev/null @@ -1,37 +0,0 @@ -# Try to find MPFR, once done this will define: -# -# MPFR_FOUND - system has MPFR -# MPFR_INCLUDE_DIR - the MPFR include directory -# MPFR_LIBRARIES - the libraries needed to use MPFR -# -# Copyright (c) 2020 Ivailo Monev -# -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. - -find_package(PkgConfig REQUIRED) -pkg_check_modules(PC_MPFR QUIET mpfr) - -set(MPFR_INCLUDE_DIR ${PC_MPFR_INCLUDE_DIRS}) -set(MPFR_LIBRARIES ${PC_MPFR_LIBRARIES}) -set(MPFR_VERSION ${PC_MPFR_VERSION}) - -if(NOT MPFR_INCLUDE_DIR OR NOT MPFR_LIBRARIES) - find_path(MPFR_INCLUDE_DIR - NAMES mpfr.h - HINTS $ENV{MPFRDIR}/include - ) - - find_library(MPFR_LIBRARIES - NAMES mpfr - HINTS $ENV{MPFRDIR}/lib - ) -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(MPFR - VERSION_VAR MPFR_VERSION - REQUIRED_VARS MPFR_LIBRARIES MPFR_INCLUDE_DIR -) - -mark_as_advanced(MPFR_INCLUDE_DIR MPFR_LIBRARIES) diff --git a/includes/CMakeLists.txt b/includes/CMakeLists.txt index cb1a3215..8bad2b1e 100644 --- a/includes/CMakeLists.txt +++ b/includes/CMakeLists.txt @@ -79,8 +79,6 @@ install( KDEDModule KDEPrintDialog KCalendarWidget - KDBusMenuExporter - KDBusMenuImporter KDesktopFile KDialog KDialogButtonBox @@ -201,7 +199,6 @@ install( KPassivePopup KPassivePopupMessageHandler KPasswordDialog - KPasteTextAction KPixmap KPixmapWidget KPluginFactory @@ -261,14 +258,12 @@ install( KStartupInfoId KStatusBar KStatusBarJobTracker - KStatusNotifierItem KStringHandler KStyle KSycoca KSycocaEntry KSystemEventFilter KSystemTimeZones - KSystemTrayIcon KTabBar KTabWidget KTempDir @@ -477,18 +472,15 @@ install( Plasma/Animation Plasma/Animator Plasma/Applet - Plasma/AppletScript Plasma/BusyWidget Plasma/CheckBox Plasma/ComboBox - Plasma/ConfigLoader Plasma/Containment Plasma/ContainmentActions Plasma/Corona Plasma/DataContainer Plasma/DataEngine Plasma/DataEngineManager - Plasma/DeclarativeWidget Plasma/Delegate Plasma/Dialog Plasma/DialogShadows @@ -516,7 +508,6 @@ install( Plasma/RadioButton Plasma/RunnerContext Plasma/RunnerManager - Plasma/ScriptEngine Plasma/ScrollBar Plasma/ScrollWidget Plasma/Separator diff --git a/includes/KDBusMenuExporter b/includes/KDBusMenuExporter deleted file mode 100644 index f44ca154..00000000 --- a/includes/KDBusMenuExporter +++ /dev/null @@ -1 +0,0 @@ -#include "../kdbusmenuexporter.h" diff --git a/includes/KDBusMenuImporter b/includes/KDBusMenuImporter deleted file mode 100644 index f8b4dad6..00000000 --- a/includes/KDBusMenuImporter +++ /dev/null @@ -1 +0,0 @@ -#include "../kdbusmenuimporter.h" diff --git a/includes/KPasteTextAction b/includes/KPasteTextAction deleted file mode 100644 index ef6a5d58..00000000 --- a/includes/KPasteTextAction +++ /dev/null @@ -1 +0,0 @@ -#include "../kpastetextaction.h" diff --git a/includes/KStatusNotifierItem b/includes/KStatusNotifierItem deleted file mode 100644 index 2698f6d1..00000000 --- a/includes/KStatusNotifierItem +++ /dev/null @@ -1 +0,0 @@ -#include "../kstatusnotifieritem.h" diff --git a/includes/KSystemTrayIcon b/includes/KSystemTrayIcon deleted file mode 100644 index edd27398..00000000 --- a/includes/KSystemTrayIcon +++ /dev/null @@ -1 +0,0 @@ -#include "../ksystemtrayicon.h" diff --git a/includes/Plasma/AppletScript b/includes/Plasma/AppletScript deleted file mode 100644 index b003ef6a..00000000 --- a/includes/Plasma/AppletScript +++ /dev/null @@ -1 +0,0 @@ -#include "../../plasma/scripting/appletscript.h" diff --git a/includes/Plasma/ConfigLoader b/includes/Plasma/ConfigLoader deleted file mode 100644 index 99951b74..00000000 --- a/includes/Plasma/ConfigLoader +++ /dev/null @@ -1 +0,0 @@ -#include "../../plasma/configloader.h" diff --git a/includes/Plasma/DeclarativeWidget b/includes/Plasma/DeclarativeWidget deleted file mode 100644 index f613ad95..00000000 --- a/includes/Plasma/DeclarativeWidget +++ /dev/null @@ -1 +0,0 @@ -#include "../../plasma/widgets/declarativewidget.h" diff --git a/includes/Plasma/ScriptEngine b/includes/Plasma/ScriptEngine deleted file mode 100644 index 472eee1a..00000000 --- a/includes/Plasma/ScriptEngine +++ /dev/null @@ -1 +0,0 @@ -#include "../../plasma/scripting/scriptengine.h" diff --git a/kdeclarative/CMakeLists.txt b/kdeclarative/CMakeLists.txt deleted file mode 100644 index b1a6cf17..00000000 --- a/kdeclarative/CMakeLists.txt +++ /dev/null @@ -1,60 +0,0 @@ -project(kdeclarative) - -if(KDE_PLATFORM_FEATURE_BINARY_COMPATIBLE_FEATURE_REDUCTION) - set(KDECLARATIVE_NO_KIO TRUE) -endif() - -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/config-kdeclarative.h.cmake - ${CMAKE_CURRENT_BINARY_DIR}/config-kdeclarative.h -) - -include_directories( - ${CMAKE_SOURCE_DIR} - ${CMAKE_BINARY_DIR} - ${KDE4_KIO_INCLUDES} - ${KDE4_KDEUI_INCLUDES} - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} -) - -set(kdeclarative_LIB_SRCS - kdeclarative.cpp - private/engineaccess.cpp - private/kiconprovider.cpp - bindings/qscriptnonguibookkeeping.cpp - bindings/i18n.cpp - bindings/icon.cpp - bindings/image.cpp - bindings/locale.cpp - bindings/url.cpp -) - -add_library(kdeclarative SHARED ${kdeclarative_LIB_SRCS}) - -set_target_properties(kdeclarative PROPERTIES - VERSION ${GENERIC_LIB_VERSION} - SOVERSION ${GENERIC_LIB_SOVERSION} -) - -target_link_libraries(kdeclarative PUBLIC - ${QT_QTSCRIPT_LIBRARY} - ${QT_QTDECLARATIVE_LIBRARY} - kdecore - kdeui -) - -generate_export_header(kdeclarative) - -install( - FILES - kdeclarative.h - ${CMAKE_CURRENT_BINARY_DIR}/kdeclarative_export.h - DESTINATION ${KDE4_INCLUDE_INSTALL_DIR} -) - -install( - TARGETS kdeclarative - EXPORT kdelibsTargets - DESTINATION ${KDE4_LIB_INSTALL_DIR} -) diff --git a/kdeclarative/bindings/backportglobal.h b/kdeclarative/bindings/backportglobal.h deleted file mode 100644 index 319a9fae..00000000 --- a/kdeclarative/bindings/backportglobal.h +++ /dev/null @@ -1,38 +0,0 @@ -/**************************************************************************** -** -** This file is part of the Qt Script Generator. -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation info@qt.nokia.com -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation -** and appearing in the file LICENSE.LGPL included in the packaging of -** this file. Please review the following information to ensure the GNU -** Lesser General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** Copyright (C) 2011 Nokia. All rights reserved -****************************************************************************/ - -#ifndef QTSCRIPTEXTENSIONS_GLOBAL_H -#define QTSCRIPTEXTENSIONS_GLOBAL_H - -#include -#include -#include - -#define DECLARE_SELF(Class, __fn__) \ - Class* self = qscriptvalue_cast(ctx->thisObject()); \ - if (!self) { \ - return ctx->throwError(QScriptContext::TypeError, \ - QString::fromLatin1("%0.prototype.%1: this object is not a %0") \ - .arg(#Class).arg(#__fn__)); \ - } - -#define ADD_ENUM_VALUE(__c__, __ns__, __v__) \ - __c__.setProperty(#__v__, QScriptValue(__c__.engine(), __ns__::__v__)) - -#endif // QTSCRIPTEXTENSIONS_GLOBAL_H diff --git a/kdeclarative/bindings/i18n.cpp b/kdeclarative/bindings/i18n.cpp deleted file mode 100644 index b6d6786a..00000000 --- a/kdeclarative/bindings/i18n.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 2009 Aaron Seigo - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License version 2 as - * published by the Free Software Foundation - * - * 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 Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "i18n_p.h" - -#include -#include - -#include -#include - -QScriptValue jsi18n(QScriptContext *context, QScriptEngine *engine) -{ - Q_UNUSED(engine) - - if (context->argumentCount() < 1) { - kDebug() << i18n("i18n() takes at least one argument"); - return engine->undefinedValue(); - } - - KLocalizedString message = ki18n(context->argument(0).toString().toUtf8()); - - const int numArgs = context->argumentCount(); - for (int i = 1; i < numArgs; ++i) { - message = message.subs(context->argument(i).toString()); - } - - return message.toString(); -} - -QScriptValue jsi18nc(QScriptContext *context, QScriptEngine *engine) -{ - Q_UNUSED(engine) - - const int numArgs = context->argumentCount(); - if (numArgs < 2) { - kDebug() << i18n("i18nc() takes at least two arguments"); - return engine->undefinedValue(); - } - - KLocalizedString message = ki18nc(context->argument(0).toString().toUtf8(), - context->argument(1).toString().toUtf8()); - - for (int i = 2; i < numArgs; ++i) { - message = message.subs(context->argument(i).toString()); - } - - return message.toString(); -} - -QScriptValue jsi18np(QScriptContext *context, QScriptEngine *engine) -{ - Q_UNUSED(engine) - - const int numArgs = context->argumentCount(); - if (numArgs < 2) { - kDebug() << i18n("i18np() takes at least two arguments"); - return engine->undefinedValue(); - } - - KLocalizedString message = ki18np(context->argument(0).toString().toUtf8(), - context->argument(1).toString().toUtf8()); - - for (int i = 2; i < numArgs; ++i) { - QScriptValue v = context->argument(i); - if (v.isNumber()) { - message = message.subs(v.toInt32()); - } else { - message = message.subs(v.toString()); - } - } - - return message.toString(); -} - -QScriptValue jsi18ncp(QScriptContext *context, QScriptEngine *engine) -{ - Q_UNUSED(engine) - - const int numArgs = context->argumentCount(); - if (numArgs < 3) { - kDebug() << i18n("i18ncp() takes at least three arguments"); - return engine->undefinedValue(); - } - - KLocalizedString message = ki18ncp(context->argument(0).toString().toUtf8(), - context->argument(1).toString().toUtf8(), - context->argument(2).toString().toUtf8()); - - for (int i = 3; i < numArgs; ++i) { - QScriptValue v = context->argument(i); - if (v.isNumber()) { - message = message.subs(v.toInt32()); - } else { - message = message.subs(v.toString()); - } - } - - return message.toString(); -} - -void bindI18N(QScriptEngine *engine) -{ - QScriptValue global = engine->globalObject(); - global.setProperty("i18n", engine->newFunction(jsi18n)); - global.setProperty("i18nc", engine->newFunction(jsi18nc)); - global.setProperty("i18np", engine->newFunction(jsi18np)); - global.setProperty("i18ncp", engine->newFunction(jsi18ncp)); -} - diff --git a/kdeclarative/bindings/i18n_p.h b/kdeclarative/bindings/i18n_p.h deleted file mode 100644 index 2ce0d76c..00000000 --- a/kdeclarative/bindings/i18n_p.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2009 Aaron Seigo - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License version 2 as - * published by the Free Software Foundation - * - * 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 Library 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. - */ - -#ifndef I18N_P_H -#define I18N_P_H - -#include - -#include -#include - -QScriptValue jsi18n(QScriptContext *context, QScriptEngine *engine); -QScriptValue jsi18nc(QScriptContext *context, QScriptEngine *engine); -QScriptValue jsi18np(QScriptContext *context, QScriptEngine *engine); -QScriptValue jsi18ncp(QScriptContext *context, QScriptEngine *engine); -void bindI18N(QScriptEngine *engine); - -#endif //I18N_P_H - diff --git a/kdeclarative/bindings/icon.cpp b/kdeclarative/bindings/icon.cpp deleted file mode 100644 index e93c631b..00000000 --- a/kdeclarative/bindings/icon.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2009 Aaron J. Seigo - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License version 2 as - * published by the Free Software Foundation - * - * 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 Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include -#include - -#include - -#include "backportglobal.h" - -Q_DECLARE_METATYPE(QIcon) -Q_DECLARE_METATYPE(QIcon*) -Q_DECLARE_METATYPE(KIcon) -Q_DECLARE_METATYPE(KIcon*) - -static QScriptValue iconCtor(QScriptContext *ctx, QScriptEngine *eng) -{ - if (ctx->argumentCount() > 0) { - QScriptValue v = ctx->argument(0); - if (v.isString()) { - QIcon icon = KIcon(v.toString()); - return qScriptValueFromValue(eng, icon); - } else if (v.isVariant()) { - QVariant variant = v.toVariant(); - QPixmap p = variant.value(); - if (!p.isNull()) { - return qScriptValueFromValue(eng, QIcon(p)); - } - } - } - return qScriptValueFromValue(eng, QIcon()); -} - -static QScriptValue iconAddPixmap(QScriptContext *ctx, QScriptEngine *eng) -{ - DECLARE_SELF(QIcon, addPixmap); - - if (ctx->argumentCount() > 0) { - QScriptValue arg = ctx->argument(0); - - if (arg.isVariant()) { - QVariant variant = arg.toVariant(); - QPixmap p = variant.value(); - if (!p.isNull()) { - self->addPixmap(p); - } - } - } - - return eng->undefinedValue(); -} - -static QScriptValue iconAddFile(QScriptContext *ctx, QScriptEngine *eng) -{ - DECLARE_SELF(QIcon, addFile); - - if (ctx->argumentCount() > 0) { - QScriptValue arg = ctx->argument(0); - - if (arg.isString()) { - self->addFile(arg.toString()); - } - } - - return eng->undefinedValue(); -} - -static QScriptValue iconIsNull(QScriptContext *ctx, QScriptEngine *eng) -{ - Q_UNUSED(eng) - DECLARE_SELF(QIcon, null); - return self->isNull(); -} - -QScriptValue constructIconClass(QScriptEngine *eng) -{ - QScriptValue proto = qScriptValueFromValue(eng, QIcon()); - QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter; - // QScriptValue::PropertyFlags setter = QScriptValue::PropertySetter; - proto.setProperty("addPixmap", eng->newFunction(iconAddPixmap)); - proto.setProperty("addFile", eng->newFunction(iconAddFile)); - proto.setProperty("null", eng->newFunction(iconIsNull), getter); - - QScriptValue ctorFun = eng->newFunction(iconCtor, proto); - ADD_ENUM_VALUE(ctorFun, QIcon, Normal); - ADD_ENUM_VALUE(ctorFun, QIcon, Disabled); - ADD_ENUM_VALUE(ctorFun, QIcon, Active); - ADD_ENUM_VALUE(ctorFun, QIcon, Selected); - ADD_ENUM_VALUE(ctorFun, QIcon, Off); - ADD_ENUM_VALUE(ctorFun, QIcon, On); - - eng->setDefaultPrototype(qMetaTypeId(), proto); - - return ctorFun; -} - diff --git a/kdeclarative/bindings/image.cpp b/kdeclarative/bindings/image.cpp deleted file mode 100644 index 4c8c221d..00000000 --- a/kdeclarative/bindings/image.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2023 Ivailo Monev - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License version 2 as - * published by the Free Software Foundation - * - * 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 Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include -#include - -#include -#include - -#include "backportglobal.h" - -Q_DECLARE_METATYPE(QImage) -Q_DECLARE_METATYPE(QImage*) -Q_DECLARE_METATYPE(QPixmap) -Q_DECLARE_METATYPE(QPixmap*) - -static QScriptValue imageCtor(QScriptContext *ctx, QScriptEngine *eng) -{ - if (ctx->argumentCount() > 0) { - QScriptValue v = ctx->argument(0); - if (v.isString()) { - return qScriptValueFromValue(eng, QImage(v.toString())); - } else if (v.isVariant()) { - QVariant variant = v.toVariant(); - QPixmap p = variant.value(); - if (!p.isNull()) { - return qScriptValueFromValue(eng, p.toImage()); - } - } - } - return qScriptValueFromValue(eng, QImage()); -} - -static QScriptValue imageIsNull(QScriptContext *ctx, QScriptEngine *eng) -{ - Q_UNUSED(eng) - DECLARE_SELF(QImage, null); - return self->isNull(); -} - -static QScriptValue imageWidth(QScriptContext *ctx, QScriptEngine *eng) -{ - Q_UNUSED(eng) - DECLARE_SELF(QImage, width); - return self->width(); -} - -static QScriptValue imageHeight(QScriptContext *ctx, QScriptEngine *eng) -{ - Q_UNUSED(eng) - DECLARE_SELF(QImage, height); - return self->height(); -} - -static QScriptValue imageDepth(QScriptContext *ctx, QScriptEngine *eng) -{ - Q_UNUSED(eng) - DECLARE_SELF(QImage, depth); - return self->depth(); -} - -static QScriptValue imageHasAlphaChannel(QScriptContext *ctx, QScriptEngine *eng) -{ - Q_UNUSED(eng) - DECLARE_SELF(QImage, hasAlphaChannel); - return self->hasAlphaChannel(); -} - -QScriptValue constructImageClass(QScriptEngine *eng) -{ - QScriptValue proto = qScriptValueFromValue(eng, QImage()); - QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter; - // QScriptValue::PropertyFlags setter = QScriptValue::PropertySetter; - proto.setProperty("null", eng->newFunction(imageIsNull), getter); - proto.setProperty("width", eng->newFunction(imageWidth), getter); - proto.setProperty("height", eng->newFunction(imageHeight), getter); - proto.setProperty("depth", eng->newFunction(imageDepth), getter); - proto.setProperty("hasAlphaChannel", eng->newFunction(imageHasAlphaChannel), getter); - - QScriptValue ctorFun = eng->newFunction(imageCtor, proto); - - eng->setDefaultPrototype(qMetaTypeId(), proto); - - return ctorFun; -} diff --git a/kdeclarative/bindings/locale.cpp b/kdeclarative/bindings/locale.cpp deleted file mode 100644 index 5c7c6ca0..00000000 --- a/kdeclarative/bindings/locale.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2023 Ivailo Monev - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License version 2 as - * published by the Free Software Foundation - * - * 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 Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include -#include - -#include - -#include "backportglobal.h" - -Q_DECLARE_METATYPE(QLocale) -Q_DECLARE_METATYPE(QLocale*) - -static QScriptValue localeCtor(QScriptContext *ctx, QScriptEngine *eng) -{ - if (ctx->argumentCount() > 0) { - QScriptValue v = ctx->argument(0); - if (v.isString()) { - return qScriptValueFromValue(eng, QLocale(v.toString())); - } - } - return qScriptValueFromValue(eng, QLocale()); -} - -static QScriptValue localeName(QScriptContext *ctx, QScriptEngine *eng) -{ - Q_UNUSED(eng) - DECLARE_SELF(QLocale, name); - return self->name(); -} - -static QScriptValue localeDecimalPoint(QScriptContext *ctx, QScriptEngine *eng) -{ - Q_UNUSED(eng) - DECLARE_SELF(QLocale, decimalPoint); - return QString(self->decimalPoint()); -} - -static QScriptValue localeGroupSeparator(QScriptContext *ctx, QScriptEngine *eng) -{ - Q_UNUSED(eng) - DECLARE_SELF(QLocale, groupSeparator); - return QString(self->groupSeparator()); -} - -static QScriptValue localePercent(QScriptContext *ctx, QScriptEngine *eng) -{ - Q_UNUSED(eng) - DECLARE_SELF(QLocale, percent); - return QString(self->percent()); -} - -static QScriptValue localeZeroDigit(QScriptContext *ctx, QScriptEngine *eng) -{ - Q_UNUSED(eng) - DECLARE_SELF(QLocale, zeroDigit); - return QString(self->zeroDigit()); -} - -static QScriptValue localeNegativeSign(QScriptContext *ctx, QScriptEngine *eng) -{ - Q_UNUSED(eng) - DECLARE_SELF(QLocale, negativeSign); - return QString(self->negativeSign()); -} - -static QScriptValue localePositiveSign(QScriptContext *ctx, QScriptEngine *eng) -{ - Q_UNUSED(eng) - DECLARE_SELF(QLocale, positiveSign); - return QString(self->positiveSign()); -} - -static QScriptValue localeExponential(QScriptContext *ctx, QScriptEngine *eng) -{ - Q_UNUSED(eng) - DECLARE_SELF(QLocale, exponential); - return QString(self->exponential()); -} - -QScriptValue constructLocaleClass(QScriptEngine *eng) -{ - QScriptValue proto = qScriptValueFromValue(eng, QLocale()); - QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter; - // QScriptValue::PropertyFlags setter = QScriptValue::PropertySetter; - proto.setProperty("name", eng->newFunction(localeName), getter); - proto.setProperty("decimalPoint", eng->newFunction(localeDecimalPoint), getter); - proto.setProperty("groupSeparator", eng->newFunction(localeGroupSeparator), getter); - proto.setProperty("percent", eng->newFunction(localePercent), getter); - proto.setProperty("zeroDigit", eng->newFunction(localeZeroDigit), getter); - proto.setProperty("negativeSign", eng->newFunction(localeNegativeSign), getter); - proto.setProperty("positiveSign", eng->newFunction(localePositiveSign), getter); - proto.setProperty("exponential", eng->newFunction(localeExponential), getter); - - QScriptValue ctorFun = eng->newFunction(localeCtor, proto); - - eng->setDefaultPrototype(qMetaTypeId(), proto); - - return ctorFun; -} diff --git a/kdeclarative/bindings/qscriptnonguibookkeeping.cpp b/kdeclarative/bindings/qscriptnonguibookkeeping.cpp deleted file mode 100644 index 11b3e18a..00000000 --- a/kdeclarative/bindings/qscriptnonguibookkeeping.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2007-2008 Richard J. Moore - * Copyright 2009 Aaron J. Seigo - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License version 2 as - * published by the Free Software Foundation - * - * 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 Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include - -#include - -#include -#include -#ifndef KDECLARATIVE_NO_KIO -#include -#include -#endif -#include - -Q_DECLARE_METATYPE(KConfigGroup) - -Q_DECLARE_METATYPE(KJob *) - -typedef KJob* KJobPtr; -QScriptValue qScriptValueFromKJob(QScriptEngine *engine, const KJobPtr &job) -{ - return engine->newQObject(const_cast(job), QScriptEngine::AutoOwnership, QScriptEngine::PreferExistingWrapperObject); -} - -void qKJobFromQScriptValue(const QScriptValue &scriptValue, KJobPtr &job) -{ - QObject *obj = scriptValue.toQObject(); - job = static_cast(obj); -} - -#ifndef KDECLARATIVE_NO_KIO -Q_DECLARE_METATYPE(KIO::Job *) -typedef KIO::Job* KioJobPtr; -QScriptValue qScriptValueFromKIOJob(QScriptEngine *engine, const KioJobPtr &job) -{ - return engine->newQObject(const_cast(job), QScriptEngine::AutoOwnership, QScriptEngine::PreferExistingWrapperObject); -} - -void qKIOJobFromQScriptValue(const QScriptValue &scriptValue, KioJobPtr &job) -{ - QObject *obj = scriptValue.toQObject(); - job = static_cast(obj); -} -#endif - -QScriptValue qScriptValueFromKConfigGroup(QScriptEngine *engine, const KConfigGroup &config) -{ - QScriptValue obj = engine->newObject(); - - if (!config.isValid()) { - return obj; - } - - QMap entryMap = config.entryMap(); - QMapIterator it(entryMap); - - //setting the group name - obj.setProperty("__file", QScriptValue(engine, config.config()->name())); - obj.setProperty("__name", QScriptValue(engine, config.name())); - - //setting the key/value pairs - while(it.hasNext()) { - it.next(); - //kDebug() << "setting" << it.key() << "to" << it.value(); - QString prop = it.key(); - prop.replace(' ', '_'); - obj.setProperty(prop, it.value()); - } - - return obj; -} - -void kConfigGroupFromScriptValue(const QScriptValue& obj, KConfigGroup &config) -{ - config = KConfigGroup(KSharedConfig::openConfig(obj.property("__file").toString()), obj.property("__name").toString()); - - QScriptValueIterator it(obj); - - while (it.hasNext()) { - it.next(); - //kDebug() << it.name() << "is" << it.value().toString(); - if (it.name() != "__name") { - config.writeEntry(it.name(), it.value().toString()); - } - } -} - -void registerNonGuiMetaTypes(QScriptEngine *engine) -{ - qScriptRegisterMetaType(engine, qScriptValueFromKConfigGroup, kConfigGroupFromScriptValue, QScriptValue()); - qScriptRegisterMetaType(engine, qScriptValueFromKJob, qKJobFromQScriptValue); -#ifndef KDECLARATIVE_NO_KIO - qScriptRegisterMetaType(engine, qScriptValueFromKIOJob, qKIOJobFromQScriptValue); -#endif -} - diff --git a/kdeclarative/bindings/url.cpp b/kdeclarative/bindings/url.cpp deleted file mode 100644 index a9bddbc1..00000000 --- a/kdeclarative/bindings/url.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2007 Richard J. Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License version 2 as - * published by the Free Software Foundation - * - * 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 Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include -#include -#include -#include "backportglobal.h" - -Q_DECLARE_METATYPE(KUrl*) -//Q_DECLARE_METATYPE(KUrl) unneeded; found in kurl.h - -static QScriptValue urlCtor(QScriptContext *ctx, QScriptEngine *eng) -{ - if (ctx->argumentCount() == 1) - { - QString url = ctx->argument(0).toString(); - return qScriptValueFromValue(eng, KUrl(url)); - } - - return qScriptValueFromValue(eng, KUrl()); -} - -static QScriptValue toString(QScriptContext *ctx, QScriptEngine *eng) -{ - DECLARE_SELF(KUrl, toString); - return QScriptValue(eng, self->prettyUrl()); -} - -static QScriptValue protocol(QScriptContext *ctx, QScriptEngine *eng) -{ - DECLARE_SELF(KUrl, protocol); - if (ctx->argumentCount()) { - QString v = ctx->argument(0).toString(); - self->setScheme(v); - } - - return QScriptValue(eng, self->protocol()); -} - -static QScriptValue host(QScriptContext *ctx, QScriptEngine *eng) -{ - DECLARE_SELF(KUrl, protocol); - if (ctx->argumentCount()) { - QString v = ctx->argument(0).toString(); - self->setHost(v); - } - - return QScriptValue(eng, self->host()); -} - -static QScriptValue path(QScriptContext *ctx, QScriptEngine *eng) -{ - DECLARE_SELF(KUrl, path); - if (ctx->argumentCount()) { - QString v = ctx->argument(0).toString(); - self->setPath(v); - } - - return QScriptValue(eng, self->path()); -} - -static QScriptValue user(QScriptContext *ctx, QScriptEngine *eng) -{ - DECLARE_SELF(KUrl, user); - if (ctx->argumentCount()) { - QString v = ctx->argument(0).toString(); - self->setUserName(v); - } - - return QScriptValue(eng, self->userName()); -} - -static QScriptValue password(QScriptContext *ctx, QScriptEngine *eng) -{ - DECLARE_SELF(KUrl, password); - if (ctx->argumentCount()) { - QString v = ctx->argument(0).toString(); - self->setPassword(v); - } - - return QScriptValue(eng, self->password()); -} - -QScriptValue constructKUrlClass(QScriptEngine *eng) -{ - QScriptValue proto = qScriptValueFromValue(eng, KUrl()); - QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter; - QScriptValue::PropertyFlags setter = QScriptValue::PropertySetter; - - proto.setProperty("toString", eng->newFunction(toString), getter); - proto.setProperty("protocol", eng->newFunction(protocol), getter | setter); - proto.setProperty("host", eng->newFunction(host), getter | setter); - proto.setProperty("path", eng->newFunction(path), getter | setter); - proto.setProperty("user", eng->newFunction(user), getter | setter); - proto.setProperty("password", eng->newFunction(password), getter | setter); - - eng->setDefaultPrototype(qMetaTypeId(), proto); - eng->setDefaultPrototype(qMetaTypeId(), proto); - - return eng->newFunction(urlCtor, proto); -} diff --git a/kdeclarative/config-kdeclarative.h.cmake b/kdeclarative/config-kdeclarative.h.cmake deleted file mode 100644 index b4602408..00000000 --- a/kdeclarative/config-kdeclarative.h.cmake +++ /dev/null @@ -1,2 +0,0 @@ -#cmakedefine KDECLARATIVE_NO_KIO - diff --git a/kdeclarative/kdeclarative.cpp b/kdeclarative/kdeclarative.cpp deleted file mode 100644 index 4aa01d95..00000000 --- a/kdeclarative/kdeclarative.cpp +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Copyright 2011 Marco Martin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library 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 Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "kdeclarative.h" -#include "bindings/i18n_p.h" -#include "private/kdeclarative_p.h" -#include "private/engineaccess_p.h" -#include "private/kiconprovider_p.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -void registerNonGuiMetaTypes(QScriptEngine *engine); -QScriptValue constructIconClass(QScriptEngine *engine); -QScriptValue constructImageClass(QScriptEngine *engine); -QScriptValue constructLocaleClass(QScriptEngine *engine); -QScriptValue constructKUrlClass(QScriptEngine *engine); - -class KScriptEngineAgent : public QScriptEngineAgent -{ -public: - KScriptEngineAgent(QScriptEngine *engine); - - // reimplementation - void exceptionThrow(qint64 scriptId, const QScriptValue &exception, bool hasHandler) final; - -private: - Q_DISABLE_COPY(KScriptEngineAgent); -}; - -KScriptEngineAgent::KScriptEngineAgent(QScriptEngine *engine) - : QScriptEngineAgent(engine) -{ - engine->setAgent(this); -}; - -void KScriptEngineAgent::exceptionThrow(qint64 scriptId, const QScriptValue &exception, bool hasHandler) -{ - // qDebug() << Q_FUNC_INFO << scriptId; - - if (!hasHandler) { - QScriptEngine* engine = QScriptEngineAgent::engine(); - if (Q_UNLIKELY(!engine)) { - kWarning() << "No engine"; - return; - } - - QScriptContext* engineContext = engine->currentContext(); - if (Q_UNLIKELY(!engineContext)) { - kWarning() << "No engine context"; - return; - } - - QScriptContextInfo contextInfo(engineContext); - const QString infoFile = contextInfo.fileName(); - const QString infoLine = QString::number(contextInfo.lineNumber()); - const QString infoString = QString::fromLatin1("%1:%2").arg(infoFile, infoLine); - kDebug() << infoString << exception.toString(); - } -} - -KDeclarativePrivate::KDeclarativePrivate() -{ -} - -KDeclarative::KDeclarative() - : d(new KDeclarativePrivate) -{ -} - -KDeclarative::~KDeclarative() -{ - delete d; -} - - -void KDeclarative::setDeclarativeEngine(QDeclarativeEngine *engine) -{ - if (d->declarativeEngine.data() == engine) { - return; - } - d->declarativeEngine = engine; -} - -QDeclarativeEngine *KDeclarative::declarativeEngine() const -{ - return d->declarativeEngine.data(); -} - -void KDeclarative::initialize() -{ - //Glorious hack:steal the engine - //create the access object - EngineAccess *engineAccess = new EngineAccess(this); - d->declarativeEngine.data()->rootContext()->setContextProperty("__engineAccess", engineAccess); - - //make engineaccess set our d->scriptengine - QDeclarativeExpression *expr = new QDeclarativeExpression(d->declarativeEngine.data()->rootContext(), d->declarativeEngine.data()->rootContext()->contextObject(), "__engineAccess.setEngine(this)"); - expr->evaluate(); - delete expr; - - //we don't need engineaccess anymore - d->declarativeEngine.data()->rootContext()->setContextProperty("__engineAccess", 0); - engineAccess->deleteLater(); - - //fail? - if (!d->scriptEngine) { - kWarning() << "Failed to get the script engine"; - return; - } - - //change the old globalobject with a new read/write copy - QScriptValue originalGlobalObject = d->scriptEngine.data()->globalObject(); - - QScriptValue newGlobalObject = d->scriptEngine.data()->newObject(); - - QScriptValueIterator iter(originalGlobalObject); - while (iter.hasNext()) { - iter.next(); - - if (iter.name() == QLatin1String("version")) { - continue; - } - - newGlobalObject.setProperty(iter.scriptName(), iter.value()); - } - - d->scriptEngine.data()->setGlobalObject(newGlobalObject); -} - -void KDeclarative::setupBindings() -{ - QScriptEngine *engine = d->scriptEngine.data(); - if (!engine) { - return; - } - - /*tell the engine to search for import in the kde4 plugin dirs. - addImportPath adds the path at the beginning, so to honour user's - paths we need to traverse the list in reverse order*/ - - const QStringList importPathList = KGlobal::dirs()->findDirs("module", "imports"); - QStringListIterator importPathIterator(importPathList); - importPathIterator.toBack(); - while (importPathIterator.hasPrevious()) { - d->declarativeEngine.data()->addImportPath(importPathIterator.previous()); - } - - QScriptValue global = engine->globalObject(); - - //KConfig and KJob - registerNonGuiMetaTypes(d->scriptEngine.data()); - - // Stuff from Katie - global.setProperty("QIcon", constructIconClass(engine)); - global.setProperty("QImage", constructImageClass(engine)); - global.setProperty("QLocale", constructLocaleClass(engine)); - - // Add stuff from KDE libs - bindI18N(engine); - qScriptRegisterSequenceMetaType(engine); - global.setProperty("Url", constructKUrlClass(engine)); - - // setup ImageProvider for KDE icons - d->declarativeEngine.data()->addImageProvider(QString("icon"), new KIconProvider); - - // the engine should take ownership - (void)new KScriptEngineAgent(engine); -} - -QScriptEngine *KDeclarative::scriptEngine() const -{ - return d->scriptEngine.data(); -} - -QString KDeclarative::defaultComponentsTarget() -{ - return QLatin1String("desktop"); -} - -QString KDeclarative::componentsTarget() -{ - return defaultComponentsTarget(); -} diff --git a/kdeclarative/kdeclarative.h b/kdeclarative/kdeclarative.h deleted file mode 100644 index 246d3803..00000000 --- a/kdeclarative/kdeclarative.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2011 Marco Martin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library 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 Library 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. - */ - -#ifndef KDECLARATIVE_H -#define KDECLARATIVE_H - -#include - -#include - -#include -#include - -class KDeclarativePrivate; - -class KDECLARATIVE_EXPORT KDeclarative -{ -public: - explicit KDeclarative(); - ~KDeclarative(); - - void initialize(); - void setupBindings(); - - void setDeclarativeEngine(QDeclarativeEngine *engine); - QDeclarativeEngine *declarativeEngine() const; - - QScriptEngine *scriptEngine() const; - - /** - * @return the QML components target, e.g. "desktop", "tablet" or "touch". The string relates - * to the platform form factor. - * @since 4.10 - */ - static QString componentsTarget(); - - /** - * @return the default components target; can be used to compare against the returned value - * from @see componentsTarget() - * @since 4.10 - */ - static QString defaultComponentsTarget(); - -private: - KDeclarativePrivate *const d; - friend class EngineAccess; -}; - -#endif diff --git a/kdeclarative/private/engineaccess.cpp b/kdeclarative/private/engineaccess.cpp deleted file mode 100644 index 042312ea..00000000 --- a/kdeclarative/private/engineaccess.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2010 Marco Martin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library 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 Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "engineaccess_p.h" -#include "kdeclarative.h" -#include "kdeclarative_p.h" - -#include - -EngineAccess::EngineAccess(KDeclarative *parent) - : QObject(0), - m_kDeclarative(parent) -{ -} - -EngineAccess::~EngineAccess() -{ -} - -void EngineAccess::setEngine(QScriptValue val) -{ - m_kDeclarative->d->scriptEngine = val.engine(); -} - -#include "moc_engineaccess_p.cpp" diff --git a/kdeclarative/private/engineaccess_p.h b/kdeclarative/private/engineaccess_p.h deleted file mode 100644 index ca4eba3b..00000000 --- a/kdeclarative/private/engineaccess_p.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2010 Marco Martin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library 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 Library 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. - */ - -#ifndef ENGINEACCESS_P_H -#define ENGINEACCESS_P_H - -#include - -#include - -class KDeclarative; - -class EngineAccess : public QObject -{ - Q_OBJECT - - -public: - EngineAccess(KDeclarative *parent); - ~EngineAccess(); - - Q_INVOKABLE void setEngine(QScriptValue val); - -private: - KDeclarative *m_kDeclarative; - -}; - -#endif diff --git a/kdeclarative/private/kdeclarative_p.h b/kdeclarative/private/kdeclarative_p.h deleted file mode 100644 index a7382a9f..00000000 --- a/kdeclarative/private/kdeclarative_p.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2011 Marco Martin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library 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 Library 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. - */ - -#ifndef KDECLARATIVE_P_H -#define KDECLARATIVE_P_H - -#include "kdeclarative.h" - -#include - -class KDeclarativePrivate -{ -public: - KDeclarativePrivate(); - - QWeakPointer declarativeEngine; - QWeakPointer scriptEngine; -}; - -#endif diff --git a/kdeclarative/private/kiconprovider.cpp b/kdeclarative/private/kiconprovider.cpp deleted file mode 100644 index d24ae8f0..00000000 --- a/kdeclarative/private/kiconprovider.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/*************************************************************************** - * Copyright 2011 Artur Duque de Souza * - * * - * 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 . * - ***************************************************************************/ - -#include "kiconprovider_p.h" -#include "kicon.h" -#include "kiconloader.h" -#include "kiconeffect.h" - -#include -#include - -KIconProvider::KIconProvider() - : QDeclarativeImageProvider(QDeclarativeImageProvider::Pixmap) -{ -} - -QPixmap KIconProvider::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) -{ - // handle QIcon::state - const QStringList source = id.split('/'); - if (source.size() < 1) { - return QDeclarativeImageProvider::requestPixmap(id, size, requestedSize); - } - - QPixmap pixmap; - if (requestedSize.isValid()) { - pixmap = KIcon(source.at(0)).pixmap(requestedSize); - } else if (size->isValid()) { - pixmap = KIcon(source.at(0)).pixmap(*size); - } else { - pixmap = KIcon(source.at(0)).pixmap(IconSize(KIconLoader::Desktop)); - } - - if (source.size() == 2) { - KIconEffect *effect = KIconLoader::global()->iconEffect(); - const QString state(source.at(1)); - int finalState = KIconLoader::DefaultState; - - if (state == QLatin1String("active")) { - finalState = KIconLoader::ActiveState; - } else if (state == QLatin1String("disabled")) { - finalState = KIconLoader::DisabledState; - } else if (state == QLatin1String("last")) { - finalState = KIconLoader::LastState; - } - - // apply the effect for state - pixmap = effect->apply(pixmap, KIconLoader::Desktop, finalState); - } - - if (!pixmap.isNull() && size) { - *size = pixmap.size(); - } - - return pixmap; -} - diff --git a/kdeclarative/private/kiconprovider_p.h b/kdeclarative/private/kiconprovider_p.h deleted file mode 100644 index abbbc242..00000000 --- a/kdeclarative/private/kiconprovider_p.h +++ /dev/null @@ -1,34 +0,0 @@ -/*************************************************************************** - * Copyright 2011 Artur Duque de Souza * - * * - * 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 . * - ***************************************************************************/ - -#ifndef ICON_PROVIDER_H -#define ICON_PROVIDER_H - -#include - - -class KIconProvider : public QDeclarativeImageProvider -{ - -public: - KIconProvider(); - QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) final; -}; - -#endif diff --git a/kdecore/kdebug.areas b/kdecore/kdebug.areas index e852664f..303fccf3 100644 --- a/kdecore/kdebug.areas +++ b/kdecore/kdebug.areas @@ -30,7 +30,6 @@ 297 kdeui (KNotificationRestrictions) 299 kdeui (KNotification) 300 kdeui (KConfigDialogManager) -301 kdeui (KDBusMenu) 700 kutils (KSettings::Dialog) 701 kutils (KSettings::Dispatcher) 702 kutils (KPluginSelector) diff --git a/kdecore/kernel/kcmdlineargs.cpp b/kdecore/kernel/kcmdlineargs.cpp index 03134a80..6f76a6ae 100644 --- a/kdecore/kernel/kcmdlineargs.cpp +++ b/kdecore/kernel/kcmdlineargs.cpp @@ -278,7 +278,6 @@ KCmdLineArgsStatic::KCmdLineArgsStatic () { #ifdef Q_WS_X11 kde_options.add("waitforwm", ki18n("Waits for a WM_NET compatible windowmanager")); #endif - kde_options.add("tray", ki18n("Show tray icon")); kde_options.add("geometry ", ki18n("sets the client geometry of the main widget - see man X for the argument format (usually WidthxHeight+XPos+YPos)")); kde_options.add("smkey "); // this option is obsolete and exists only to allow smooth upgrades from sessions } diff --git a/kdecore/tests/kautostarttest.cpp b/kdecore/tests/kautostarttest.cpp index 5fbf0d61..3e0acc23 100644 --- a/kdecore/tests/kautostarttest.cpp +++ b/kdecore/tests/kautostarttest.cpp @@ -73,8 +73,6 @@ void KAutostartTest::testStartphase_data() QTest::addColumn("startPhase"); if ( KAutostart::isServiceRegistered("plasma-desktop") ) QTest::newRow("plasma-desktop") << "plasma-desktop" << (int)KAutostart::BaseDesktop; - if ( KAutostart::isServiceRegistered("klipper") ) - QTest::newRow("klipper") << "klipper" << (int)KAutostart::Applications; QTest::newRow("does not exist") << "doesnotexist" << (int)KAutostart::Applications; } diff --git a/kdeui/CMakeLists.txt b/kdeui/CMakeLists.txt index c3c94dc5..0547fac4 100644 --- a/kdeui/CMakeLists.txt +++ b/kdeui/CMakeLists.txt @@ -55,7 +55,6 @@ set(kdeui_LIB_SRCS actions/kdualaction.cpp actions/kfontaction.cpp actions/kfontsizeaction.cpp - actions/kpastetextaction.cpp actions/krecentfilesaction.cpp actions/kselectaction.cpp actions/kstandardaction.cpp @@ -154,12 +153,6 @@ set(kdeui_LIB_SRCS notifications/knotification.cpp notifications/knotificationconfigwidget.cpp notifications/knotificationrestrictions.cpp - notifications/kdbusmenuexporter.cpp - notifications/kdbusmenuimporter.cpp - notifications/kdbusmenu_p.cpp - notifications/ksystemtrayicon.cpp - notifications/kstatusnotifieritem.cpp - notifications/kstatusnotifieritemdbus_p.cpp paged/kpagedialog.cpp paged/kpageview.cpp paged/kpageview_p.cpp @@ -257,17 +250,6 @@ set(kdeui_LIB_SRCS windowmanagement/netwm.cpp ) -qt4_add_dbus_interface(kdeui_LIB_SRCS - notifications/org.kde.StatusNotifierWatcher.xml - statusnotifierwatcher_interface -) - -qt4_add_dbus_adaptor(kdeui_LIB_SRCS - notifications/org.kde.StatusNotifierItem.xml - notifications/kstatusnotifieritemdbus_p.h - KStatusNotifierItemDBus -) - if (X11_Xkb_FOUND AND X11_Xkbfile_FOUND) include_directories ( ${X11_Xkb_INCLUDE_PATH} @@ -383,7 +365,6 @@ install( actions/kcodecaction.h actions/kfontaction.h actions/kfontsizeaction.h - actions/kpastetextaction.h actions/krecentfilesaction.h actions/kselectaction.h actions/kstandardaction.h @@ -461,13 +442,9 @@ install( kernel/kglobalsettings.h kernel/ksystemeventfilter.h kernel/ktoolinvocation.h - notifications/kstatusnotifieritem.h - notifications/ksystemtrayicon.h notifications/knotification.h notifications/knotificationconfigwidget.h notifications/knotificationrestrictions.h - notifications/kdbusmenuexporter.h - notifications/kdbusmenuimporter.h paged/kpagedialog.h paged/kpageview.h paged/kpagewidget.h @@ -585,7 +562,5 @@ install( FILES jobs/org.kde.JobViewServer.xml jobs/org.kde.JobView.xml - notifications/org.kde.StatusNotifierItem.xml - notifications/org.kde.StatusNotifierWatcher.xml DESTINATION ${KDE4_DBUS_INTERFACES_INSTALL_DIR} ) diff --git a/kdeui/actions/kpastetextaction.cpp b/kdeui/actions/kpastetextaction.cpp deleted file mode 100644 index 82ac6ac4..00000000 --- a/kdeui/actions/kpastetextaction.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1999 Reginald Stadlbauer - (C) 1999 Simon Hausmann - (C) 2000 Nicolas Hadacek - (C) 2000 Kurt Granroth - (C) 2000 Michael Koch - (C) 2001 Holger Freyther - (C) 2002 Ellis Whitehead - (C) 2002 Joseph Wenninger - (C) 2003 Andras Mantia - (C) 2005-2006 Hamish Rodda - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "kpastetextaction.h" - -#include -#include - -#include -#include -#include -#include - -#include "kmenu.h" - -class KPasteTextActionPrivate -{ -public: - KPasteTextActionPrivate(KPasteTextAction *parent) - : q(parent), - m_popup(nullptr) - { - } - - ~KPasteTextActionPrivate() - { - delete m_popup; - } - - void _k_menuAboutToShow(); - void _k_slotTriggered(QAction*); - - void init(); - - KPasteTextAction *q; - KMenu *m_popup; -}; - -KPasteTextAction::KPasteTextAction(QObject *parent) - : KAction(parent), - d(new KPasteTextActionPrivate(this)) -{ - d->init(); -} - -KPasteTextAction::KPasteTextAction(const QString &text, QObject *parent) - : KAction(parent), - d(new KPasteTextActionPrivate(this)) -{ - d->init(); - setText(text); -} - -KPasteTextAction::KPasteTextAction(const KIcon &icon, const QString &text, QObject *parent) - : KAction(icon, text, parent), - d(new KPasteTextActionPrivate(this)) -{ - d->init(); -} - -void KPasteTextActionPrivate::init() -{ - m_popup = new KMenu(); - q->connect(m_popup, SIGNAL(aboutToShow()), q, SLOT(_k_menuAboutToShow())); - q->connect(m_popup, SIGNAL(triggered(QAction*)), q, SLOT(_k_slotTriggered(QAction*))); -} - -KPasteTextAction::~KPasteTextAction() -{ - delete d; -} - -void KPasteTextActionPrivate::_k_menuAboutToShow() -{ - m_popup->clear(); - QStringList list; - QDBusInterface klipper("org.kde.klipper", "/klipper", "org.kde.klipper.klipper"); - if (klipper.isValid()) { - QDBusReply reply = klipper.call("getClipboardHistoryMenu"); - if (reply.isValid()) { - list = reply; - } - } - QString clipboardText = qApp->clipboard()->text(QClipboard::Clipboard); - if (list.isEmpty()) { - list << clipboardText; - } - bool found = false; - const QFontMetrics fm = m_popup->fontMetrics(); - foreach (const QString &string, list) { - QString text = fm.elidedText(string.simplified(), Qt::ElideMiddle, fm.maxWidth() * 20); - text.replace('&', "&&"); - QAction* action = m_popup->addAction(text); - if (!found && string == clipboardText) { - action->setChecked(true); - found = true; - } - } -} - -void KPasteTextActionPrivate::_k_slotTriggered(QAction* action) -{ - QDBusInterface klipper("org.kde.klipper", "/klipper", "org.kde.klipper.klipper"); - if (klipper.isValid()) { - QDBusReply reply = klipper.call("getClipboardHistoryItem", m_popup->actions().indexOf(action)); - if (!reply.isValid()) { - return; - } - QString clipboardText = reply; - reply = klipper.call("setClipboardContents", clipboardText); - if (reply.isValid()) { - kDebug(129) << "Clipboard: " << qApp->clipboard()->text(QClipboard::Clipboard); - } - } -} - -#include "moc_kpastetextaction.cpp" diff --git a/kdeui/actions/kpastetextaction.h b/kdeui/actions/kpastetextaction.h deleted file mode 100644 index 0c9c680a..00000000 --- a/kdeui/actions/kpastetextaction.h +++ /dev/null @@ -1,89 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1999 Reginald Stadlbauer - (C) 1999 Simon Hausmann - (C) 2000 Nicolas Hadacek - (C) 2000 Kurt Granroth - (C) 2000 Michael Koch - (C) 2001 Holger Freyther - (C) 2002 Ellis Whitehead - (C) 2003 Andras Mantia - (C) 2005-2006 Hamish Rodda - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef KPASTETEXTACTION_H -#define KPASTETEXTACTION_H - -#include - - -class KPasteTextActionPrivate; -/** - * An action for pasting text from the clipboard. - * It's useful for text handling applications as - * when plugged into a toolbar it provides a menu - * with the clipboard history if klipper is running. - * If klipper is not running, the menu has only one - * item: the current clipboard content. - */ -class KDEUI_EXPORT KPasteTextAction: public KAction -{ - Q_OBJECT -public: - /** - * Constructs an action with the specified parent. - * - * @param parent The parent of this action. - */ - explicit KPasteTextAction(QObject *parent); - - ~KPasteTextAction(); - - /** - * Constructs an action with text; a shortcut may be specified by - * the ampersand character (e.g. \"&Option\" creates a shortcut with key \e O ) - * - * This is the most common KAction used when you do not have a - * corresponding icon (note that it won't appear in the current version - * of the "Edit ToolBar" dialog, because an action needs an icon to be - * plugged in a toolbar...). - * - * @param text The text that will be displayed. - * @param parent The parent of this action. - */ - KPasteTextAction(const QString &text, QObject *parent); - - /** - * Constructs an action with text and an icon; a shortcut may be specified by - * the ampersand character (e.g. \"&Option\" creates a shortcut with key \e O ) - * - * This is the other common KAction used. Use it when you - * \e do have a corresponding icon. - * - * @param icon The icon to display. - * @param text The text that will be displayed. - * @param parent The parent of this action. - */ - KPasteTextAction(const KIcon &icon, const QString &text, QObject *parent); - -private: - KPasteTextActionPrivate * const d; - - Q_PRIVATE_SLOT(d, void _k_menuAboutToShow()) - Q_PRIVATE_SLOT(d, void _k_slotTriggered(QAction*)) -}; - -#endif diff --git a/kdeui/actions/kstandardaction.cpp b/kdeui/actions/kstandardaction.cpp index b4813deb..b69d1854 100644 --- a/kdeui/actions/kstandardaction.cpp +++ b/kdeui/actions/kstandardaction.cpp @@ -40,7 +40,6 @@ #include "kdualaction.h" #include "krecentfilesaction.h" #include "ktogglefullscreenaction.h" -#include "kpastetextaction.h" #include "kactioncollection.h" namespace KStandardAction @@ -156,9 +155,6 @@ KAction *create(StandardAction id, const QObject *recvr, const char *slot, QObje pAction = new KToggleFullScreenAction(parent); pAction->setCheckable(true); break; - case PasteText: - pAction = new KPasteTextAction(parent); - break; // Same as default, but with the app icon case AboutApp: pAction = new KAction(parent); @@ -306,11 +302,6 @@ KAction *paste( const QObject *recvr, const char *slot, QObject *parent ) return KStandardAction::create( Paste, recvr, slot, parent ); } -KAction *pasteText( const QObject *recvr, const char *slot, QObject *parent ) -{ - return KStandardAction::create( PasteText, recvr, slot, parent ); -} - KAction *clear( const QObject *recvr, const char *slot, QObject *parent ) { return KStandardAction::create( Clear, recvr, slot, parent ); diff --git a/kdeui/actions/kstandardaction.h b/kdeui/actions/kstandardaction.h index 1d27d4e3..34e82782 100644 --- a/kdeui/actions/kstandardaction.h +++ b/kdeui/actions/kstandardaction.h @@ -159,7 +159,6 @@ namespace KStandardAction ConfigureNotifications, FullScreen, Clear, - PasteText, SwitchApplicationLanguage }; @@ -346,13 +345,6 @@ namespace KStandardAction */ KDEUI_EXPORT KAction *paste(const QObject *recvr, const char *slot, QObject *parent); - /** - * Paste the contents of clipboard at the current mouse or cursor - * position. Provide a button on the toolbar with the clipboard history - * menu if Klipper is running. - */ - KDEUI_EXPORT KAction *pasteText(const QObject *recvr, const char *slot, QObject *parent); - /** * Clear the content of the focus widget */ diff --git a/kdeui/actions/kstandardaction_p.h b/kdeui/actions/kstandardaction_p.h index da4670b4..ecbd8b49 100644 --- a/kdeui/actions/kstandardaction_p.h +++ b/kdeui/actions/kstandardaction_p.h @@ -57,7 +57,6 @@ static const KStandardActionInfo g_rgActionInfo[] = { Cut, KStandardShortcut::Cut, "edit_cut", I18N_NOOP("Cu&t"), I18N_NOOP("Cut selection to clipboard"), "edit-cut" }, { Copy, KStandardShortcut::Copy, "edit_copy", I18N_NOOP("&Copy"), I18N_NOOP("Copy selection to clipboard"), "edit-copy" }, { Paste, KStandardShortcut::Paste, "edit_paste", I18N_NOOP("&Paste"), I18N_NOOP("Paste clipboard content"), "edit-paste" }, - { PasteText, KStandardShortcut::Paste, "edit_paste", I18N_NOOP("&Paste"), I18N_NOOP("Paste clipboard content"), "edit-paste" }, { Clear, KStandardShortcut::Clear, "edit_clear", I18N_NOOP("C&lear"), 0, "edit-clear" }, { SelectAll, KStandardShortcut::SelectAll, "edit_select_all", I18N_NOOP("Select &All"), 0, "edit-select-all" }, { Deselect, KStandardShortcut::Deselect, "edit_deselect", I18N_NOOP("Dese&lect"), 0, 0 }, diff --git a/kdeui/kernel/kapplication.cpp b/kdeui/kernel/kapplication.cpp index a6edf93e..7fa17807 100644 --- a/kdeui/kernel/kapplication.cpp +++ b/kdeui/kernel/kapplication.cpp @@ -57,7 +57,6 @@ #include "kde_file.h" #include "kstartupinfo.h" #include "kcomponentdata.h" -#include "kstatusnotifieritem.h" #include "kmainwindow.h" #include "kmenu.h" #include "kactioncollection.h" @@ -116,155 +115,6 @@ static void quit_handler(int sig) qApp->quit(); } -class KAppStatusNotifierItem : public KStatusNotifierItem -{ - Q_OBJECT -public: - KAppStatusNotifierItem(const KComponentData &componentData, QObject* parent = nullptr); - -private Q_SLOTS: - void slotActivateRequested(bool active, const QPoint &pos); - void slotSkipTaskBar(); - void slotSkipPager(); - void slotWindowChanged(WId id); - -private: - void updateStatus(const QString &name, const QString &icon); - -private: - QAction* m_skiptaskbaraction; - QAction* m_skippageraction; -}; - -KAppStatusNotifierItem::KAppStatusNotifierItem(const KComponentData &componentData, QObject* parent) - : KStatusNotifierItem(QString::number(::getpid()), parent), - m_skiptaskbaraction(nullptr), - m_skippageraction(nullptr) -{ - setCategory(KStatusNotifierItem::ApplicationStatus); - setStatus(KStatusNotifierItem::Active); - - // TODO: -icon argument override - updateStatus( - componentData.aboutData()->programName(), - componentData.aboutData()->programIconName() - ); - - connect( - this, SIGNAL(activateRequested(bool,QPoint)), - this, SLOT(slotActivateRequested(bool,QPoint)) - ); - - bool skiptaskbar = false; - bool skippager = false; - const QList mainwindows = KMainWindow::memberList(); - foreach (const KMainWindow* mainwindow, mainwindows) { - const WId mainwindowid = mainwindow->winId(); - NETWinInfo netwininfo( - QX11Info::display(), mainwindowid, QX11Info::appRootWindow(), - NET::XAWMState | NET::WMState - ); - if (netwininfo.state() & NET::SkipTaskbar) { - skiptaskbar = true; - } - if (netwininfo.state() & NET::SkipPager) { - skippager = true; - } - } - - m_skiptaskbaraction = new QAction(i18n("Skip &Taskbar"), contextMenu()->contextMenu()); - m_skiptaskbaraction->setCheckable(true); - m_skiptaskbaraction->setChecked(skiptaskbar); - connect(m_skiptaskbaraction, SIGNAL(triggered()), this, SLOT(slotSkipTaskBar())); - actionCollection()->addAction("tray_skiptaskbar", m_skiptaskbaraction); - contextMenu()->addAction(m_skiptaskbaraction); - - m_skippageraction = new QAction(i18n("Skip &Pager"), contextMenu()->contextMenu()); - m_skippageraction->setCheckable(true); - m_skippageraction->setChecked(skippager); - connect(m_skippageraction, SIGNAL(triggered()), this, SLOT(slotSkipPager())); - actionCollection()->addAction("tray_skippager", m_skippageraction); - contextMenu()->addAction(m_skippageraction); - - connect(KWindowSystem::self(), SIGNAL(windowChanged(WId)), this, SLOT(slotWindowChanged(WId))); -} - -void KAppStatusNotifierItem::updateStatus(const QString &name, const QString &icon) -{ - if (!name.isEmpty()) { - setTitle(name); - } else { - setTitle(i18n("KAppStatusNotifierItem")); - } - if (!icon.isEmpty()) { - setIconByName(icon); - } else { - setIconByName("xorg"); - } - setToolTip(icon, name, QString()); -} - -void KAppStatusNotifierItem::slotActivateRequested(bool active, const QPoint &pos) -{ - Q_UNUSED(active); - Q_UNUSED(pos); - const QList mainwindows = KMainWindow::memberList(); - foreach (const KMainWindow* mainwindow, mainwindows) { - const WId mainwindowid = mainwindow->winId(); - NETWinInfo netwininfo( - QX11Info::display(), mainwindowid, QX11Info::appRootWindow(), - NET::XAWMState | NET::WMState - ); - kDebug() << "window state is" << mainwindowid << netwininfo.mappingState(); - if (netwininfo.mappingState() != NET::Visible) { - KWindowSystem::activateWindow(mainwindowid); - } else { - KWindowSystem::minimizeWindow(mainwindowid); - } - } -} - -void KAppStatusNotifierItem::slotSkipTaskBar() -{ - const bool skiptaskbar = m_skiptaskbaraction->isChecked(); - const QList mainwindows = KMainWindow::memberList(); - foreach (const KMainWindow* mainwindow, mainwindows) { - const WId mainwindowid = mainwindow->winId(); - if (skiptaskbar) { - KWindowSystem::clearState(mainwindowid, NET::SkipTaskbar); - } else { - KWindowSystem::setState(mainwindowid, NET::SkipTaskbar); - } - } - m_skiptaskbaraction->setChecked(!skiptaskbar); -} - -void KAppStatusNotifierItem::slotSkipPager() -{ - const bool skippager = m_skippageraction->isChecked(); - const QList mainwindows = KMainWindow::memberList(); - foreach (const KMainWindow* mainwindow, mainwindows) { - const WId mainwindowid = mainwindow->winId(); - if (skippager) { - KWindowSystem::clearState(mainwindowid, NET::SkipPager); - } else { - KWindowSystem::setState(mainwindowid, NET::SkipPager); - } - } - m_skippageraction->setChecked(!skippager); -} - -void KAppStatusNotifierItem::slotWindowChanged(WId id) -{ - Q_UNUSED(id); - QString subtitle; - const QList mainwindows = KMainWindow::memberList(); - foreach (const KMainWindow* mainwindow, mainwindows) { - subtitle.append(QString::fromLatin1("

%1

").arg(mainwindow->windowTitle())); - } - setToolTipSubTitle(subtitle); -} - /* Private data to make keeping binary compatibility easier */ @@ -279,7 +129,6 @@ public: , session_save(false) , pSessionConfig(nullptr) , bSessionManagement(true) - , statusNotifier(nullptr) { } @@ -291,7 +140,6 @@ public: , session_save(false) , pSessionConfig(nullptr) , bSessionManagement(true) - , statusNotifier(nullptr) { } @@ -303,7 +151,6 @@ public: , session_save(false) , pSessionConfig(nullptr) , bSessionManagement(true) - , statusNotifier(nullptr) { } @@ -325,34 +172,8 @@ public: QString sessionKey; KConfig* pSessionConfig; //instance specific application config object bool bSessionManagement; - - KAppStatusNotifierItem *statusNotifier; }; - -void kAppCreateTray() -{ - if (!kapp || kapp->d->statusNotifier) { - return; - } - KCmdLineArgs *args = KCmdLineArgs::parsedArgs("kde"); - if (!args) { - return; - } - if (args->isSet("tray")) { - kapp->d->statusNotifier = new KAppStatusNotifierItem(kapp->d->componentData, kapp); - } -} - -void kAppDestroyTray() -{ - if (!kapp) { - return; - } - delete kapp->d->statusNotifier; - kapp->d->statusNotifier = nullptr; -} - static QList< QWeakPointer< QWidget > > *x11Filter = 0; /** @@ -745,16 +566,6 @@ void KApplication::saveState( QSessionManager& sm ) delete d->pSessionConfig; d->pSessionConfig = 0; - // tell the session manager about our new lifecycle - QStringList restartCommand = sm.restartCommand(); - - KCmdLineArgs *args = KCmdLineArgs::parsedArgs("kde"); - if (args && args->isSet("tray")) { - restartCommand.append(QLatin1String("-tray")); - } - - sm.setRestartCommand( restartCommand ); - // finally: do session management bool canceled = false; foreach(KSessionManager* it, KSessionManager::sessionClients()) { @@ -1010,4 +821,3 @@ void KApplicationPrivate::_k_disableAutorestartSlot() } #include "moc_kapplication.cpp" -#include "kapplication.moc" diff --git a/kdeui/notifications/kdbusmenu_p.cpp b/kdeui/notifications/kdbusmenu_p.cpp deleted file mode 100644 index 3724f9ab..00000000 --- a/kdeui/notifications/kdbusmenu_p.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2023 Ivailo Monev - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "kdbusmenu_p.h" - -QDBusArgument& operator<<(QDBusArgument &argument, const KDBusMenu &kdbusmenu) -{ - argument.beginStructure(); - argument << kdbusmenu.icon; - argument << kdbusmenu.title; - argument << kdbusmenu.icondata; - argument.endStructure(); - return argument; -} - -const QDBusArgument& operator>>(const QDBusArgument &argument, KDBusMenu &kdbusmenu) -{ - argument.beginStructure(); - argument >> kdbusmenu.icon; - argument >> kdbusmenu.title; - argument >> kdbusmenu.icondata; - argument.endStructure(); - return argument; -} - - -QDBusArgument& operator<<(QDBusArgument &argument, const KDBusMenuAction &kdbusmenuaction) -{ - argument.beginStructure(); - argument << kdbusmenuaction.id; - argument << kdbusmenuaction.text << kdbusmenuaction.icon; - argument << kdbusmenuaction.tooltip << kdbusmenuaction.statustip << kdbusmenuaction.whatsthis; - argument << kdbusmenuaction.separator << kdbusmenuaction.checkable << kdbusmenuaction.checked << kdbusmenuaction.enabled << kdbusmenuaction.visible; - argument << kdbusmenuaction.shortcuts; - argument << kdbusmenuaction.icondata; - argument << kdbusmenuaction.title; - argument << kdbusmenuaction.exclusive; - argument << kdbusmenuaction.submenu; - argument.endStructure(); - return argument; -} - -const QDBusArgument& operator>>(const QDBusArgument &argument, KDBusMenuAction &kdbusmenuaction) -{ - argument.beginStructure(); - argument >> kdbusmenuaction.id; - argument >> kdbusmenuaction.text >> kdbusmenuaction.icon; - argument >> kdbusmenuaction.tooltip >> kdbusmenuaction.statustip >> kdbusmenuaction.whatsthis; - argument >> kdbusmenuaction.separator >> kdbusmenuaction.checkable >> kdbusmenuaction.checked >> kdbusmenuaction.enabled >> kdbusmenuaction.visible; - argument >> kdbusmenuaction.shortcuts; - argument >> kdbusmenuaction.icondata; - argument >> kdbusmenuaction.title; - argument >> kdbusmenuaction.exclusive; - argument >> kdbusmenuaction.submenu; - argument.endStructure(); - return argument; -} diff --git a/kdeui/notifications/kdbusmenu_p.h b/kdeui/notifications/kdbusmenu_p.h deleted file mode 100644 index cf2245f3..00000000 --- a/kdeui/notifications/kdbusmenu_p.h +++ /dev/null @@ -1,148 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2023 Ivailo Monev - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef KDBUSMENU_H -#define KDBUSMENU_H - -#include "kiconloader.h" -#include "kdebug.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -static const int s_kdbusmenuiconsize = KIconLoader::SizeSmall; -static const QByteArray s_kdbusmenuiconformat = QImageWriter::defaultImageFormat(); -// see kdebug.areas -static const int s_kdbusmenuarea = 301; - -struct KDBusMenu -{ - QString icon; - QString title; - QByteArray icondata; -}; -Q_DECLARE_METATYPE(KDBusMenu); - -QDBusArgument& operator<<(QDBusArgument &argument, const KDBusMenu &kdbusmenu); -const QDBusArgument& operator>>(const QDBusArgument &argument, KDBusMenu &kdbusmenu); - -struct KDBusMenuAction -{ - quint64 id; - QString text; - QString icon; - QString tooltip; - QString statustip; - QString whatsthis; - bool separator; - bool checkable; - bool checked; - bool enabled; - bool visible; - QStringList shortcuts; - QByteArray icondata; - bool title; - bool exclusive; - bool submenu; -}; -Q_DECLARE_METATYPE(KDBusMenuAction); -Q_DECLARE_METATYPE(QList); - -QDBusArgument& operator<<(QDBusArgument &argument, const KDBusMenuAction &kdbusmenuaction); -const QDBusArgument& operator>>(const QDBusArgument &argument, KDBusMenuAction &kdbusmenuaction); - -static quint64 kDBusMenuActionID(const QAction *action) -{ - return quint64(quintptr(action)); -} - -static QByteArray kDBusMenuIconData(const QIcon &actionicon) -{ - QBuffer iconbuffer; - QPixmap iconpixmap = actionicon.pixmap(s_kdbusmenuiconsize); - if (iconpixmap.isNull()) { - // it is common for actions to not have a icon - kDebug(s_kdbusmenuarea) << "Action/menu icon name is empty and icon pixmap is null"; - return QByteArray(); - } - const bool iconsaved = iconpixmap.save(&iconbuffer, s_kdbusmenuiconformat); - if (!iconsaved) { - kWarning(s_kdbusmenuarea) << "Could not save action/menu icon pixmap"; - return QByteArray(); - } - return iconbuffer.data(); -} - -static QIcon kDBusMenuIcon(const QByteArray &actionicondata) -{ - if (actionicondata.isEmpty()) { - // see kDBusMenuIconData() - return QIcon(); - } - QPixmap actionpixmap; - const bool pixmaploaded = actionpixmap.loadFromData(actionicondata, s_kdbusmenuiconformat); - if (!pixmaploaded) { - kWarning(s_kdbusmenuarea) << "Could not load action/menu icon pixmap"; - return QIcon(); - } - return QIcon(actionpixmap); -} - -static QAction* kDBusMenuAction(QMenu *menu, const KDBusMenuAction &actionproperties) -{ - QAction* action = new QAction(menu); - action->setText(actionproperties.text); - action->setToolTip(actionproperties.tooltip); - action->setStatusTip(actionproperties.statustip); - action->setWhatsThis(actionproperties.whatsthis); - action->setSeparator(actionproperties.separator); - action->setCheckable(actionproperties.checkable); - action->setChecked(actionproperties.checked); - action->setEnabled(actionproperties.enabled); - action->setVisible(actionproperties.visible); - QList shortcuts; - shortcuts.reserve(actionproperties.shortcuts.size()); - foreach (const QString &keysequence, actionproperties.shortcuts) { - shortcuts.append(QKeySequence::fromString(keysequence)); - } - action->setShortcuts(shortcuts); - if (actionproperties.exclusive) { - QActionGroup *actiongroup = new QActionGroup(action); - actiongroup->addAction(action); - } - action->setData(QVariant(actionproperties.id)); - return action; -} - -static void kDBusSetIcon(QAction *action, const QIcon &icon) -{ - // because KIcon is never null setting icon on separator makes it look odd - if (action->isSeparator()) { - return; - } - action->setIcon(icon); -} - -#endif // KDBUSMENU_H diff --git a/kdeui/notifications/kdbusmenuexporter.cpp b/kdeui/notifications/kdbusmenuexporter.cpp deleted file mode 100644 index e02578de..00000000 --- a/kdeui/notifications/kdbusmenuexporter.cpp +++ /dev/null @@ -1,225 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2023 Ivailo Monev - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "kdbusmenuexporter.h" -#include "kdebug.h" -#include "kdbusmenu_p.h" - -#include -#include -#include -#include -#include - -class KDBusMenuAdaptor: public QDBusAbstractAdaptor -{ - Q_OBJECT - Q_CLASSINFO("D-Bus Interface", "org.kde.DBusMenu") -public: - KDBusMenuAdaptor(KDBusMenuExporter *exporter, QMenu* menu); - -public Q_SLOTS: - KDBusMenu menu() const; - - QList actions(quint64 actionid = 0) const; - bool triggerAction(quint64 actionid) const; - -private: - KDBusMenuExporter* m_exporter; - QPointer m_menu; -}; - -KDBusMenuAdaptor::KDBusMenuAdaptor(KDBusMenuExporter *exporter, QMenu* menu) - : QDBusAbstractAdaptor(exporter), - m_exporter(exporter), - m_menu(menu) -{ - qDBusRegisterMetaType(); - qDBusRegisterMetaType(); - qDBusRegisterMetaType>(); -} - -KDBusMenu KDBusMenuAdaptor::menu() const -{ - KDBusMenu result; - if (m_menu.isNull()) { - kWarning(s_kdbusmenuarea) << "Menu is null"; - return result; - } - // NOTE: KStatusNotifierItem adds actions to the menu when aboutToShow is emitted - const bool menusignaled = QMetaObject::invokeMethod(m_menu.data(), "aboutToShow", Qt::DirectConnection); - if (!menusignaled) { - kWarning(s_kdbusmenuarea) << "Could not invoke menu aboutToShow() signal"; - } - const QIcon menuicon = m_menu->icon(); - result.icon = menuicon.name(); - result.title = m_menu->title(); - if (result.icon.isEmpty()) { - result.icondata = kDBusMenuIconData(menuicon); - } - return result; -} - -QList KDBusMenuAdaptor::actions(quint64 actionid) const -{ - QList result; - if (m_menu.isNull()) { - kWarning(s_kdbusmenuarea) << "Menu is null"; - return result; - } - QList actionslist; - if (actionid == 0) { - actionslist = m_menu->actions(); - } else { - foreach (const QAction* action, m_menu->actions()) { - const quint64 itactionid = kDBusMenuActionID(action); - if (actionid == itactionid) { - const QMenu* actionmenu = action->menu(); - if (!actionmenu) { - kWarning(s_kdbusmenuarea) << "Requested actions for non-menu action" << actionid; - return result; - } - actionslist = actionmenu->actions(); - } - } - } - foreach (QAction* action, actionslist) { - const quint64 itactionid = kDBusMenuActionID(action); - kDebug(s_kdbusmenuarea) << "Exporting action" << itactionid; - KDBusMenuAction actionproperties; - // see kdeui/widgets/kmenu.cpp - actionproperties.title = (action->objectName() == QLatin1String("kmenu_title")); - if (actionproperties.title) { - const QWidgetAction *actionwidget = qobject_cast(action); - if (!actionwidget) { - kWarning(s_kdbusmenuarea) << "Title has no widget" << itactionid; - } else { - const QToolButton *actionbutton = qobject_cast(actionwidget->defaultWidget()); - if (!actionbutton) { - kWarning(s_kdbusmenuarea) << "Title has no button" << itactionid; - } else { - action = actionbutton->defaultAction(); - } - } - } - actionproperties.id = itactionid; - actionproperties.text = action->text(); - actionproperties.icon = m_exporter->iconNameForAction(action); - actionproperties.tooltip = action->toolTip(); - actionproperties.statustip = action->statusTip(); - actionproperties.whatsthis = action->whatsThis(); - actionproperties.separator = action->isSeparator(); - actionproperties.checkable = action->isCheckable(); - actionproperties.checked = action->isChecked(); - actionproperties.enabled = action->isEnabled(); - actionproperties.visible = action->isVisible(); - QStringList shortcuts; - foreach (const QKeySequence &keysequence, action->shortcuts()) { - shortcuts.append(keysequence.toString()); - } - actionproperties.shortcuts = shortcuts; - if (actionproperties.icon.isEmpty()) { - actionproperties.icondata = kDBusMenuIconData(action->icon()); - } - const QActionGroup* actiongroup = action->actionGroup(); - actionproperties.exclusive = (actiongroup && actiongroup->isExclusive()); - const QMenu* actionmenu = action->menu(); - actionproperties.submenu = (actionmenu != nullptr); - result.append(actionproperties); - } - return result; -} - -bool KDBusMenuAdaptor::triggerAction(quint64 actionid) const -{ - kDebug(s_kdbusmenuarea) << "Triggering action" << actionid; - if (m_menu.isNull()) { - kWarning(s_kdbusmenuarea) << "Menu is null"; - return false; - } - foreach (QAction* action, m_menu->actions()) { - quint64 itactionid = kDBusMenuActionID(action); - if (itactionid == actionid) { - return QMetaObject::invokeMethod(action, "triggered"); - } - const QMenu* actionmenu = action->menu(); - if (actionmenu) { - foreach (QAction* subaction, actionmenu->actions()) { - itactionid = kDBusMenuActionID(subaction); - if (itactionid == actionid) { - return QMetaObject::invokeMethod(subaction, "triggered"); - } - } - } - } - kWarning(s_kdbusmenuarea) << "Could not find action for" << actionid; - return false; -} - - -class KDBusMenuExporterPrivate -{ -public: - KDBusMenuExporterPrivate(); - - KDBusMenuAdaptor* adaptor; - QString objectpath; - QString connectionname; -}; - -KDBusMenuExporterPrivate::KDBusMenuExporterPrivate() - : adaptor(nullptr) -{ -} - - -KDBusMenuExporter::KDBusMenuExporter(const QString &objectpath, QMenu *menu, const QDBusConnection &connection) - : QObject(menu), - d(new KDBusMenuExporterPrivate()) -{ - kDebug(s_kdbusmenuarea) << "Exporting menu" << objectpath; - - d->adaptor = new KDBusMenuAdaptor(this, menu); - d->objectpath = objectpath; - d->connectionname = connection.name(); - - QDBusConnection dbusconnection(connection.name()); - dbusconnection.registerObject(objectpath, this); -} - -KDBusMenuExporter::~KDBusMenuExporter() -{ - QDBusConnection dbusconnection(d->connectionname); - dbusconnection.unregisterObject(d->objectpath); - delete d; -} - -QString KDBusMenuExporter::iconNameForAction(QAction *action) -{ - if (!action) { - return QString(); - } - const QIcon icon = action->icon(); - if (action->isIconVisibleInMenu() && !icon.isNull()) { - return icon.name(); - } - return QString(); -} - -#include "kdbusmenuexporter.moc" diff --git a/kdeui/notifications/kdbusmenuexporter.h b/kdeui/notifications/kdbusmenuexporter.h deleted file mode 100644 index b64df9dd..00000000 --- a/kdeui/notifications/kdbusmenuexporter.h +++ /dev/null @@ -1,67 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2023 Ivailo Monev - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef KDBUSMENUEXPORTER_H -#define KDBUSMENUEXPORTER_H - -#include "kdeui_export.h" - -#include -#include -#include - -class KDBusMenuExporterPrivate; - -/*! - D-Bus menu exporting class - - KDBusMenuExporter class can be used to export menu (QMenu or KMenu) from one application - to other applications. - - @since 4.23 - @see KDBusMenuImporter -*/ -class KDEUI_EXPORT KDBusMenuExporter : public QObject -{ - Q_OBJECT -public: - /*! - @brief Creates menu exporter for the given object path @p objectpath, path @p path and - connection @p connection. - @note The exporter is parented to the menu @p menu thus when the menu is destroyed the - exporter becomes non-operational and should not be used. - */ - KDBusMenuExporter(const QString &objectpath, QMenu *menu, const QDBusConnection &connection = QDBusConnection::sessionBus()); - virtual ~KDBusMenuExporter(); - -protected: - /*! - @brief Reimplement to provide custom icons for actions and menus. The default - implementation returns the action icon name. - */ - virtual QString iconNameForAction(QAction *action); - -private: - KDBusMenuExporterPrivate *d; - Q_DISABLE_COPY(KDBusMenuExporter); - - friend class KDBusMenuAdaptor; -}; - -#endif // KDBUSMENUEXPORTER_H diff --git a/kdeui/notifications/kdbusmenuimporter.cpp b/kdeui/notifications/kdbusmenuimporter.cpp deleted file mode 100644 index 41c313d0..00000000 --- a/kdeui/notifications/kdbusmenuimporter.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2023 Ivailo Monev - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "kdbusmenuimporter.h" -#include "kmenu.h" -#include "kdebug.h" -#include "kdbusmenu_p.h" - -#include -#include -#include - -class KDBusMenuImporterPrivate -{ -public: - KDBusMenuImporterPrivate(); - - QDBusInterface* interface; - QMenu* menu; -}; - -KDBusMenuImporterPrivate::KDBusMenuImporterPrivate() - : interface(nullptr), - menu(nullptr) -{ -} - - -KDBusMenuImporter::KDBusMenuImporter(const QString &service, const QString &path, QObject *parent) - : QObject(parent), - d(new KDBusMenuImporterPrivate()) -{ - kDebug(s_kdbusmenuarea) << "Importing menu" << service << path; - - qDBusRegisterMetaType(); - qDBusRegisterMetaType(); - qDBusRegisterMetaType>(); - - QDBusConnection dbusconnection = QDBusConnection::sessionBus(); - d->interface = new QDBusInterface(service, path, QString::fromLatin1("org.kde.DBusMenu"), dbusconnection, this); -} - -KDBusMenuImporter::~KDBusMenuImporter() -{ - delete d; -} - -QMenu* KDBusMenuImporter::menu() const -{ - return d->menu; -} - -void KDBusMenuImporter::updateMenu() -{ - kDebug(s_kdbusmenuarea) << "Updating menu"; - if (!d->menu) { - d->menu = createMenu(nullptr); - } else { - d->menu->clear(); - } - QDBusReply menureply = d->interface->call("menu"); - if (!menureply.isValid()) { - kWarning(s_kdbusmenuarea) << "Invalid menu reply" << menureply.error(); - return; - } - const KDBusMenu menuproperties = menureply.value(); - d->menu->setTitle(menuproperties.title); - QIcon menuicon = iconForName(menuproperties.icon); - if (menuicon.isNull()) { - menuicon = kDBusMenuIcon(menuproperties.icondata); - } - d->menu->setIcon(menuicon); - - QDBusReply> actionsreply = d->interface->call("actions"); - if (!actionsreply.isValid()) { - kWarning(s_kdbusmenuarea) << "Invalid actions reply" << actionsreply.error(); - return; - } - foreach (const KDBusMenuAction &actionproperties, actionsreply.value()) { - const quint64 actionid = actionproperties.id; - kDebug(s_kdbusmenuarea) << "Importing action" << actionid; - QIcon actionicon = iconForName(actionproperties.icon); - if (actionicon.isNull()) { - actionicon = kDBusMenuIcon(actionproperties.icondata); - } - QAction* action = nullptr; - if (actionproperties.title) { - // see kdeui/widgets/kmenu.cpp - action = KMenu::titleAction(actionicon, actionproperties.text, d->menu); - } else { - action = kDBusMenuAction(d->menu, actionproperties); - } - if (actionproperties.submenu) { - QDBusReply> subactionsreply = d->interface->call("actions", actionid); - if (!subactionsreply.isValid()) { - kWarning(s_kdbusmenuarea) << "Invalid sub-actions reply" << subactionsreply.error(); - return; - } - QMenu* subactionmenu = createMenu(d->menu); - foreach (const KDBusMenuAction &subactionproperties, subactionsreply.value()) { - QIcon subactionicon = iconForName(subactionproperties.icon); - if (subactionicon.isNull()) { - subactionicon = kDBusMenuIcon(subactionproperties.icondata); - } - QAction* subaction = kDBusMenuAction(subactionmenu, subactionproperties); - kDBusSetIcon(subaction, subactionicon); - connect(subaction, SIGNAL(triggered()), this, SLOT(slotActionTriggered())); - subactionmenu->addAction(subaction); - } - action->setMenu(subactionmenu); - } - kDBusSetIcon(action, actionicon); - connect(action, SIGNAL(triggered()), this, SLOT(slotActionTriggered())); - d->menu->addAction(action); - } - emit menuUpdated(); -} - -QMenu* KDBusMenuImporter::createMenu(QWidget *parent) -{ - return new QMenu(parent); -} - -QIcon KDBusMenuImporter::iconForName(const QString &name) -{ - return QIcon::fromTheme(name); -} - -void KDBusMenuImporter::slotActionTriggered() -{ - QAction* action = qobject_cast(sender()); - const quint64 actionid = action->data().toULongLong(); - kDebug(s_kdbusmenuarea) << "Action triggered" << actionid; - QDBusReply triggerreply = d->interface->call("triggerAction", actionid); - if (!triggerreply.isValid()) { - kWarning(s_kdbusmenuarea) << "Invalid action trigger reply" << triggerreply.error(); - return; - } - if (triggerreply.value() != true) { - kWarning(s_kdbusmenuarea) << "Could not trigger action" << actionid; - } -} diff --git a/kdeui/notifications/kdbusmenuimporter.h b/kdeui/notifications/kdbusmenuimporter.h deleted file mode 100644 index e15dc4ef..00000000 --- a/kdeui/notifications/kdbusmenuimporter.h +++ /dev/null @@ -1,89 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 2023 Ivailo Monev - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef KDBUSMENUIMPORTER_H -#define KDBUSMENUIMPORTER_H - -#include "kdeui_export.h" - -#include -#include -#include -#include - -class KDBusMenuImporterPrivate; - -/*! - D-Bus menu importing class - - KDBusMenuImporter class can be used to import menu (QMenu or KMenu) from other application - exported via KDBusMenuExporter. - - @since 4.23 - @see KDBusMenuExporter -*/ -class KDEUI_EXPORT KDBusMenuImporter : public QObject -{ - Q_OBJECT -public: - /*! - @brief Creates menu importer for the given service @p service and path @p path. - */ - KDBusMenuImporter(const QString &service, const QString &path, QObject *parent = 0); - virtual ~KDBusMenuImporter(); - - /*! - @brief Returns nearly perfect copy of the exported menu, if any. - */ - QMenu* menu() const; - -public Q_SLOTS: - /*! - @brief Forces update of the menu, must be called for @p KDBusMenuImporter::menu() to return - valid menu. - */ - void updateMenu(); - -Q_SIGNALS: - /*! - @brief Signals that the menu was updated. - */ - void menuUpdated(); - -protected: - /*! - @brief Reimplement to provide custom menus, affects the root menu and sub-menus. The - default implementation simply creates QMenu parented to @p parent. - */ - virtual QMenu* createMenu(QWidget *parent); - /*! - @brief Reimplement to provide custom icons for actions and menus. The default - implementation returns the result of QIcon::fromTheme() for @p name. - */ - virtual QIcon iconForName(const QString &name); - -private Q_SLOTS: - void slotActionTriggered(); - -private: - KDBusMenuImporterPrivate *d; - Q_DISABLE_COPY(KDBusMenuImporter); -}; - -#endif // KDBUSMENUIMPORTER_H diff --git a/kdeui/notifications/kstatusnotifieritem.cpp b/kdeui/notifications/kstatusnotifieritem.cpp deleted file mode 100644 index 4bf11aa8..00000000 --- a/kdeui/notifications/kstatusnotifieritem.cpp +++ /dev/null @@ -1,921 +0,0 @@ -/* This file is part of the KDE libraries - Copyright 2009 by Marco Martin - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License (LGPL) as published by the Free Software Foundation; - either version 2 of the License, or (at your option) any later - version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "config.h" -#include "kstatusnotifieritem.h" -#include "kstatusnotifieritemprivate_p.h" -#include "kstatusnotifieritemdbus_p.h" - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "statusnotifieritemadaptor.h" - -static const QString s_statusNotifierWatcherServiceName("org.kde.StatusNotifierWatcher"); - -KStatusNotifierItem::KStatusNotifierItem(QObject *parent) - : QObject(parent), - d(new KStatusNotifierItemPrivate(this)) -{ - d->init(QString()); -} - - -KStatusNotifierItem::KStatusNotifierItem(const QString &id, QObject *parent) - : QObject(parent), - d(new KStatusNotifierItemPrivate(this)) -{ - d->init(id); -} - -KStatusNotifierItem::~KStatusNotifierItem() -{ - delete d->statusNotifierWatcher; - delete d->systemTrayIcon; - if (!qApp->closingDown()) { - delete d->menu; - } - delete d; - KGlobal::deref(); -} - -QString KStatusNotifierItem::id() const -{ - //kDebug(299) << "id requested" << d->id; - return d->id; -} - -void KStatusNotifierItem::setCategory(const ItemCategory category) -{ - d->category = category; -} - -KStatusNotifierItem::ItemStatus KStatusNotifierItem::status() const -{ - return d->status; -} - -KStatusNotifierItem::ItemCategory KStatusNotifierItem::category() const -{ - return d->category; -} - -void KStatusNotifierItem::setTitle(const QString &title) -{ - d->title = title; -} - -void KStatusNotifierItem::setStatus(const ItemStatus status) -{ - if (d->status == status) { - return; - } - - d->status = status; - emit d->statusNotifierItemDBus->NewStatus(metaObject()->enumerator(metaObject()->indexOfEnumerator("ItemStatus")).valueToKey(d->status)); - - if (d->systemTrayIcon) { - d->syncLegacySystemTrayIcon(); - } -} - - - -//normal icon - -void KStatusNotifierItem::setIconByName(const QString &name) -{ - if (d->iconName == name) { - return; - } - - d->serializedIcon = KDbusImageVector(); - d->iconName = name; - emit d->statusNotifierItemDBus->NewIcon(); - if (d->systemTrayIcon) { - d->systemTrayIcon->setIcon(KIcon(name)); - } -} - -QString KStatusNotifierItem::iconName() const -{ - return d->iconName; -} - -void KStatusNotifierItem::setIconByPixmap(const QIcon &icon) -{ - if (d->icon.cacheKey() == icon.cacheKey()) { - return; - } - - d->iconName.clear(); - d->serializedIcon = d->iconToVector(icon); - emit d->statusNotifierItemDBus->NewIcon(); - - d->icon = icon; - if (d->systemTrayIcon) { - d->systemTrayIcon->setIcon(icon); - } -} - -QIcon KStatusNotifierItem::iconPixmap() const -{ - return d->icon; -} - -void KStatusNotifierItem::setOverlayIconByName(const QString &name) -{ - if (d->overlayIconName == name) { - return; - } - - d->overlayIconName = name; - emit d->statusNotifierItemDBus->NewOverlayIcon(); - if (d->systemTrayIcon) { - QPixmap iconPixmap = KIcon(d->iconName).pixmap(KIconLoader::SizeSmallMedium, KIconLoader::SizeSmallMedium); - if (!name.isEmpty()) { - QPixmap overlayPixmap = KIcon(d->overlayIconName).pixmap(KIconLoader::SizeSmallMedium/2, KIconLoader::SizeSmallMedium/2); - QPainter p(&iconPixmap); - p.drawPixmap(iconPixmap.width()-overlayPixmap.width(), iconPixmap.height()-overlayPixmap.height(), overlayPixmap); - p.end(); - } - d->systemTrayIcon->setIcon(iconPixmap); - } -} - -QString KStatusNotifierItem::overlayIconName() const -{ - return d->overlayIconName; -} - -void KStatusNotifierItem::setOverlayIconByPixmap(const QIcon &icon) -{ - if (d->overlayIconName.isEmpty() && d->overlayIcon.cacheKey() == icon.cacheKey()) { - return; - } - - d->overlayIconName.clear(); - d->serializedOverlayIcon = d->iconToVector(icon); - emit d->statusNotifierItemDBus->NewOverlayIcon(); - - d->overlayIcon = icon; - if (d->systemTrayIcon) { - QPixmap iconPixmap = d->icon.pixmap(KIconLoader::SizeSmallMedium, KIconLoader::SizeSmallMedium); - QPixmap overlayPixmap = d->overlayIcon.pixmap(KIconLoader::SizeSmallMedium/2, KIconLoader::SizeSmallMedium/2); - - QPainter p(&iconPixmap); - p.drawPixmap(iconPixmap.width()-overlayPixmap.width(), iconPixmap.height()-overlayPixmap.height(), overlayPixmap); - p.end(); - d->systemTrayIcon->setIcon(iconPixmap); - } -} - -QIcon KStatusNotifierItem::overlayIconPixmap() const -{ - return d->overlayIcon; -} - -//Icons for requesting attention state - -void KStatusNotifierItem::setAttentionIconByName(const QString &name) -{ - if (d->attentionIconName == name) { - return; - } - - d->serializedAttentionIcon = KDbusImageVector(); - d->attentionIconName = name; - emit d->statusNotifierItemDBus->NewAttentionIcon(); -} - -QString KStatusNotifierItem::attentionIconName() const -{ - return d->attentionIconName; -} - -void KStatusNotifierItem::setAttentionIconByPixmap(const QIcon &icon) -{ - if (d->attentionIconName.isEmpty() && d->attentionIcon.cacheKey() == icon.cacheKey()) { - return; - } - - d->attentionIconName.clear(); - d->serializedAttentionIcon = d->iconToVector(icon); - d->attentionIcon = icon; - emit d->statusNotifierItemDBus->NewAttentionIcon(); -} - -QIcon KStatusNotifierItem::attentionIconPixmap() const -{ - return d->attentionIcon; -} - -//ToolTip - -void KStatusNotifierItem::setToolTip(const QString &iconName, const QString &title, const QString &subTitle) -{ - if (d->toolTipIconName == iconName && - d->toolTipTitle == title && - d->toolTipSubTitle == subTitle) { - return; - } - - d->serializedToolTipIcon = KDbusImageVector(); - d->toolTipIconName = iconName; - - d->toolTipTitle = title; - if (d->systemTrayIcon) { - d->systemTrayIcon->setToolTip(title); - } - - d->toolTipSubTitle = subTitle; - emit d->statusNotifierItemDBus->NewToolTip(); -} - -void KStatusNotifierItem::setToolTip(const QIcon &icon, const QString &title, const QString &subTitle) -{ - if (d->toolTipIconName.isEmpty() && d->toolTipIcon.cacheKey() == icon.cacheKey() && - d->toolTipTitle == title && - d->toolTipSubTitle == subTitle) { - return; - } - - d->toolTipIconName.clear(); - d->serializedToolTipIcon = d->iconToVector(icon); - d->toolTipIcon = icon; - - d->toolTipTitle = title; - if (d->systemTrayIcon) { - d->systemTrayIcon->setToolTip(title); - } - - d->toolTipSubTitle = subTitle; - emit d->statusNotifierItemDBus->NewToolTip(); -} - -void KStatusNotifierItem::setToolTipIconByName(const QString &name) -{ - if (d->toolTipIconName == name) { - return; - } - - d->serializedToolTipIcon = KDbusImageVector(); - d->toolTipIconName = name; - emit d->statusNotifierItemDBus->NewToolTip(); -} - -QString KStatusNotifierItem::toolTipIconName() const -{ - return d->toolTipIconName; -} - -void KStatusNotifierItem::setToolTipIconByPixmap(const QIcon &icon) -{ - if (d->toolTipIconName.isEmpty() && d->toolTipIcon.cacheKey() == icon.cacheKey()) { - return; - } - - d->toolTipIconName.clear(); - d->serializedToolTipIcon = d->iconToVector(icon); - d->toolTipIcon = icon; - emit d->statusNotifierItemDBus->NewToolTip(); -} - -QIcon KStatusNotifierItem::toolTipIconPixmap() const -{ - return d->toolTipIcon; -} - -void KStatusNotifierItem::setToolTipTitle(const QString &title) -{ - if (d->toolTipTitle == title) { - return; - } - - d->toolTipTitle = title; - emit d->statusNotifierItemDBus->NewToolTip(); - if (d->systemTrayIcon) { - d->systemTrayIcon->setToolTip(title); - } -} - -QString KStatusNotifierItem::toolTipTitle() const -{ - return d->toolTipTitle; -} - -void KStatusNotifierItem::setToolTipSubTitle(const QString &subTitle) -{ - if (d->toolTipSubTitle == subTitle) { - return; - } - - d->toolTipSubTitle = subTitle; - emit d->statusNotifierItemDBus->NewToolTip(); -} - -QString KStatusNotifierItem::toolTipSubTitle() const -{ - return d->toolTipSubTitle; -} - -void KStatusNotifierItem::setContextMenu(KMenu *menu) -{ - if (d->menu && d->menu != menu) { - d->menu->removeEventFilter(this); - delete d->menu; - } - - if (!menu) { - d->menu = 0; - return; - } - - if (d->systemTrayIcon) { - d->systemTrayIcon->setContextMenu(menu); - } else if (d->menu != menu) { - if (getenv("KSNI_NO_DBUSMENU")) { - // This is a hack to make it possible to disable DBusMenu in an - // application. The string "/NO_DBUSMENU" must be the same as in - // DBusSystemTrayWidget::findDBusMenuInterface() in the Plasma - // systemtray applet. - d->menuObjectPath = "/NO_DBUSMENU"; - menu->installEventFilter(this); - } else { - d->menuObjectPath = "/MenuBar"; - new KDBusMenuExporter(d->menuObjectPath, menu, d->statusNotifierItemDBus->dbusConnection()); - } - - connect(menu, SIGNAL(aboutToShow()), this, SLOT(contextMenuAboutToShow())); - } - - d->menu = menu; - d->menu->setParent(0); -} - -KMenu *KStatusNotifierItem::contextMenu() const -{ - return d->menu; -} - -void KStatusNotifierItem::setAssociatedWidget(QWidget *associatedWidget) -{ - if (associatedWidget) { - d->associatedWidget = associatedWidget->window(); - } else { - d->associatedWidget = 0; - } - - if (d->systemTrayIcon) { - delete d->systemTrayIcon; - d->systemTrayIcon = 0; - d->setLegacySystemTrayEnabled(true); - } - - if (d->associatedWidget && d->associatedWidget != d->menu) { - QAction *action = d->actionCollection->action("minimizeRestore"); - - if (!action) { - action = d->actionCollection->addAction("minimizeRestore"); - action->setText(i18n("&Minimize")); - connect(action, SIGNAL(triggered(bool)), this, SLOT(minimizeRestore())); - } - -#ifdef Q_WS_X11 - KWindowInfo info = KWindowSystem::windowInfo(d->associatedWidget->winId(), NET::WMDesktop); - d->onAllDesktops = info.onAllDesktops(); -#else - d->onAllDesktops = false; -#endif - } else { - if (d->menu && d->hasQuit) { - QAction *action = d->actionCollection->action("minimizeRestore"); - if (action) { - d->menu->removeAction(action); - } - } - - d->onAllDesktops = false; - } -} - -QWidget *KStatusNotifierItem::associatedWidget() const -{ - return d->associatedWidget; -} - -KActionCollection *KStatusNotifierItem::actionCollection() const -{ - return d->actionCollection; -} - -void KStatusNotifierItem::setStandardActionsEnabled(bool enabled) -{ - if (d->standardActionsEnabled == enabled) { - return; - } - - d->standardActionsEnabled = enabled; - - if (d->menu && !enabled && d->hasQuit) { - QAction *action = d->actionCollection->action("minimizeRestore"); - if (action) { - d->menu->removeAction(action); - } - - action = d->actionCollection->action(KStandardAction::name(KStandardAction::Quit)); - if (action) { - d->menu->removeAction(action); - } - - - d->hasQuit = false; - } -} - -bool KStatusNotifierItem::standardActionsEnabled() const -{ - return d->standardActionsEnabled; -} - -QString KStatusNotifierItem::title() const -{ - return d->title; -} - -void KStatusNotifierItem::activate(const QPoint &pos) -{ - //if the user activated the icon the NeedsAttention state is no longer necessary - //FIXME: always true? - if (d->status == NeedsAttention) { - d->status = Active; - emit d->statusNotifierItemDBus->NewStatus(metaObject()->enumerator(metaObject()->indexOfEnumerator("ItemStatus")).valueToKey(d->status)); - } - - if (d->associatedWidget == d->menu) { - d->statusNotifierItemDBus->ContextMenu(pos.x(), pos.y()); - return; - } - - if (d->menu->isVisible()) { - d->menu->hide(); - } - - if (!d->associatedWidget) { - emit activateRequested(true, pos); - return; - } - - d->checkVisibility(pos); -} - -bool KStatusNotifierItemPrivate::checkVisibility(QPoint pos, bool perform) -{ -#if defined(Q_WS_X11) - KWindowInfo info1 = KWindowSystem::windowInfo(associatedWidget->winId(), NET::XAWMState | NET::WMState | NET::WMDesktop); - // mapped = visible (but possibly obscured) - bool mapped = (info1.mappingState() == NET::Visible) && !info1.isMinimized(); - -// - not mapped -> show, raise, focus -// - mapped -// - obscured -> raise, focus -// - not obscured -> hide - //info1.mappingState() != NET::Visible -> window on another desktop? - if (!mapped) { - if (perform) { - minimizeRestore(true); - emit q->activateRequested(true, pos); - } - - return true; - } else { - QListIterator< WId > it (KWindowSystem::stackingOrder()); - it.toBack(); - while (it.hasPrevious()) { - WId id = it.previous(); - if (id == associatedWidget->winId()) { - break; - } - - KWindowInfo info2 = KWindowSystem::windowInfo(id, - NET::WMDesktop | NET::WMGeometry | NET::XAWMState | NET::WMState | NET::WMWindowType); - - if (info2.mappingState() != NET::Visible) { - continue; // not visible on current desktop -> ignore - } - - if (!info2.geometry().intersects(associatedWidget->geometry())) { - continue; // not obscuring the window -> ignore - } - - if (!info1.hasState(NET::KeepAbove) && info2.hasState(NET::KeepAbove)) { - continue; // obscured by window kept above -> ignore - } - - NET::WindowType type = info2.windowType(NET::NormalMask | NET::DesktopMask - | NET::DockMask | NET::ToolbarMask | NET::MenuMask | NET::DialogMask - | NET::UtilityMask | NET::SplashMask); - - if (type == NET::Dock) { - continue; // obscured by dock -> ignore - } - - if (perform) { - KWindowSystem::raiseWindow(associatedWidget->winId()); - KWindowSystem::forceActiveWindow(associatedWidget->winId()); - emit q->activateRequested(true, pos); - } - - return true; - } - - //not on current desktop? - if (!info1.isOnCurrentDesktop()) { - if (perform) { - KWindowSystem::activateWindow(associatedWidget->winId()); - emit q->activateRequested(true, pos); - } - - return true; - } - - if (perform) { - minimizeRestore(false); // hide - emit q->activateRequested(false, pos); - } - - return false; - } -#endif - - return true; -} - -bool KStatusNotifierItem::eventFilter(QObject *watched, QEvent *event) -{ - if (d->systemTrayIcon == 0) { - //FIXME: ugly ugly workaround to weird QMenu's focus problems - if (watched == d->menu && - (event->type() == QEvent::WindowDeactivate || (event->type() == QEvent::MouseButtonRelease && static_cast(event)->button() == Qt::LeftButton))) { - //put at the back of even queue to let the action activate anyways - QTimer::singleShot(0, this, SLOT(hideMenu())); - } - } - return false; -} - - -//KStatusNotifierItemPrivate - -static const int s_protocolVersion = 0; - -KStatusNotifierItemPrivate::KStatusNotifierItemPrivate(KStatusNotifierItem *item) - : q(item), - category(KStatusNotifierItem::ApplicationStatus), - status(KStatusNotifierItem::Passive), - menu(0), - titleAction(0), - statusNotifierWatcher(0), - systemTrayIcon(0), - hasQuit(false), - onAllDesktops(false), - standardActionsEnabled(true) -{ -} - -void KStatusNotifierItemPrivate::init(const QString &extraId) -{ - // Ensure that closing the last KMainWindow doesn't exit the application - // if a system tray icon is still present. - KGlobal::ref(); - - qDBusRegisterMetaType(); - qDBusRegisterMetaType(); - qDBusRegisterMetaType(); - - actionCollection = new KActionCollection(q); - statusNotifierItemDBus = new KStatusNotifierItemDBus(q); - q->setAssociatedWidget(qobject_cast(q->parent())); - - QDBusServiceWatcher *watcher = new QDBusServiceWatcher(s_statusNotifierWatcherServiceName, - QDBusConnection::sessionBus(), - QDBusServiceWatcher::WatchForOwnerChange, - q); - QObject::connect(watcher, SIGNAL(serviceOwnerChanged(QString,QString,QString)), - q, SLOT(serviceChange(QString,QString,QString))); - - //create a default menu, just like in KSystemtrayIcon - KMenu *m = new KMenu(associatedWidget); - titleAction = m->addTitle(qApp->windowIcon(), KGlobal::caption()); - m->setTitle(KGlobal::mainComponent().aboutData()->programName()); - q->setContextMenu(m); - - KStandardAction::quit(q, SLOT(maybeQuit()), actionCollection); - - id = title = KGlobal::mainComponent().aboutData()->programName(); - - if (!extraId.isEmpty()) { - id.append('_').append(extraId); - } - - // Init iconThemePath to the app folder for now - QStringList dirs = KGlobal::dirs()->findDirs("appdata", "icons"); - if (!dirs.isEmpty()) { - iconThemePath = dirs.first(); - } - - registerToDaemon(); -} - -void KStatusNotifierItemPrivate::registerToDaemon() -{ - kDebug(299) << "Registering a client interface to the KStatusNotifierWatcher"; - if (!statusNotifierWatcher) { - statusNotifierWatcher = new org::kde::StatusNotifierWatcher(s_statusNotifierWatcherServiceName, "/StatusNotifierWatcher", - QDBusConnection::sessionBus()); - QObject::connect(statusNotifierWatcher, SIGNAL(StatusNotifierHostRegistered()), - q, SLOT(checkForRegisteredHosts())); - QObject::connect(statusNotifierWatcher, SIGNAL(StatusNotifierHostUnregistered()), - q, SLOT(checkForRegisteredHosts())); - } - - if (statusNotifierWatcher->isValid() && - statusNotifierWatcher->property("ProtocolVersion").toInt() == s_protocolVersion) { - - statusNotifierWatcher->RegisterStatusNotifierItem(statusNotifierItemDBus->service()); - setLegacySystemTrayEnabled(false); - } else { - kDebug(299)<<"KStatusNotifierWatcher not reachable"; - setLegacySystemTrayEnabled(true); - } -} - -void KStatusNotifierItemPrivate::serviceChange(const QString &name, const QString &oldOwner, const QString &newOwner) -{ - Q_UNUSED(name) - if (newOwner.isEmpty()) { - //unregistered - kDebug(299) << "Connection to the KStatusNotifierWatcher lost"; - setLegacyMode(true); - delete statusNotifierWatcher; - statusNotifierWatcher = 0; - } else if (oldOwner.isEmpty()) { - //registered - setLegacyMode(false); - } -} - -void KStatusNotifierItemPrivate::checkForRegisteredHosts() -{ - setLegacyMode(!statusNotifierWatcher || - !statusNotifierWatcher->property("IsStatusNotifierHostRegistered").toBool()); -} - -void KStatusNotifierItemPrivate::setLegacyMode(bool legacy) -{ - if (legacy == (systemTrayIcon != 0)) { - return; - } - - if (legacy) { - //unregistered - setLegacySystemTrayEnabled(true); - } else { - //registered - registerToDaemon(); - } -} - -void KStatusNotifierItemPrivate::legacyWheelEvent(int delta) -{ - statusNotifierItemDBus->Scroll(delta, "vertical"); -} - -void KStatusNotifierItemPrivate::legacyActivated(QSystemTrayIcon::ActivationReason reason) -{ - if (reason == QSystemTrayIcon::MiddleClick) { - emit q->secondaryActivateRequested(systemTrayIcon->geometry().topLeft()); - } -} - -void KStatusNotifierItemPrivate::setLegacySystemTrayEnabled(bool enabled) -{ - if (enabled == (systemTrayIcon != 0)) { - // already in the correct state - return; - } - - if (enabled) { - if (!systemTrayIcon) { - systemTrayIcon = new KStatusNotifierLegacyIcon(associatedWidget); - syncLegacySystemTrayIcon(); - systemTrayIcon->setToolTip(toolTipTitle); - systemTrayIcon->show(); - QObject::connect(systemTrayIcon, SIGNAL(wheel(int)), q, SLOT(legacyWheelEvent(int))); - QObject::connect(systemTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), q, SLOT(legacyActivated(QSystemTrayIcon::ActivationReason))); - } - - if (menu) { - menu->setWindowFlags(Qt::Popup); - } - } else { - delete systemTrayIcon; - systemTrayIcon = 0; - - if (menu) { - menu->setWindowFlags(Qt::Window); - } - } - - if (menu) { - KMenu *m = menu; - menu = 0; - q->setContextMenu(m); - } -} - -void KStatusNotifierItemPrivate::syncLegacySystemTrayIcon() -{ - if (status == KStatusNotifierItem::NeedsAttention) { - if (!attentionIconName.isNull()) { - systemTrayIcon->setIcon(KIcon(attentionIconName)); - } else { - systemTrayIcon->setIcon(attentionIcon); - } - } else { - if (!iconName.isNull()) { - systemTrayIcon->setIcon(KIcon(iconName)); - } else { - systemTrayIcon->setIcon(icon); - } - } - - systemTrayIcon->setToolTip(toolTipTitle); -} - -void KStatusNotifierItemPrivate::contextMenuAboutToShow() -{ - if (!hasQuit && standardActionsEnabled) { - // we need to add the actions to the menu afterwards so that these items - // appear at the _END_ of the menu - menu->addSeparator(); - if (associatedWidget && associatedWidget != menu) { - QAction *action = actionCollection->action("minimizeRestore"); - - if (action) { - menu->addAction(action); - } - } - - QAction *action = actionCollection->action(KStandardAction::name(KStandardAction::Quit)); - - if (action) { - menu->addAction(action); - } - - hasQuit = true; - } - - if (associatedWidget && associatedWidget != menu) { - QAction* action = actionCollection->action("minimizeRestore"); - if (checkVisibility(QPoint(0, 0), false)) { - action->setText(i18n("&Restore")); - } else { - action->setText(i18n("&Minimize")); - } - } -} - -void KStatusNotifierItemPrivate::maybeQuit() -{ - QString caption = KGlobal::caption(); - QString query = i18n("Are you sure you want to quit %1?", caption); - - if (KMessageBox::warningContinueCancel(associatedWidget, query, - i18n("Confirm Quit From System Tray"), - KStandardGuiItem::quit(), - KStandardGuiItem::cancel(), - QString("systemtrayquit%1") - .arg(caption)) == KMessageBox::Continue) { - qApp->quit(); - } - -} - -void KStatusNotifierItemPrivate::minimizeRestore() -{ - q->activate(QPoint(0, 0)); -} - -void KStatusNotifierItemPrivate::hideMenu() -{ - menu->hide(); -} - -void KStatusNotifierItemPrivate::minimizeRestore(bool show) -{ -#ifdef Q_WS_X11 - KWindowInfo info = KWindowSystem::windowInfo(associatedWidget->winId(), NET::WMDesktop | NET::WMFrameExtents); - if (show) { - if (onAllDesktops) { - KWindowSystem::setOnAllDesktops(associatedWidget->winId(), true); - } else { - KWindowSystem::setCurrentDesktop(info.desktop()); - } - - associatedWidget->move(info.frameGeometry().topLeft()); // avoid placement policies - associatedWidget->show(); - associatedWidget->raise(); - KWindowSystem::raiseWindow(associatedWidget->winId()); - KWindowSystem::forceActiveWindow(associatedWidget->winId()); - } else { - onAllDesktops = info.onAllDesktops(); - associatedWidget->hide(); - } -#else - if (show) { - associatedWidget->show(); - associatedWidget->raise(); - KWindowSystem::forceActiveWindow(associatedWidget->winId()); - } else { - associatedWidget->hide(); - } -#endif -} - -KDbusImageStruct KStatusNotifierItemPrivate::imageToStruct(const QImage &image) -{ - KDbusImageStruct icon; - icon.width = image.width(); - icon.height = image.height(); - if (image.format() == QImage::Format_ARGB32) { - icon.data = QByteArray((const char*)image.constBits(), image.byteCount()); - } else { - QImage image32 = image.convertToFormat(QImage::Format_ARGB32); - icon.data = QByteArray((const char*)image32.constBits(), image32.byteCount()); - } - - return icon; -} - -KDbusImageVector KStatusNotifierItemPrivate::iconToVector(const QIcon &icon) -{ - KDbusImageVector iconVector; - - QPixmap iconPixmap; - - bool imageAdded = false; - const QList availableSizes = icon.availableSizes(); - foreach (const QSize &size, availableSizes) { - // hopefully huge and enormous not necessary right now since it's quite costly - if (size.width() <= KIconLoader::SizeLarge) { - imageAdded = true; - iconPixmap = icon.pixmap(size); - iconVector.append(imageToStruct(iconPixmap.toImage())); - } - } - if (!imageAdded && !availableSizes.isEmpty()) { - // but if only enormous size is available scale it down and add that, this happens to be - // the case for some window icons - iconPixmap = icon.pixmap(KIconLoader::SizeLarge); - iconVector.append(imageToStruct(iconPixmap.toImage())); - } - - return iconVector; -} - -#include "moc_kstatusnotifieritem.cpp" -#include "moc_kstatusnotifieritemprivate_p.cpp" diff --git a/kdeui/notifications/kstatusnotifieritem.h b/kdeui/notifications/kstatusnotifieritem.h deleted file mode 100644 index f21e7078..00000000 --- a/kdeui/notifications/kstatusnotifieritem.h +++ /dev/null @@ -1,445 +0,0 @@ -/* This file is part of the KDE libraries - Copyright 2009 by Marco Martin - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License (LGPL) as published by the Free Software Foundation; - either version 2 of the License, or (at your option) any later - version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef KSTATUSNOTIFIERITEM_H -#define KSTATUSNOTIFIERITEM_H - -#include -#include -#include - -#include "kdeui_export.h" - -class KActionCollection; -class KMenu; -class KStatusNotifierItemPrivate; - -/** - * \brief %KDE Status notifier Item protocol implementation - * - * This class implements the Status notifier Item Dbus specification. - * It provides an icon similar to the classical systemtray icons, - * with some key differences: - * - * - the actual representation is done by the systemtray (or the app behaving - * like it) itself, not by this app. Since 4.5 this also includes the menu, - * which means you cannot use embed widgets in the menu. - * - * - there is communication between the systemtray and the icon owner, so the - * system tray can know if the application is in a normal or in a requesting - * attention state. - * - * - icons are divided in categories, so the systemtray can represent in a - * different way the icons from normal applications and for instance the ones - * about hardware status. - * - * Whenever possible you should prefer passing icon by name rather than by - * pixmap because: - * - * - it is much lighter on Dbus (no need to pass all image pixels). - * - * - it makes it possible for the systemtray to load an icon of the appropriate - * size or to replace your icon with a systemtray specific icon which matches - * with the desktop theme. - * - * - some implementations of the system tray do not support passing icons by - * pixmap and will show a blank icon instead. - * - * @author Marco Martin - * @since 4.4 - */ -class KDEUI_EXPORT KStatusNotifierItem : public QObject -{ - Q_OBJECT - - Q_ENUMS(ItemStatus) - Q_ENUMS(ItemCategory) - Q_PROPERTY( ItemCategory category READ category WRITE setCategory ) - Q_PROPERTY( QString title READ title WRITE setTitle ) - Q_PROPERTY( ItemStatus status READ status WRITE setStatus ) - Q_PROPERTY( QString iconName READ iconName WRITE setIconByName ) - Q_PROPERTY( QString overlayIconName READ overlayIconName WRITE setOverlayIconByName ) - Q_PROPERTY( QString attentionIconName READ attentionIconName WRITE setAttentionIconByName ) - Q_PROPERTY( QString toolTipIconName READ toolTipIconName WRITE setToolTipIconByName ) - Q_PROPERTY( QString toolTipTitle READ toolTipTitle WRITE setToolTipTitle ) - Q_PROPERTY( QString toolTipSubTitle READ toolTipSubTitle WRITE setToolTipSubTitle ) - - friend class KStatusNotifierItemDBus; - friend class KStatusNotifierItemPrivate; -public: - /** - * All the possible status this icon can have, depending on the - * importance of the events that happens in the parent application - */ - enum ItemStatus { - /// Nothing is happening in the application, so showing this icon is not required - Passive = 1, - /// The application is doing something, or it is important that the - /// icon is always reachable from the user - Active = 2, - /// The application requests the attention of the user, for instance - /// battery running out or a new IM message was received - NeedsAttention = 3 - }; - - /** - * Different kinds of applications announce their type to the systemtray, - * so can be drawn in a different way or in a different place - */ - enum ItemCategory { - /// An icon for a normal application, can be seen as its taskbar entry - ApplicationStatus = 1, - /// This is a communication oriented application; this icon will be used - /// for things such as the notification of a new message - Communications = 2, - /// This is a system service, it can show itself in the system tray if - /// it requires interaction from the user or wants to inform him about - /// something - SystemServices = 3, - /// This application shows hardware status or a means to control it - Hardware = 4, - }; - - /** - * Construct a new status notifier item - * - * @param parent the parent object for this object. If the object passed in as - * a parent is also a QWidget, it will be used as the main application window - * represented by this icon and will be shown/hidden when an activation is requested. - * @see associatedWidget - **/ - explicit KStatusNotifierItem(QObject *parent = 0); - - /** - * Construct a new status notifier item with a unique identifier. - * If your application has more than one status notifier item and the user - * should be able to manipulate them separately (e.g. mark them for hiding - * in a user interface), the id can be used to differentiate between them. - * - * The id should remain consistent even between application restarts. - * Status notifier items without ids default to the application's name for the id. - * This id may be used, for instance, by hosts displaying status notifier items to - * associate configuration information with this item in a way that can persist - * between sessions or application restarts. - * - * @param id the unique id for this icon - * @param parent the parent object for this object. If the object passed in as - * a parent is also a QWidget, it will be used as the main application window - * represented by this icon and will be shown/hidden when an activation is requested. - * @see associatedWidget - **/ - explicit KStatusNotifierItem(const QString &id, QObject *parent = 0); - - ~KStatusNotifierItem(); - - /** - * @return The id which was specified in the constructor. This should be - * guaranteed to be consistent between application starts and - * untranslated, as host applications displaying items may use it for - * storing configuration related to this item. - */ - QString id() const; - - /** - * Sets the category for this icon, usually it's needed to call this function only once - * - * @param category the new category for this icon - */ - void setCategory(const ItemCategory category); - - /** - * @return the application category - */ - ItemCategory category() const; - - /** - * Sets a title for this icon - */ - void setTitle(const QString &title); - - /** - * @return the title of this icon - */ - QString title() const; - - /** - * Sets a new status for this icon. - */ - void setStatus(const ItemStatus status); - - /** - * @return the current application status - */ - ItemStatus status() const; - - //Main icon related functions - /** - * Sets a new main icon for the system tray - * - * @param name it must be a KIconLoader compatible name, this is - * the preferred way to set an icon - */ - void setIconByName(const QString &name); - - /** - * @return the name of the main icon to be displayed - * if image() is not empty this will always return an empty string - */ - QString iconName() const; - - /** - * Sets a new main icon for the system tray - * - * @param pixmap our icon, use setIcon(const QString) when possible - */ - void setIconByPixmap(const QIcon &icon); - - /** - * @return a pixmap of the icon - */ - QIcon iconPixmap() const; - - /** - * Sets an icon to be used as overlay for the main one - * @param icon name, if name is and empty QString() - * (and overlayIconPixmap() is empty too) the icon will be removed - */ - void setOverlayIconByName(const QString &name); - - /** - * @return the name of the icon to be used as overlay fr the main one - */ - QString overlayIconName() const; - - /** - * Sets an icon to be used as overlay for the main one - * setOverlayIconByPixmap(QIcon()) will remove the overlay when - * overlayIconName() is empty too. - * - * @param pixmap our overlay icon, use setOverlayIcon(const QString) when possible. - */ - void setOverlayIconByPixmap(const QIcon &icon); - - /** - * @return a pixmap of the icon - */ - QIcon overlayIconPixmap() const; - - //Requesting attention icon - - /** - * Sets a new icon that should be used when the application - * wants to request attention (usually the systemtray - * will blink between this icon and the main one) - * - * @param name KIconLoader-compatible name of icon to use - */ - void setAttentionIconByName(const QString &name); - - /** - * @return the name of the icon to be displayed when the application - * is requesting the user's attention - * if attentionImage() is not empty this will always return an empty string - */ - QString attentionIconName() const; - - /** - * Sets the pixmap of the requesting attention icon. - * Use setAttentionIcon(const QString) instead when possible. - * - * @param icon QIcon to use for requesting attention. - */ - void setAttentionIconByPixmap(const QIcon &icon); - - /** - * @return a pixmap of the requesting attention icon - */ - QIcon attentionIconPixmap() const; - - //ToolTip handling - /** - * Sets a new toolTip or this icon, a toolTip is composed of an icon, - * a title ad a text, all fields are optional. - * - * @param iconName a KIconLoader compatible name for the tootip icon - * @param title tootip title - * @param subTitle subtitle for the toolTip - */ - void setToolTip(const QString &iconName, const QString &title, const QString &subTitle); - - /** - * Sets a new toolTip or this status notifier item. - * This is an overloaded member provided for convenience - */ - void setToolTip(const QIcon &icon, const QString &title, const QString &subTitle); - - /** - * Set a new icon for the toolTip - * - * @param name the name for the icon - */ - void setToolTipIconByName(const QString &name); - - /** - * @return the name of the toolTip icon - * if toolTipImage() is not empty this will always return an empty string - */ - QString toolTipIconName() const; - - /** - * Set a new icon for the toolTip. - * - * Use setToolTipIconByName(QString) if possible. - * @param pixmap representing the icon - */ - void setToolTipIconByPixmap(const QIcon &icon); - - /** - * @return a serialization of the toolTip icon data - */ - QIcon toolTipIconPixmap() const; - - /** - * Sets a new title for the toolTip - */ - void setToolTipTitle(const QString &title); - - /** - * @return the title of the main icon toolTip - */ - QString toolTipTitle() const; - - /** - * Sets a new subtitle for the toolTip - */ - void setToolTipSubTitle(const QString &subTitle); - - /** - * @return the subtitle of the main icon toolTip - */ - QString toolTipSubTitle() const; - - /** - * Sets a new context menu for this StatusNotifierItem. - * the menu will be shown with a contextMenu(int,int) - * call by the systemtray over dbus - * usually you don't need to call this unless you want to use - * a custom KMenu subclass as context menu - */ - void setContextMenu(KMenu *menu); - - /** - * Access the context menu associated to this status notifier item - */ - KMenu *contextMenu() const; - - /** - * Sets the main widget associated with this StatusNotifierItem - * - * If you pass contextMenu() as a parent then the menu will be displayed - * when the user activate the icon. In this case the activate() method will - * not be called and the activateRequested() signal will not be emitted - * - * @param parent the new main widget: must be a top level window, - * if it's not parent->window() will be used instead. - */ - void setAssociatedWidget(QWidget *parent); - - /** - * Access the main widget associated with this StatusNotifierItem - */ - QWidget *associatedWidget() const; - - /** - * All the actions present in the menu - */ - KActionCollection *actionCollection() const; - - /** - * Sets whether to show the standard items in the menu, such as Quit - */ - void setStandardActionsEnabled(bool enabled); - - /** - * @return if the standard items in the menu, such as Quit - */ - bool standardActionsEnabled() const; - -public Q_SLOTS: - - /** - * Shows the main widget and try to position it on top - * of the other windows, if the widget is already visible, hide it. - * - * @param pos if it's a valid position it represents the mouse coordinates when the event was triggered - */ - virtual void activate(const QPoint &pos = QPoint()); - -Q_SIGNALS: - /** - * Inform the host application that the mouse wheel - * (or another mean of scrolling that the visualization provides) has been used - * - * @param delta the amount of scrolling, can be either positive or negative - * @param orientation direction of the scrolling, can be either horizontal or vertical - */ - void scrollRequested(int delta, Qt::Orientation orientation); - - /** - * Inform the host application that an activation has been requested, - * for instance left mouse click, but this is not guaranteed since - * it's dependent from the visualization - * @param active if it's true the application asked for the activatin - * of the main window, if it's false it asked for hiding - * @param pos the position in the screen where the user clicked to - * trigger this signal, QPoint() if it's not the consequence of a mouse click. - */ - void activateRequested(bool active, const QPoint &pos); - - /** - * Alternate activate action, - * for instance right mouse click, but this is not guaranteed since - * it's dependent from the visualization - * - * @param pos the position in the screen where the user clicked to - * trigger this signal, QPoint() if it's not the consequence of a mouse click. - */ - void secondaryActivateRequested(const QPoint &pos); - -protected: - bool eventFilter(QObject *watched, QEvent *event); - -private: - KStatusNotifierItemPrivate *const d; - - Q_PRIVATE_SLOT(d, void serviceChange(const QString& name, - const QString& oldOwner, - const QString& newOwner)) - Q_PRIVATE_SLOT(d, void checkForRegisteredHosts()) - Q_PRIVATE_SLOT(d, void registerToDaemon()) - Q_PRIVATE_SLOT(d, void contextMenuAboutToShow()) - Q_PRIVATE_SLOT(d, void maybeQuit()) - Q_PRIVATE_SLOT(d, void minimizeRestore()) - Q_PRIVATE_SLOT(d, void hideMenu()) - Q_PRIVATE_SLOT(d, void legacyWheelEvent(int)) - Q_PRIVATE_SLOT(d, void legacyActivated(QSystemTrayIcon::ActivationReason)) -}; - -#endif diff --git a/kdeui/notifications/kstatusnotifieritemdbus_p.cpp b/kdeui/notifications/kstatusnotifieritemdbus_p.cpp deleted file mode 100644 index 98283550..00000000 --- a/kdeui/notifications/kstatusnotifieritemdbus_p.cpp +++ /dev/null @@ -1,308 +0,0 @@ -/* This file is part of the KDE libraries - Copyright 2009 by Marco Martin - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License (LGPL) as published by the Free Software Foundation; - either version 2 of the License, or (at your option) any later - version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "kstatusnotifieritemdbus_p.h" -#include "kstatusnotifieritemprivate_p.h" -#include "kstatusnotifieritem.h" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "statusnotifierwatcher_interface.h" -#include "statusnotifieritemadaptor.h" - -// Marshall the ImageStruct data into a D-BUS argument -const QDBusArgument &operator<<(QDBusArgument &argument, const KDbusImageStruct &icon) -{ - argument.beginStructure(); - argument << icon.width; - argument << icon.height; - argument << icon.data; - argument.endStructure(); - return argument; -} - -// Retrieve the ImageStruct data from the D-BUS argument -const QDBusArgument &operator>>(const QDBusArgument &argument, KDbusImageStruct &icon) -{ - qint32 width; - qint32 height; - QByteArray data; - - argument.beginStructure(); - argument >> width; - argument >> height; - argument >> data; - argument.endStructure(); - - icon.width = width; - icon.height = height; - icon.data = data; - - return argument; -} - - -// Marshall the ImageVector data into a D-BUS argument -const QDBusArgument &operator<<(QDBusArgument &argument, const KDbusImageVector &iconVector) -{ - argument.beginArray(qMetaTypeId()); - for (int i=0; i>(const QDBusArgument &argument, KDbusImageVector &iconVector) -{ - argument.beginArray(); - iconVector.clear(); - - while ( !argument.atEnd() ) { - KDbusImageStruct element; - argument >> element; - iconVector.append(element); - } - - argument.endArray(); - - - return argument; -} - -// Marshall the ToolTipStruct data into a D-BUS argument -const QDBusArgument &operator<<(QDBusArgument &argument, const KDbusToolTipStruct &toolTip) -{ - argument.beginStructure(); - argument << toolTip.icon; - argument << toolTip.image; - argument << toolTip.title; - argument << toolTip.subTitle; - argument.endStructure(); - return argument; -} - -// Retrieve the ToolTipStruct data from the D-BUS argument -const QDBusArgument &operator>>(const QDBusArgument &argument, KDbusToolTipStruct &toolTip) -{ - QString icon; - KDbusImageVector image; - QString title; - QString subTitle; - - argument.beginStructure(); - argument >> icon; - argument >> image; - argument >> title; - argument >> subTitle; - argument.endStructure(); - - toolTip.icon = icon; - toolTip.image = image; - toolTip.title = title; - toolTip.subTitle = subTitle; - - return argument; -} - - -int KStatusNotifierItemDBus::s_serviceCount = 0; - -KStatusNotifierItemDBus::KStatusNotifierItemDBus(KStatusNotifierItem *parent) - : QObject(parent), - m_statusNotifierItem(parent), - m_service(QString("org.kde.StatusNotifierItem-%1-%2") - .arg(QCoreApplication::applicationPid()) - .arg(++s_serviceCount)), - m_dbus(QDBusConnection::connectToBus(QDBusConnection::SessionBus, m_service)) -{ - new StatusNotifierItemAdaptor(this); - kDebug(299) << "service is" << m_service; - m_dbus.registerService(m_service); - m_dbus.registerObject("/StatusNotifierItem", this); -} - -KStatusNotifierItemDBus::~KStatusNotifierItemDBus() -{ - m_dbus.unregisterObject("/StatusNotifierItem"); - m_dbus.unregisterService(m_service); - m_dbus.disconnectFromBus(m_service); -} - -QDBusConnection KStatusNotifierItemDBus::dbusConnection() const -{ - return m_dbus; -} - -QString KStatusNotifierItemDBus::service() const -{ - return m_service; -} - -bool KStatusNotifierItemDBus::ItemIsMenu() const -{ - return (m_statusNotifierItem->d->associatedWidget == m_statusNotifierItem->d->menu); -} - -//DBUS slots - -QString KStatusNotifierItemDBus::Category() const -{ - return m_statusNotifierItem->metaObject()->enumerator(m_statusNotifierItem->metaObject()->indexOfEnumerator("ItemCategory")).valueToKey(m_statusNotifierItem->category()); -} - -QString KStatusNotifierItemDBus::Title() const -{ - return m_statusNotifierItem->title(); -} - -QString KStatusNotifierItemDBus::Id() const -{ - return m_statusNotifierItem->id(); -} - -QString KStatusNotifierItemDBus::Status() const - { - return m_statusNotifierItem->metaObject()->enumerator(m_statusNotifierItem->metaObject()->indexOfEnumerator("ItemStatus")).valueToKey(m_statusNotifierItem->status()); -} - -qlonglong KStatusNotifierItemDBus::WindowId() const -{ - if (m_statusNotifierItem->d->associatedWidget && m_statusNotifierItem->d->associatedWidget != m_statusNotifierItem->d->menu) { - return static_cast(m_statusNotifierItem->d->associatedWidget->winId()); - } else { - return 0; - } -} - - -//Icon - -QString KStatusNotifierItemDBus::IconName() const -{ - return m_statusNotifierItem->iconName(); -} - -KDbusImageVector KStatusNotifierItemDBus::IconPixmap() const -{ - return m_statusNotifierItem->d->serializedIcon; -} - -QString KStatusNotifierItemDBus::OverlayIconName() const -{ - return m_statusNotifierItem->overlayIconName(); -} - -KDbusImageVector KStatusNotifierItemDBus::OverlayIconPixmap() const -{ - return m_statusNotifierItem->d->serializedOverlayIcon; -} - -//Requesting attention icon - -QString KStatusNotifierItemDBus::AttentionIconName() const -{ - return m_statusNotifierItem->attentionIconName(); -} - -KDbusImageVector KStatusNotifierItemDBus::AttentionIconPixmap() const -{ - return m_statusNotifierItem->d->serializedAttentionIcon; -} - - -//ToolTip - -KDbusToolTipStruct KStatusNotifierItemDBus::ToolTip() const -{ - KDbusToolTipStruct toolTip; - toolTip.icon = m_statusNotifierItem->toolTipIconName(); - toolTip.image = m_statusNotifierItem->d->serializedToolTipIcon; - toolTip.title = m_statusNotifierItem->toolTipTitle(); - toolTip.subTitle = m_statusNotifierItem->toolTipSubTitle(); - - return toolTip; -} - -QString KStatusNotifierItemDBus::IconThemePath() const -{ - return m_statusNotifierItem->d->iconThemePath; -} - -//Menu -QDBusObjectPath KStatusNotifierItemDBus::Menu() const -{ - return QDBusObjectPath(m_statusNotifierItem->d->menuObjectPath); -} - -//Interaction - -void KStatusNotifierItemDBus::ContextMenu(int x, int y) -{ - if (!m_statusNotifierItem->d->menu) { - return; - } - - //TODO: nicer placement, possible? - if (!m_statusNotifierItem->d->menu->isVisible()) { - m_statusNotifierItem->d->menu->setWindowFlags(Qt::Window|Qt::FramelessWindowHint); - m_statusNotifierItem->d->menu->popup(QPoint(x,y)); - KWindowSystem::setState(m_statusNotifierItem->d->menu->winId(), NET::SkipTaskbar|NET::SkipPager|NET::KeepAbove); - KWindowSystem::setType(m_statusNotifierItem->d->menu->winId(), NET::PopupMenu); - KWindowSystem::forceActiveWindow(m_statusNotifierItem->d->menu->winId()); - } else { - m_statusNotifierItem->d->menu->hide(); - } -} - -void KStatusNotifierItemDBus::Activate(int x, int y) -{ - if (m_statusNotifierItem->d->associatedWidget == m_statusNotifierItem->d->menu) { - ContextMenu(x, y); - } else { - m_statusNotifierItem->activate(QPoint(x,y)); - } -} - -void KStatusNotifierItemDBus::SecondaryActivate(int x, int y) -{ - emit m_statusNotifierItem->secondaryActivateRequested(QPoint(x,y)); -} - -void KStatusNotifierItemDBus::Scroll(int delta, const QString &orientation) -{ - Qt::Orientation dir = (orientation.toLower() == "horizontal" ? Qt::Horizontal : Qt::Vertical); - emit m_statusNotifierItem->scrollRequested(delta, dir); -} - -#include "moc_kstatusnotifieritemdbus_p.cpp" diff --git a/kdeui/notifications/kstatusnotifieritemdbus_p.h b/kdeui/notifications/kstatusnotifieritemdbus_p.h deleted file mode 100644 index d6f3eb75..00000000 --- a/kdeui/notifications/kstatusnotifieritemdbus_p.h +++ /dev/null @@ -1,242 +0,0 @@ -/* This file is part of the KDE libraries - Copyright 2009 by Marco Martin - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License (LGPL) as published by the Free Software Foundation; - either version 2 of the License, or (at your option) any later - version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef KSTATUSNOTIFIERITEMDBUS_H -#define KSTATUSNOTIFIERITEMDBUS_H - -#include - -#include -#include -#include -#include -#include - -//Custom message type for DBus -struct KDbusImageStruct { - int width; - int height; - QByteArray data; -}; - -typedef QVector KDbusImageVector; - -struct KDbusToolTipStruct { - QString icon; - KDbusImageVector image; - QString title; - QString subTitle; -}; - -class KStatusNotifierItem; - -class KStatusNotifierItemDBus : public QObject -{ - Q_OBJECT - - Q_PROPERTY(QString Category READ Category) - Q_PROPERTY(QString Id READ Id) - Q_PROPERTY(QString Title READ Title) - Q_PROPERTY(QString Status READ Status) - Q_PROPERTY(qlonglong WindowId READ WindowId) - Q_PROPERTY(bool ItemIsMenu READ ItemIsMenu) - Q_PROPERTY(QString IconName READ IconName) - Q_PROPERTY(KDbusImageVector IconPixmap READ IconPixmap) - Q_PROPERTY(QString OverlayIconName READ OverlayIconName) - Q_PROPERTY(KDbusImageVector OverlayIconPixmap READ OverlayIconPixmap) - Q_PROPERTY(QString AttentionIconName READ AttentionIconName) - Q_PROPERTY(KDbusImageVector AttentionIconPixmap READ AttentionIconPixmap) - Q_PROPERTY(KDbusToolTipStruct ToolTip READ ToolTip) - Q_PROPERTY(QString IconThemePath READ IconThemePath) - Q_PROPERTY(QDBusObjectPath Menu READ Menu) - - friend class KStatusNotifierItem; -public: - KStatusNotifierItemDBus(KStatusNotifierItem *parent); - ~KStatusNotifierItemDBus(); - - /** - * @return the dbus connection used by this object - */ - QDBusConnection dbusConnection() const; - - /** - * @return the service this object is registered on the bus under - */ - QString service() const; - - /** - * @return the category of the application associated to this item - * @see Category - */ - QString Category() const; - - /** - * @return the id of this item - */ - QString Id() const; - - /** - * @return the title of this item - */ - QString Title() const; - - /** - * @return The status of this item - * @see Status - */ - QString Status() const; - - /** - * @return The id of the main window of the application that controls the item - */ - qlonglong WindowId() const; - - /** - * @return The item only support the context menu, the visualization should prefer sending ContextMenu() instead of Activate() - */ - bool ItemIsMenu() const; - - /** - * @return the name of the main icon to be displayed - * if image() is not empty this will always return an empty string - */ - QString IconName() const; - - /** - * @return a serialization of the icon data - */ - KDbusImageVector IconPixmap() const; - - /** - * @return the name of the overlay of the main icon to be displayed - * if image() is not empty this will always return an empty string - */ - QString OverlayIconName() const; - - /** - * @return a serialization of the icon data - */ - KDbusImageVector OverlayIconPixmap() const; - - /** - * @return the name of the icon to be displayed when the application - * is requesting the user's attention - * if attentionImage() is not empty this will always return an empty string - */ - QString AttentionIconName() const; - - /** - * @return a serialization of the requesting attention icon data - */ - KDbusImageVector AttentionIconPixmap() const; - - /** - * all the data needed for a tooltip - */ - KDbusToolTipStruct ToolTip() const; - - /** - * @return path to extra icon theme, to load application specific icons - */ - QString IconThemePath() const; - - /** - * @return object path to the dbusmenu object - */ - QDBusObjectPath Menu() const; - -public Q_SLOTS: - //interaction - /** - * Shows the context menu associated to this item - * at the desired screen position - */ - void ContextMenu(int x, int y); - - /** - * Shows the main widget and try to position it on top - * of the other windows, if the widget is already visible, hide it. - */ - void Activate(int x, int y); - - /** - * The user activated the item in an alternate way (for instance with middle mouse button, this depends from the systray implementation) - */ - void SecondaryActivate(int x, int y); - - /** - * Inform this item that the mouse wheel was used on its representation - */ - void Scroll(int delta, const QString &orientation); - -Q_SIGNALS: - /** - * Inform the systemtray that the own main icon has been changed, - * so should be reloaded - */ - void NewIcon(); - - /** - * Inform the systemtray that there is a new icon to be used as overlay - */ - void NewOverlayIcon(); - - /** - * Inform the systemtray that the requesting attention icon - * has been changed, so should be reloaded - */ - void NewAttentionIcon(); - - /** - * Inform the systemtray that something in the tooltip has been changed - */ - void NewToolTip(); - - /** - * Signal the new status when it has been changed - * @see Status - */ - void NewStatus(const QString &status); - -private: - KStatusNotifierItem *m_statusNotifierItem; - QString m_service; - QDBusConnection m_dbus; - static int s_serviceCount; -}; - - -const QDBusArgument &operator<<(QDBusArgument &argument, const KDbusImageStruct &icon); -const QDBusArgument &operator>>(const QDBusArgument &argument, KDbusImageStruct &icon); - -Q_DECLARE_METATYPE(KDbusImageStruct) - -const QDBusArgument &operator<<(QDBusArgument &argument, const KDbusImageVector &iconVector); -const QDBusArgument &operator>>(const QDBusArgument &argument, KDbusImageVector &iconVector); - -Q_DECLARE_METATYPE(KDbusImageVector) - -const QDBusArgument &operator<<(QDBusArgument &argument, const KDbusToolTipStruct &toolTip); -const QDBusArgument &operator>>(const QDBusArgument &argument, KDbusToolTipStruct &toolTip); - -Q_DECLARE_METATYPE(KDbusToolTipStruct) - -#endif diff --git a/kdeui/notifications/kstatusnotifieritemprivate_p.h b/kdeui/notifications/kstatusnotifieritemprivate_p.h deleted file mode 100644 index 8ea165f3..00000000 --- a/kdeui/notifications/kstatusnotifieritemprivate_p.h +++ /dev/null @@ -1,131 +0,0 @@ -/* This file is part of the KDE libraries - Copyright 2009 by Marco Martin - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License (LGPL) as published by the Free Software Foundation; - either version 2 of the License, or (at your option) any later - version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef KSTATUSNOTIFIERITEMPRIVATE_H -#define KSTATUSNOTIFIERITEMPRIVATE_H - -#include -#include -#include - -#include - -#include "kstatusnotifieritem.h" -#include "kstatusnotifieritemdbus_p.h" - -#include "statusnotifierwatcher_interface.h" - -class KActionCollection; -class KSystemTrayIcon; -class KMenu; - -// this class is needed because we can't just put an event filter on it: -// the events that are passed to QSystemTrayIcon are done so in a way that -// bypasses the usual event filtering mechanisms *sigh* -class KStatusNotifierLegacyIcon : public KSystemTrayIcon -{ - Q_OBJECT - -public: - KStatusNotifierLegacyIcon(QWidget *parent) - : KSystemTrayIcon(parent) - { - } - - bool event(QEvent *e) - { - if (e->type() == QEvent::Wheel) { - QWheelEvent *wheelEvent = static_cast(e); - emit wheel(wheelEvent->delta()); - } - - return false; - } - -Q_SIGNALS: - void wheel(int); -}; - -class KStatusNotifierItemPrivate -{ -public: - KStatusNotifierItemPrivate(KStatusNotifierItem *item); - - void init(const QString &extraId); - void registerToDaemon(); - void serviceChange(const QString &name, const QString &oldOwner, const QString &newOwner); - void setLegacySystemTrayEnabled(bool enabled); - void syncLegacySystemTrayIcon(); - void contextMenuAboutToShow(); - void maybeQuit(); - void minimizeRestore(); - void minimizeRestore(bool show); - void hideMenu(); - void setLegacyMode(bool legacy); - void checkForRegisteredHosts(); - void legacyWheelEvent(int delta); - void legacyActivated(QSystemTrayIcon::ActivationReason reason); - - KDbusImageStruct imageToStruct(const QImage &image); - KDbusImageVector iconToVector(const QIcon &icon); - bool checkVisibility(QPoint pos, bool perform = true); - - KStatusNotifierItem *q; - - KStatusNotifierItem::ItemCategory category; - QString id; - QString title; - KStatusNotifierItem::ItemStatus status; - - QString iconName; - KDbusImageVector serializedIcon; - QIcon icon; - - QString overlayIconName; - KDbusImageVector serializedOverlayIcon; - QIcon overlayIcon; - - QString attentionIconName; - QIcon attentionIcon; - KDbusImageVector serializedAttentionIcon; - - QString toolTipIconName; - KDbusImageVector serializedToolTipIcon; - QIcon toolTipIcon; - QString toolTipTitle; - QString toolTipSubTitle; - QString iconThemePath; - QString menuObjectPath; - - KMenu *menu; - KActionCollection* actionCollection; - QWidget *associatedWidget; - QAction* titleAction; - org::kde::StatusNotifierWatcher *statusNotifierWatcher; - - KSystemTrayIcon *systemTrayIcon; - KStatusNotifierItemDBus *statusNotifierItemDBus; - - bool hasQuit; - bool onAllDesktops; - bool standardActionsEnabled; -}; - -#endif diff --git a/kdeui/notifications/ksystemtrayicon.cpp b/kdeui/notifications/ksystemtrayicon.cpp deleted file mode 100644 index 54a7f628..00000000 --- a/kdeui/notifications/ksystemtrayicon.cpp +++ /dev/null @@ -1,334 +0,0 @@ -/* This file is part of the KDE libraries - - Copyright (C) 1999 Matthias Ettrich (ettrich@kde.org) - Copyright (c) 2007 by Charles Connell - Copyright (C) 2008 Lukas Appelhans - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "ksystemtrayicon.h" -#include "kaboutdata.h" -#include "kaction.h" -#include "kcomponentdata.h" -#include "klocale.h" -#include "kmenu.h" -#include "kmessagebox.h" -#include "kshortcut.h" -#include "kactioncollection.h" -#include "kstandardaction.h" -#include - -#ifdef Q_WS_X11 -#include -#endif - -#include -#include -#include - -#include - -class KSystemTrayIconPrivate -{ -public: - KSystemTrayIconPrivate(KSystemTrayIcon* trayIcon, QWidget* parent) - : q(trayIcon) - { - actionCollection = new KActionCollection( trayIcon ); - hasQuit = false; - onAllDesktops = false; - window = parent; - } - - ~KSystemTrayIconPrivate() - { - delete actionCollection; - delete menu; - } - - KSystemTrayIcon* q; - KActionCollection* actionCollection; - KMenu* menu; - QWidget* window; - QAction* titleAction; - bool onAllDesktops : 1; // valid only when the parent widget was hidden - bool hasQuit : 1; -}; - -KSystemTrayIcon::KSystemTrayIcon( QWidget* parent ) - : QSystemTrayIcon( parent ), - d( new KSystemTrayIconPrivate( this, parent ) ) -{ - init( parent ); -} - -KSystemTrayIcon::KSystemTrayIcon( const QString& icon, QWidget* parent ) - : QSystemTrayIcon( loadIcon( icon ), parent ), - d( new KSystemTrayIconPrivate( this, parent ) ) -{ - init( parent ); -} - -KSystemTrayIcon::KSystemTrayIcon( const QIcon& icon, QWidget* parent ) - : QSystemTrayIcon( icon, parent ), - d( new KSystemTrayIconPrivate( this, parent ) ) -{ - init( parent ); -} - -void KSystemTrayIcon::init( QWidget* parent ) -{ - // Ensure that closing the last KMainWindow doesn't exit the application - // if a system tray icon is still present. - KGlobal::ref(); - d->menu = new KMenu( parent ); - d->titleAction = d->menu->addTitle( qApp->windowIcon(), KGlobal::caption() ); - d->menu->setTitle( KGlobal::mainComponent().aboutData()->programName() ); - connect( d->menu, SIGNAL(aboutToShow()), this, SLOT(contextMenuAboutToShow()) ); - setContextMenu( d->menu ); - - KStandardAction::quit( this, SLOT(maybeQuit()), d->actionCollection ); - - if ( parent ) - { - QAction *action = d->actionCollection->addAction("minimizeRestore"); - action->setText(i18n("Minimize")); - connect( action, SIGNAL(triggered(bool)), this, SLOT(minimizeRestoreAction()) ); - -#ifdef Q_WS_X11 - KWindowInfo info = KWindowSystem::windowInfo( parent->winId(), NET::WMDesktop ); - d->onAllDesktops = info.onAllDesktops(); -#else - d->onAllDesktops = false; -#endif - } - else - { - d->onAllDesktops = false; - } - - connect( this, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), - SLOT(activateOrHide(QSystemTrayIcon::ActivationReason)) ); -} - -QWidget *KSystemTrayIcon::parentWidget() const -{ - return d->window; -} - -KSystemTrayIcon::~KSystemTrayIcon() -{ - delete d; - KGlobal::deref(); -} - -void KSystemTrayIcon::contextMenuAboutToShow( ) -{ - if ( !d->hasQuit ) - { - // we need to add the actions to the menu afterwards so that these items - // appear at the _END_ of the menu - d->menu->addSeparator(); - QAction* action = d->actionCollection->action( "minimizeRestore" ); - - if ( action ) - { - d->menu->addAction( action ); - } - - action = d->actionCollection->action( KStandardAction::name( KStandardAction::Quit ) ); - - if ( action ) - { - d->menu->addAction( action ); - } - - d->hasQuit = true; - } - - if ( d->window ) - { - QAction* action = d->actionCollection->action("minimizeRestore"); - if ( d->window->isVisible() ) - { - action->setText( i18n("&Minimize") ); - } - else - { - action->setText( i18n("&Restore") ); - } - } -} - -// called from the popup menu - always do what the menu entry says, -// i.e. if the window is shown, no matter if active or not, the menu -// entry is "minimize", otherwise it's "restore" -void KSystemTrayIcon::minimizeRestoreAction() -{ - if ( d->window ) - { - bool restore = !( d->window->isVisible() ); - minimizeRestore( restore ); - } -} - -void KSystemTrayIcon::maybeQuit() -{ - QString caption = KGlobal::caption(); - QString query = i18n("Are you sure you want to quit %1?", - caption); - if (KMessageBox::warningContinueCancel(d->window, query, - i18n("Confirm Quit From System Tray"), - KStandardGuiItem::quit(), - KStandardGuiItem::cancel(), - QString("systemtrayquit%1") - .arg(caption)) != - KMessageBox::Continue) - { - return; - } - - emit quitSelected(); - qApp->quit(); -} - -// if the window is not the active one, show it if needed, and activate it -// (just like taskbar); otherwise hide it -void KSystemTrayIcon::activateOrHide( QSystemTrayIcon::ActivationReason reasonCalled ) -{ - if ( reasonCalled != QSystemTrayIcon::Trigger ) - { - return; - } - - QWidget *pw = d->window; - if ( !pw ) - { - return; - } -#if defined(Q_WS_X11) - KWindowInfo info1 = KWindowSystem::windowInfo( pw->winId(), NET::XAWMState | NET::WMState ); - // mapped = visible (but possibly obscured) - bool mapped = (info1.mappingState() == NET::Visible) && !info1.isMinimized(); -// - not mapped -> show, raise, focus -// - mapped -// - obscured -> raise, focus -// - not obscured -> hide - if( !mapped ) - minimizeRestore( true ); - else - { - QListIterator< WId > it (KWindowSystem::stackingOrder()); - it.toBack(); - while( it.hasPrevious() ) - { - WId id = it.previous(); - if( id == pw->winId() ) - break; - KWindowInfo info2 = KWindowSystem::windowInfo( id, - NET::WMGeometry | NET::XAWMState | NET::WMState | NET::WMWindowType ); - if( info2.mappingState() != NET::Visible ) - continue; // not visible on current desktop -> ignore - if( !info2.geometry().intersects( pw->geometry())) - continue; // not obscuring the window -> ignore - if( !info1.hasState( NET::KeepAbove ) && info2.hasState( NET::KeepAbove )) - continue; // obscured by window kept above -> ignore - NET::WindowType type = info2.windowType( NET::NormalMask | NET::DesktopMask - | NET::DockMask | NET::ToolbarMask | NET::MenuMask | NET::DialogMask - | NET::UtilityMask | NET::SplashMask ); - if( type == NET::Dock ) - continue; // obscured by dock -> ignore - pw->raise(); - KWindowSystem::activateWindow( pw->winId()); - return; - } - minimizeRestore( false ); // hide - } -#endif -} - -void KSystemTrayIcon::minimizeRestore( bool restore ) -{ - QWidget* pw = d->window; - if (!pw) - return; -#ifdef Q_WS_X11 - KWindowInfo info = KWindowSystem::windowInfo(pw->winId(), NET::WMGeometry | NET::WMDesktop); - if (restore) { - if (d->onAllDesktops) { - KWindowSystem::setOnAllDesktops(pw->winId(), true); - } else { - KWindowSystem::setCurrentDesktop(info.desktop()); - } - pw->move(info.geometry().topLeft()); // avoid placement policies - pw->show(); - pw->raise(); - KWindowSystem::activateWindow(pw->winId()); - } else { - d->onAllDesktops = info.onAllDesktops(); - pw->hide(); - } -#else - if ( restore ) - { - pw->show(); - pw->raise(); - KWindowSystem::forceActiveWindow( pw->winId() ); - } else { - pw->hide(); - } -#endif -} - -KActionCollection* KSystemTrayIcon::actionCollection() -{ - return d->actionCollection; -} - -QIcon KSystemTrayIcon::loadIcon(const QString &icon, const KComponentData &componentData) -{ - KConfigGroup cg(componentData.config(), "System Tray"); - const int iconWidth = cg.readEntry("systrayIconWidth", 22); - return KIconLoader::global()->loadIcon( icon, KIconLoader::Panel, iconWidth ); -} - -void KSystemTrayIcon::toggleActive() -{ - activateOrHide( QSystemTrayIcon::Trigger ); -} - -bool KSystemTrayIcon::parentWidgetTrayClose() const -{ - if( kapp != NULL && kapp->sessionSaving()) - return false; // normal close - return true; -} - -void KSystemTrayIcon::setContextMenuTitle(QAction *action) -{ - // can never be null, and is always the requsted type, so no need to do null checks after casts. - QToolButton *button = static_cast((static_cast(d->titleAction))->defaultWidget()); - button->setDefaultAction(action); -} - -QAction *KSystemTrayIcon::contextMenuTitle() const -{ - QToolButton *button = static_cast((static_cast(d->titleAction))->defaultWidget()); - return button->defaultAction(); -} - -#include "moc_ksystemtrayicon.cpp" diff --git a/kdeui/notifications/ksystemtrayicon.h b/kdeui/notifications/ksystemtrayicon.h deleted file mode 100644 index 1a5e90be..00000000 --- a/kdeui/notifications/ksystemtrayicon.h +++ /dev/null @@ -1,164 +0,0 @@ -/* This file is part of the KDE libraries - Copyright (C) 1999 Matthias Ettrich - Copyright (C) 2007 by Charles Connell - Copyright (C) 2008 Lukas Appelhans - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ -#ifndef KSYSTEMTRAY_H -#define KSYSTEMTRAY_H - -#include -#include - -#include -#include - -class KActionCollection; -class KSystemTrayIconPrivate; - -/** - * \brief %KDE System Tray Window class - * - * This class implements system tray windows. - * - * A tray window is a small window (typically 22x22 pixel) that docks - * into the system tray in the desktop panel. It usually displays an - * icon or an animated icon there. The icon represents - * the application, similar to a taskbar button, but consumes less - * screen space. - * - * When the user clicks with the left mouse button on the icon, the - * main application window is shown/raised and activated. With the - * right mouse button, she gets a popupmenu with application specific - * commands, including "Minimize/Restore" and "Quit". - * - * Please note that this class is being phased out in favor of the KStatusNotifierItem - * class, you should consider to use it instead if you are writing a new application - * or consider porting the code that uses this class to the KStatusNotifierItem API. - * - * Also, QSystemTrayIcon::showMessage(..) should not be - * used for KDE application because the popup message has no KDE standard - * look & feel and cannot be controlled by KDE configurations. - * Use KNotification or KPassivePopup instead. - * - * @author Matthias Ettrich - **/ -class KDEUI_EXPORT KSystemTrayIcon : public QSystemTrayIcon //krazy:exclude=qclasses -{ - Q_OBJECT -public: - /** - * Construct a system tray icon. - * - * The parent widget @p parent has a special meaning: - * Besides owning the tray window, the parent widget will - * disappear from taskbars when it is iconified while the tray - * window is visible. This is the desired behavior. After all, - * the tray window @p is the parent's taskbar icon. - * - * Furthermore, the parent widget is shown or raised respectively - * when the user clicks on the tray window with the left mouse - * button. - **/ - explicit KSystemTrayIcon( QWidget* parent = 0 ); - - /** - * Same as above but allows one to define the icon by name that should - * be used for the system tray icon. - */ - explicit KSystemTrayIcon( const QString& icon, QWidget* parent = 0 ); - - /** - * Same as above but allows one to define the icon by name that should - * be used for the system tray icon. - */ - explicit KSystemTrayIcon( const QIcon& icon, QWidget* parent = 0 ); - - /** - * Destructor - */ - ~KSystemTrayIcon(); - - /** - Easy access to the actions in the context menu - Currently includes KStandardAction::Quit and minimizeRestore - */ - KActionCollection* actionCollection(); - - /** - Returns the QWidget set by the constructor - */ - QWidget *parentWidget() const; - - /** - Function to be used from function handling closing of the window associated - with the tray icon (i.e. QWidget::closeEvent(), KMainWindow::queryClose() or - similar). When false is returned, the window closing should proceed normally, - when true is returned, special systray-related handling should take place. - */ - bool parentWidgetTrayClose() const; - - /** - * Loads an icon @p icon using the icon loader class of the given componentData @p componentData. - * The icon is applied the panel effect as it should only be used to be shown in the - * system tray. - * It's commonly used in the form : systray->setPixmap( systray->loadIcon( "mysystray" ) ); - */ - static QIcon loadIcon(const QString &icon, const KComponentData &componentData = KGlobal::mainComponent()); - - /** - * Sets the context menu title action to @p action. - * The following code shows how to change the current title. - * - * QAction *titleAction = contextMenuTitle(); - * titleAction->setText("New Title"); - * setContextMenuTitle(titleAction); - * - * @since 4.1 - */ - void setContextMenuTitle(QAction *action); - - /** - * Returns the context menu title action. - * @since 4.1 - */ - QAction *contextMenuTitle() const; - -Q_SIGNALS: - /** - * Emitted when quit is selected in the menu. If you want to perform any other - * action than to close the main application window please connect to this signal. - */ - void quitSelected(); - -public Q_SLOTS: - void toggleActive(); - -private Q_SLOTS: - void contextMenuAboutToShow(); - void minimizeRestoreAction(); - void maybeQuit(); - void activateOrHide( QSystemTrayIcon::ActivationReason reasonCalled ); - -private: - void init( QWidget* ); - void minimizeRestore( bool restore ); - - KSystemTrayIconPrivate* const d; -}; - -#endif - diff --git a/kdeui/notifications/org.kde.StatusNotifierItem.xml b/kdeui/notifications/org.kde.StatusNotifierItem.xml deleted file mode 100644 index 3a13b23b..00000000 --- a/kdeui/notifications/org.kde.StatusNotifierItem.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/kdeui/notifications/org.kde.StatusNotifierWatcher.xml b/kdeui/notifications/org.kde.StatusNotifierWatcher.xml deleted file mode 100644 index 2eb1a7a0..00000000 --- a/kdeui/notifications/org.kde.StatusNotifierWatcher.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/kdeui/widgets/kmainwindow.cpp b/kdeui/widgets/kmainwindow.cpp index 154b3d91..2d7242d1 100644 --- a/kdeui/widgets/kmainwindow.cpp +++ b/kdeui/widgets/kmainwindow.cpp @@ -197,9 +197,6 @@ K_GLOBAL_STATIC(KMWSessionManager, ksm) K_GLOBAL_STATIC(QList, sMemberList) static bool being_first = true; -extern void kAppCreateTray(); -extern void kAppDestroyTray(); - KMainWindow::KMainWindow( QWidget* parent, Qt::WindowFlags f ) : QMainWindow(parent, f), k_ptr(new KMainWindowPrivate) { @@ -273,8 +270,6 @@ void KMainWindowPrivate::init(KMainWindow *_q) letDirtySettings = true; sizeApplied = false; - - kAppCreateTray(); } static bool endsWithHashNumber( const QString& s ) @@ -455,9 +450,6 @@ KMainWindow::~KMainWindow() sMemberList->removeAll( this ); delete static_cast(k_ptr->dockResizeListener); //so we don't get anymore events after k_ptr is destroyed delete k_ptr; - if (sMemberList->isEmpty()) { - kAppDestroyTray(); - } KGlobal::deref(); } diff --git a/kio/application.desktop b/kio/application.desktop index 52e4ca89..606582aa 100644 --- a/kio/application.desktop +++ b/kio/application.desktop @@ -132,6 +132,3 @@ Type=bool [PropertyDef::X-KDE-Protocols] Type=QStringList - -[PropertyDef::X-KDE-HasTrayOption] -Type=bool diff --git a/kio/kfile/kpropertiesdesktopadvbase.ui b/kio/kfile/kpropertiesdesktopadvbase.ui index 529574f5..2414dc59 100644 --- a/kio/kfile/kpropertiesdesktopadvbase.ui +++ b/kio/kfile/kpropertiesdesktopadvbase.ui @@ -154,16 +154,6 @@ - - - - Check this option if you want to have a system tray handle for your application. - - - &Place in system tray - - - diff --git a/kio/kfile/kpropertiesdialog.cpp b/kio/kfile/kpropertiesdialog.cpp index f104097e..55904c11 100644 --- a/kio/kfile/kpropertiesdialog.cpp +++ b/kio/kfile/kpropertiesdialog.cpp @@ -2989,8 +2989,6 @@ public: , m_terminalBool(false) , m_suidBool(false) , m_startupBool(false) - , m_systrayBool(false) - , m_canSystrayBool(false) { } ~KDesktopPropsPluginPrivate() @@ -3009,8 +3007,6 @@ public: bool m_terminalBool; bool m_suidBool; bool m_startupBool; - bool m_systrayBool; - bool m_canSystrayBool; }; KDesktopPropsPlugin::KDesktopPropsPlugin(KPropertiesDialog *props) @@ -3067,12 +3063,6 @@ KDesktopPropsPlugin::KDesktopPropsPlugin(KPropertiesDialog *props) QString genNameStr = _config.readGenericName(); QString commentStr = _config.readComment(); QString commandStr = config.readEntry("Exec", QString()); - if (commandStr.endsWith(QLatin1String(" -tray"))) { - commandStr.chop(6); - d->m_systrayBool = true; - } else { - d->m_systrayBool = false; - } d->m_origCommandStr = commandStr; QString pathStr = config.readEntry("Path", QString()); // not readPathEntry, see kservice.cpp @@ -3082,7 +3072,6 @@ KDesktopPropsPlugin::KDesktopPropsPlugin(KPropertiesDialog *props) d->m_suidUserStr = config.readEntry("X-KDE-Username"); d->m_startupBool = config.readEntry("StartupNotify", false); d->m_startupClassStr = config.readEntry("StartupWMClass", QString()); - d->m_canSystrayBool = config.readEntry("X-KDE-HasTrayOption", false); const QStringList mimeTypes = config.readXdgListEntry("MimeType"); @@ -3219,11 +3208,7 @@ void KDesktopPropsPlugin::applyChanges() config.writeEntry("GenericName", d->w->genNameEdit->text() ); config.writeEntry("GenericName", d->w->genNameEdit->text(), KConfigGroup::Persistent | KConfigGroup::Localized ); // for compat - if (d->m_systrayBool) { - config.writeEntry("Exec", d->w->commandEdit->text().append(" -tray")); - } else { - config.writeEntry("Exec", d->w->commandEdit->text()); - } + config.writeEntry("Exec", d->w->commandEdit->text()); config.writeEntry("Path", d->w->pathEdit->lineEdit()->text()); // not writePathEntry, see kservice.cpp // Write mimeTypes @@ -3253,7 +3238,6 @@ void KDesktopPropsPlugin::applyChanges() config.writeEntry("X-KDE-Username", d->m_suidUserStr); config.writeEntry("StartupNotify", d->m_startupBool); config.writeEntry("StartupWMClass", d->m_startupClassStr); - config.writeEntry("X-KDE-HasTrayOption", d->m_canSystrayBool); config.sync(); // KSycoca update needed? @@ -3326,8 +3310,6 @@ void KDesktopPropsPlugin::slotAdvanced() w.startupClassEdit->setText(d->m_startupClassStr); w.startupClassEdit->setEnabled(d->m_startupBool); w.startupClassLabel->setEnabled(d->m_startupBool); - w.systrayCheck->setChecked(d->m_systrayBool); - w.systrayCheck->setEnabled(d->m_canSystrayBool); // Provide username completion up to 1000 users. KCompletion *kcom = new KCompletion; @@ -3353,7 +3335,6 @@ void KDesktopPropsPlugin::slotAdvanced() connect(w.suidEdit, SIGNAL(textChanged(QString)), this, SIGNAL(changed()) ); connect(w.startupInfoCheck, SIGNAL(toggled(bool)), this, SIGNAL(changed()) ); connect(w.startupClassEdit, SIGNAL(textChanged(QString)), this, SIGNAL(changed()) ); - connect(w.systrayCheck, SIGNAL(toggled(bool)), this, SIGNAL(changed()) ); if (dlg.exec() == QDialog::Accepted) { d->m_terminalOptionStr = w.terminalEdit->text().trimmed(); @@ -3362,7 +3343,6 @@ void KDesktopPropsPlugin::slotAdvanced() d->m_suidUserStr = w.suidEdit->text().trimmed(); d->m_startupBool = w.startupInfoCheck->isChecked(); d->m_startupClassStr = w.startupClassEdit->text().trimmed(); - d->m_systrayBool = w.systrayCheck->isChecked(); if (w.terminalCloseCheck->isChecked()) { d->m_terminalOptionStr.append(" --noclose"); diff --git a/plasma/CMakeLists.txt b/plasma/CMakeLists.txt index c615c28c..90149d00 100644 --- a/plasma/CMakeLists.txt +++ b/plasma/CMakeLists.txt @@ -9,8 +9,6 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${KDE4_KDECORE_INCLUDES} ${KDE4_KDEUI_INCLUDES} - ${CMAKE_SOURCE_DIR}/kdeclarative - ${CMAKE_BINARY_DIR}/kdeclarative ${CMAKE_SOURCE_DIR}/plasma/extenders # for the export headers ${CMAKE_BINARY_DIR}/kutils @@ -27,11 +25,6 @@ if(NOT PLASMA_NO_SOLID) set(PLASMA_EXTRA_LIBS ${PLASMA_EXTRA_LIBS} solid) endif() -if(NOT PLASMA_NO_KUTILS) - include_directories(${CMAKE_SOURCE_DIR}/kutils) - set(PLASMA_EXTRA_LIBS ${PLASMA_EXTRA_LIBS} kcmutils) -endif() - configure_file( config-plasma.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-plasma.h @@ -62,7 +55,6 @@ set(plasma_LIB_SRCS animations/widgetsnapshot.cpp animations/zoom.cpp applet.cpp - configloader.cpp containment.cpp containmentactions.cpp containmentactionspluginsconfig.cpp @@ -84,7 +76,6 @@ set(plasma_LIB_SRCS private/applethandle.cpp private/associatedapplicationmanager.cpp private/datacontainer_p.cpp - private/dataenginebindings.cpp private/dataengineconsumer.cpp private/extenderapplet.cpp private/extenderitemmimedata.cpp @@ -100,8 +91,6 @@ set(plasma_LIB_SRCS runnercontext.cpp runnermanager.cpp runnersyntax.cpp - scripting/appletscript.cpp - scripting/scriptengine.cpp service.cpp servicejob.cpp svg.cpp @@ -113,7 +102,6 @@ set(plasma_LIB_SRCS windoweffects.cpp widgets/checkbox.cpp widgets/combobox.cpp - widgets/declarativewidget.cpp widgets/flashinglabel.cpp widgets/frame.cpp widgets/groupbox.cpp @@ -153,16 +141,11 @@ set_source_files_properties( add_library(plasma SHARED ${plasma_LIB_SRCS}) target_link_libraries(plasma PUBLIC - ${QT_QTUITOOLS_LIBRARY} - ${QT_QTSCRIPT_LIBRARY} ${QT_QTNETWORK_LIBRARY} - ${QT_QTXML_LIBRARY} ${QT_QTSVG_LIBRARY} - ${QT_QTDECLARATIVE_LIBRARY} ${PLASMA_EXTRA_LIBS} kdecore kdeui - kdeclarative ) target_link_libraries(plasma PRIVATE ${X11_LIBRARIES}) @@ -192,7 +175,6 @@ install( animations/animation.h animator.h applet.h - configloader.h containment.h containmentactions.h containmentactionspluginsconfig.h @@ -232,7 +214,6 @@ install( FILES widgets/checkbox.h widgets/combobox.h - widgets/declarativewidget.h widgets/flashinglabel.h widgets/frame.h widgets/groupbox.h @@ -260,13 +241,6 @@ install( DESTINATION ${KDE4_INCLUDE_INSTALL_DIR}/plasma/widgets ) -install( - FILES - scripting/appletscript.h - scripting/scriptengine.h - DESTINATION ${KDE4_INCLUDE_INSTALL_DIR}/plasma/scripting -) - install( FILES animations/animation.h @@ -282,7 +256,6 @@ install( data/servicetypes/plasma-containmentactions.desktop data/servicetypes/plasma-dataengine.desktop data/servicetypes/plasma-runner.desktop - data/servicetypes/plasma-scriptengine.desktop data/servicetypes/plasma-toolbox.desktop data/servicetypes/plasma-wallpaper.desktop DESTINATION ${KDE4_SERVICETYPES_INSTALL_DIR} diff --git a/plasma/abstractrunner.h b/plasma/abstractrunner.h index 904be24d..44dd44a5 100644 --- a/plasma/abstractrunner.h +++ b/plasma/abstractrunner.h @@ -421,8 +421,7 @@ class PLASMA_EXPORT AbstractRunner : public QObject protected Q_SLOTS: /** * Reimplement this slot to run any initialization routines on first load. - * By default, it calls reloadConfiguration(); for scripted Runners this - * method also sets up the ScriptEngine. + * By default, it calls reloadConfiguration() */ void init(); diff --git a/plasma/applet.cpp b/plasma/applet.cpp index 1110fa9d..e395c058 100644 --- a/plasma/applet.cpp +++ b/plasma/applet.cpp @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include #include @@ -42,9 +42,8 @@ #include #include #include -#include +#include #include -#include #include #include @@ -64,20 +63,13 @@ #include #include #include - -#ifndef PLASMA_NO_KUTILS -#include -#include -#else -#include -#endif +#include #ifndef PLASMA_NO_SOLID #include #endif #include "abstracttoolbox.h" -#include "configloader.h" #include "containment.h" #include "corona.h" #include "dataenginemanager.h" @@ -86,7 +78,6 @@ #include "extenders/extenderitem.h" #include "package.h" #include "plasma.h" -#include "scripting/appletscript.h" #include "svg.h" #include "framesvg.h" #include "popupapplet.h" @@ -188,14 +179,6 @@ Applet::Applet(QObject *parentObject, const QVariantList &args) // inflexibility of KService::createInstance } -Applet::Applet(const QString &packagePath, uint appletId, const QVariantList &args) - : QGraphicsWidget(0), - d(new AppletPrivate(KService::Ptr(new KService(packagePath + "/metadata.desktop")), 0, appletId, this)) -{ - Q_UNUSED(args) // FIXME? - d->init(packagePath); -} - Applet::~Applet() { //let people know that i will die @@ -223,25 +206,9 @@ Applet::~Applet() delete d; } -PackageStructure::Ptr Applet::packageStructure() -{ - if (!AppletPrivate::packageStructure) { - AppletPrivate::packageStructure = new PlasmoidPackage(); - } - - return AppletPrivate::packageStructure; -} - void Applet::init() { setFlag(ItemIsMovable, true); - if (d->script) { - d->setupScriptSupport(); - - if (!d->script->init() && !d->failed) { - setFailedToLaunch(true, i18n("Script initialization failed")); - } - } } uint Applet::id() const @@ -290,14 +257,6 @@ void Applet::save(KConfigGroup &g) const KConfigGroup appletConfigGroup(&group, "Configuration"); saveState(appletConfigGroup); - - if (d->configLoader) { - // we're saving so we know its changed, we don't need or want the configChanged - // signal bubbling up at this point due to that - disconnect(d->configLoader, SIGNAL(configChanged()), this, SLOT(propagateConfigChanged())); - d->configLoader->writeConfig(); - connect(d->configLoader, SIGNAL(configChanged()), this, SLOT(propagateConfigChanged())); - } } void Applet::restore(KConfigGroup &group) @@ -414,10 +373,6 @@ void Applet::setFailedToLaunch(bool failed, const QString &reason) void Applet::saveState(KConfigGroup &group) const { - if (d->script) { - emit d->script->saveState(group); - } - if (group.config()->name() != config().config()->name()) { // we're being saved to a different file! // let's just copy the current values in our configuration over @@ -535,10 +490,6 @@ void AppletPrivate::cleanUpAndDelete() } } - if (configLoader) { - configLoader->setDefaults(); - } - resetConfigurationObject(); if (q->scene()) { @@ -661,21 +612,11 @@ void AppletPrivate::destroyMessageOverlay() } } -ConfigLoader *Applet::configScheme() const -{ - return d->configLoader; -} - DataEngine *Applet::dataEngine(const QString &name) const { return d->dataEngine(name); } -const Package *Applet::package() const -{ - return d->package; -} - QGraphicsView *Applet::view() const { // It's assumed that we won't be visible on more than one view here. @@ -744,22 +685,15 @@ void Applet::constraintsEvent(Plasma::Constraints constraints) Q_UNUSED(constraints) //kDebug() << constraints << "constraints are FormFactor: " << formFactor() // << ", Location: " << location(); - if (d->script) { - d->script->constraintsEvent(constraints); - } } void Applet::initExtenderItem(ExtenderItem *item) { - if (d->script) { - emit extenderItemRestored(item); - } else { - kWarning() << "Missing implementation of initExtenderItem in the applet " - << item->config().readEntry("SourceAppletPluginName", "") - << "!\n Any applet that uses extenders should implement initExtenderItem to " - << "instantiate a widget. Destroying the item..."; - item->destroy(); - } + kWarning() << "Missing implementation of initExtenderItem in the applet " + << item->config().readEntry("SourceAppletPluginName", "") + << "!\n Any applet that uses extenders should implement initExtenderItem to " + << "instantiate a widget. Destroying the item..."; + item->destroy(); } Extender *Applet::extender() const @@ -834,6 +768,7 @@ QString Applet::pluginName() const bool Applet::shouldConserveResources() const { +#warning TODO: remove this method, applets should use the solid method #ifndef PLASMA_NO_SOLID return Solid::PowerManagement::appShouldConserveResources(); #else @@ -1360,7 +1295,7 @@ int Applet::type() const QList Applet::contextualActions() { //kDebug() << "empty context actions"; - return d->script ? d->script->contextualActions() : QList(); + return QList(); } QAction *Applet::action(const QString &name) const @@ -1445,11 +1380,7 @@ void Applet::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QW void Applet::paintInterface(QPainter *painter, const QStyleOptionGraphicsItem *option, const QRect &contentsRect) { - if (d->script) { - d->script->paintInterface(painter, option, contentsRect); - } else { - //kDebug() << "Applet::paintInterface() default impl"; - } + //kDebug() << "Applet::paintInterface() default impl"; } FormFactor Applet::formFactor() const @@ -1832,91 +1763,9 @@ void Applet::showConfigurationInterface() return; } - if (d->package) { - KConfigDialog *dialog = 0; - - const QString uiFile = d->package->filePath("mainconfigui"); - KDesktopFile df(d->package->path() + "/metadata.desktop"); - const QStringList kcmPlugins = df.desktopGroup().readEntry("X-Plasma-ConfigPlugins", QStringList()); - if (!uiFile.isEmpty() || !kcmPlugins.isEmpty()) { - KConfigSkeleton *configLoader = d->configLoader ? d->configLoader : new KConfigSkeleton(); - dialog = new AppletConfigDialog(0, d->configDialogId(), configLoader); - - if (!d->configLoader) { - // delete the temporary when this dialog is done - configLoader->setParent(dialog); - } - - dialog->setWindowTitle(d->configWindowTitle()); - dialog->setAttribute(Qt::WA_DeleteOnClose, true); - bool hasPages = false; - - QFile f(uiFile); - QUiLoader loader; - QWidget *w = loader.load(&f); - if (w) { - dialog->addPage(w, i18n("Settings"), icon(), i18n("%1 Settings", name())); - hasPages = true; - } - - foreach (const QString &kcm, kcmPlugins) { -#ifndef PLASMA_NO_KUTILS - KCModuleProxy *module = new KCModuleProxy(kcm); - if (module->realModule()) { - //preemptively load modules to prevent save() crashing on some kcms, like powerdevil ones - module->load(); - connect(module, SIGNAL(changed(bool)), dialog, SLOT(settingsModified(bool))); - connect(dialog, SIGNAL(okClicked()), - module->realModule(), SLOT(save())); - connect(dialog, SIGNAL(applyClicked()), - module->realModule(), SLOT(save())); - dialog->addPage(module, module->moduleInfo().moduleName(), module->moduleInfo().icon()); - hasPages = true; - } else { - delete module; - } -#else - KService::Ptr service = KService::serviceByStorageId(kcm); - if (service) { - QString error; - KCModule *module = service->createInstance(dialog, QVariantList(), &error); - if (module) { - module->load(); - connect(module, SIGNAL(changed(bool)), dialog, SLOT(settingsModified(bool))); - connect(dialog, SIGNAL(okClicked()), - module, SLOT(save())); - connect(dialog, SIGNAL(applyClicked()), - module, SLOT(save())); - dialog->addPage(module, service->name(), service->icon()); - hasPages = true; - } else { -#ifndef NDEBUG - kDebug() << "failed to load kcm" << kcm << "for" << name(); -#endif - } - } -#endif - } - - if (hasPages) { - d->addGlobalShortcutsPage(dialog); - dialog->show(); - } else { - delete dialog; - dialog = 0; - } - } - - if (!dialog && d->script) { - d->script->showConfigurationInterface(); - } - } else if (d->script) { - d->script->showConfigurationInterface(); - } else { - KConfigDialog *dialog = d->generateGenericConfigDialog(); - d->addStandardConfigurationPages(dialog); - showConfigurationInterface(dialog); - } + KConfigDialog *dialog = d->generateGenericConfigDialog(); + d->addStandardConfigurationPages(dialog); + showConfigurationInterface(dialog); emit releaseVisualFocus(); } @@ -2021,12 +1870,9 @@ void AppletPrivate::configDialogFinished() } - if (!configLoader) { - // the config loader will trigger this for us, so we don't need to. - propagateConfigChanged(); - if (KConfigDialog *dialog = qobject_cast(q->sender())) { - dialog->enableButton(KDialog::Apply, false); - } + propagateConfigChanged(); + if (KConfigDialog *dialog = qobject_cast(q->sender())) { + dialog->enableButton(KDialog::Apply, false); } } @@ -2071,12 +1917,6 @@ void AppletPrivate::propagateConfigChanged() void Applet::configChanged() { - if (d->script) { - if (d->configLoader) { - d->configLoader->readConfig(); - } - d->script->configChanged(); - } } void Applet::createConfigurationInterface(KConfigDialog *parent) @@ -2229,24 +2069,6 @@ QStringList Applet::listCategories(const QString &parentApp, bool visibleOnly) return categories; } -Applet *Applet::loadPlasmoid(const QString &path, uint appletId, const QVariantList &args) -{ - if (QFile::exists(path + "/metadata.desktop")) { - KService service(path + "/metadata.desktop"); - const QStringList& types = service.serviceTypes(); - - if (types.contains("Plasma/Containment")) { - return new Containment(path, appletId, args); - } else if (types.contains("Plasma/PopupApplet")) { - return new PopupApplet(path, appletId, args); - } else { - return new Applet(path, appletId, args); - } - } - - return 0; -} - Applet *Applet::load(const QString &appletName, uint appletId, const QVariantList &args) { return PluginLoader::loadApplet(appletName, appletId, args); @@ -2325,15 +2147,6 @@ QVariant Applet::itemChange(GraphicsItemChange change, const QVariant &value) return ret; } -QPainterPath Applet::shape() const -{ - if (d->script) { - return d->script->shape(); - } - - return QGraphicsWidget::shape(); -} - QSizeF Applet::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const { QSizeF hint = QGraphicsWidget::sizeHint(which, constraint); @@ -2484,9 +2297,6 @@ AppletPrivate::AppletPrivate(KService::Ptr service, const KPluginInfo *info, int messageOverlay(0), messageOverlayProxy(0), busyWidget(0), - script(0), - package(0), - configLoader(0), actions(AppletPrivate::defaultActions(applet)), activationAction(0), itemStatus(UnknownStatus), @@ -2515,18 +2325,12 @@ AppletPrivate::~AppletPrivate() delete extender.data(); - delete script; - script = 0; - delete package; - package = 0; - delete configLoader; - configLoader = 0; delete mainConfig; mainConfig = 0; delete modificationsTimer; } -void AppletPrivate::init(const QString &packagePath) +void AppletPrivate::init() { // WARNING: do not access config() OR globalConfig() in this method! // that requires a scene, which is not available at this point @@ -2568,73 +2372,6 @@ void AppletPrivate::init(const QString &packagePath) } //kDebug() << "size" << size; q->resize(size); - - QString api = appletDescription.property("X-Plasma-API").toString(); - - // we have a scripted plasmoid - if (!api.isEmpty()) { - // find where the Package is - QString path = packagePath.isEmpty() ? appletDescription.pluginName() : packagePath; - // create the package and see if we have something real - PackageStructure::Ptr structure = Plasma::packageStructure(api, Plasma::AppletComponent); - package = new Package(path, structure); - //kDebug() << "***** package is" << package->path(); - - if (package->isValid()) { - // now we try and set up the script engine. - // it will be parented to this applet and so will get - // deleted when the applet does - - script = Plasma::loadScriptEngine(api, q); - if (!script) { - delete package; - package = 0; - q->setFailedToLaunch(true, - i18nc("API or programming language the widget was written in, name of the widget", - "Could not create a %1 ScriptEngine for the %2 widget.", - api, appletDescription.name())); - } - } else { - q->setFailedToLaunch(true, i18nc("Package file, name of the widget", - "Could not open the %1 package required for the %2 widget.", - appletDescription.pluginName(), appletDescription.name())); - delete package; - package = 0; - } - } -} - -// put all setup routines for script here. at this point we can assume that -// package exists and that we have a script engine -void AppletPrivate::setupScriptSupport() -{ - if (!package) { - return; - } - - kDebug() << "setting up script support, package is in" << package->path() - << "which is a" << package->structure()->type() << "package" - << ", main script is" << package->filePath("mainscript"); - - QString translationsPath = package->filePath("translations"); - if (!translationsPath.isEmpty()) { - //FIXME: we should _probably_ use a KComponentData to segregate the applets - // from each other; but I want to get the basics working first :) - KGlobal::dirs()->addResourceDir("locale", translationsPath); - KGlobal::locale()->insertCatalog(package->metadata().pluginName()); - } - - QString xmlPath = package->filePath("mainconfigxml"); - if (!xmlPath.isEmpty()) { - QFile file(xmlPath); - KConfigGroup config = q->config(); - configLoader = new ConfigLoader(&config, &file); - QObject::connect(configLoader, SIGNAL(configChanged()), q, SLOT(propagateConfigChanged())); - } - - if (!package->filePath("mainconfigui").isEmpty()) { - q->setHasConfigurationInterface(true); - } } QString AppletPrivate::globalName() const @@ -2689,7 +2426,6 @@ KConfigGroup *AppletPrivate::mainConfigGroup() return mainConfig; } - bool newGroup = false; if (isContainment) { Corona *corona = qobject_cast(q->scene()); KConfigGroup containmentConfig; @@ -2701,10 +2437,6 @@ KConfigGroup *AppletPrivate::mainConfigGroup() containmentConfig = KConfigGroup(KGlobal::config(), "Containments"); } - if (package && !containmentConfig.hasGroup(QString::number(appletId))) { - newGroup = true; - } - mainConfig = new KConfigGroup(&containmentConfig, QString::number(appletId)); } else { KConfigGroup appletConfig; @@ -2725,23 +2457,9 @@ KConfigGroup *AppletPrivate::mainConfigGroup() appletConfig = KConfigGroup(KGlobal::config(), "Applets"); } - if (package && !appletConfig.hasGroup(QString::number(appletId))) { - newGroup = true; - } - mainConfig = new KConfigGroup(&appletConfig, QString::number(appletId)); } - if (newGroup) { - //see if we have a default configuration in our package - const QString defaultConfigFile = q->package()->filePath("defaultconfig"); - if (!defaultConfigFile.isEmpty()) { - kDebug() << "copying default config: " << q->package()->filePath("defaultconfig"); - KConfigGroup defaultConfig(KSharedConfig::openConfig(defaultConfigFile)->group("Configuration")); - defaultConfig.copyTo(mainConfig); - } - } - return mainConfig; } @@ -2811,7 +2529,6 @@ void ContainmentPrivate::checkRemoveAction() uint AppletPrivate::s_maxAppletId = 0; int AppletPrivate::s_maxZValue = 0; int AppletPrivate::s_minZValue = 0; -PackageStructure::Ptr AppletPrivate::packageStructure(0); AppletOverlayWidget::AppletOverlayWidget(QGraphicsWidget *parent) : QGraphicsWidget(parent), diff --git a/plasma/applet.h b/plasma/applet.h index f2f7f654..8d6a933c 100644 --- a/plasma/applet.h +++ b/plasma/applet.h @@ -28,13 +28,12 @@ #include #include +#include #include #include #include #include -#include -#include #include #include #include @@ -51,8 +50,6 @@ class Context; class DataEngine; class Extender; class ExtenderItem; -class Package; - /** * @class Applet plasma/applet.h @@ -66,9 +63,8 @@ class Package; * management of data engines (e.g. all data engines accessed via * Applet::dataEngine(const QString&) are properly deref'd on Applet * destruction), background painting (allowing for consistent and complex - * look and feel in just one line of code for applets), loading and starting - * of scripting support for each applet, providing access to the associated - * plasmoid package (if any) and access to configuration data. + * look and feel in just one line of code for applets), providing access to + * the to configuration data. */ class PLASMA_EXPORT Applet : public QGraphicsWidget { @@ -109,11 +105,6 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget ~Applet(); - /** - * @return a package structure representing an Applet - */ - static PackageStructure::Ptr packageStructure(); - /** * @return the id of this applet */ @@ -168,14 +159,6 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget */ KConfigGroup globalConfig() const; - /** - * Returns the config skeleton object from this applet's package, - * if any. - * - * @return config skeleton object, or 0 if none - **/ - ConfigLoader *configScheme() const; - /** * Loads the given DataEngine * @@ -195,14 +178,6 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget */ Q_INVOKABLE DataEngine *dataEngine(const QString &name) const; - /** - * Accessor for the associated Package object if any. - * Generally, only Plasmoids come in a Package. - * - * @return the Package object, or 0 if none - **/ - const Package *package() const; - /** * Returns the view this widget is visible on, or 0 if none can be found. * @warning do NOT assume this will always return a view! @@ -325,23 +300,6 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget static QStringList listCategories(const QString &parentApp = QString(), bool visibleOnly = true); - /** - * Attempts to load an applet from a package - * - * Returns a pointer to the applet if successful. - * The caller takes responsibility for the applet, including - * deleting it when no longer needed. - * - * @param path the path to the package - * @param appletId unique ID to assign the applet, or zero to have one - * assigned automatically. - * @param args to send the applet extra arguments - * @return a pointer to the loaded applet, or 0 on load failure - * @since 4.3 - **/ - static Applet *loadPlasmoid(const QString &path, uint appletId = 0, - const QVariantList &args = QVariantList()); - /** * Attempts to load an applet * @@ -1030,11 +988,6 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget */ QVariant itemChange(GraphicsItemChange change, const QVariant &value); - /** - * Reimplemented from QGraphicsItem - */ - QPainterPath shape() const; - /** * Reimplemented from QGraphicsLayoutItem */ @@ -1045,18 +998,7 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget */ void timerEvent(QTimerEvent *event); - private: - /** - * @internal This constructor is to be used with the Package loading system. - * - * @param parent a QObject parent; you probably want to pass in 0 - * @param args a list of strings containing two entries: the service id - * and the applet id - * @since 4.3 - */ - Applet(const QString &packagePath, uint appletId, const QVariantList &args); - Q_PRIVATE_SLOT(d, void setFocus()) Q_PRIVATE_SLOT(d, void themeChanged()) Q_PRIVATE_SLOT(d, void cleanUpAndDelete()) @@ -1081,7 +1023,6 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget friend class CoronaPrivate; friend class Containment; friend class ContainmentPrivate; - friend class AppletScript; friend class AppletHandle; friend class AppletPrivate; friend class PluginLoader; diff --git a/plasma/config-plasma.h.cmake b/plasma/config-plasma.h.cmake index 99e68f7c..74d39275 100644 --- a/plasma/config-plasma.h.cmake +++ b/plasma/config-plasma.h.cmake @@ -1,5 +1,4 @@ #cmakedefine PLASMA_NO_SOLID #cmakedefine PLASMA_NO_KIO -#cmakedefine PLASMA_NO_KUTILS #cmakedefine PLASMA_NO_GLOBAL_SHORTCUTS diff --git a/plasma/configloader.cpp b/plasma/configloader.cpp deleted file mode 100644 index 443e65ef..00000000 --- a/plasma/configloader.cpp +++ /dev/null @@ -1,432 +0,0 @@ -/* - * Copyright 2007 Aaron Seigo - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library 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 Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "configloader.h" -#include "private/configloader_p.h" - -#include -#include -#include -#include - -#include -#include - -namespace Plasma -{ -class ConfigLoaderHandler : public QXmlDefaultHandler -{ -public: - ConfigLoaderHandler(ConfigLoader *config, ConfigLoaderPrivate *d); - bool startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts); - bool endElement(const QString &namespaceURI, const QString &localName, - const QString &qName); - bool characters(const QString &ch); - -private: - void addItem(); - void resetState(); - - ConfigLoader *m_config; - ConfigLoaderPrivate *d; - int m_min; - int m_max; - QString m_name; - QString m_key; - QString m_type; - QString m_label; - QString m_default; - QString m_cdata; - QString m_whatsThis; - KConfigSkeleton::ItemEnum::Choice m_choice; - QList m_enumChoices; - bool m_haveMin; - bool m_haveMax; - bool m_inChoice; -}; - -void ConfigLoaderPrivate::parse(ConfigLoader *loader, QIODevice *xml) -{ - QXmlInputSource source(xml); - QXmlSimpleReader reader; - ConfigLoaderHandler handler(loader, this); - reader.setContentHandler(&handler); - reader.parse(&source, false); -} - -ConfigLoaderHandler::ConfigLoaderHandler(ConfigLoader *config, ConfigLoaderPrivate *d) - : QXmlDefaultHandler(), - m_config(config), - d(d) -{ - resetState(); -} - -bool ConfigLoaderHandler::startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &attrs) -{ - Q_UNUSED(namespaceURI) - Q_UNUSED(qName) - -// kDebug() << "ConfigLoaderHandler::startElement(" << localName << qName; - int numAttrs = attrs.count(); - QString tag = localName.toLower(); - if (tag == "group") { - QString group; - for (int i = 0; i < numAttrs; ++i) { - QString name = attrs.localName(i).toLower(); - if (name == "name") { - //kDebug() << "set group to" << attrs.value(i); - group = attrs.value(i); - } - } - if (group.isEmpty()) { - group = d->baseGroup; - } else { - d->groups.append(group); - if (!d->baseGroup.isEmpty()) { - group = d->baseGroup + '\x1d' + group; - } - } - m_config->setCurrentGroup(group); - } else if (tag == "entry") { - for (int i = 0; i < numAttrs; ++i) { - QString name = attrs.localName(i).toLower(); - if (name == "name") { - m_name = attrs.value(i).trimmed(); - } else if (name == "type") { - m_type = attrs.value(i).toLower(); - } else if (name == "key") { - m_key = attrs.value(i).trimmed(); - } - } - } else if (tag == "choice") { - m_choice.name.clear(); - m_choice.label.clear(); - m_choice.whatsThis.clear(); - for (int i = 0; i < numAttrs; ++i) { - QString name = attrs.localName(i).toLower(); - if (name == "name") { - m_choice.name = attrs.value(i); - } - } - m_inChoice = true; - } - - return true; -} - -bool ConfigLoaderHandler::characters(const QString &ch) -{ - m_cdata.append(ch); - return true; -} - -bool ConfigLoaderHandler::endElement(const QString &namespaceURI, - const QString &localName, const QString &qName) -{ - Q_UNUSED(namespaceURI) - Q_UNUSED(qName) - -// kDebug() << "ConfigLoaderHandler::endElement(" << localName << qName; - const QString tag = localName.toLower(); - if (tag == "entry") { - addItem(); - resetState(); - } else if (tag == "label") { - if (m_inChoice) { - m_choice.label = m_cdata.trimmed(); - } else { - m_label = m_cdata.trimmed(); - } - } else if (tag == "whatsthis") { - if (m_inChoice) { - m_choice.whatsThis = m_cdata.trimmed(); - } else { - m_whatsThis = m_cdata.trimmed(); - } - } else if (tag == "default") { - m_default = m_cdata.trimmed(); - } else if (tag == "min") { - m_min = m_cdata.toInt(&m_haveMin); - } else if (tag == "max") { - m_max = m_cdata.toInt(&m_haveMax); - } else if (tag == "choice") { - m_enumChoices.append(m_choice); - m_inChoice = false; - } - - m_cdata.clear(); - return true; -} - -void ConfigLoaderHandler::addItem() -{ - if (m_name.isEmpty()) { - if (m_key.isEmpty()) { - return; - } - - m_name = m_key; - } - - m_name.remove(' '); - - KConfigSkeletonItem *item = 0; - - if (m_type == "bool") { - bool defaultValue = m_default.toLower() == "true"; - item = m_config->addItemBool(m_name, *d->newBool(), defaultValue, m_key); - } else if (m_type == "color") { - QColor color; - - if (m_default.count(',') == 3) { - const QStringList values = m_default.split(','); - - color = QColor(values.at(0).toInt(), values.at(1).toInt(), values.at(2).toInt(), values.at(3).toInt()); - } else { - color = QColor(m_default); - } - - item = m_config->addItemColor(m_name, *d->newColor(), color, m_key); - } else if (m_type == "datetime") { - item = m_config->addItemDateTime(m_name, *d->newDateTime(), - QDateTime::fromString(m_default), m_key); - } else if (m_type == "enum") { - m_key = (m_key.isEmpty()) ? m_name : m_key; - KConfigSkeleton::ItemEnum *enumItem = - new KConfigSkeleton::ItemEnum(m_config->currentGroup(), - m_key, *d->newInt(), - m_enumChoices, - m_default.toUInt()); - m_config->addItem(enumItem, m_name); - item = enumItem; - } else if (m_type == "font") { - item = m_config->addItemFont(m_name, *d->newFont(), QFont(m_default), m_key); - } else if (m_type == "int") { - KConfigSkeleton::ItemInt *intItem = m_config->addItemInt(m_name, *d->newInt(), - m_default.toInt(), m_key); - - if (m_haveMin) { - intItem->setMinValue(m_min); - } - - if (m_haveMax) { - intItem->setMaxValue(m_max); - } - - item = intItem; - } else if (m_type == "path") { - item = m_config->addItemPath(m_name, *d->newString(), m_default, m_key); - } else if (m_type == "string") { - item = m_config->addItemString(m_name, *d->newString(), m_default, m_key); - } else if (m_type == "stringlist") { - //FIXME: the split() is naive and will break on lists with ,'s in them - item = m_config->addItemStringList(m_name, *d->newStringList(), - m_default.split(','), m_key); - } else if (m_type == "uint") { - KConfigSkeleton::ItemUInt *uintItem = - m_config->addItemUInt(m_name, *d->newUint(), m_default.toUInt(), m_key); - if (m_haveMin) { - uintItem->setMinValue(m_min); - } - if (m_haveMax) { - uintItem->setMaxValue(m_max); - } - item = uintItem; - } else if (m_type == "url") { - m_key = (m_key.isEmpty()) ? m_name : m_key; - KConfigSkeleton::ItemUrl *urlItem = - new KConfigSkeleton::ItemUrl(m_config->currentGroup(), - m_key, *d->newUrl(), - m_default); - m_config->addItem(urlItem, m_name); - item = urlItem; - } else if (m_type == "double") { - KConfigSkeleton::ItemDouble *doubleItem = m_config->addItemDouble(m_name, - *d->newDouble(), m_default.toDouble(), m_key); - if (m_haveMin) { - doubleItem->setMinValue(m_min); - } - if (m_haveMax) { - doubleItem->setMaxValue(m_max); - } - item = doubleItem; - } else if (m_type == "intlist") { - QStringList tmpList = m_default.split(','); - QList defaultList; - foreach (const QString &tmp, tmpList) { - defaultList.append(tmp.toInt()); - } - item = m_config->addItemIntList(m_name, *d->newIntList(), defaultList, m_key); - } else if (m_type == "longlong") { - KConfigSkeleton::ItemLongLong *longlongItem = m_config->addItemLongLong(m_name, - *d->newLongLong(), m_default.toLongLong(), m_key); - if (m_haveMin) { - longlongItem->setMinValue(m_min); - } - if (m_haveMax) { - longlongItem->setMaxValue(m_max); - } - item = longlongItem; - /* No addItemPathList in KConfigSkeleton ? - } else if (m_type == "PathList") { - //FIXME: the split() is naive and will break on lists with ,'s in them - item = m_config->addItemPathList(m_name, *d->newStringList(), m_default.split(","), m_key); - */ - } else if (m_type == "point") { - QPoint defaultPoint; - QStringList tmpList = m_default.split(','); - if (tmpList.size() >= 2) { - defaultPoint.setX(tmpList[0].toInt()); - defaultPoint.setY(tmpList[1].toInt()); - } - item = m_config->addItemPoint(m_name, *d->newPoint(), defaultPoint, m_key); - } else if (m_type == "rect") { - QRect defaultRect; - QStringList tmpList = m_default.split(','); - if (tmpList.size() >= 4) { - defaultRect.setCoords(tmpList[0].toInt(), tmpList[1].toInt(), - tmpList[2].toInt(), tmpList[3].toInt()); - } - item = m_config->addItemRect(m_name, *d->newRect(), defaultRect, m_key); - } else if (m_type == "size") { - QSize defaultSize; - QStringList tmpList = m_default.split(','); - if (tmpList.size() >= 2) { - defaultSize.setWidth(tmpList[0].toInt()); - defaultSize.setHeight(tmpList[1].toInt()); - } - item = m_config->addItemSize(m_name, *d->newSize(), defaultSize, m_key); - } else if (m_type == "ulonglong") { - KConfigSkeleton::ItemULongLong *ulonglongItem = - m_config->addItemULongLong(m_name, *d->newULongLong(), m_default.toULongLong(), m_key); - if (m_haveMin) { - ulonglongItem->setMinValue(m_min); - } - if (m_haveMax) { - ulonglongItem->setMaxValue(m_max); - } - item = ulonglongItem; - /* No addItemUrlList in KConfigSkeleton ? - } else if (m_type == "urllist") { - //FIXME: the split() is naive and will break on lists with ,'s in them - QStringList tmpList = m_default.split(","); - KUrl::List defaultList; - foreach (const QString& tmp, tmpList) { - defaultList.append(KUrl(tmp)); - } - item = m_config->addItemUrlList(m_name, *d->newUrlList(), defaultList, m_key);*/ - } - - if (item) { - item->setLabel(m_label); - item->setWhatsThis(m_whatsThis); - d->keysToNames.insert(item->group() + item->key(), item->name()); - } -} - -void ConfigLoaderHandler::resetState() -{ - m_haveMin = false; - m_min = 0; - m_haveMax = false; - m_max = 0; - m_name.clear(); - m_type.clear(); - m_label.clear(); - m_default.clear(); - m_key.clear(); - m_whatsThis.clear(); - m_enumChoices.clear(); - m_inChoice = false; -} - -ConfigLoader::ConfigLoader(const QString &configFile, QIODevice *xml, QObject *parent) - : KConfigSkeleton(configFile, parent), - d(new ConfigLoaderPrivate) -{ - d->parse(this, xml); -} - -ConfigLoader::ConfigLoader(KSharedConfigPtr config, QIODevice *xml, QObject *parent) - : KConfigSkeleton(config, parent), - d(new ConfigLoaderPrivate) -{ - d->parse(this, xml); -} - -//FIXME: obviously this is broken and should be using the group as the root, -// but KConfigSkeleton does not currently support this. it will eventually though, -// at which point this can be addressed properly -ConfigLoader::ConfigLoader(const KConfigGroup *config, QIODevice *xml, QObject *parent) - : KConfigSkeleton(KSharedConfig::openConfig(config->config()->name(), KConfig::SimpleConfig), parent), - d(new ConfigLoaderPrivate) -{ - KConfigGroup group = config->parent(); - d->baseGroup = config->name(); - while (group.isValid() && group.name() != "") { - d->baseGroup = group.name() + '\x1d' + d->baseGroup; - group = group.parent(); - } - d->parse(this, xml); -} - -ConfigLoader::~ConfigLoader() -{ - delete d; -} - -KConfigSkeletonItem *ConfigLoader::findItemByGroup(const QString &group, const QString &key) const -{ - return KConfigSkeleton::findItem(d->keysToNames[group + key]); -} - -QVariant ConfigLoader::property(const QString &name) const -{ - KConfigSkeletonItem *item = KConfigSkeleton::findItem(name); - if (item) { - return item->property(); - } - return QVariant(); -} - -bool ConfigLoader::hasGroup(const QString &group) const -{ - return d->groups.contains(group); -} - -QStringList ConfigLoader::groupList() const -{ - return d->groups; -} - -void ConfigLoader::usrWriteConfig() -{ - if (d->saveDefaults) { - KConfigSkeletonItem::List itemList = items(); - for(int i = 0; i < itemList.size(); i++) { - KConfigGroup cg(config(), itemList.at(i)->group()); - cg.writeEntry(itemList.at(i)->key(), ""); - } - } -} - -} // Plasma namespace diff --git a/plasma/configloader.h b/plasma/configloader.h deleted file mode 100644 index 4251f3c5..00000000 --- a/plasma/configloader.h +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright 2007 Aaron Seigo - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library 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 Library 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. - */ - -#ifndef PLASMA_CONFIGLOADER_H -#define PLASMA_CONFIGLOADER_H - -#include -#include -#include - -#include - -/** - * @class ConfigLoader plasma/configloader.h - * - * @short A KConfigSkeleton that populates itself based on KConfigXT XML - * - * This class allows one to ship an XML file and reconstitute it into a - * KConfigSkeleton object at runtime. Common usage might look like this: - * - * \code - * QFile file(xmlFilePath); - * Plasma::ConfigLoader appletConfig(configFilePath, &file); - * \endcode - * - * Alternatively, any QIODevice may be used in place of QFile in the - * example above. - * - * Currently the following data types are supported: - * - * @li bools - * @li colors - * @li datetimes - * @li enumerations - * @li fonts - * @li ints - * @li passwords - * @li paths - * @li strings - * @li stringlists - * @li uints - * @li urls - * @li doubles - * @li int lists - * @li longlongs - * @li path lists - * @li points - * @li rects - * @li sizes - * @li ulonglongs - * @li url lists - **/ - -namespace Plasma -{ - -class ConfigLoaderPrivate; - -class PLASMA_EXPORT ConfigLoader : public KConfigSkeleton -{ -public: - /** - * Creates a KConfigSkeleton populated using the definition found in - * the XML data passed in. - * - * @param configFile path to the configuration file to use - * @param xml the xml data; must be valid KConfigXT data - * @param parent optional QObject parent - **/ - ConfigLoader(const QString &configFile, QIODevice *xml, QObject *parent = 0); - - /** - * Creates a KConfigSkeleton populated using the definition found in - * the XML data passed in. - * - * @param config the configuration object to use - * @param xml the xml data; must be valid KConfigXT data - * @param parent optional QObject parent - **/ - ConfigLoader(KSharedConfigPtr config, QIODevice *xml, QObject *parent = 0); - - /** - * Creates a KConfigSkeleton populated using the definition found in - * the XML data passed in. - * - * @param config the group to use as the root for configuration items - * @param xml the xml data; must be valid KConfigXT data - * @param parent optional QObject parent - **/ - ConfigLoader(const KConfigGroup *config, QIODevice *xml, QObject *parent = 0); - ~ConfigLoader(); - - /** - * Finds the item for the given group and key. - * - * @param group the group in the config file to look in - * @param key the configuration key to find - * @return the associated KConfigSkeletonItem, or 0 if none - */ - KConfigSkeletonItem *findItemByGroup(const QString &group, const QString &key) const; - - /** - * Returns the property (variantized value) of the named item - */ - QVariant property(const QString &name) const; - - /** - * Check to see if a group exists - * - * @param group the name of the group to check for - * @return true if the group exists, or false if it does not - */ - bool hasGroup(const QString &group) const; - - /** - * @return the list of groups defined by the XML - */ - QStringList groupList() const; - -protected: - /** - * Hack used to force writing when no default exists in config file. - */ - void usrWriteConfig(); - -private: - friend class Service; - ConfigLoaderPrivate * const d; -}; - -} // Plasma namespace - -#endif //multiple inclusion guard diff --git a/plasma/containment.cpp b/plasma/containment.cpp index e0af0c35..6a52ddc0 100644 --- a/plasma/containment.cpp +++ b/plasma/containment.cpp @@ -126,16 +126,6 @@ Containment::Containment(QObject *parent, const QVariantList &args) setBackgroundHints(NoBackground); } -Containment::Containment(const QString &packagePath, uint appletId, const QVariantList &args) - : Plasma::Applet(packagePath, appletId, args), - d(new ContainmentPrivate(this)) -{ - // WARNING: do not access config() OR globalConfig() in this method! - // that requires a scene, which is not available at this point - setPos(0, 0); - setBackgroundHints(NoBackground); -} - Containment::~Containment() { // Applet touches our dptr if we are a containment and is the superclass (think of dtors) diff --git a/plasma/containment.h b/plasma/containment.h index 72eb32a8..b1373ed4 100644 --- a/plasma/containment.h +++ b/plasma/containment.h @@ -38,7 +38,6 @@ namespace Plasma class AppletHandle; class DataEngine; -class Package; class Corona; class View; class Wallpaper; @@ -595,16 +594,6 @@ Q_SIGNALS: AbstractToolBox *toolBox() const; private: - /** - * @internal This constructor is to be used with the Package loading system. - * - * @param parent a QObject parent; you probably want to pass in 0 - * @param args a list of strings containing two entries: the service id - * and the applet id - * @since 4.3 - */ - Containment(const QString &packagePath, uint appletId, const QVariantList &args); - Q_PRIVATE_SLOT(d, void appletDestroyed(Plasma::Applet*)) Q_PRIVATE_SLOT(d, void appletAppearAnimationComplete()) Q_PRIVATE_SLOT(d, void triggerShowAddWidgets()) @@ -621,7 +610,6 @@ Q_SIGNALS: friend class Applet; friend class AppletPrivate; - friend class AppletScript; friend class CoronaPrivate; friend class ContainmentPrivate; friend class ContainmentActions; diff --git a/plasma/data/servicetypes/plasma-applet.desktop b/plasma/data/servicetypes/plasma-applet.desktop index a1dc5f3f..8136787c 100644 --- a/plasma/data/servicetypes/plasma-applet.desktop +++ b/plasma/data/servicetypes/plasma-applet.desktop @@ -82,9 +82,6 @@ Comment[x-test]=xxPlasma appletxx Comment[zh_CN]=Plasma 小程序 Comment[zh_TW]=Plasma 小程式 -[PropertyDef::X-Plasma-API] -Type=QString - [PropertyDef::X-Plasma-DropMimeTypes] Type=QStringList diff --git a/plasma/data/servicetypes/plasma-scriptengine.desktop b/plasma/data/servicetypes/plasma-scriptengine.desktop deleted file mode 100644 index f1fa61a8..00000000 --- a/plasma/data/servicetypes/plasma-scriptengine.desktop +++ /dev/null @@ -1,86 +0,0 @@ -[Desktop Entry] -Type=ServiceType -X-KDE-ServiceType=Plasma/ScriptEngine - -Comment=Scripting language extension for Plasma -Comment[ar]=امتداد لغة سكربت لبلازما -Comment[as]=Plasma ৰ কাৰণে স্ক্ৰিপ্টিং ভাষাৰ সম্প্ৰসাৰণ -Comment[ast]=Estensión de llinguaxe de guiones pa Plasma -Comment[be@latin]=Pašyreńnie skryptavaj movy dla systemy „Plasma” -Comment[bg]=Разширение на Plasma за скриптов език -Comment[bs]=Proširenje Plazme za skriptne jezike -Comment[ca]=Extensió de llenguatge d'scripts per al Plasma -Comment[ca@valencia]=Extensió de llenguatge d'scripts per al Plasma -Comment[cs]=Rozšíření pro skriptovací jazyky Plasma -Comment[da]=Scriptsprog-udvidelse til Plasma -Comment[de]=Skriptsprachen-Erweiterung für Plasma -Comment[el]=Επέκταση γλώσσας σεναρίων για το Plasma -Comment[en_GB]=Scripting language extension for Plasma -Comment[eo]=Skriptlingva etendaĵo por Plasma -Comment[es]=Extensión de lenguaje de script para Plasma -Comment[et]=Skriptikeele laiendus Plasmale -Comment[eu]=Plasmarako script lengoaien gehigarria -Comment[fi]=Skriptauskielituki Plasmalle -Comment[fr]=Extension du langage de script pour Plasma -Comment[fy]=Scripting taal taheaksel foar Plasma -Comment[ga]=Eisínteacht teanga scriptithe le haghaidh Plasma -Comment[gl]=Extensión de linguaxe de scripts para o Plasma -Comment[gu]=પ્લાઝમા માટે સ્ક્રિપ્ટીંગ ભાષા એક્સટેન્શન -Comment[he]=הרחבת שפת תסריטים של Plasma -Comment[hne]=प्लाज्मा बर स्क्रिप्टिंग भाखा -Comment[hr]=Proširenje Plasme za skriptne jezike -Comment[hsb]=Skriptowa rěč jako Plasma-ekstensija -Comment[hu]=Szkriptkezelő bővítmény a Plasmához -Comment[ia]=Extension del language de script de Plasma -Comment[id]=Tambahan bahasa skrip untuk Plasma -Comment[is]=Framlenging á skriftunarmál fyrir Plasma -Comment[it]=Estensione linguaggio scripting per Plasma -Comment[ja]=Plasma のためのスクリプト言語拡張 -Comment[kk]=Plasma-ның скрипт тілі -Comment[km]=ផ្នែក​បន្ថែម​ភាសា​ស្គ្រីប​សម្រាប់​ប្លាស្មា -Comment[kn]=ಪ್ಲಾಸ್ಮಾ ಕ್ಕೆ ವಿಧಿಗುಚ್ಛ (ಸ್ಕ್ರಿಪ್ಟ್) ರಚನಾ ಭಾಷೆ ಯ ವಿಸ್ತರಣೆ -Comment[ko]=Plasma 스크립트 언어 확장 -Comment[ku]=Pêveka zimanê skrîpt kirinê ji bo Plasma -Comment[lt]=Scenarijų kalbos praplėtimas, skirtas Plasma -Comment[lv]=Skriptēšanas valodu Plasma paplašinājums -Comment[mai]=प्लाजमाक लेल स्क्रिप्टिंग भाषाक विस्तार -Comment[ml]=പ്ലാസ്മയ്ക്കുള്ള സ്ക്രിപ്റ്റിങ്ങ് ഭാഷാ എക്സ്റ്റന്‍ഷന്‍ -Comment[mr]=प्लाज्मा साठी स्क्रिप्टींग भाषा एक्सटेंशन -Comment[nb]=Skriptspråk-utvidelse for Plasma -Comment[nds]=Skriptspraak-Verwiedern för Plasma -Comment[nl]=Scripttaalextensie voor Plasma -Comment[nn]=Skriptspråkutviding for Plasma -Comment[pa]=ਪਲਾਜ਼ਮਾ ਲਈ ਸਕ੍ਰਿਪਟਿੰਗ ਭਾਸ਼ਾ ਇਕਸਟੈਨਸ਼ਨ -Comment[pl]=Rozszerzenie języka skryptów dla Plazmy -Comment[pt]=Extensão de linguagens de programação para o Plasma -Comment[pt_BR]=Extensão de linguagem de script do Plasma -Comment[ro]=Extensie de limbaj pentru scripturi Plasma -Comment[ru]=Поддержка языков сценариев для Plasma -Comment[se]=Skriptagiellaviiddádus Plasmai -Comment[si]=Plasma සඳහා ස්කටිප්ට භාෂා දිගුව -Comment[sk]=Rozšírenie pre skriptovacie jazyky Plasma -Comment[sl]=Razširitev skriptnega jezika za Plasmo -Comment[sr]=Проширење Плазме за скриптне језике -Comment[sr@ijekavian]=Проширење Плазме за скриптне језике -Comment[sr@ijekavianlatin]=Proširenje Plasme za skriptne jezike -Comment[sr@latin]=Proširenje Plasme za skriptne jezike -Comment[sv]=Skriptspråksutökning för Plasma -Comment[ta]=பிளாஸ்மாவிற்கான குறுநிரலாக்க மொழி விரிவாக்கம் -Comment[tg]=Скрипти забонҳои иловагӣ барои Plasma -Comment[th]=ส่วนเสริมภาษาสคริปต์สำหรับพลาสมา -Comment[tr]=Plasma için betik dili eklentisi -Comment[tt]=Plasma өчен скрипт телләр өстәмәсе -Comment[ug]=Plasma نىڭ قوليازما تىل كېڭەيتىلمىسى -Comment[uk]=Розширення скриптових мов для Плазми -Comment[vi]=Phần mở rộng ngôn ngữ lệnh cho Plasma -Comment[wa]=Rawete di lingaedje di scriptaedje po Plasma -Comment[x-test]=xxScripting language extension for Plasmaxx -Comment[zh_CN]=Plasma 的脚本语言扩展 -Comment[zh_TW]=Plasma 文稿語言延伸 - -[PropertyDef::X-Plasma-ComponentTypes] -Type=QStringList - -[PropertyDef::X-Plasma-PackageFormat] -Type=QString - diff --git a/plasma/dataenginemanager.cpp b/plasma/dataenginemanager.cpp index 7141b277..40b0cd5a 100644 --- a/plasma/dataenginemanager.cpp +++ b/plasma/dataenginemanager.cpp @@ -32,7 +32,6 @@ #include "pluginloader.h" #include "private/dataengine_p.h" #include "private/datacontainer_p.h" -#include "scripting/scriptengine.h" namespace Plasma { diff --git a/plasma/extenders/extenderitem.cpp b/plasma/extenders/extenderitem.cpp index 78a42bab..8eab8734 100644 --- a/plasma/extenders/extenderitem.cpp +++ b/plasma/extenders/extenderitem.cpp @@ -49,7 +49,6 @@ #include "widgets/iconwidget.h" #include "widgets/pushbutton.h" -#include "private/applethandle_p.h" #include "private/extender_p.h" #include "private/extenderapplet_p.h" #include "private/extendergroup_p.h" diff --git a/plasma/packagemetadata.cpp b/plasma/packagemetadata.cpp index 14e0f48e..3f2c547e 100644 --- a/plasma/packagemetadata.cpp +++ b/plasma/packagemetadata.cpp @@ -49,7 +49,6 @@ class PackageMetadataPrivate QString pluginName; QString type; QString serviceType; - QString api; }; PackageMetadata::PackageMetadata(const PackageMetadata &other) @@ -102,7 +101,6 @@ void PackageMetadata::write(const QString &filename) const config.writeEntry("X-KDE-PluginInfo-Website", d->website); config.writeEntry("X-KDE-PluginInfo-License", d->license); config.writeEntry("X-KDE-PluginInfo-Category", d->category); - config.writeEntry("X-Plasma-API", d->api); config.writeEntry("X-KDE-ParentApp", d->app); config.writeEntry("Type", d->type); } @@ -147,7 +145,6 @@ void PackageMetadata::read(const QString &filename) d->website = config.readEntry("X-KDE-PluginInfo-Website", d->website); d->license = config.readEntry("X-KDE-PluginInfo-License", d->license); d->category = config.readEntry("X-KDE-PluginInfo-Category", d->category); - d->api = config.readEntry("X-Plasma-API", d->api); d->app = config.readEntry("X-KDE-ParentApp", d->app); d->type = config.readEntry("Type", d->type); } @@ -227,16 +224,6 @@ QString PackageMetadata::type() const return d->type; } -QString PackageMetadata::implementationApi() const -{ - return d->api; -} - -void PackageMetadata::setImplementationApi(const QString &api) -{ - d->api = api; -} - QString PackageMetadata::pluginName() const { return d->pluginName; diff --git a/plasma/packagemetadata.h b/plasma/packagemetadata.h index 0818b1ef..ca3c0000 100644 --- a/plasma/packagemetadata.h +++ b/plasma/packagemetadata.h @@ -89,7 +89,6 @@ public: QString application() const; QString category() const; QString pluginName() const; - QString implementationApi() const; QString type() const; @@ -187,11 +186,6 @@ public: */ void setPluginName(const QString &name); - /** - * Set the implementation API this package uses. - */ - void setImplementationApi(const QString &api); - private: PackageMetadataPrivate * const d; }; diff --git a/plasma/packagestructure.cpp b/plasma/packagestructure.cpp index a8e5ad2e..621419d6 100644 --- a/plasma/packagestructure.cpp +++ b/plasma/packagestructure.cpp @@ -45,6 +45,11 @@ namespace Plasma { +static PackageStructure::Ptr defaultPackageStructure() +{ + return PackageStructure::Ptr(new PackageStructure()); +} + class ContentStructure { public: @@ -122,22 +127,22 @@ PackageStructure::Ptr PackageStructure::load(const QString &packageFormat) PackageStructure::Ptr structure; if (packageFormat == "Plasma/Applet") { - structure = defaultPackageStructure(AppletComponent); + structure = defaultPackageStructure(); structure->d->type = "Plasma/Applet"; } else if (packageFormat == "Plasma/DataEngine") { - structure = defaultPackageStructure(DataEngineComponent); + structure = defaultPackageStructure(); structure->d->type = "Plasma/DataEngine"; } else if (packageFormat == "Plasma/Runner") { - structure = defaultPackageStructure(RunnerComponent); + structure = defaultPackageStructure(); structure->d->type = "Plasma/Runner"; } else if (packageFormat == "Plasma/Wallpaper") { - structure = defaultPackageStructure(WallpaperComponent); + structure = defaultPackageStructure(); structure->d->type = "Plasma/Wallpaper"; } else if (packageFormat == "Plasma/Theme") { structure = Theme::packageStructure(); structure->d->type = "Plasma/Theme"; } else if (packageFormat == "Plasma/Generic") { - structure = defaultPackageStructure(GenericComponent); + structure = defaultPackageStructure(); structure->d->type = "Plasma/Generic"; structure->setDefaultPackageRoot("plasma/packages/"); } diff --git a/plasma/plasma.cpp b/plasma/plasma.cpp index fcc71811..6f3e86be 100644 --- a/plasma/plasma.cpp +++ b/plasma/plasma.cpp @@ -31,21 +31,6 @@ namespace Plasma { -qreal scalingFactor(ZoomLevel level) -{ - switch (level) { - case DesktopZoom: - return 1; - case GroupZoom: - return 0.5; - case OverviewZoom: - return 0.2; - } - - // to make odd compilers not warn like silly beasts - return 1; -} - Direction locationToDirection(Location location) { switch (location) { diff --git a/plasma/plasma.h b/plasma/plasma.h index 45235374..4e6c1179 100644 --- a/plasma/plasma.h +++ b/plasma/plasma.h @@ -147,27 +147,6 @@ enum PopupPlacement { to the bottom of the widget */ }; -/** - * Flip enumeration - */ -enum FlipDirection { - NoFlip = 0, /**< Do not flip */ - HorizontalFlip = 1, /**< Flip horizontally */ - VerticalFlip = 2 /**< Flip vertically */ -}; -Q_DECLARE_FLAGS(Flip, FlipDirection) - -/** - * Zoom levels that Plasma is aware of... - **/ -enum ZoomLevel { - DesktopZoom = 0, /**< Normal desktop usage, plasmoids are painted normally - and have full interaction */ - GroupZoom, /**< Plasmoids are shown as icons in visual groups; drag - and drop and limited context menu interaction only */ - OverviewZoom /**< Groups become icons themselves */ -}; - /** * Possible timing alignments **/ @@ -254,17 +233,6 @@ enum ItemStatus { }; Q_ENUMS(ItemStatus) -enum AnnouncementMethod { - NoAnnouncement = 0, /**< No announcements **/ - ZeroconfAnnouncement = 1 /**< Announcements via ZeroConf **/ -}; -Q_DECLARE_FLAGS(AnnouncementMethods, AnnouncementMethod) - -/** - * @return the scaling factor (0..1) for a ZoomLevel - **/ -PLASMA_EXPORT qreal scalingFactor(ZoomLevel level); - /** * Converts a location to a direction. Handy for figuring out which way to send a popup based on * location or to point arrows and other directional items. @@ -309,7 +277,6 @@ PLASMA_EXPORT QList actionsFromMenu(QMenu *menu, } // Plasma namespace Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::Constraints) -Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::Flip) Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::ComponentTypes) Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::MessageButtons) diff --git a/plasma/pluginloader.cpp b/plasma/pluginloader.cpp index dcd4aa53..0d44e1f3 100644 --- a/plasma/pluginloader.cpp +++ b/plasma/pluginloader.cpp @@ -72,22 +72,6 @@ Applet *PluginLoader::loadApplet(const QString &name, uint appletId, const QVari QVariantList allArgs; allArgs << offer->storageId() << appletId << args; - if (!offer->property("X-Plasma-API").toString().isEmpty()) { - kDebug() << "we have a script using the" - << offer->property("X-Plasma-API").toString() << "API"; - if (isContainment) { - return new Containment(0, allArgs); - } else { - if (offer->serviceTypes().contains("Plasma/Containment")) { - return new Containment(0, allArgs); - } else if (offer->serviceTypes().contains("Plasma/PopupApplet")) { - return new PopupApplet(0, allArgs); - } else { - return new Applet(0, allArgs); - } - } - } - Applet *applet = 0; QString error; if (name == "internal:extender") { @@ -117,13 +101,8 @@ DataEngine *PluginLoader::loadDataEngine(const QString &name) } else { QVariantList allArgs; allArgs << offers.first()->storageId(); - QString api = offers.first()->property("X-Plasma-API").toString(); - if (api.isEmpty()) { - if (offers.first()) { - engine = offers.first()->createInstance(0, allArgs, &error); - } - } else { - engine = new DataEngine(0, offers.first()); + if (offers.first()) { + engine = offers.first()->createInstance(0, allArgs, &error); } } diff --git a/plasma/popupapplet.cpp b/plasma/popupapplet.cpp index 1971d788..7ee10c61 100644 --- a/plasma/popupapplet.cpp +++ b/plasma/popupapplet.cpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #include @@ -45,7 +44,6 @@ #include "plasma/extenders/extenderitem.h" #include "plasma/package.h" #include "plasma/theme.h" -#include "plasma/scripting/appletscript.h" #include "plasma/tooltipmanager.h" #include "plasma/widgets/iconwidget.h" @@ -58,12 +56,6 @@ PopupApplet::PopupApplet(QObject *parent, const QVariantList &args) { } -PopupApplet::PopupApplet(const QString &packagePath, uint appletId, const QVariantList &args) - : Plasma::Applet(packagePath, appletId, args), - d(new PopupAppletPrivate(this)) -{ -} - PopupApplet::~PopupApplet() { delete widget(); @@ -90,16 +82,7 @@ void PopupApplet::setPopupIcon(const QIcon &icon) void PopupApplet::setPopupIcon(const QString &iconName) { - // Attempt 1: is it in the plasmoid package? - if (package()) { - const QString file = package()->filePath("images", iconName); - if (!file.isEmpty()) { - setPopupIcon(KIcon(file)); - return; - } - } - - // Attempt 2: is it a svg in the icons directory? + // Is it a svg in the icons directory? const QString name = QString("icons/") + iconName.split("-").first(); if (!Plasma::Theme::defaultTheme()->imagePath(name).isEmpty()) { d->createIconWidget(); @@ -237,21 +220,19 @@ void PopupAppletPrivate::popupConstraintsEvent(Plasma::Constraints constraints) minimum = qWidget->minimumSizeHint(); } - //99% of the times q->parentWidget() is the containment, but using it we can also manage the applet-in-applet case (i.e. systray) - //there are also cases where the parentlayoutitem is bigger than the containment (e.g. newspaper) - QDeclarativeItem *di = qobject_cast(q->parentObject()); + // 99% of the times q->parentWidget() is the containment, but using it we can also manage + // the applet-in-applet case (i.e. systray) there are also cases where the parentlayoutitem + // is bigger than the containment if (q->parentLayoutItem()) { parentSize = q->parentLayoutItem()->geometry().size(); } else if (q->parentWidget()) { parentSize = q->parentWidget()->size(); - } else if (di) { - parentSize = QSizeF(di->width(), di->height()); } - //check if someone did the nasty trick of applets in applets, in this case we always want to be collapsed + // check if someone did the nasty trick of applets in applets, in this case we always want to be collapsed QGraphicsWidget *candidateParentApplet = q; Plasma::Applet *parentApplet = 0; - //this loop should be executed normally a single time, at most 2-3 times for quite complex containments + // this loop should be executed normally a single time, at most 2-3 times for quite complex containments while (candidateParentApplet) { candidateParentApplet = candidateParentApplet->parentWidget(); parentApplet = qobject_cast(candidateParentApplet); @@ -666,9 +647,6 @@ Qt::AlignmentFlag PopupApplet::popupAlignment() const void PopupApplet::popupEvent(bool popped) { - if (Applet::d->script) { - emit Applet::d->script->popupEvent(popped); - } } void PopupApplet::setPassivePopup(bool passive) diff --git a/plasma/popupapplet.h b/plasma/popupapplet.h index 450ac4cc..b80e5043 100644 --- a/plasma/popupapplet.h +++ b/plasma/popupapplet.h @@ -211,16 +211,6 @@ protected: void timerEvent(QTimerEvent *event); private: - /** - * @internal This constructor is to be used with the Package loading system. - * - * @param parent a QObject parent; you probably want to pass in 0 - * @param args a list of strings containing two entries: the service id - * and the applet id - * @since 4.3 - */ - PopupApplet(const QString &packagePath, uint appletId, const QVariantList &args); - Q_PRIVATE_SLOT(d, void internalTogglePopup()) Q_PRIVATE_SLOT(d, void hideTimedPopup()) Q_PRIVATE_SLOT(d, void clearPopupLostFocus()) diff --git a/plasma/private/applet_p.h b/plasma/private/applet_p.h index 707f786d..722caf95 100644 --- a/plasma/private/applet_p.h +++ b/plasma/private/applet_p.h @@ -39,7 +39,6 @@ namespace Plasma class Dialog; class FrameSvg; -class AppletScript; class Wallpaper; class BusyWidget; class PushButton; @@ -96,11 +95,7 @@ public: AppletPrivate(KService::Ptr service, const KPluginInfo *info, int uniqueID, Applet *applet); ~AppletPrivate(); - void init(const QString &packagePath = QString()); - - // put all setup routines for script here. at this point we can assume that - // package exists and that we have a script engin - void setupScriptSupport(); + void init(); /** * Sets whether or not this Applet is acting as a Containment @@ -140,7 +135,6 @@ public: static uint s_maxAppletId; static int s_maxZValue; static int s_minZValue; - static PackageStructure::Ptr packageStructure; //TODO: examine the usage of memory here; there's a pretty large // number of members at this point. @@ -176,10 +170,7 @@ public: QWeakPointer messageCancelButton; QWeakPointer messageCloseAction; - // sripting and package stuff - AppletScript *script; - Package *package; - ConfigLoader *configLoader; + // package stuff QWeakPointer handle; // actions stuff; put activationAction into actions? @@ -203,13 +194,12 @@ public: QBasicTimer *modificationsTimer; // a great green field of booleans :) - bool hasConfigurationInterface : 1; - bool failed : 1; - bool isContainment : 1; - bool square : 1; - bool transient : 1; - bool needsConfig : 1; - bool started : 1; + bool hasConfigurationInterface; + bool failed; + bool isContainment; + bool transient ; + bool needsConfig; + bool started; }; } // Plasma namespace diff --git a/plasma/private/configloader_p.h b/plasma/private/configloader_p.h deleted file mode 100644 index 50d30985..00000000 --- a/plasma/private/configloader_p.h +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright 2007-2008 Aaron Seigo - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library 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 Library 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. - */ - -#ifndef PLASMA_CONFIGLOADER_P_H -#define PLASMA_CONFIGLOADER_P_H - -namespace Plasma -{ - -class ConfigLoaderPrivate -{ - public: - ConfigLoaderPrivate() - : saveDefaults(false) - { - } - - ~ConfigLoaderPrivate() - { - qDeleteAll(bools); - qDeleteAll(strings); - qDeleteAll(stringlists); - qDeleteAll(colors); - qDeleteAll(fonts); - qDeleteAll(ints); - qDeleteAll(uints); - qDeleteAll(urls); - qDeleteAll(dateTimes); - qDeleteAll(doubles); - qDeleteAll(intlists); - qDeleteAll(longlongs); - qDeleteAll(points); - qDeleteAll(rects); - qDeleteAll(sizes); - qDeleteAll(ulonglongs); - qDeleteAll(urllists); - } - - bool *newBool() - { - bool *v = new bool(false); - bools.append(v); - return v; - } - - QString *newString() - { - QString *v = new QString(); - strings.append(v); - return v; - } - - QStringList *newStringList() - { - QStringList *v = new QStringList(); - stringlists.append(v); - return v; - } - - QColor *newColor() - { - QColor *v = new QColor(); - colors.append(v); - return v; - } - - QFont *newFont() - { - QFont *v = new QFont(); - fonts.append(v); - return v; - } - - qint32 *newInt() - { - qint32 *v = new qint32(0); - ints.append(v); - return v; - } - - quint32 *newUint() - { - quint32 *v = new quint32(0); - uints.append(v); - return v; - } - - KUrl *newUrl() - { - KUrl *v = new KUrl; - urls.append(v); - return v; - } - - QDateTime *newDateTime() - { - QDateTime *v = new QDateTime(); - dateTimes.append(v); - return v; - } - - double *newDouble() - { - double *v = new double; - doubles.append(v); - return v; - } - - QList* newIntList() - { - QList *v = new QList(); - intlists.append(v); - return v; - } - - qint64 *newLongLong() - { - qint64 *v = new qint64(0); - longlongs.append(v); - return v; - } - - QPoint *newPoint() - { - QPoint *v = new QPoint(); - points.append(v); - return v; - } - - QRect *newRect() - { - QRect *v = new QRect(); - rects.append(v); - return v; - } - - QSize *newSize() - { - QSize *v = new QSize(); - sizes.append(v); - return v; - } - - quint64 *newULongLong() - { - quint64 *v = new quint64(0); - ulonglongs.append(v); - return v; - } - - KUrl::List *newUrlList() - { - KUrl::List *v = new KUrl::List(); - urllists.append(v); - return v; - } - - void parse(ConfigLoader *loader, QIODevice *xml); - - /** - * Whether or not to write out default values. - * - * @param writeDefaults true if defaults should be written out - */ - void setWriteDefaults(bool writeDefaults) - { - saveDefaults = writeDefaults; - } - - /** - * @return true if default values will also be written out - */ - bool writeDefaults() const - { - return saveDefaults; - } - - - QList bools; - QList strings; - QList stringlists; - QList colors; - QList fonts; - QList ints; - QList uints; - QList urls; - QList dateTimes; - QList doubles; - QList *> intlists; - QList longlongs; - QList points; - QList rects; - QList sizes; - QList ulonglongs; - QList urllists; - QString baseGroup; - QStringList groups; - QHash keysToNames; - bool saveDefaults; -}; - -} // namespace Plasma - -#endif - diff --git a/plasma/private/dataenginebindings.cpp b/plasma/private/dataenginebindings.cpp deleted file mode 100644 index 8fb60802..00000000 --- a/plasma/private/dataenginebindings.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2007 Richard J. Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License version 2 as - * published by the Free Software Foundation - * - * 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 Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "dataenginebindings_p.h" - -typedef Plasma::Service *ServicePtr; -QScriptValue qScriptValueFromService(QScriptEngine *engine, const ServicePtr &service) -{ - return engine->newQObject(const_cast(service), QScriptEngine::AutoOwnership, QScriptEngine::PreferExistingWrapperObject); -} - -void serviceFromQScriptValue(const QScriptValue &scriptValue, ServicePtr &service) -{ - QObject *obj = scriptValue.toQObject(); - service = static_cast(obj); -} - -typedef Plasma::DataEngine *DataEnginePtr; -QScriptValue qScriptValueFromDataEngine(QScriptEngine *engine, const DataEnginePtr &dataEngine) -{ - return engine->newQObject(const_cast(dataEngine), QScriptEngine::AutoOwnership, QScriptEngine::PreferExistingWrapperObject); -} - -void dataEngineFromQScriptValue(const QScriptValue &scriptValue, DataEnginePtr &dataEngine) -{ - QObject *obj = scriptValue.toQObject(); - dataEngine = static_cast(obj); -} - -typedef Plasma::ServiceJob *ServiceJobPtr; -QScriptValue qScriptValueFromServiceJob(QScriptEngine *engine, const ServiceJobPtr &serviceJob) -{ - return engine->newQObject(const_cast(serviceJob), QScriptEngine::AutoOwnership, QScriptEngine::PreferExistingWrapperObject); -} - -void serviceJobFromQScriptValue(const QScriptValue &scriptValue, ServiceJobPtr &serviceJob) -{ - QObject *obj = scriptValue.toQObject(); - serviceJob = static_cast(obj); -} - -void registerDataEngineMetaTypes(QScriptEngine *engine) -{ - qRegisterMetaType("Plasma::DataEngine::Data"); - qRegisterMetaType("DataEngine::Data"); - qScriptRegisterMapMetaType(engine); - qScriptRegisterMetaType(engine, qScriptValueFromService, serviceFromQScriptValue); - qScriptRegisterMetaType(engine, qScriptValueFromDataEngine, dataEngineFromQScriptValue); - qScriptRegisterMetaType(engine, qScriptValueFromServiceJob, serviceJobFromQScriptValue); -} - diff --git a/plasma/private/dataenginebindings_p.h b/plasma/private/dataenginebindings_p.h deleted file mode 100644 index a4923970..00000000 --- a/plasma/private/dataenginebindings_p.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2007 Richard J. Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License version 2 as - * published by the Free Software Foundation - * - * 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 Library 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. - */ - -#ifndef DATAENGINE_H -#define DATAENGINE_H - -#include -#include -#include -#include - -#include -#include -#include - -using namespace Plasma; - -Q_DECLARE_METATYPE(DataEngine::Dict) -Q_DECLARE_METATYPE(DataEngine::Data) - -template -QScriptValue qScriptValueFromMap(QScriptEngine *eng, const M &map) -{ - //kDebug() << "qScriptValueFromMap called"; - QScriptValue obj = eng->newObject(); - typename M::const_iterator begin = map.constBegin(); - typename M::const_iterator end = map.constEnd(); - typename M::const_iterator it; - for (it = begin; it != end; ++it) { - if (it.value().type() == QVariant::Hash) { - obj.setProperty(it.key(), qScriptValueFromMap(eng, it.value().toHash())); - } else if (it.value().type() == QVariant::Map) { - obj.setProperty(it.key(), qScriptValueFromMap(eng, it.value().toMap())); - } else { - obj.setProperty(it.key(), qScriptValueFromValue(eng, it.value())); - } - } - - return obj; -} - -template -void qScriptValueToMap(const QScriptValue &value, M &map) -{ - //kDebug() << "qScriptValueToMap called"; - QScriptValueIterator it(value); - while (it.hasNext()) { - it.next(); - map[it.name()] = qscriptvalue_cast(it.value()); - } -} - -template -int qScriptRegisterMapMetaType( - QScriptEngine *engine, - const QScriptValue &prototype = QScriptValue() -#ifndef qdoc - , T * /* dummy */ = 0 -#endif -) -{ - return qScriptRegisterMetaType(engine, qScriptValueFromMap, qScriptValueToMap, prototype); -} - -void registerDataEngineMetaTypes(QScriptEngine *engine); - -#endif // DATAENGINE_H - diff --git a/plasma/private/packages.cpp b/plasma/private/packages.cpp index df5d272f..afccafd9 100644 --- a/plasma/private/packages.cpp +++ b/plasma/private/packages.cpp @@ -35,59 +35,6 @@ namespace Plasma { -PlasmoidPackage::PlasmoidPackage(QObject *parent) - : Plasma::PackageStructure(parent, QString("Plasmoid")) -{ - QStringList platform; - platform << "platformcontents/desktop" << "contents"; - setContentsPrefixPaths(platform); - - addDirectoryDefinition("images", "images", i18n("Images")); - addDirectoryDefinition("theme", "theme", i18n("Themed Images")); - QStringList mimetypes; - mimetypes << "image/svg+xml" << "image/png" << "image/jpeg"; - setMimetypes("images", mimetypes); - setMimetypes("theme", mimetypes); - - addDirectoryDefinition("config", "config", i18n("Configuration Definitions")); - mimetypes.clear(); - mimetypes << "text/xml"; - setMimetypes("config", mimetypes); - - addDirectoryDefinition("ui", "ui", i18n("User Interface")); - setMimetypes("ui", mimetypes); - - addDirectoryDefinition("data", "data", i18n("Data Files")); - - addDirectoryDefinition("scripts", "code", i18n("Executable Scripts")); - mimetypes.clear(); - mimetypes << "text/plain"; - setMimetypes("scripts", mimetypes); - - addDirectoryDefinition("translations", "locale", i18n("Translations")); - - addFileDefinition("mainconfigui", "ui/config.ui", i18n("Main Config UI File")); - addFileDefinition("mainconfigxml", "config/main.xml", i18n("Configuration XML file")); - addFileDefinition("mainscript", "code/main", i18n("Main Script File")); - addFileDefinition("defaultconfig", "config/default-configrc", i18n("Default configuration")); - setRequired("mainscript", true); -} - -PlasmoidPackage::~PlasmoidPackage() -{ -} - -void PlasmoidPackage::pathChanged() -{ - KDesktopFile config(path() + "/metadata.desktop"); - KConfigGroup cg = config.desktopGroup(); - QString mainScript = cg.readEntry("X-Plasma-MainScript", QString()); - if (!mainScript.isEmpty()) { - addFileDefinition("mainscript", mainScript, i18n("Main Script File")); - setRequired("mainscript", true); - } -} - ThemePackage::ThemePackage(QObject *parent) : Plasma::PackageStructure(parent, QString("Plasma Theme")) { diff --git a/plasma/private/packages_p.h b/plasma/private/packages_p.h index ce10d530..ffa960df 100644 --- a/plasma/private/packages_p.h +++ b/plasma/private/packages_p.h @@ -30,19 +30,6 @@ namespace Plasma { -class PlasmoidPackage : public PackageStructure -{ - Q_OBJECT -public: - explicit PlasmoidPackage(QObject *parent = 0); - ~PlasmoidPackage(); - -protected: - void pathChanged(); - -private: -}; - class ThemePackage : public PackageStructure { Q_OBJECT @@ -85,8 +72,6 @@ public: explicit ContainmentActionsPackage(QObject *parent = 0); }; -PackageStructure::Ptr defaultPackageStructure(ComponentType type); - } // namespace Plasma #endif // LIBS_PLASMA_PACKAGES_P_H diff --git a/plasma/runnermanager.cpp b/plasma/runnermanager.cpp index 27b34479..6ee72e23 100644 --- a/plasma/runnermanager.cpp +++ b/plasma/runnermanager.cpp @@ -233,19 +233,12 @@ public: if (runner) { runner->setParent(q); } else { - const QString api = service->property("X-Plasma-API").toString(); - - if (api.isEmpty()) { - QVariantList args; - args << service->storageId(); - QString error; - runner = service->createInstance(q, args, &error); - if (!runner) { - kDebug() << "Failed to load runner:" << service->name() << ". error reported:" << error; - } - } else { - //kDebug() << "got a script runner known as" << api; - runner = new AbstractRunner(service, q); + QVariantList args; + args << service->storageId(); + QString error; + runner = service->createInstance(q, args, &error); + if (!runner) { + kDebug() << "Failed to load runner:" << service->name() << ". error reported:" << error; } } diff --git a/plasma/scripting/appletscript.cpp b/plasma/scripting/appletscript.cpp deleted file mode 100644 index f269dcd1..00000000 --- a/plasma/scripting/appletscript.cpp +++ /dev/null @@ -1,259 +0,0 @@ -/* - * Copyright 2007 by Aaron Seigo - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library 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 Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "scripting/appletscript.h" - -#include "kconfig.h" -#include "kconfigdialog.h" - -#include "animator.h" -#include "applet.h" -#include "package.h" -#include "private/applet_p.h" - -namespace Plasma -{ - -class AppletScriptPrivate -{ -public: - Applet *applet; -}; - -AppletScript::AppletScript(QObject *parent) - : ScriptEngine(parent), - d(new AppletScriptPrivate) -{ - d->applet = 0; -} - -AppletScript::~AppletScript() -{ - delete d; -} - -void AppletScript::setApplet(Plasma::Applet *applet) -{ - d->applet = applet; -} - -Applet *AppletScript::applet() const -{ - Q_ASSERT(d->applet); - return d->applet; -} - -void AppletScript::paintInterface(QPainter *painter, - const QStyleOptionGraphicsItem *option, - const QRect &contentsRect) -{ - Q_UNUSED(painter); - Q_UNUSED(option); - Q_UNUSED(contentsRect); -} - -QSizeF AppletScript::size() const -{ - if (applet()) { - return applet()->size(); - } - - return QSizeF(); -} - -void AppletScript::constraintsEvent(Plasma::Constraints constraints) -{ - Q_UNUSED(constraints); -} - -QList AppletScript::contextualActions() -{ - return QList(); -} - -QPainterPath AppletScript::shape() const -{ - if (applet()) { - QPainterPath path; - path.addRect(applet()->boundingRect()); - return path; - } - - return QPainterPath(); -} - -void AppletScript::setHasConfigurationInterface(bool hasInterface) -{ - if (applet()) { - applet()->setHasConfigurationInterface(hasInterface); - } -} - -void AppletScript::setConfigurationRequired(bool req, const QString &reason) -{ - if (applet()) { - applet()->setConfigurationRequired(req, reason); - } -} - -void AppletScript::setFailedToLaunch(bool failed, const QString &reason) -{ - if (applet()) { - applet()->setFailedToLaunch(failed, reason); - } -} - -void AppletScript::configNeedsSaving() const -{ - if (applet()) { - emit applet()->configNeedsSaving(); - } -} - -void AppletScript::showConfigurationInterface() -{ - if (applet()) { - KConfigDialog *dialog = applet()->d->generateGenericConfigDialog(); - applet()->d->addStandardConfigurationPages(dialog); - dialog->show(); - } -} - -KConfigDialog *AppletScript::standardConfigurationDialog() -{ - if (applet()) { - return applet()->d->generateGenericConfigDialog(); - } - - return 0; -} - -void AppletScript::addStandardConfigurationPages(KConfigDialog *dialog) -{ - if (applet()) { - applet()->d->addStandardConfigurationPages(dialog); - } -} - -void AppletScript::showMessage(const QIcon &icon, const QString &message, const MessageButtons buttons) -{ - if (applet()) { - applet()->showMessage(icon, message, buttons); - } -} - -void AppletScript::registerAsDragHandle(QGraphicsItem *item) -{ - if (applet()) { - applet()->registerAsDragHandle(item); - } -} - -void AppletScript::unregisterAsDragHandle(QGraphicsItem *item) -{ - if (applet()) { - applet()->unregisterAsDragHandle(item); - } -} - -bool AppletScript::isRegisteredAsDragHandle(QGraphicsItem *item) -{ - if (applet()) { - return applet()->isRegisteredAsDragHandle(item); - } - return false; -} - -void AppletScript::configChanged() -{ -} - -DataEngine *AppletScript::dataEngine(const QString &engine) const -{ - Q_ASSERT(d->applet); - return d->applet->dataEngine(engine); -} - -QString AppletScript::mainScript() const -{ - Q_ASSERT(d->applet); - return d->applet->package()->filePath("mainscript"); -} - -const Package *AppletScript::package() const -{ - Q_ASSERT(d->applet); - return d->applet->package(); -} - -KPluginInfo AppletScript::description() const -{ - Q_ASSERT(d->applet); - return d->applet->d->appletDescription; -} - -Extender *AppletScript::extender() const -{ - Q_ASSERT(d->applet); - return d->applet->extender(); -} - -bool AppletScript::drawWallpaper() const -{ - Q_ASSERT(d->applet); - Plasma::Containment *cont = qobject_cast(d->applet); - if (cont) { - return cont->drawWallpaper(); - } else { - return false; - } -} - -void AppletScript::setDrawWallpaper(bool drawWallpaper) -{ - Q_ASSERT(d->applet); - Plasma::Containment *cont = qobject_cast(d->applet); - if (cont) { - cont->setDrawWallpaper(drawWallpaper); - } -} - -Containment::Type AppletScript::containmentType() const -{ - Q_ASSERT(d->applet); - Plasma::Containment *cont = qobject_cast(d->applet); - if (cont) { - return cont->containmentType(); - } else { - return Containment::NoContainmentType; - } -} - -void AppletScript::setContainmentType(Containment::Type type) -{ - Q_ASSERT(d->applet); - Plasma::Containment *cont = qobject_cast(d->applet); - if (cont) { - cont->setContainmentType(type); - } -} - -} // Plasma namespace - -#include "moc_appletscript.cpp" diff --git a/plasma/scripting/appletscript.h b/plasma/scripting/appletscript.h deleted file mode 100644 index 0c04d2e3..00000000 --- a/plasma/scripting/appletscript.h +++ /dev/null @@ -1,268 +0,0 @@ -/* - * Copyright 2007 by Aaron Seigo - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library 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 Library 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. - */ - -#ifndef PLASMA_APPLETSCRIPT_H -#define PLASMA_APPLETSCRIPT_H - -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include -class KConfigDialog; - -namespace Plasma -{ - -class Animation; -class AppletScriptPrivate; -class Extender; - -/** - * @class AppletScript plasma/scripting/appletscript.h - * - * @short Provides a restricted interface for scripted applets. - */ -class PLASMA_EXPORT AppletScript : public ScriptEngine -{ - Q_OBJECT - -public: - /** - * Default constructor for an AppletScript. - * - * Subclasses should not attempt to access the Plasma::Applet - * associated with this AppletScript in the constructor. All - * such set up that requires the Applet itself should be done - * in the init() method. - */ - explicit AppletScript(QObject *parent = 0); - ~AppletScript(); - - /** - * Sets the applet associated with this AppletScript - */ - void setApplet(Plasma::Applet *applet); - - /** - * Returns the Plasma::Applet associated with this script component - */ - Plasma::Applet *applet() const; - - /** - * Called when the script should paint the applet - * - * @param painter the QPainter to use - * @param option the style option containing such flags as selection, level of detail, etc - * @param contentsRect the rect to paint within; automatically adjusted for - * the background, if any - */ - virtual void paintInterface(QPainter *painter, - const QStyleOptionGraphicsItem *option, - const QRect &contentsRect); - - /** - * Returns the area within which contents can be painted. - **/ - Q_INVOKABLE QSizeF size() const; - - /** - * Called when any of the geometry constraints have been updated. - * - * This is always called prior to painting and should be used as an - * opportunity to layout the widget, calculate sizings, etc. - * - * Do not call update() from this method; an update() will be triggered - * at the appropriate time for the applet. - * - * @param constraints the type of constraints that were updated - */ - virtual void constraintsEvent(Plasma::Constraints constraints); - - /** - * Returns a list of context-related QAction instances. - * - * @return A list of actions. The default implementation returns an - * empty list. - */ - virtual QList contextualActions(); - - /** - * Returns the shape of the widget, defaults to the bounding rect - */ - virtual QPainterPath shape() const; - - /** - * Sets whether or not this script has a configuration interface or not - * - * @param hasInterface true if the applet is user configurable - */ - void setHasConfigurationInterface(bool hasInterface); - - /** - * @see Applet - */ - void setConfigurationRequired(bool req, const QString &reason = QString()); - - /** - * @see Applet - */ - void setFailedToLaunch(bool failed, const QString &reason = QString()); - - /** - * @see Applet - */ - void configNeedsSaving() const; - - /** - * @see Applet - */ - Extender *extender() const; - - //FIXME plasma2: setWallpaperEnabled and setContainmentType should become public? - /** - * @return true if the applet is a containment AND if the wallpaper is enabled - * @see Containment - * @since 4.7 - */ - bool drawWallpaper() const; - /** - * set if the containment draws its own wallpaper: it has no effect if the applet is not a containment - * @see Containment - * @since 4.7 - */ - void setDrawWallpaper(bool drawWallpaper); - - /** - * @see Containment - * @since 4.7 - */ - Containment::Type containmentType() const; - - /** - * @see Containment - * @since 4.7 - */ - void setContainmentType(Containment::Type type); - -Q_SIGNALS: - /** - * @see Applet - */ - void saveState(KConfigGroup &group) const; - - /** - * @see PopupApplet - */ - void popupEvent(bool popped) const; - -public Q_SLOTS: - - /** - * Show a configuration dialog. - */ - virtual void showConfigurationInterface(); - - /** - * Configure was changed. - */ - virtual void configChanged(); - -protected: - /** - * @param engine name of the engine - * @return a data engine associated with this plasmoid - */ - Q_INVOKABLE DataEngine *dataEngine(const QString &engine) const; - - /** - * @return absolute path to the main script file for this plasmoid - */ - QString mainScript() const; - - /** - * @return the Package associated with this plasmoid which can - * be used to request resources, such as images and - * interface files. - */ - const Package *package() const; - - /** - * @return the KPluginInfo associated with this plasmoid - */ - KPluginInfo description() const; - - /** - * @return a standard Plasma applet configuration dialog, ready - * to have pages added to it. - * - * Note that the dialog returned is set to delete on close. - */ - KConfigDialog *standardConfigurationDialog(); - - /** - * This method should be called after a scripting applet has added - * its own pages to a configuration dialog - * - * @since 4.3.1 - */ - void addStandardConfigurationPages(KConfigDialog *dialog); - - /** - * @see Applet - */ - void showMessage(const QIcon &icon, const QString &message, const MessageButtons buttons); - - /** - * @see Applet - */ - void registerAsDragHandle(QGraphicsItem *item); - - /** - * @see Applet - */ - void unregisterAsDragHandle(QGraphicsItem *item); - - /** - * @see Applet - */ - bool isRegisteredAsDragHandle(QGraphicsItem *item); - -private: - friend class Applet; - friend class PopupApplet; - - AppletScriptPrivate *const d; -}; - -#define K_EXPORT_PLASMA_APPLETSCRIPTENGINE(libname, classname) \ -K_PLUGIN_FACTORY(factory, registerPlugin();) \ -K_EXPORT_PLUGIN(factory("plasma_appletscriptengine_" #libname)) - -} //Plasma namespace - -#endif diff --git a/plasma/scripting/scriptengine.cpp b/plasma/scripting/scriptengine.cpp deleted file mode 100644 index e721fe7d..00000000 --- a/plasma/scripting/scriptengine.cpp +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright 2007 by Aaron Seigo - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library 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 Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "scripting/scriptengine.h" - -#include -#include -#include - -#include "abstractrunner.h" -#include "applet.h" -#include "dataengine.h" -#include "package.h" -#include "scripting/appletscript.h" - -#include "private/packages_p.h" - -namespace Plasma -{ - -ScriptEngine::ScriptEngine(QObject *parent) - : QObject(parent) -{ -} - -ScriptEngine::~ScriptEngine() -{ -// delete d; -} - -bool ScriptEngine::init() -{ - return true; -} - -const Package *ScriptEngine::package() const -{ - return 0; -} - -QString ScriptEngine::mainScript() const -{ - return QString(); -} - -QStringList knownLanguages(ComponentTypes types) -{ - QString constraintTemplate = "'%1' in [X-Plasma-ComponentTypes]"; - QString constraint; - - if (types & AppletComponent) { - constraint.append(constraintTemplate.arg("Applet")); - } - - KService::List offers = KServiceTypeTrader::self()->query("Plasma/ScriptEngine", constraint); - //kDebug() << "Applet::knownApplets constraint was '" << constraint - // << "' which got us " << offers.count() << " matches"; - - QStringList languages; - foreach (const KService::Ptr &service, offers) { - QString language = service->property("X-Plasma-API").toString(); - if (!languages.contains(language)) { - languages.append(language); - } - } - - return languages; -} - -KService::List engineOffers(const QString &language, ComponentType type) -{ - if (language.isEmpty()) { - return KService::List(); - } - - QRegExp re("[^a-zA-Z0-9\\-_]"); - if (re.indexIn(language) != -1) { - kDebug() << "invalid language attempted:" << language; - return KService::List(); - } - - QString component; - switch (type) { - case AppletComponent: { - component = "Applet"; - break; - } - default: { - return KService::List(); - } - } - - QString constraint = QString("[X-Plasma-API] == '%1' and " - "'%2' in [X-Plasma-ComponentTypes]").arg(language, component); - KService::List offers = KServiceTypeTrader::self()->query("Plasma/ScriptEngine", constraint); - /* kDebug() << "********************* loadingApplet with Plasma/ScriptEngine" << constraint - << "resulting in" << offers.count() << "results";*/ - if (offers.isEmpty()) { - kDebug() << "No offers for \"" << language << "\""; - } - - return offers; -} - -ScriptEngine *loadEngine(const QString &language, ComponentType type, QObject *parent) -{ - KService::List offers = engineOffers(language, type); - - QVariantList args; - QString error; - - ScriptEngine *engine = 0; - foreach (const KService::Ptr &service, offers) { - switch (type) { - case AppletComponent: { - engine = service->createInstance(parent, args, &error); - break; - } - default: { - return 0; - } - } - - if (engine) { - return engine; - } - - kDebug() << "Couldn't load script engine for language " << language - << "! error reported: " << error; - } - - return 0; -} - -AppletScript *loadScriptEngine(const QString &language, Applet *applet) -{ - AppletScript *engine = - static_cast(loadEngine(language, AppletComponent, applet)); - - if (engine) { - engine->setApplet(applet); - } - - return engine; -} - -PackageStructure::Ptr defaultPackageStructure(ComponentType type) -{ - switch (type) { - case AppletComponent: - case GenericComponent: - return PackageStructure::Ptr(new PlasmoidPackage()); - default: - // TODO: we don't have any special structures for other components yet - break; - } - - return PackageStructure::Ptr(new PackageStructure()); -} - -PackageStructure::Ptr packageStructure(const QString &language, ComponentType type) -{ - KService::List offers = engineOffers(language, type); - - if (offers.isEmpty()) { - return defaultPackageStructure(type); - } - - KService::Ptr offer = offers.first(); - QString packageFormat = offer->property("X-Plasma-PackageFormat").toString(); - - if (packageFormat.isEmpty()) { - return defaultPackageStructure(type); - } else { - PackageStructure::Ptr structure = PackageStructure::load(packageFormat); - return structure; - } -} - -} // namespace Plasma - -#include "moc_scriptengine.cpp" - diff --git a/plasma/scripting/scriptengine.h b/plasma/scripting/scriptengine.h deleted file mode 100644 index 7af91dbe..00000000 --- a/plasma/scripting/scriptengine.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright 2007 by Aaron Seigo - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library 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 Library 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. - */ - -#ifndef PLASMA_SCRIPTENGINE_H -#define PLASMA_SCRIPTENGINE_H - -#include -#include -#include - -#include -#include -#include - -#include -#include - -namespace Plasma -{ - -class AbstractRunner; -class Applet; -class AppletScript; -class DataEngine; -class Wallpaper; -class Package; - -/** - * @class ScriptEngine plasma/scripting/scriptengine.h - * - * @short The base class for scripting interfaces to be used in loading - * plasmoids of a given language. - * - * All ScriptEngines should export as consistent an interface as possible - * so that the learning curve is limited. In particular, the following - * API should be made available in the script environment: - * - * TODO: define the actual scripting APIas ... - * PlasmaApplet - the applet of this plasmoid - * LoadUserInterface(String uiFile) - loads and returns a given UI file - * LoadImage - loads an image resource out of the plasmoid's package - * PlasmaSvg - creates and returns an Svg file - **/ - -class PLASMA_EXPORT ScriptEngine : public QObject -{ - Q_OBJECT - -public: - ~ScriptEngine(); - - /** - * Called when it is safe to initialize the internal state of the engine - */ - virtual bool init(); - -protected: - explicit ScriptEngine(QObject *parent = 0); - - /** - * @return absolute path to the main script file for this plasmoid - */ - virtual QString mainScript() const; - - /** - * @return the Package associated with this plasmoid which can - * be used to request resources, such as images and - * interface files. - */ - virtual const Package *package() const; -}; - -/** - * @param types a set of ComponentTypes flags for which to look up the - * language support for - * @return a list of all supported languages for the given type(s). - **/ -PLASMA_EXPORT QStringList knownLanguages(ComponentTypes types); - -/** - * Loads an Applet script engine for the given language. - * - * @param language the language to load for - * @param applet the Plasma::Applet for this script - * @return pointer to the AppletScript or 0 on failure; the caller is responsible - * for the return object which will be parented to the Applet - **/ -PLASMA_EXPORT AppletScript *loadScriptEngine(const QString &language, Applet *applet); - -/** - * Loads an appropriate PackageStructure for the given language and type - * - * @param language the language to load the PackageStructure for - * @param type the component type - * @return a guarded PackageStructure pointer - */ -PLASMA_EXPORT PackageStructure::Ptr packageStructure(const QString &language, ComponentType type); - -} // namespace Plasma - -#endif - diff --git a/plasma/svg.cpp b/plasma/svg.cpp index 1d00901d..ea4b4487 100644 --- a/plasma/svg.cpp +++ b/plasma/svg.cpp @@ -291,21 +291,10 @@ void SvgPrivate::createRenderer() //kDebug() << kBacktrace(); if (themed && path.isEmpty() && !themeFailed) { - Applet *applet = qobject_cast(q->parent()); - if (applet && applet->package()) { - path = applet->package()->filePath("images", themePath + ".svg"); - - if (path.isEmpty()) { - path = applet->package()->filePath("images", themePath + ".svgz"); - } - } - - if (path.isEmpty()) { - path = actualTheme()->imagePath(themePath); - themeFailed = path.isEmpty(); - if (themeFailed) { - kWarning() << "No image path found for" << themePath; - } + path = actualTheme()->imagePath(themePath); + themeFailed = path.isEmpty(); + if (themeFailed) { + kWarning() << "No image path found for" << themePath; } } diff --git a/plasma/tests/CMakeLists.txt b/plasma/tests/CMakeLists.txt index edec5a76..6572aea1 100644 --- a/plasma/tests/CMakeLists.txt +++ b/plasma/tests/CMakeLists.txt @@ -12,9 +12,6 @@ MACRO(PLASMA_UNIT_TESTS) ENDMACRO(PLASMA_UNIT_TESTS) PLASMA_UNIT_TESTS( - packagestructuretest packagemetadatatest - plasmoidpackagetest runnercontexttest - configloadertest ) diff --git a/plasma/tests/configloadertest.cpp b/plasma/tests/configloadertest.cpp deleted file mode 100644 index cd8b371e..00000000 --- a/plasma/tests/configloadertest.cpp +++ /dev/null @@ -1,213 +0,0 @@ -/******************************************************************************** -* Copyright 2010 by Martin Blumenstingl * -* * -* This library is free software; you can redistribute it and/or * -* modify it under the terms of the GNU Library General Public * -* License as published by the Free Software Foundation; either * -* version 2 of the License, or (at your option) any later version. * -* * -* This library 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 * -* Library General Public License for more details. * -* * -* You should have received a copy of the GNU Library General Public License * -* along with this library; see the file COPYING.LIB. If not, write to * -* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * -* Boston, MA 02110-1301, USA. * -*********************************************************************************/ - -#include "configloadertest.h" - -#include -#include -#include -#include - -#include "plasma/configloader.h" - -Q_DECLARE_METATYPE(QList) - -#define TEST_NAME QString::fromLatin1("configloadertest") - -#define GET_CONFIG_ITEM_VALUE(type, configName) \ - KConfigSkeletonItem* item = cl->findItemByGroup(TEST_NAME, configName); \ - /* Check if we got back a valid item. */ \ - QVERIFY(item != 0); \ - /* Cast the item to the given type. */ \ - type typeItem = dynamic_cast(item); \ - /* Make sure the cast was successful. */ \ - QVERIFY(typeItem != 0); - -void ConfigLoaderTest::init() -{ - QString fileName = TEST_NAME + QString::fromLatin1(".xml"); - configFile = new QFile(QString::fromLatin1(KDESRCDIR) + QString::fromLatin1("/") + fileName); - cl = new Plasma::ConfigLoader(configFile->fileName(), configFile); -} - -void ConfigLoaderTest::cleanup() -{ - delete cl; - delete configFile; -} - -void ConfigLoaderTest::boolDefaultValue() -{ - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemBool*, "DefaultBoolItem"); - - QVERIFY(typeItem->isEqual(true)); -} - -void ConfigLoaderTest::colorDefaultValue() -{ - GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemColor*, "DefaultColorItem"); - - QVERIFY(typeItem->isEqual(QColor("#00FF00"))); -} - -void ConfigLoaderTest::colorWithAlphaDefaultValue() -{ - GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemColor*, "DefaultColorWithAlphaItem"); - - QVERIFY(typeItem->isEqual(QColor(100, 100, 100, 100))); -} - -void ConfigLoaderTest::dateTimeDefaultValue() -{ - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemDateTime*, "DefaultDateTimeItem"); - - QVERIFY(typeItem->isEqual(QDateTime::fromString("Thu Sep 09 2010"))); -} - -void ConfigLoaderTest::enumDefaultValue() -{ - GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemEnum*, "DefaultEnumItem"); - - QVERIFY(typeItem->isEqual(3)); -} - -void ConfigLoaderTest::fontDefaultValue() -{ - GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemFont*, "DefaultFontItem"); - - QVERIFY(typeItem->isEqual(QFont("DejaVu Sans"))); -} - -void ConfigLoaderTest::intDefaultValue() -{ - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemInt*, "DefaultIntItem"); - - QVERIFY(typeItem->isEqual(27)); -} - -void ConfigLoaderTest::pathDefaultValue() -{ - GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemPath*, "DefaultPathItem"); - - QVERIFY(typeItem->isEqual(QString::fromLatin1("/dev/null"))); -} - -void ConfigLoaderTest::stringDefaultValue() -{ - GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemString*, "DefaultStringItem"); - - QVERIFY(typeItem->isEqual(QString::fromLatin1("TestString"))); -} - -void ConfigLoaderTest::stringListDefaultValue() -{ - GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemStringList*, "DefaultStringListItem"); - - // Create a string list with the expected values. - QStringList expected; - expected.append("One"); - expected.append("Two"); - expected.append("Three"); - expected.append("Four"); - expected.append("Five"); - - QVERIFY(typeItem->isEqual(expected)); -} - -void ConfigLoaderTest::uintDefaultValue() -{ - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemUInt*, "DefaultUIntItem"); - - QVERIFY(typeItem->isEqual(7U)); -} - -void ConfigLoaderTest::urlDefaultValue() -{ - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemUrl*, "DefaultUrlItem"); - - QVERIFY(typeItem->isEqual(KUrl("http://kde.org"))); -} - -void ConfigLoaderTest::doubleDefaultValue() -{ - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemDouble*, "DefaultDoubleItem"); - - QVERIFY(typeItem->isEqual(13.37)); -} - -void ConfigLoaderTest::intListDefaultValue() -{ - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemIntList*, "DefaultIntListItem"); - - // Create a int list with the expected values. - QList expected; - expected.append(1); - expected.append(1); - expected.append(2); - expected.append(3); - expected.append(5); - expected.append(8); - - QVERIFY(typeItem->isEqual(qVariantFromValue(expected))); -} - -void ConfigLoaderTest::longLongDefaultValue() -{ - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemLongLong*, "DefaultLongLongItem"); - - QVERIFY(typeItem->isEqual(Q_INT64_C(-9211372036854775808))); -} - -void ConfigLoaderTest::pointDefaultValue() -{ - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemPoint*, "DefaultPointItem"); - - QVERIFY(typeItem->isEqual(QPoint(185, 857))); -} - -void ConfigLoaderTest::rectDefaultValue() -{ - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemRect*, "DefaultRectItem"); - - // Create a new QRect with the expected value. - QRect expected; - expected.setCoords(3, 7, 951, 358); - - QVERIFY(typeItem->isEqual(expected)); -} - -void ConfigLoaderTest::sizeDefaultValue() -{ - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemSize*, "DefaultSizeItem"); - - QVERIFY(typeItem->isEqual(QSize(640, 480))); -} - -void ConfigLoaderTest::ulongLongDefaultValue() -{ - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemULongLong*, "DefaultULongLongItem"); - - QVERIFY(typeItem->isEqual(Q_UINT64_C(9223372036854775806))); -} - - -QTEST_KDEMAIN(ConfigLoaderTest, NoGUI) - -//#include "configloadertest.moc" - diff --git a/plasma/tests/configloadertest.h b/plasma/tests/configloadertest.h deleted file mode 100644 index a96fa0ee..00000000 --- a/plasma/tests/configloadertest.h +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************** -* Copyright 2010 by Martin Blumenstingl * -* * -* This library is free software; you can redistribute it and/or * -* modify it under the terms of the GNU Library General Public * -* License as published by the Free Software Foundation; either * -* version 2 of the License, or (at your option) any later version. * -* * -* This library 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 * -* Library General Public License for more details. * -* * -* You should have received a copy of the GNU Library General Public License * -* along with this library; see the file COPYING.LIB. If not, write to * -* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * -* Boston, MA 02110-1301, USA. * -*********************************************************************************/ - -#ifndef CONFIGLOADERTEST_H -#define CONFIGLOADERTEST_H - -#include - -namespace Plasma -{ - class ConfigLoader; -} - -#include - -class ConfigLoaderTest : public QObject -{ - Q_OBJECT - -public Q_SLOTS: - void init(); - void cleanup(); - -private Q_SLOTS: - void boolDefaultValue(); - void colorDefaultValue(); - void colorWithAlphaDefaultValue(); - void dateTimeDefaultValue(); - void enumDefaultValue(); - void fontDefaultValue(); - void intDefaultValue(); - void pathDefaultValue(); - void stringDefaultValue(); - void stringListDefaultValue(); - void uintDefaultValue(); - void urlDefaultValue(); - void doubleDefaultValue(); - void intListDefaultValue(); - void longLongDefaultValue(); - void pointDefaultValue(); - void rectDefaultValue(); - void sizeDefaultValue(); - void ulongLongDefaultValue(); - -private: - Plasma::ConfigLoader* cl; - QFile* configFile; -}; - -#endif - diff --git a/plasma/tests/configloadertest.xml b/plasma/tests/configloadertest.xml deleted file mode 100644 index cf7bd10d..00000000 --- a/plasma/tests/configloadertest.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - true - - - #00FF00 - - - 100,100,100,100 - - - Thu Sep 09 2010 - - - 3 - - - - - - - DejaVu Sans - - - 27 - - - /dev/null - - - TestString - - - One,Two,Three,Four,Five - - - 7 - - - http://kde.org - - - 13.37 - - - 1,1,2,3,5,8 - - - -9211372036854775808 - - - 185,857 - - - 3,7,951,358 - - - 640,480 - - - 9223372036854775806 - - - \ No newline at end of file diff --git a/plasma/tests/packagestructuretest.cpp b/plasma/tests/packagestructuretest.cpp deleted file mode 100644 index fa254933..00000000 --- a/plasma/tests/packagestructuretest.cpp +++ /dev/null @@ -1,215 +0,0 @@ -/****************************************************************************** -* Copyright 2007 by Aaron Seigo * -* * -* This library is free software; you can redistribute it and/or * -* modify it under the terms of the GNU Library General Public * -* License as published by the Free Software Foundation; either * -* version 2 of the License, or (at your option) any later version. * -* * -* This library 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 * -* Library General Public License for more details. * -* * -* You should have received a copy of the GNU Library General Public License * -* along with this library; see the file COPYING.LIB. If not, write to * -* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * -* Boston, MA 02110-1301, USA. * -*******************************************************************************/ - -#include "packagestructuretest.h" - -#include -#include -#include - -#include "plasma/package.h" -#include "plasma/packagestructure.h" -#include "plasma/applet.h" - -class NoPrefixes : public Plasma::PackageStructure -{ -public: - explicit NoPrefixes() - : Plasma::PackageStructure(0, "StructureLess") - { - setContentsPrefixPaths(QStringList()); - addDirectoryDefinition("bin", "bin", "bin"); - } -}; - - -void PackageStructureTest::init() -{ - ps = Plasma::Applet::packageStructure(); -} - -void PackageStructureTest::cleanup() -{ -} - -void PackageStructureTest::emptyContentsPrefix() -{ - Plasma::PackageStructure::Ptr structure(new NoPrefixes); - Plasma::Package package("/", structure); - QString path(package.filePath("bin", "ls")); - qDebug() << path; - QCOMPARE(path, QString("/bin/ls")); -} - -void PackageStructureTest::type() -{ - QCOMPARE(ps->type(), QString("Plasmoid")); -} - -void PackageStructureTest::directories() -{ - QList dirs; - dirs << "config" << "data" << "images" << "scripts" << "theme" << "translations" << "ui"; - - QList psDirs = ps->directories(); - - QCOMPARE(dirs.count(), psDirs.count()); - - for (int i = 0; i < psDirs.count(); ++i) { - QCOMPARE(dirs[i], psDirs[i]); - } -} - -void PackageStructureTest::requiredDirectories() -{ - QCOMPARE(ps->requiredDirectories().size(), 0); -} - -void PackageStructureTest::files() -{ - QList files; - files << "defaultconfig" << "mainconfigui" << "mainconfigxml" << "mainscript"; - - QList psFiles = ps->files(); - - //for (int i = 0; i < psFiles.count(); ++i) { - // qDebug() << psFiles[i]; - //} - QCOMPARE(files.count(), psFiles.count()); - for (int i = 0; i < files.count(); ++i) { - QCOMPARE(files[i], psFiles[i]); - } -} - -void PackageStructureTest::requiredFiles() -{ - QList files; - files << "mainscript"; - - QList psFiles = ps->requiredFiles(); - - QCOMPARE(files.count(), psFiles.count()); - for (int i = 0; i < files.count(); ++i) { - QCOMPARE(files[i], psFiles[i]); - } -} - -void PackageStructureTest::path() -{ - QCOMPARE(ps->path("images"), QString("images")); - QCOMPARE(ps->path("mainscript"), QString("code/main")); -} - -void PackageStructureTest::name() -{ - QCOMPARE(ps->name("config"), i18n("Configuration Definitions")); - QCOMPARE(ps->name("mainscript"), i18n("Main Script File")); -} - -void PackageStructureTest::required() -{ - QVERIFY(ps->isRequired("mainscript")); -} - -void PackageStructureTest::mimetypes() -{ - QStringList mimetypes; - mimetypes << "image/svg+xml" << "image/png" << "image/jpeg"; - QCOMPARE(ps->mimetypes("images"), mimetypes); - QCOMPARE(ps->mimetypes("theme"), mimetypes); -} - -void PackageStructureTest::read() -{ - QString structurePath = QString(KDESRCDIR) + "/plasmoidpackagerc"; - KConfig config(structurePath, KConfig::SimpleConfig); - Plasma::PackageStructure structure; - structure.read(&config); - - // check some names - QCOMPARE(structure.name("config"), i18n("Configuration Definitions")); - QCOMPARE(structure.name("mainscript"), i18n("Main Script File")); - - // check some paths - QCOMPARE(structure.path("images"), QString("images")); - QCOMPARE(structure.path("mainscript"), QString("code/main")); - - // compare files - QList files; - files << "mainconfiggui" << "mainconfigxml" << "mainscript"; - - QList psFiles = structure.files(); - - QCOMPARE(psFiles.count(), files.count()); - for (int i = 0; i < files.count(); ++i) { - QCOMPARE(psFiles[i], files[i]); - } - - // compare required files - QList reqFiles = structure.requiredFiles(); - QCOMPARE(reqFiles.count(), 1); - QCOMPARE(reqFiles[0], QByteArray("mainscript")); - - // compare directories - QList dirs; - dirs << "config" << "configui" << "images" << "scripts"; - QList psDirs = structure.directories(); - QCOMPARE(psDirs.count(), dirs.count()); - for (int i = 0; i < dirs.count(); i++) { - QCOMPARE(psDirs[i], dirs[i]); - } - QCOMPARE(structure.requiredDirectories().size(), 0); -} - -void PackageStructureTest::write() -{ - QString file1 = QDir::homePath() + "/.kde-unit-test/packagerc"; - QString file2 = QString(KDESRCDIR) + "/plasmoidpackagerc"; - - KConfig config(file1, KConfig::SimpleConfig); - ps->write(&config); - - // check type - QCOMPARE(config.group("").readEntry("Type", QString()), QString("Plasmoid")); - - // check groups - QStringList groups; - groups << "images" << "theme" << "config" << "data" << "defaultconfig" << "scripts" - << "mainconfigui" << "mainconfigxml" << "mainscript" - << "translations" << "ui"; - groups.sort(); - - QStringList actualGroups = config.groupList(); - actualGroups.sort(); - //kDebug() << actualGroups; - QCOMPARE(actualGroups, groups); - - // check scripts - KConfigGroup scripts = config.group("scripts"); - QCOMPARE(scripts.readEntry("Path", QString()), QString("code")); - QCOMPARE(scripts.readEntry("Name", QString()), QString("Executable Scripts")); - QCOMPARE(scripts.readEntry("Mimetypes", QStringList()), QStringList() << "text/plain"); - QCOMPARE(scripts.readEntry("Directory", false), true); - QCOMPARE(scripts.readEntry("Required", false), false); -} - -QTEST_KDEMAIN(PackageStructureTest, NoGUI) - -//#include "packagestructuretest.moc" - diff --git a/plasma/tests/plasmoidpackagerc b/plasma/tests/plasmoidpackagerc deleted file mode 100644 index 3feaaa4e..00000000 --- a/plasma/tests/plasmoidpackagerc +++ /dev/null @@ -1,38 +0,0 @@ -Type=Plasmoid - -[images] -Path=images -Name=Images -Mimetypes=image/svg+xml,image/png,image/jpeg -Directory=true - -[config] -Path=config/xml -Name=Configuration Definitions -Mimetypes=text/xml -Directory=true - -[configui] -Path=config/ui -Name=Configuration UI -Mimetypes=text/xml -Directory=true - -[scripts] -Path=code -Name=Executable Scripts -Mimetypes=text/* -Directory=true - -[mainconfiggui] -Path=config/ui/main.ui -Name=Main Config UI File - -[mainconfigxml] -Path=config/ui/main.xml -Name=Configuration XML File - -[mainscript] -Path=code/main -Name=Main Script File -Required=true diff --git a/plasma/tests/plasmoidpackagetest.cpp b/plasma/tests/plasmoidpackagetest.cpp deleted file mode 100644 index ad2d9484..00000000 --- a/plasma/tests/plasmoidpackagetest.cpp +++ /dev/null @@ -1,294 +0,0 @@ -/****************************************************************************** -* Copyright 2007 by Bertjan Broeksema * -* * -* This library is free software; you can redistribute it and/or * -* modify it under the terms of the GNU Library General Public * -* License as published by the Free Software Foundation; either * -* version 2 of the License, or (at your option) any later version. * -* * -* This library 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 * -* Library General Public License for more details. * -* * -* You should have received a copy of the GNU Library General Public License * -* along with this library; see the file COPYING.LIB. If not, write to * -* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * -* Boston, MA 02110-1301, USA. * -*******************************************************************************/ - -#include "plasmoidpackagetest.h" -#include "plasma/applet.h" -#include "plasma/packagemetadata.h" -#include "../config-plasma.h" - -#include - -#include -#include -#include - -void PlasmoidPackageTest::init() -{ - mPackage = QString("Package"); - mPackageRoot = QDir::homePath() + "/.kde-unit-test/packageRoot"; - ps = Plasma::Applet::packageStructure(); -} - -void PlasmoidPackageTest::cleanup() -{ - delete p; - p = 0; - - // Clean things up. - QDir local(QDir::homePath() + QLatin1String("/.kde-unit-test/packageRoot")); - foreach (const QString &dir, local.entryList(QDir::Dirs)) { - removeDir(QLatin1String("packageRoot/") + dir.toLatin1() + "/contents/code"); - removeDir(QLatin1String("packageRoot/") + dir.toLatin1() + "/contents/images"); - removeDir(QLatin1String("packageRoot/") + dir.toLatin1() + "/contents"); - removeDir(QLatin1String("packageRoot/") + dir.toLatin1()); - } - - QDir().rmpath(QDir::homePath() + "/.kde-unit-test/packageRoot"); -} - -// Copied from ktimezonetest.h -void PlasmoidPackageTest::removeDir(const QString &subdir) -{ - QDir local(QDir::homePath() + QLatin1String("/.kde-unit-test/") + subdir); - foreach(const QString &file, local.entryList(QDir::Files)) - if(!local.remove(file)) - qWarning("%s: removing failed", qPrintable( file )); - QCOMPARE((int)local.entryList(QDir::Files).count(), 0); - local.cdUp(); - QString subd = subdir; - subd.remove(QRegExp("^.*/")); - local.rmpath(subd); -} - -void PlasmoidPackageTest::createTestPackage(const QString &packageName) -{ - QDir pRoot(mPackageRoot); - // Create the root and package dir. - if (!pRoot.exists()) { - QVERIFY(QDir().mkpath(mPackageRoot)); - } - - // Create the package dir - QVERIFY(QDir().mkpath(mPackageRoot + "/" + packageName)); - - // Create the metadata.desktop file - QFile file(mPackageRoot + "/" + packageName + "/metadata.desktop"); - - QVERIFY(file.open(QIODevice::WriteOnly | QIODevice::Text)); - - QTextStream out(&file); - out << "[Desktop Entry]\n"; - out << "Name=" << packageName << "\n"; - out << "X-KDE-PluginInfo-Name=" << packageName << "\n"; - file.flush(); - file.close(); - - // Create the code dir. - QVERIFY(QDir().mkpath(mPackageRoot + "/" + packageName + "/contents/code")); - - // Create the main file. - file.setFileName(mPackageRoot + "/" + packageName + "/contents/code/main"); - QVERIFY(file.open(QIODevice::WriteOnly | QIODevice::Text)); - - out << "THIS IS A PLASMOID SCRIPT....."; - file.flush(); - file.close(); - - // Now we have a minimal plasmoid package which is valid. Let's add some - // files to it for test purposes. - - // Create the images dir. - QVERIFY(QDir().mkpath(mPackageRoot + "/" + packageName + "/contents/images")); - file.setFileName(mPackageRoot + "/" + packageName + "/contents/images/image-1.svg"); - - QVERIFY(file.open(QIODevice::WriteOnly | QIODevice::Text)); - - out << "This is a test image"; - file.flush(); - file.close(); - - file.setFileName(mPackageRoot + "/" + packageName + "/contents/images/image-2.svg"); - - QVERIFY(file.open(QIODevice::WriteOnly | QIODevice::Text)); - - out.setDevice(&file); - out << "This is another test image"; - file.flush(); - file.close(); -} - -void PlasmoidPackageTest::isValid() -{ - p = new Plasma::Package(mPackageRoot, mPackage, ps); - - // A PlasmoidPackage is valid when: - // - The package root exists. - // - The package root consists an file named "code/main" - QVERIFY(!p->isValid()); - - // Create the root and package dir. - QVERIFY(QDir().mkpath(mPackageRoot)); - QVERIFY(QDir().mkpath(mPackageRoot + "/" + mPackage)); - - // Should still be invalid. - delete p; - p = new Plasma::Package(mPackageRoot, mPackage, ps); - QVERIFY(!p->isValid()); - - // Create the metadata.desktop file. - QFile file(mPackageRoot + "/" + mPackage + "/metadata.desktop"); - QVERIFY(file.open(QIODevice::WriteOnly | QIODevice::Text)); - - QTextStream out(&file); - out << "[Desktop Entry]\n"; - out << "Name=test\n"; - out << "Description=Just a test desktop file"; - file.flush(); - file.close(); - - // Create the code dir. - QVERIFY(QDir().mkpath(mPackageRoot + "/" + mPackage + "/contents/code")); - - // No main file yet so should still be invalid. - delete p; - p = new Plasma::Package(mPackageRoot, mPackage, ps); - QVERIFY(!p->isValid()); - - // Create the main file. - file.setFileName(mPackageRoot + "/" + mPackage + "/contents/code/main"); - QVERIFY(file.open(QIODevice::WriteOnly | QIODevice::Text)); - - out.setDevice(&file); - out << "THIS IS A PLASMOID SCRIPT.....\n"; - file.flush(); - file.close(); - - file.setPermissions(QFile::ReadUser | QFile::WriteUser); - // Main file exists so should be valid now. - delete p; - p = new Plasma::Package(mPackageRoot, mPackage, ps); - QVERIFY(p->isValid()); -} - -void PlasmoidPackageTest::filePath() -{ - // Package::filePath() returns - // - {package_root}/{package_name}/path/to/file if the file exists - // - QString() otherwise. - p = new Plasma::Package(mPackageRoot, mPackage, ps); - - QCOMPARE(p->filePath("scripts", "main"), QString()); - - QVERIFY(QDir().mkpath(mPackageRoot + "/" + mPackage + "/contents/code")); - QFile file(mPackageRoot + "/" + mPackage + "/contents/code/main"); - QVERIFY(file.open(QIODevice::WriteOnly | QIODevice::Text)); - - QTextStream out(&file); - out << "THIS IS A PLASMOID SCRIPT....."; - file.flush(); - file.close(); - - // The package is valid by now so a path for code/main should get returned. - delete p; - p = new Plasma::Package(mPackageRoot, mPackage, ps); - - const QString path = KStandardDirs::realFilePath(mPackageRoot + "/" + mPackage + "/contents/code/main"); - - // Two ways to get the same info. - // 1. Give the file type which refers to a class of files (a directory) in - // the package structure and the file name. - // 2. Give the file type which refers to a file in the package structure. - // - // NOTE: scripts, main and mainscript are defined in packages.cpp and are - // specific for a PlasmoidPackage. - QCOMPARE(p->filePath("scripts", "main"), path); - QCOMPARE(p->filePath("mainscript"), path); -} - -void PlasmoidPackageTest::entryList() -{ - QString packageName("SomePlasmoid"); - - // Create a package named @p packageName which is valid and has some images. - createTestPackage(packageName); - - // Create a package object and verify that it is valid. - p = new Plasma::Package(mPackageRoot, packageName, ps); - QVERIFY(p->isValid()); - - // Now we have a valid package that should contain the following files in - // given filetypes: - // fileTye - Files - // scripts - {"main"} - // images - {"image-1.svg", "image-2.svg"} - QStringList files = p->entryList("scripts"); - QCOMPARE(files.size(), 1); - QVERIFY(files.contains("main")); - - files = p->entryList("images"); - QCOMPARE(files.size(), 2); - QVERIFY(files.contains("image-1.svg")); - QVERIFY(files.contains("image-2.svg")); -} - -void PlasmoidPackageTest::knownPackages() -{ - // Don't do strange things when package root doesn't exists. - QDir pRoot = QDir(mPackageRoot + "blah"); - QVERIFY(!pRoot.exists()); - p = new Plasma::Package(mPackageRoot + "blah", mPackage, ps); - QCOMPARE(Plasma::Package::listInstalled(mPackageRoot), QStringList()); - delete p; - - // Don't do strange things when an empty package root exists - QVERIFY(QDir().mkpath(mPackageRoot)); - //QVERIFY(pRoot.exists()); - p = new Plasma::Package(mPackageRoot, mPackage, ps); - QCOMPARE(Plasma::Package::listInstalled(mPackageRoot), QStringList()); - delete p; - - // Do not return a directory as package if it has no metadata.desktop file - QVERIFY(QDir().mkpath(mPackageRoot + "/invalid_plasmoid")); - p = new Plasma::Package(mPackageRoot, mPackage, ps); - QCOMPARE(Plasma::Package::listInstalled(mPackageRoot), QStringList()); - delete p; - - // Let's add a valid package and see what happens. - QString plamoid1("a_valid_plasmoid"); - createTestPackage(plamoid1); - p = new Plasma::Package(mPackageRoot, mPackage, ps); - - QStringList packages = Plasma::Package::listInstalled(mPackageRoot); - QCOMPARE(packages.size(), 1); - QVERIFY(packages.contains(plamoid1)); - - // Ok.... one more valid package. - QString plamoid2("another_valid_plasmoid"); - createTestPackage(plamoid2); - p = new Plasma::Package(mPackageRoot, mPackage, ps); - - packages = Plasma::Package::listInstalled(mPackageRoot); - QCOMPARE(packages.size(), 2); - QVERIFY(packages.contains(plamoid1)); - QVERIFY(packages.contains(plamoid2)); -} - -void PlasmoidPackageTest::metadata() -{ - QString plasmoid("plasmoid_with_metadata"); - createTestPackage(plasmoid); - - QString path = mPackageRoot + '/' + plasmoid + "/metadata.desktop"; - p = new Plasma::Package(mPackageRoot, plasmoid, ps); - const Plasma::PackageMetadata metadata = p->metadata(); - QVERIFY(p->isValid()); - QCOMPARE(metadata.name(), plasmoid); -} - -QTEST_KDEMAIN(PlasmoidPackageTest, NoGUI) diff --git a/plasma/tests/plasmoidpackagetest.h b/plasma/tests/plasmoidpackagetest.h deleted file mode 100644 index 1096f538..00000000 --- a/plasma/tests/plasmoidpackagetest.h +++ /dev/null @@ -1,52 +0,0 @@ -/****************************************************************************** -* Copyright 2007 by Bertjan Broeksema * -* * -* This library is free software; you can redistribute it and/or * -* modify it under the terms of the GNU Library General Public * -* License as published by the Free Software Foundation; either * -* version 2 of the License, or (at your option) any later version. * -* * -* This library 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 * -* Library General Public License for more details. * -* * -* You should have received a copy of the GNU Library General Public License * -* along with this library; see the file COPYING.LIB. If not, write to * -* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * -* Boston, MA 02110-1301, USA. * -*******************************************************************************/ - -#ifndef PACKAGETEST_H - -#include - -#include "plasma/package.h" - -class PlasmoidPackageTest : public QObject -{ - Q_OBJECT - -public Q_SLOTS: - void init(); - void cleanup(); - -private Q_SLOTS: - void isValid(); - void filePath(); - void entryList(); - void knownPackages(); - void metadata(); - -private: - void removeDir(const QString &subdir); - void createTestPackage(const QString &packageName); - - QString mPackageRoot; - QString mPackage; - Plasma::PackageStructure::Ptr ps; - Plasma::Package *p; -}; - -#endif - diff --git a/plasma/widgets/declarativewidget.cpp b/plasma/widgets/declarativewidget.cpp deleted file mode 100644 index c5ba6bc3..00000000 --- a/plasma/widgets/declarativewidget.cpp +++ /dev/null @@ -1,328 +0,0 @@ -/* - * Copyright 2010 Marco Martin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library 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 Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "declarativewidget.h" - - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "private/dataenginebindings_p.h" - -namespace Plasma -{ - -class DeclarativeWidgetPrivate -{ -public: - DeclarativeWidgetPrivate(DeclarativeWidget *parent) - : q(parent), - engine(0), - scriptEngine(0), - component(0), - root(0), - delay(false) - { - } - - ~DeclarativeWidgetPrivate() - { - } - - void errorPrint(); - void execute(const QString &fileName); - void finishExecute(); - void scheduleExecutionEnd(); - void minimumWidthChanged(); - void minimumHeightChanged(); - void maximumWidthChanged(); - void maximumHeightChanged(); - void implicitWidthChanged(); - void implicitHeightChanged(); - - - DeclarativeWidget *q; - - QString qmlPath; - QDeclarativeEngine* engine; - QScriptEngine *scriptEngine; - QDeclarativeComponent* component; - QObject *root; - bool delay : 1; -}; - -void DeclarativeWidgetPrivate::errorPrint() -{ - QString errorStr = "Error loading QML file.\n"; - if(component->isError()){ - QList errors = component->errors(); - foreach (const QDeclarativeError &error, errors) { - errorStr += (error.line()>0?QString(QString::number(error.line()) + QLatin1String(": ")):QLatin1String("")) - + error.description() + '\n'; - } - } - kWarning() << component->url().toString() + '\n' + errorStr; -} - -void DeclarativeWidgetPrivate::execute(const QString &fileName) -{ - if (fileName.isEmpty()) { - kDebug() << "File name empty!"; - return; - } - - KDeclarative kdeclarative; - kdeclarative.setDeclarativeEngine(engine); - kdeclarative.initialize(); - //binds things like kconfig and icons - kdeclarative.setupBindings(); - - component->loadUrl(fileName); - - scriptEngine = kdeclarative.scriptEngine(); - registerDataEngineMetaTypes(scriptEngine); - - if (delay) { - QTimer::singleShot(0, q, SLOT(scheduleExecutionEnd())); - } else { - scheduleExecutionEnd(); - } -} - -void DeclarativeWidgetPrivate::scheduleExecutionEnd() -{ - if (component->isReady() || component->isError()) { - finishExecute(); - } else { - QObject::connect( - component, SIGNAL(statusChanged(QDeclarativeComponent::ComponentStatus)), - q, SLOT(finishExecute()) - ); - } -} - -void DeclarativeWidgetPrivate::finishExecute() -{ - if (component->isError()) { - errorPrint(); - } - - root = component->create(); - - if (!root) { - errorPrint(); - } - - kDebug() << "Execution of QML done!"; - QGraphicsWidget *widget = dynamic_cast(root); - QGraphicsObject *object = dynamic_cast(root); - - - if (object) { - static_cast(object)->setParentItem(q); - } - - if (widget) { - q->setPreferredSize(-1,-1); - QGraphicsLinearLayout *lay = static_cast(q->layout()); - if (!lay) { - lay = new QGraphicsLinearLayout(q); - lay->setContentsMargins(0, 0, 0, 0); - } - lay->addItem(widget); - } else { - q->setLayout(0); - qreal minimumWidth = 0; - qreal minimumHeight = 0; - qreal maximumWidth = 0; - qreal maximumHeight = 0; - qreal implicitWidth = 0; - qreal implicitHeight = 0; - if (object) { - object->setProperty("width", q->size().width()); - object->setProperty("height", q->size().height()); - - if (object->metaObject()->indexOfProperty("minimumWidth")>=0) { - minimumWidth = object->property("minimumWidth").toReal(); - QObject::connect(object, SIGNAL(minimumWidthChanged()), q, SLOT(minimumWidthChanged())); - } - if (object->metaObject()->indexOfProperty("minimumHeight")>=0) { - minimumHeight = object->property("minimumHeight").toReal(); - QObject::connect(object, SIGNAL(minimumHeightChanged()), q, SLOT(minimumHeightChanged())); - } - - if (object->metaObject()->indexOfProperty("maximumWidth")>=0) { - maximumWidth = object->property("maximumWidth").toReal(); - QObject::connect(object, SIGNAL(maximumWidthChanged()), q, SLOT(maximumWidthChanged())); - } - if (object->metaObject()->indexOfProperty("maximumHeight")>=0) { - maximumHeight = object->property("maximumHeight").toReal(); - QObject::connect(object, SIGNAL(maximumHeightChanged()), q, SLOT(maximumHeightChanged())); - } - - if (object->metaObject()->indexOfProperty("implicitWidth")>=0) { - implicitWidth = object->property("implicitWidth").toReal(); - QObject::connect(object, SIGNAL(implicitWidthChanged()), q, SLOT(implicitWidthChanged())); - } - if (object->metaObject()->indexOfProperty("implicitHeight")>=0) { - implicitHeight = object->property("implicitHeight").toReal(); - QObject::connect(object, SIGNAL(implicitHeightChanged()), q, SLOT(implicitHeightChanged())); - } - } - - if (minimumWidth > 0 && minimumHeight > 0) { - q->setMinimumSize(minimumWidth, minimumHeight); - } else { - q->setMinimumSize(-1, -1); - } - - if (maximumWidth > 0 && maximumHeight > 0) { - q->setMaximumSize(maximumWidth, maximumHeight); - } else { - q->setMaximumSize(-1, -1); - } - - if (implicitWidth > 0 && implicitHeight > 0) { - q->setPreferredSize(implicitWidth, implicitHeight); - } else { - q->setPreferredSize(-1, -1); - } - } - emit q->finished(); -} - -void DeclarativeWidgetPrivate::minimumWidthChanged() -{ - qreal minimumWidth = root->property("minimumWidth").toReal(); - q->setMinimumWidth(minimumWidth); -} - -void DeclarativeWidgetPrivate::minimumHeightChanged() -{ - qreal minimumHeight = root->property("minimumHeight").toReal(); - q->setMinimumHeight(minimumHeight); -} - -void DeclarativeWidgetPrivate::maximumWidthChanged() -{ - qreal maximumWidth = root->property("maximumWidth").toReal(); - q->setMaximumWidth(maximumWidth); -} - -void DeclarativeWidgetPrivate::maximumHeightChanged() -{ - qreal maximumHeight = root->property("maximumHeight").toReal(); - q->setMaximumHeight(maximumHeight); -} - -void DeclarativeWidgetPrivate::implicitWidthChanged() -{ - qreal implicitWidth = root->property("implicitWidth").toReal(); - q->setPreferredWidth(implicitWidth); -} - -void DeclarativeWidgetPrivate::implicitHeightChanged() -{ - qreal implicitHeight = root->property("implicitHeight").toReal(); - q->setPreferredHeight(implicitHeight); -} - -DeclarativeWidget::DeclarativeWidget(QGraphicsWidget *parent) - : QGraphicsWidget(parent), - d(new DeclarativeWidgetPrivate(this)) -{ - setFlag(QGraphicsItem::ItemHasNoContents); - - d->engine = new QDeclarativeEngine(this); - - d->component = new QDeclarativeComponent(d->engine, this); -} - -DeclarativeWidget::~DeclarativeWidget() -{ - delete d; -} - -void DeclarativeWidget::setQmlPath(const QString &path) -{ - d->qmlPath = path; - d->execute(path); -} - -QString DeclarativeWidget::qmlPath() const -{ - return d->qmlPath; -} - -void DeclarativeWidget::setInitializationDelayed(const bool delay) -{ - d->delay = delay; -} - -bool DeclarativeWidget::isInitializationDelayed() const -{ - return d->delay; -} - -QDeclarativeEngine* DeclarativeWidget::engine() -{ - return d->engine; -} - -QScriptEngine *DeclarativeWidget::scriptEngine() const -{ - return d->scriptEngine; -} - -QObject *DeclarativeWidget::rootObject() const -{ - return d->root; -} - -QDeclarativeComponent *DeclarativeWidget::mainComponent() const -{ - return d->component; -} - -void DeclarativeWidget::resizeEvent(QGraphicsSceneResizeEvent *event) -{ - QGraphicsWidget::resizeEvent(event); - - if (d->root) { - d->root->setProperty("width", size().width()); - d->root->setProperty("height", size().height()); - } -} - - -} // namespace Plasma - -#include "moc_declarativewidget.cpp" - diff --git a/plasma/widgets/declarativewidget.h b/plasma/widgets/declarativewidget.h deleted file mode 100644 index 2f8901bd..00000000 --- a/plasma/widgets/declarativewidget.h +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright 2010 Marco Martin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library 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 Library 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. - */ - -#ifndef PLASMA_DECLARATIVEWIDGET_H -#define PLASMA_DECLARATIVEWIDGET_H - -#include - -#include - -#include -#include -#include - -namespace Plasma -{ - -class DeclarativeWidgetPrivate; - -/** - * @class DeclarativeWidget plasma/declarativewidget.h - * - * @author Marco Martin - * - * @short A widget that contains an entire QML context, with its own declarative engine - * - * Plasma::DeclarativeWidget provides a class for conveniently use QML based - * declarative user interfaces inside Plasma widgets. - * To one DeclarativeWidget corresponds one QML file (that can eventually include others) - * tere will be its own QDeclarativeEngine with a single root object, - * described in the QML file. - */ -class PLASMA_EXPORT DeclarativeWidget : public QGraphicsWidget -{ - Q_OBJECT - - Q_PROPERTY(QString qmlPath READ qmlPath WRITE setQmlPath) - Q_PROPERTY(bool initializationDelayed READ isInitializationDelayed WRITE setInitializationDelayed) - Q_PROPERTY(QObject * rootObject READ rootObject) - -public: - - /** - * Constructs a new DeclarativeWidget - * - * @param parent the parent of this widget - */ - explicit DeclarativeWidget(QGraphicsWidget *parent = 0); - ~DeclarativeWidget(); - - /** - * Sets the path of the QML file to parse and execute - * - * @param path the absolute path of a QML file - */ - void setQmlPath(const QString &path); - - /** - * @return the absolute path of the current QML file - */ - QString qmlPath() const; - - /** - * Sets whether the execution of the QML file has to be delayed later in the event loop. It has to be called before setQmlPath(). - * In this case will be possible to assign new objects in the main engine context - * before the main component gets initialized. - * So it will be possible to access it immediately from the QML code. - * - * @param delay if true the initilization of the QML file will be delayed - * at the end of the event loop - */ - void setInitializationDelayed(const bool delay); - - /** - * @return true if the initilization of the QML file will be delayed - * at the end of the event loop - */ - bool isInitializationDelayed() const; - - /** - * @return the declarative engine that runs the qml file assigned to this widget. - */ - QDeclarativeEngine* engine(); - - /** - * @return the script engine used by the declarative engine - * @since 4.7 - */ - QScriptEngine *scriptEngine() const; - - /** - * @return the root object of the declarative object tree - */ - QObject *rootObject() const; - - /** - * @return the main QDeclarativeComponent of the engine - */ - QDeclarativeComponent *mainComponent() const; - -protected: - void resizeEvent(QGraphicsSceneResizeEvent *event); - -Q_SIGNALS: - /** - * Emitted when the parsing and execution of the QML file is terminated - */ - void finished(); - -private: - friend class DeclarativeWidgetPrivate; - DeclarativeWidgetPrivate * const d; - - Q_PRIVATE_SLOT(d, void finishExecute()) - Q_PRIVATE_SLOT(d, void scheduleExecutionEnd()) - Q_PRIVATE_SLOT(d, void minimumWidthChanged()) - Q_PRIVATE_SLOT(d, void minimumHeightChanged()) - Q_PRIVATE_SLOT(d, void maximumWidthChanged()) - Q_PRIVATE_SLOT(d, void maximumHeightChanged()) - Q_PRIVATE_SLOT(d, void implicitWidthChanged()) - Q_PRIVATE_SLOT(d, void implicitHeightChanged()) -}; - -} // namespace Plasma - -#endif // multiple inclusion guard