diff --git a/CMakeLists.txt b/CMakeLists.txt index 9002f6b..5b1376a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,150 +1,163 @@ cmake_minimum_required(VERSION 3.5) set(KF5_VERSION "5.61.0") # handled by release scripts set(KF5_DEP_VERSION "5.60.0") # handled by release scripts project(KNotifications VERSION ${KF5_VERSION}) # ECM setup include(FeatureSummary) find_package(ECM 5.60.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://projects.kde.org/projects/kdesupport/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) include(GenerateExportHeader) include(ECMSetupVersion) include(ECMGenerateHeaders) include(ECMQtDeclareLoggingCategory) include(ECMPoQmTools) include(ECMAddQch) option(BUILD_QCH "Build API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)" OFF) add_feature_info(QCH ${BUILD_QCH} "API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)") ecm_setup_version(PROJECT VARIABLE_PREFIX KNOTIFICATIONS VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/knotifications_version.h" PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5NotificationsConfigVersion.cmake" SOVERSION 5) # Dependencies set(REQUIRED_QT_VERSION 5.11.0) set(CMAKE_AUTORCC TRUE) find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Widgets) find_package(Qt5 ${REQUIRED_QT_VERSION} QUIET OPTIONAL_COMPONENTS TextToSpeech) set_package_properties(Qt5TextToSpeech PROPERTIES DESCRIPTION "Qt text to speech module" TYPE OPTIONAL PURPOSE "Required to build text to speech notification support") if (Qt5TextToSpeech_FOUND) add_definitions(-DHAVE_SPEECH) endif() include(KDEInstallDirs) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(KDECMakeSettings) if (NOT APPLE AND NOT WIN32) find_package(X11) endif() set(HAVE_X11 ${X11_FOUND}) set(HAVE_XTEST ${X11_XTest_FOUND}) if(X11_FOUND) find_package(Qt5X11Extras ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE) endif() if(APPLE) find_package(Qt5MacExtras ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE) endif() find_package(KF5WindowSystem ${KF5_DEP_VERSION} REQUIRED) find_package(KF5Config ${KF5_DEP_VERSION} REQUIRED) find_package(KF5Codecs ${KF5_DEP_VERSION} REQUIRED) find_package(KF5CoreAddons ${KF5_DEP_VERSION} REQUIRED) if (NOT WIN32) if (ANDROID) find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED AndroidExtras) find_package(Gradle REQUIRED) else() find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED DBus) find_package(Canberra) set_package_properties(Canberra PROPERTIES DESCRIPTION "Library for generating event sounds" PURPOSE "Needed to build audio notification support" URL "http://0pointer.de/lennart/projects/libcanberra" TYPE OPTIONAL) if (Canberra_FOUND) add_definitions(-DHAVE_CANBERRA) else() # This is REQUIRED since you cannot tell CMake "either one of those two optional ones are required" find_package(Phonon4Qt5 4.6.60 NO_MODULE REQUIRED) set_package_properties(Phonon4Qt5 PROPERTIES DESCRIPTION "Qt-based audio library" PURPOSE "Needed to build audio notification support when Canberra isn't available") add_definitions(-DHAVE_PHONON4QT5) endif() endif() +else() + find_package(LibSnoreToast REQUIRED) + set_package_properties(LibSnoreToast PROPERTIES TYPE REQUIRED + PURPOSE "for the Windows Toast Notifications" + DESCRIPTION "A command line application, capable of creating + Windows Toast notifications on Windows (>=)8 " + ) + find_package(Qt5Network REQUIRED) endif() remove_definitions(-DQT_NO_CAST_FROM_BYTEARRAY) #add_definitions(-DQT_NO_FOREACH) if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/po") ecm_install_po_files_as_qm(po) endif() if (NOT APPLE) # QtMac::setBadgeLabelText is deprecated add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050d00) endif() add_subdirectory(src) if (BUILD_TESTING) add_subdirectory(tests) add_subdirectory(autotests) endif() # create a Config.cmake and a ConfigVersion.cmake file and install them set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5Notifications") if (BUILD_QCH) ecm_install_qch_export( TARGETS KF5Notifications_QCH FILE KF5NotificationsQchTargets.cmake DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel ) set(PACKAGE_INCLUDE_QCHTARGETS "include(\"\${CMAKE_CURRENT_LIST_DIR}/KF5NotificationsQchTargets.cmake\")") endif() include(CMakePackageConfigHelpers) set(HAVE_DBUS FALSE) if (TARGET Qt5::DBus) + find_package(dbusmenu-qt5 CONFIG) + set_package_properties(dbusmenu-qt5 PROPERTIES DESCRIPTION "DBusMenuQt" + URL "https://launchpad.net/libdbusmenu-qt" TYPE OPTIONAL + PURPOSE "Support for notification area menus via the DBusMenu protocol") + set(HAVE_DBUS TRUE) endif() configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/KF5NotificationsConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/KF5NotificationsConfig.cmake" PATH_VARS KDE_INSTALL_DBUSINTERFACEDIR INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR} ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/KF5NotificationsConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/KF5NotificationsConfigVersion.cmake" DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel ) install(EXPORT KF5NotificationsTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KF5NotificationsTargets.cmake NAMESPACE KF5:: ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/knotifications_version.h DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5} COMPONENT Devel ) install(FILES knotifications.categories DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR}) feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5089959..0bb0655 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,220 +1,210 @@ if (Phonon4Qt5_FOUND) include_directories(${PHONON_INCLUDE_DIR}) endif() if (CANBERRA_FOUND) include_directories(${CANBERRA_INCLUDE_DIRS}) endif() ecm_create_qm_loader(knotifications_QM_LOADER knotifications5_qt) set(knotifications_SRCS knotification.cpp knotificationmanager.cpp kpassivepopup.cpp knotifyconfig.cpp knotificationplugin.cpp notifybypopupgrowl.cpp notifybyexecute.cpp notifybylogfile.cpp notifybytaskbar.cpp ${knotifications_QM_LOADER} ) if (TARGET Qt5::DBus) list(APPEND knotifications_SRCS kstatusnotifieritem.cpp kstatusnotifieritemdbus_p.cpp knotificationrestrictions.cpp imageconverter.cpp #needed to marshal images for sending over dbus by NotifyByPopup notifybypopup.cpp notifybyportal.cpp ) endif() if (ANDROID) add_subdirectory(android) list(APPEND knotifications_SRCS notifybyandroid.cpp knotifications.qrc) endif() if (WIN32) - find_package(LibSnoreToast REQUIRED) - set_package_properties(LibSnoreToast PROPERTIES TYPE REQUIRED - PURPOSE "for the Windows Toast Notifications" - DESCRIPTION "A command line application, capable of creating Windows Toast notifications on Windows (>=)8 " - ) - find_package(Qt5Network REQUIRED) list(APPEND knotifications_SRCS notifybysnore.cpp) endif () ecm_qt_declare_logging_category(knotifications_SRCS HEADER debug_p.h IDENTIFIER LOG_KNOTIFICATIONS CATEGORY_NAME org.kde.knotifications) if (Canberra_FOUND) set(knotifications_SRCS ${knotifications_SRCS} notifybyaudio_canberra.cpp) elseif (Phonon4Qt5_FOUND) set(knotifications_SRCS ${knotifications_SRCS} notifybyaudio_phonon.cpp) endif() if (Qt5TextToSpeech_FOUND) set(knotifications_SRCS ${knotifications_SRCS} notifybytts.cpp) endif() if (TARGET Qt5::DBus) - find_package(dbusmenu-qt5 CONFIG) - set_package_properties(dbusmenu-qt5 PROPERTIES DESCRIPTION "DBusMenuQt" - URL "https://launchpad.net/libdbusmenu-qt" TYPE OPTIONAL - PURPOSE "Support for notification area menus via the DBusMenu protocol") if (dbusmenu-qt5_FOUND) message("dbusmenu-qt5_FOUND") set(HAVE_DBUSMENUQT 1) include_directories(${dbusmenu-qt5_INCLUDE_DIRS}) else() set(HAVE_DBUSMENUQT 0) endif() if (TARGET Qt5::DBus) qt5_add_dbus_adaptor(knotifications_SRCS org.kde.StatusNotifierItem.xml kstatusnotifieritemdbus_p.h KStatusNotifierItemDBus) set(statusnotifierwatcher_xml org.kde.StatusNotifierWatcher.xml) qt5_add_dbus_interface(knotifications_SRCS ${statusnotifierwatcher_xml} statusnotifierwatcher_interface) set(notifications_xml org.freedesktop.Notifications.xml) qt5_add_dbus_interface(knotifications_SRCS ${notifications_xml} notifications_interface) endif() endif() configure_file(config-knotifications.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-knotifications.h ) add_library(KF5Notifications ${knotifications_SRCS}) generate_export_header(KF5Notifications BASE_NAME KNotifications) add_library(KF5::Notifications ALIAS KF5Notifications) target_include_directories(KF5Notifications INTERFACE "$") target_link_libraries(KF5Notifications PUBLIC Qt5::Widgets ) if (TARGET Qt5::DBus) target_link_libraries(KF5Notifications PUBLIC Qt5::DBus) endif() target_link_libraries(KF5Notifications PRIVATE KF5::CoreAddons KF5::ConfigCore KF5::WindowSystem KF5::Codecs ) if (TARGET SnoreToast::SnoreToastActions) target_link_libraries(KF5Notifications PRIVATE Qt5::Network SnoreToast::SnoreToastActions) endif () if (Phonon4Qt5_FOUND) target_link_libraries(KF5Notifications PRIVATE ${PHONON_LIBRARIES}) endif() if (Canberra_FOUND) target_link_libraries(KF5Notifications PRIVATE Canberra::Canberra) endif() if (Qt5TextToSpeech_FOUND) target_link_libraries(KF5Notifications PRIVATE Qt5::TextToSpeech) endif() if(X11_FOUND) target_link_libraries(KF5Notifications PRIVATE ${X11_X11_LIB} Qt5::X11Extras) endif() if(APPLE) target_link_libraries(KF5Notifications PRIVATE Qt5::MacExtras) endif() if(X11_XTest_FOUND) target_link_libraries(KF5Notifications PRIVATE ${X11_XTest_LIB}) endif() if(HAVE_DBUSMENUQT) target_link_libraries(KF5Notifications PRIVATE dbusmenu-qt5) endif() if (ANDROID) target_link_libraries(KF5Notifications PRIVATE Qt5::AndroidExtras) endif() set_target_properties(KF5Notifications PROPERTIES VERSION ${KNOTIFICATIONS_VERSION_STRING} SOVERSION ${KNOTIFICATIONS_SOVERSION} EXPORT_NAME Notifications ) ecm_generate_headers(KNotifications_HEADERS HEADER_NAMES KNotification KPassivePopup KStatusNotifierItem KNotificationRestrictions KNotificationPlugin KNotifyConfig REQUIRED_HEADERS KNotifications_HEADERS ) install(TARGETS KF5Notifications EXPORT KF5NotificationsTargets ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/knotifications_export.h ${KNotifications_HEADERS} DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/KNotifications COMPONENT Devel ) if(BUILD_QCH) ecm_add_qch( KF5Notifications_QCH NAME KNotifications BASE_NAME KF5Notifications VERSION ${KF5_VERSION} ORG_DOMAIN org.kde SOURCES # using only public headers, to cover only public API ${KNotifications_HEADERS} MD_MAINPAGE "${CMAKE_SOURCE_DIR}/README.md" IMAGE_DIRS "${CMAKE_SOURCE_DIR}/docs/pics" LINK_QCHS Qt5Widgets_QCH BLANK_MACROS KNOTIFICATIONS_EXPORT KNOTIFICATIONS_DEPRECATED KNOTIFICATIONS_DEPRECATED_EXPORT TAGFILE_INSTALL_DESTINATION ${KDE_INSTALL_QTQCHDIR} QCH_INSTALL_DESTINATION ${KDE_INSTALL_QTQCHDIR} COMPONENT Devel ) endif() if (TARGET Qt5::DBus) install(FILES org.kde.StatusNotifierItem.xml DESTINATION ${KDE_INSTALL_DBUSINTERFACEDIR} RENAME kf5_org.kde.StatusNotifierItem.xml) install(FILES org.kde.StatusNotifierWatcher.xml DESTINATION ${KDE_INSTALL_DBUSINTERFACEDIR} RENAME kf5_org.kde.StatusNotifierWatcher.xml) endif() install(FILES knotificationplugin.desktop DESTINATION ${KDE_INSTALL_KSERVICETYPES5DIR}) include(ECMGeneratePriFile) ecm_generate_pri_file(BASE_NAME KNotifications LIB_NAME KF5Notifications DEPS "widgets" FILENAME_VAR PRI_FILENAME INCLUDE_INSTALL_DIR ${KDE_INSTALL_INCLUDEDIR_KF5}/KNotifications) install(FILES ${PRI_FILENAME} DESTINATION ${ECM_MKSPECS_INSTALL_DIR}) if (ANDROID) install(FILES KF5Notifications-android-dependencies.xml DESTINATION ${KDE_INSTALL_LIBDIR}) endif() diff --git a/src/knotification.cpp b/src/knotification.cpp index 862eac3..d931de5 100644 --- a/src/knotification.cpp +++ b/src/knotification.cpp @@ -1,581 +1,581 @@ /* This file is part of the KDE libraries Copyright (C) 2005-2006 Olivier Goffart Copyright (C) 2013-2014 Martin Klapetek code from KNotify/KNotifyClient Copyright (c) 1997 Christian Esken (esken@kde.org) 2000 Charles Samuels (charles@kde.org) 2000 Stefan Schimanski (1Stein@gmx.de) 2000 Matthias Ettrich (ettrich@kde.org) 2000 Waldo Bastian 2000-2003 Carsten Pfeiffer 2005 Allan Sandfeld Jensen 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 "knotification.h" #include "knotificationmanager_p.h" #include #include #include #include #include #include #include #include #include #include #include struct Q_DECL_HIDDEN KNotification::Private { QString eventId; int id; int ref; QWidget *widget; QString title; QString text; QString iconName; QString defaultAction; QStringList actions; QPixmap pixmap; ContextList contexts; NotificationFlags flags; QString componentName; QList urls; KNotification::Urgency urgency; QVariantMap hints; QTimer updateTimer; bool needUpdate; Private() : id(-1), ref(0), widget(nullptr), urgency(KNotification::DefaultUrgency), needUpdate(false) {} /** * recursive function that raise the widget. @p w * * @see raiseWidget() */ static void raiseWidget(QWidget *w); }; KNotification::KNotification(const QString &eventId, QWidget *parent, const NotificationFlags &flags) : QObject(parent), d(new Private) { d->eventId = eventId; d->flags = flags; setWidget(parent); connect(&d->updateTimer, &QTimer::timeout, this, &KNotification::update); d->updateTimer.setSingleShot(true); d->updateTimer.setInterval(100); } KNotification::KNotification( const QString &eventId, const NotificationFlags &flags, QObject *parent) : QObject(parent), d(new Private) { d->eventId = eventId; d->flags = flags; connect(&d->updateTimer, &QTimer::timeout, this, &KNotification::update); d->updateTimer.setSingleShot(true); d->updateTimer.setInterval(100); d->widget = nullptr; } KNotification::~KNotification() { if (d->id >= 0) { KNotificationManager::self()->close(d->id); } delete d; } QString KNotification::eventId() const { return d->eventId; } QString KNotification::title() const { return d->title; } QString KNotification::text() const { return d->text; } QWidget *KNotification::widget() const { return d->widget; } void KNotification::setWidget(QWidget *wid) { d->widget = wid; // setParent(wid); if (wid && d->flags & CloseWhenWidgetActivated) { wid->installEventFilter(this); } } void KNotification::setTitle(const QString &title) { if (title == d->title) { return; } d->needUpdate = true; d->title = title; if (d->id >= 0) { d->updateTimer.start(); } } void KNotification::setText(const QString &text) { if (text == d->text) { return; } d->needUpdate = true; d->text = text; if (d->id >= 0) { d->updateTimer.start(); } } void KNotification::setIconName(const QString &icon) { if (icon == d->iconName) { return; } d->needUpdate = true; d->iconName = icon; if (d->id >= 0) { d->updateTimer.start(); } } QString KNotification::iconName() const { return d->iconName; } QPixmap KNotification::pixmap() const { return d->pixmap; } void KNotification::setPixmap(const QPixmap &pix) { d->needUpdate = true; d->pixmap = pix; if (d->id >= 0) { d->updateTimer.start(); } } QStringList KNotification::actions() const { return d->actions; } void KNotification::setActions(const QStringList &as) { if (as == d->actions) { return; } d->needUpdate = true; d->actions = as; if (d->id >= 0) { d->updateTimer.start(); } } void KNotification::setDefaultAction(const QString &defaultAction) { if (defaultAction == d->defaultAction) { return; } d->needUpdate = true; d->defaultAction = defaultAction; if (d->id >= 0) { d->updateTimer.start(); } } QString KNotification::defaultAction() const { return d->defaultAction; } KNotification::ContextList KNotification::contexts() const { return d->contexts; } void KNotification::setContexts(const KNotification::ContextList &contexts) { d->contexts = contexts; } void KNotification::addContext(const KNotification::Context &context) { d->contexts << context; } void KNotification::addContext(const QString &context_key, const QString &context_value) { d->contexts << qMakePair(context_key, context_value); } KNotification::NotificationFlags KNotification::flags() const { return d->flags; } void KNotification::setFlags(const NotificationFlags &flags) { if (d->flags == flags) { return; } d->needUpdate = true; d->flags = flags; if (d->id >= 0) { d->updateTimer.start(); } } void KNotification::setComponentName(const QString &c) { d->componentName = c; } QList KNotification::urls() const { return d->urls; } void KNotification::setUrls(const QList &urls) { if (d->urls == urls) { return; } d->needUpdate = true; d->urls = urls; if (d->id >= 0) { d->updateTimer.start(); } } KNotification::Urgency KNotification::urgency() const { return d->urgency; } void KNotification::setUrgency(Urgency urgency) { if (d->urgency == urgency) { return; } d->needUpdate = true; d->urgency = urgency; if (d->id >= 0) { d->updateTimer.start(); } } void KNotification::activate(unsigned int action) { switch (action) { case 0: emit activated(); break; case 1: emit action1Activated(); break; case 2: emit action2Activated(); break; case 3: emit action3Activated(); break; } // emitting activated() makes the Manager close all the active plugins // which will deref() the KNotification object, which will result // in closing the notification emit activated(action); } void KNotification::close() { if (d->id >= 0) { KNotificationManager::self()->close(d->id); } if (d->id == -1) { d->id = -2; emit closed(); deleteLater(); } } void KNotification::raiseWidget() { if (!d->widget) { return; } Private::raiseWidget(d->widget); } void KNotification::Private::raiseWidget(QWidget *w) { //TODO this function is far from finished. if (w->isTopLevel()) { w->raise(); KWindowSystem::activateWindow(w->winId()); #if defined(Q_OS_MACOS) w->activateWindow(); #endif } else { QWidget *pw = w->parentWidget(); raiseWidget(pw); if (QTabWidget *tab_widget = qobject_cast(pw)) { tab_widget->setCurrentIndex(tab_widget->indexOf(w)); } } } static QString defaultComponentName() { #if defined(Q_OS_ANDROID) return QStringLiteral("android_defaults"); #elif defined(Q_OS_WIN) - return QStringLiteral("win32_defaults"); + return QStringLiteral("win32_defaults"); #else return QStringLiteral("plasma_workspace"); #endif } KNotification *KNotification::event(const QString &eventid, const QString &title, const QString &text, const QPixmap &pixmap, QWidget *widget, const NotificationFlags &flags, const QString &componentName) { KNotification *notify = new KNotification(eventid, widget, flags); notify->setTitle(title); notify->setText(text); notify->setPixmap(pixmap); notify->setComponentName((flags & DefaultEvent) ? defaultComponentName() : componentName); QTimer::singleShot(0, notify, &KNotification::sendEvent); return notify; } KNotification *KNotification::event(const QString &eventid, const QString &text, const QPixmap &pixmap, QWidget *widget, const NotificationFlags &flags, const QString &componentName) { return event(eventid, QString(), text, pixmap, widget, flags, componentName); } KNotification *KNotification::event(StandardEvent eventid, const QString &title, const QString &text, const QPixmap &pixmap, QWidget *widget, const NotificationFlags &flags) { return event(standardEventToEventId(eventid), title, text, pixmap, widget, flags | DefaultEvent); } KNotification *KNotification::event(StandardEvent eventid, const QString &text, const QPixmap &pixmap, QWidget *widget, const NotificationFlags &flags) { return event(eventid, QString(), text, pixmap, widget, flags); } KNotification *KNotification::event(const QString &eventid, const QString &title, const QString &text, const QString &iconName, QWidget *widget, const NotificationFlags &flags, const QString &componentName) { KNotification *notify = new KNotification(eventid, widget, flags); notify->setTitle(title); notify->setText(text); notify->setIconName(iconName); notify->setComponentName((flags & DefaultEvent) ? defaultComponentName() : componentName); QTimer::singleShot(0, notify, &KNotification::sendEvent); return notify; } KNotification *KNotification::event(StandardEvent eventid, const QString &title, const QString &text, const QString &iconName, QWidget *widget, const NotificationFlags &flags) { return event(standardEventToEventId(eventid), title, text, iconName, widget, flags | DefaultEvent); } KNotification* KNotification::event(StandardEvent eventid, const QString &title, const QString &text, QWidget *widget, const NotificationFlags &flags) { return event(standardEventToEventId(eventid), title, text, standardEventToIconName(eventid), widget, flags | DefaultEvent); } void KNotification::ref() { d->ref++; } void KNotification::deref() { Q_ASSERT(d->ref > 0); d->ref--; if (d->ref == 0) { d->id = -1; close(); } } void KNotification::beep(const QString &reason, QWidget *widget) { event(QStringLiteral("beep"), reason, QPixmap(), widget, CloseOnTimeout | DefaultEvent); } void KNotification::sendEvent() { d->needUpdate = false; if (d->id == -1) { d->id = KNotificationManager::self()->notify(this); } else if (d->id >= 0) { KNotificationManager::self()->reemit(this); } } int KNotification::id() { if (!d) { return -1; } return d->id; } QString KNotification::appName() const { QString appname; if (d->flags & DefaultEvent) { appname = defaultComponentName(); } else if (!d->componentName.isEmpty()) { appname = d->componentName; } else { appname = QCoreApplication::applicationName(); } return appname; } void KNotification::update() { if (d->needUpdate) { KNotificationManager::self()->update(this); } } bool KNotification::eventFilter(QObject *watched, QEvent *event) { if (watched == d->widget) { if (event->type() == QEvent::WindowActivate) { if (d->flags & CloseWhenWidgetActivated) { QTimer::singleShot(500, this, &KNotification::close); } } } return false; } QString KNotification::standardEventToEventId(KNotification::StandardEvent event) { QString eventId; switch (event) { case Warning: eventId = QStringLiteral("warning"); break; case Error: eventId = QStringLiteral("fatalerror"); break; case Catastrophe: eventId = QStringLiteral("catastrophe"); break; case Notification: // fall through default: eventId = QStringLiteral("notification"); break; } return eventId; } QString KNotification::standardEventToIconName(KNotification::StandardEvent event) { QString iconName; switch (event) { case Warning: iconName = QStringLiteral("dialog-warning"); break; case Error: iconName = QStringLiteral("dialog-error"); break; case Catastrophe: iconName = QStringLiteral("dialog-error"); break; case Notification: // fall through default: iconName = QStringLiteral("dialog-information"); break; } return iconName; } void KNotification::setHint(const QString &hint, const QVariant &value) { if (value == d->hints.value(hint)) { return; } d->needUpdate = true; d->hints[hint] = value; if (d->id >= 0) { d->updateTimer.start(); } } QVariantMap KNotification::hints() const { return d->hints; } diff --git a/src/knotifications.qrc b/src/knotifications.qrc index 928e805..a36b4f0 100644 --- a/src/knotifications.qrc +++ b/src/knotifications.qrc @@ -1,5 +1,6 @@ android_defaults.notifyrc + win32_defaults.notifyrc diff --git a/src/win32_defaults.notifyrc b/src/win32_defaults.notifyrc new file mode 100644 index 0000000..ccea332 --- /dev/null +++ b/src/win32_defaults.notifyrc @@ -0,0 +1,365 @@ +[Event/fatalerror] +Name=Fatal Error +Name[ar]=خطأ فادح +Name[bs]=Kobna greška +Name[ca]=Error fatal +Name[ca@valencia]=Error fatal +Name[cs]=Kritická chyba +Name[da]=Fatal fejl +Name[de]=Schwerer Fehler +Name[el]=Μοιραίο σφάλμα +Name[en_GB]=Fatal Error +Name[es]=Error fatal +Name[et]=Parandamatu tõrge +Name[eu]=Zoritxarreko errorea +Name[fi]=Vakava virhe +Name[fr]=Erreur fatale +Name[gd]=Mearachd mharbhtach +Name[gl]=Erro fatal +Name[he]=שגיאה חמורה +Name[hu]=Végzetes hiba +Name[ia]=Error Fatal +Name[id]=Error Fatal +Name[it]=Errore grave +Name[ko]=치명적 오류 +Name[lt]=Lemtingoji klaida +Name[nb]=Kritisk feil +Name[nds]=Swoor Fehler +Name[nl]=Fatale fout +Name[nn]=Kritisk feil +Name[pl]=Poważny błąd +Name[pt]=Erro Fatal +Name[pt_BR]=Erro fatal +Name[ru]=Критическая ошибка +Name[sk]=Fatálna chyba +Name[sl]=Usodna napaka +Name[sr]=Кобна грешка +Name[sr@ijekavian]=Кобна грешка +Name[sr@ijekavianlatin]=Kobna greška +Name[sr@latin]=Kobna greška +Name[sv]=Allvarligt fel +Name[tr]=Ölümcül Hata +Name[uk]=Критична помилка +Name[x-test]=xxFatal Errorxx +Name[zh_CN]=严重错误 +Name[zh_TW]=嚴重錯誤 +Comment=There was a serious error causing the program to exit +Comment[ar]=حدث خطأ جاد سبّب للبرنامج بإغلاقه +Comment[bs]=Došlo je do ozbiljne greške zbog koje je program obustavljen +Comment[ca]=S'ha produït un error seriós que ha provocat la sortida del programa +Comment[ca@valencia]=S'ha produït un error seriós que ha provocat l'eixida del programa +Comment[cs]=Nastala závažná chyba, v důsledku které byl program ukončen +Comment[da]=Der var en alvorlig fejl som forårsagede at programmet afsluttede +Comment[de]=Es ist ein schwerer Fehler aufgetreten, woraufhin das Programm beendet wurde. +Comment[el]=Υπήρξε ένα σοβαρό σφάλμα που προκάλεσε την έξοδο του προγράμματος +Comment[en_GB]=There was a serious error causing the program to exit +Comment[es]=Ha ocurrido un error serio que ha causado la salida del programa +Comment[et]=Tekkis tõsine viga, mis sundis programmi tööd lõpetama +Comment[eu]=Errore garrantzitsua bat egon da programa ixtea eragin duena +Comment[fi]=Vakava virhe aiheutti ohjelman päättymisen +Comment[fr]=Une erreur grave a entraîné la fin du programme +Comment[gd]=Chaidh am prògram fhàgail ri linn mearachd dona +Comment[gl]=Produciuse un erro grave que fixo que o programa saíse +Comment[he]=ארעה שגיאה חמורה הגורמה ליישום להיסגר +Comment[hu]=Olyan hiba történt a programban, melynek hatására a program futása befejeződött +Comment[ia]=Il esseva un serie error que il causava le programma a exir +Comment[id]=Ada error serius yang menyebabkan program keluar +Comment[it]=Si è verificato un errore grave, che ha causato la chiusura del programma +Comment[ko]=프로그램이 종료될 정도의 큰 오류가 발생함 +Comment[lt]=Įvyko rimta klaida, privertusi programą užbaigti darbą +Comment[nb]=Det oppsto en alvorlig feil som gjorde at programmet avsluttet +Comment[nds]=Dat geev en swoor Fehler, dat Programm is utstegen +Comment[nl]=Er deed zich een serieuze fout voor die het programma deed afsluiten +Comment[nn]=Det oppstod ein alvorleg feil som gjorde av programmet avslutta +Comment[pl]=Wystąpił poważny błąd i program zakończył działanie +Comment[pt]=Ocorreu um erro sério que fez com que o programa saísse +Comment[pt_BR]=Ocorreu um erro grave que causou o fechamento do programa +Comment[ru]=Произошла серьёзная ошибка, приведшая к завершению работы программы +Comment[sk]=Vyskytla sa vážna chyba, ktorá spôsobila ukončenie programu +Comment[sl]=Prišlo je do resne napake, zaradi katere se je program končal +Comment[sr]=Дошло је до озбиљне грешке због које је програм обустављен +Comment[sr@ijekavian]=Дошло је до озбиљне грешке због које је програм обустављен +Comment[sr@ijekavianlatin]=Došlo je do ozbiljne greške zbog koje je program obustavljen +Comment[sr@latin]=Došlo je do ozbiljne greške zbog koje je program obustavljen +Comment[sv]=Ett allvarligt fel uppstod vilket fick programmet att avslutas +Comment[tr]=Uygulamadan çıkılacak kadar önemli bir hata oluştu +Comment[uk]=Трапилась серйозна помилка, що призвела до закриття програми +Comment[x-test]=xxThere was a serious error causing the program to exitxx +Comment[zh_CN]=有一个严重错误导致程序退出 +Comment[zh_TW]=程式發生了嚴重錯誤,必須離開 +Action=Snore + +[Event/notification] +Name=Notification +Name[ar]=إخطار +Name[bs]=Obavještenje +Name[ca]=Notificació +Name[ca@valencia]=Notificació +Name[cs]=Upozornění +Name[da]=Bekendtgørelse +Name[de]=Benachrichtigung +Name[el]=Ειδοποίηση +Name[en_GB]=Notification +Name[es]=Notificación +Name[et]=Märguanne +Name[eu]=Jakinarazpena +Name[fi]=Ilmoitus +Name[fr]=Notification +Name[gd]=Brath +Name[gl]=Notificación +Name[he]=התראה +Name[hu]=Értesítés +Name[ia]=Notification +Name[id]=Notifikasi +Name[it]=Notifica +Name[ko]=알림 +Name[lt]=Pranešimas +Name[nb]=Varsling +Name[nds]=Bescheed +Name[nl]=Melding +Name[nn]=Varsling +Name[pa]=ਸੂਚਨਾ +Name[pl]=Powiadomienie +Name[pt]=Notificação +Name[pt_BR]=Notificação +Name[ru]=Уведомление +Name[sk]=Pripomienka +Name[sl]=Obvestila +Name[sr]=Обавештење +Name[sr@ijekavian]=Обавештење +Name[sr@ijekavianlatin]=Obaveštenje +Name[sr@latin]=Obaveštenje +Name[sv]=Underrättelse +Name[tr]=Bildirim +Name[uk]=Сповіщення +Name[x-test]=xxNotificationxx +Name[zh_CN]=通知 +Name[zh_TW]=通知 +Comment=Something special happened in the program +Comment[ar]=حدث شيء خاص في البرنامج +Comment[bs]=Nešto posebno se dogodilo u programu +Comment[ca]=Quelcom especial ha passat en el programa +Comment[ca@valencia]=Alguna cosa especial ha passat en el programa +Comment[cs]=Něco zvláštního se stalo s programem +Comment[da]=Noget specielt skete i programmet +Comment[de]=Im Programm ist ein besonderes Ereignis eingetreten +Comment[el]=Κάτι ιδιαίτερο συνέβη στο πρόγραμμα +Comment[en_GB]=Something special happened in the program +Comment[es]=Ha ocurrido algo especial en el programa +Comment[et]=Programmis juhtus midagi erilist +Comment[eu]=Zerbait berezia gertatu da programan +Comment[fi]=Ohjelmassa tapahtui jotakin erikoista +Comment[fr]=Quelque chose d'anormal s'est produit dans le programme +Comment[gd]=Thachair rudeigin sònraichte sa phrògram +Comment[gl]=Ocorreu algo especial no programa +Comment[he]=משהו מיוחד קרה ביישום +Comment[hu]=Valamilyen esemény következett be a programban +Comment[ia]=Il occurreva qualcosa de special in le programma +Comment[id]=Sesuatu yang istimewa terjadi dalam program +Comment[it]=Si è verificato qualcosa di speciale nel programma +Comment[ko]=프로그램에서 특별한 일이 발생함 +Comment[lt]=Programoje nutikos kažkas specialaus +Comment[nb]=Det hendte noe spesielt i programmet +Comment[nds]=Dat geev en afsünnerlich Begeefnis binnen dat Programm +Comment[nl]=Er gebeurde iets bijzonders in het programma +Comment[nn]=Det skjedde noko spesielt i programmet +Comment[pl]=Coś niezwykłego stało się z programem +Comment[pt]=Ocorreu algo de especial no programa +Comment[pt_BR]=Algo especial aconteceu no programa +Comment[ru]=С программой произошло что-то странное +Comment[sk]=V programe sa stalo niečo zvláštne +Comment[sl]=V programu se je zgodilo nekaj posebnega +Comment[sr]=Нешто посебно се догодило у програму +Comment[sr@ijekavian]=Нешто посебно се догодило у програму +Comment[sr@ijekavianlatin]=Nešto posebno se dogodilo u programu +Comment[sr@latin]=Nešto posebno se dogodilo u programu +Comment[sv]=Någonting speciellt inträffade i programmet +Comment[tr]=Uygulamada bazı özel durumlar oluştu +Comment[uk]=Щось особливе сталось у програмі +Comment[x-test]=xxSomething special happened in the programxx +Comment[zh_CN]=这个程序中发生了特殊的事情 +Comment[zh_TW]=程式中發生了特殊事件 +Action=Snore + +[Event/warning] +Name=Warning +Name[ar]=تحذير +Name[bs]=Upozorenje +Name[ca]=Avís +Name[ca@valencia]=Avís +Name[cs]=Varování +Name[da]=Advarsel +Name[de]=Warnung +Name[el]=Προειδοποίηση +Name[en_GB]=Warning +Name[es]=Advertencia +Name[et]=Hoiatus +Name[eu]=Abisua +Name[fi]=Varoitus +Name[fr]=Avertissement +Name[gd]=Rabhadh +Name[gl]=Aviso +Name[he]=אזהרה +Name[hu]=Figyelmeztetés +Name[ia]=Aviso +Name[id]=Peringatan +Name[it]=Avviso +Name[ko]=경고 +Name[lt]=Įspėjimas +Name[nb]=Advarsel +Name[nds]=Wohrschoen +Name[nl]=Waarschuwing +Name[nn]=Åtvaring +Name[pa]=ਚੇਤਾਵਨੀ +Name[pl]=Ostrzeżenie +Name[pt]=Aviso +Name[pt_BR]=Aviso +Name[ru]=Предупреждение +Name[sk]=Upozornenie +Name[sl]=Opozorilo +Name[sr]=Упозорење +Name[sr@ijekavian]=Упозорење +Name[sr@ijekavianlatin]=Upozorenje +Name[sr@latin]=Upozorenje +Name[sv]=Varning +Name[tr]=Uyarı +Name[uk]=Попередження +Name[x-test]=xxWarningxx +Name[zh_CN]=警告 +Name[zh_TW]=警告 +Comment=There was an error in the program which may cause problems +Comment[ar]=حدث خطأ في البرنامج مما تسبّب بمشاكل +Comment[bs]=Došlo je do greške u programu koja može izazvati probleme +Comment[ca]=S'ha produït un error en el programa que pot provocar problemes +Comment[ca@valencia]=S'ha produït un error en el programa que pot provocar problemes +Comment[cs]=V programu nastala chyba, která může způsobit problémy +Comment[da]=Der var en fejl i program som kan volde problemer +Comment[de]=Im Programm ist ein Fehler aufgetreten, der Probleme verursachen könnte +Comment[el]=Υπήρξε σφάλμα στο πρόγραμμα που μπορεί να προκαλέσει προβλήματα +Comment[en_GB]=There was an error in the program which may cause problems +Comment[es]=Ha ocurrido un error en el programa que puede causar problemas +Comment[et]=Programmis tekkis viga, mis võib tekitada probleeme +Comment[eu]=Errore bat egon da programan arazoak sor ditzakeena +Comment[fi]=Ohjelmassa oli virhe, joka voi aiheuttaa ongelmia +Comment[fr]=Il y a eu une erreur dans le programme qui peut causer des problèmes +Comment[gd]=Bha mearachd sa phrògram a dh'adhbharaicheas trioblaid ma dh'fhaoidte +Comment[gl]=Produciuse un erro no programa que pode causar problemas +Comment[he]=אירעה שגיאה ביישום, דבר העלול לגרום לבעיות +Comment[hu]=Hiba történt a programban, de a program futása folytatódhat +Comment[ia]=Il habeva un error in le programma que il pote causar problemas +Comment[id]=Ada sebuah error dalam program yang menyebabkan masalah +Comment[it]=Si è verificato un errore nel programma che potrebbe causare problemi +Comment[ko]=프로그램에 문제를 가져올 수 있는 오류가 발생함 +Comment[lt]=Programoje įvyko klaida, galinti sukelti problemų +Comment[nb]=I programmet oppsto det en feil som kan gi vanskeligheter +Comment[nds]=Dat geev en Fehler binnen dat Programm, villicht suert dor Problemen bi rut +Comment[nl]=Er deed zich een fout voor in het programma dat problemen kan veroorzaken +Comment[nn]=Det oppstod ein feil i programmet som kan gje problem +Comment[pl]=W programie wystąpił błąd, może powodować problemy +Comment[pt]=Ocorreu um erro no programa que poderá provocar problemas +Comment[pt_BR]=Ocorreu um erro no programa, que pode causar problemas +Comment[ru]=В программе произошла ошибка, которая может вызвать проблемы +Comment[sk]=V programe sa vyskytla chyba, ktorá môže spôsobiť problémy +Comment[sl]=V programu je prišlo do napake, ki lahko povzroči težave +Comment[sr]=Дошло је до грешке у програму која може изазвати проблеме +Comment[sr@ijekavian]=Дошло је до грешке у програму која може изазвати проблеме +Comment[sr@ijekavianlatin]=Došlo je do greške u programu koja može izazvati probleme +Comment[sr@latin]=Došlo je do greške u programu koja može izazvati probleme +Comment[sv]=Det uppstod ett fel i programmet vilket kan orsaka problem +Comment[tr]=Uygulamada sorunlara neden olabilecek bir hata oluştu +Comment[uk]=В програмі трапилась помилка, яка може спричинити проблеми +Comment[x-test]=xxThere was an error in the program which may cause problemsxx +Comment[zh_CN]=程序中有一个错误,它可能导致一些问题 +Comment[zh_TW]=程式中發生錯誤,可能造成問題 +Action=Snore + +[Event/catastrophe] +Name=Catastrophe +Name[ar]=كارثة +Name[bs]=Katastrofa +Name[ca]=Catàstrofe +Name[ca@valencia]=Catàstrofe +Name[cs]=Katastrofa +Name[da]=Katastrofe +Name[de]=Katastrophe +Name[el]=Καταστροφή +Name[en_GB]=Catastrophe +Name[es]=Catástrofe +Name[et]=Katastroof +Name[eu]=Hondamendia +Name[fi]=Katastrofi +Name[fr]=Catastrophe +Name[gd]=Tubaist +Name[gl]=Catástrofe +Name[he]=קטטסטרופה +Name[hu]=Súlyos hiba +Name[ia]=Catastrophe +Name[id]=Malapetaka +Name[it]=Catastrofe +Name[ko]=중대한 오류 +Name[lt]=Katastrofa +Name[nb]=Katastrofe +Name[nds]=Groot Malöör +Name[nl]=Catastrofe +Name[nn]=Katastrofe +Name[pl]=Katastrofa +Name[pt]=Catástrofe +Name[pt_BR]=Catástrofe +Name[ru]=Катастрофа +Name[sk]=Katastrofa +Name[sl]=Katastrofa +Name[sr]=Катастрофа +Name[sr@ijekavian]=Катастрофа +Name[sr@ijekavianlatin]=Katastrofa +Name[sr@latin]=Katastrofa +Name[sv]=Katastrof +Name[tr]=Felaket +Name[uk]=Катастрофа +Name[x-test]=xxCatastrophexx +Name[zh_CN]=严重故障 +Name[zh_TW]=發生大災難 +Comment=A very serious error occurred, at least causing the program to exit +Comment[ar]=حدث خطأ جاد جدًا، تسبّب للبرنامج بإنهائه على أقل تقدير +Comment[bs]=Došlo je do vrlo ozbiljne greške, zbog koje je bar program obustavljen +Comment[ca]=S'ha produït un error molt seriós, com a mínim ha provocat la sortida del programa +Comment[ca@valencia]=S'ha produït un error molt seriós, com a mínim ha provocat l'eixida del programa +Comment[cs]=Nastala velmi závažná chyba, která má za následek minimálně ukončení programu +Comment[da]=En meget alvorlig fejl opstod, som mindst forårsagede at programmet afsluttede +Comment[de]=Ein sehr schwerer Fehler ist aufgetreten, der wenigstens das Programm zum Beenden bringt +Comment[el]=Συνέβη ένα πολύ σοβαρό σφάλμα, που προκάλεσε την έξοδο του προγράμματος +Comment[en_GB]=A very serious error occurred, at least causing the program to exit +Comment[es]=Ha ocurrido un error muy serio que ha causado, al menos, la salida del programa +Comment[et]=Tekkis väga tõsine viga, mis sundis programmi tööd lõpetama +Comment[eu]=Errore oso garrantzitsu bat egon da, gutxienez programa ixtea eragin duena +Comment[fi]=Tapahtui erittäin vakava virhe, joka aiheutti ainakin ohjelman päättymisen +Comment[fr]=Une erreur très grave s'est produite, provoquant au minimum la fin du programme +Comment[gd]=Thachair mearachd glè dhona agus chaidh am prògram fhàgail air a char as lugha +Comment[gl]=Produciuse un erro moi grave, que como mínimo fixo que o programa saíse +Comment[he]=אירעה שגיאה חמורה מאוד, הגרמה ליישום כנראה להיסגר +Comment[hu]=Hiba történt a programban, a program futása befejeződött +Comment[ia]=Il occurreva un error le plus serie, al minus causante le exito del programma +Comment[id]=Sebuah error yang sangat serius terjadi, setidaknya menyebabkan program keluar +Comment[it]=Si è verificato un errore molto grave, che ha causato almeno la chiusura del programma +Comment[ko]=프로그램이 종료될 정도의 매우 큰 오류가 발생함 +Comment[lt]=Įvyko labai rimta klaida, privertusi programą bent jau užbaigti darbą +Comment[nb]=Det oppsto en meget alvorlig feil som minst førte til at programmet stoppet +Comment[nds]=Dat geev en groot Malöör, tominnst dat Programm is utstegen +Comment[nl]=Er deed zich een serieuze fout voor dat er op zijn minst voor zorgde dat het programma werd afgesloten +Comment[nn]=Det oppstod ein svært alvorleg feil som førte til at programmet avslutta +Comment[pl]=Wystąpił bardzo poważny błąd, co najmniej nastąpiło zakończenie pracy programu +Comment[pt]=Ocorreu um erro muito sério, que fez pelo menos com que o programa saísse +Comment[pt_BR]=Um erro muito sério aconteceu, que causou (no mínimo) o fechamento do programa +Comment[ru]=Произошла очень серьёзная ошибка, как минимум, вызвавшая завершение работы программы +Comment[sk]=Nastala veľmi vážna chyba, ktorá zapríčinila minimálne ukončenie programu +Comment[sl]=Prišlo je do zelo resne napake, zaradi katere se je program končal +Comment[sr]=Дошло је до врло озбиљне грешке, због које је бар програм обустављен +Comment[sr@ijekavian]=Дошло је до врло озбиљне грешке, због које је бар програм обустављен +Comment[sr@ijekavianlatin]=Došlo je do vrlo ozbiljne greške, zbog koje je bar program obustavljen +Comment[sr@latin]=Došlo je do vrlo ozbiljne greške, zbog koje je bar program obustavljen +Comment[sv]=Ett mycket allvarligt fel uppstod, som åtminstone fick programmet att avslutas +Comment[tr]=En azından uygulamadan çıkılacak kadar önemli bir hata oluştu +Comment[uk]=Трапилась дуже серйозна помилка, яка призвела до закриття програми +Comment[x-test]=xxA very serious error occurred, at least causing the program to exitxx +Comment[zh_CN]=发生了一个非常严重的错误,至少已经导致了这个程序退出 +Comment[zh_TW]=發生了非常嚴重的問題,至少造成程式被迫結束 +Action=Snore