From e145b8a2cad6c94c3a5e376afb340f05faed12f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrew=20Lee=20=28=E6=9D=8E=E5=81=A5=E7=A7=8B=29?= Date: Wed, 12 Aug 2015 04:40:04 +0800 Subject: [PATCH] Adding upstream version 0.9.0. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Andrew Lee (李健秋) --- .gitignore | 1 + AUTHORS | 10 + CMakeLists.txt | 35 ++ COPYING | 461 +++++++++++++++ config/CMakeLists.txt | 51 ++ config/advancedsettings.cpp | 66 +++ config/advancedsettings.h | 54 ++ config/advancedsettings.ui | 119 ++++ config/basicsettings.cpp | 102 ++++ config/basicsettings.h | 53 ++ config/basicsettings.ui | 88 +++ config/lxqt-config-notificationd.desktop.in | 11 + config/main.cpp | 46 ++ config/mainwindow.cpp | 54 ++ config/mainwindow.h | 44 ++ .../translations/lxqt-config-notificationd.ts | 107 ++++ .../lxqt-config-notificationd_ar.desktop | 4 + .../lxqt-config-notificationd_cs.desktop | 4 + .../lxqt-config-notificationd_cs_CZ.desktop | 4 + .../lxqt-config-notificationd_da.desktop | 4 + .../lxqt-config-notificationd_da_DK.desktop | 4 + .../lxqt-config-notificationd_de.desktop | 3 + .../lxqt-config-notificationd_de_DE.desktop | 4 + .../lxqt-config-notificationd_el_GR.desktop | 4 + .../lxqt-config-notificationd_eo.desktop | 4 + .../lxqt-config-notificationd_es.desktop | 4 + .../lxqt-config-notificationd_es_VE.desktop | 4 + .../lxqt-config-notificationd_eu.desktop | 4 + .../lxqt-config-notificationd_fi.desktop | 4 + .../lxqt-config-notificationd_fr_FR.desktop | 3 + .../lxqt-config-notificationd_hu.desktop | 4 + .../lxqt-config-notificationd_id_ID.desktop | 3 + .../lxqt-config-notificationd_it.desktop | 3 + .../lxqt-config-notificationd_it_IT.desktop | 4 + .../lxqt-config-notificationd_ja.desktop | 4 + .../lxqt-config-notificationd_lt.desktop | 4 + .../lxqt-config-notificationd_nl.desktop | 4 + .../lxqt-config-notificationd_pl.desktop | 3 + .../lxqt-config-notificationd_pl_PL.desktop | 4 + .../lxqt-config-notificationd_pt.desktop | 4 + .../lxqt-config-notificationd_pt.ts | 109 ++++ .../lxqt-config-notificationd_pt_BR.desktop | 4 + .../lxqt-config-notificationd_ro_RO.desktop | 4 + .../lxqt-config-notificationd_ru.desktop | 4 + .../lxqt-config-notificationd_ru.ts | 125 ++++ .../lxqt-config-notificationd_ru_RU.desktop | 4 + .../lxqt-config-notificationd_ru_RU.ts | 125 ++++ .../lxqt-config-notificationd_sl.desktop | 4 + ...lxqt-config-notificationd_sr@latin.desktop | 3 + .../lxqt-config-notificationd_th_TH.desktop | 4 + .../lxqt-config-notificationd_tr.desktop | 4 + .../lxqt-config-notificationd_uk.desktop | 4 + .../lxqt-config-notificationd_zh_CN.desktop | 4 + .../lxqt-config-notificationd_zh_TW.desktop | 4 + docs/notification-spec-latest.html | 538 ++++++++++++++++++ src/CMakeLists.txt | 51 ++ src/main.cpp | 89 +++ src/notification.cpp | 322 +++++++++++ src/notification.h | 134 +++++ src/notification.ui | 163 ++++++ src/notificationarea.cpp | 128 +++++ src/notificationarea.h | 70 +++ src/notificationlayout.cpp | 200 +++++++ src/notificationlayout.h | 104 ++++ src/notificationwidgets.cpp | 134 +++++ src/notificationwidgets.h | 102 ++++ src/notifyd.cpp | 148 +++++ src/notifyd.h | 138 +++++ src/org.freedesktop.Notifications.xml | 69 +++ src/translations/lxqt-notificationd.ts | 15 + src/translations/lxqt-notificationd_pt.ts | 15 + src/translations/lxqt-notificationd_ru.ts | 17 + src/translations/lxqt-notificationd_ru_RU.ts | 17 + test/NotifyTest.pro | 20 + test/lxqt-notification-test-multiples.sh | 12 + test/lxqt-notification-test.sh | 15 + test/main.cpp | 35 ++ test/mainwindow.cpp | 73 +++ test/mainwindow.h | 53 ++ test/mainwindow.ui | 76 +++ 80 files changed, 4533 insertions(+) create mode 100644 .gitignore create mode 100644 AUTHORS create mode 100644 CMakeLists.txt create mode 100644 COPYING create mode 100644 config/CMakeLists.txt create mode 100644 config/advancedsettings.cpp create mode 100644 config/advancedsettings.h create mode 100644 config/advancedsettings.ui create mode 100644 config/basicsettings.cpp create mode 100644 config/basicsettings.h create mode 100644 config/basicsettings.ui create mode 100644 config/lxqt-config-notificationd.desktop.in create mode 100644 config/main.cpp create mode 100644 config/mainwindow.cpp create mode 100644 config/mainwindow.h create mode 100644 config/translations/lxqt-config-notificationd.ts create mode 100644 config/translations/lxqt-config-notificationd_ar.desktop create mode 100644 config/translations/lxqt-config-notificationd_cs.desktop create mode 100644 config/translations/lxqt-config-notificationd_cs_CZ.desktop create mode 100644 config/translations/lxqt-config-notificationd_da.desktop create mode 100644 config/translations/lxqt-config-notificationd_da_DK.desktop create mode 100644 config/translations/lxqt-config-notificationd_de.desktop create mode 100644 config/translations/lxqt-config-notificationd_de_DE.desktop create mode 100644 config/translations/lxqt-config-notificationd_el_GR.desktop create mode 100644 config/translations/lxqt-config-notificationd_eo.desktop create mode 100644 config/translations/lxqt-config-notificationd_es.desktop create mode 100644 config/translations/lxqt-config-notificationd_es_VE.desktop create mode 100644 config/translations/lxqt-config-notificationd_eu.desktop create mode 100644 config/translations/lxqt-config-notificationd_fi.desktop create mode 100644 config/translations/lxqt-config-notificationd_fr_FR.desktop create mode 100644 config/translations/lxqt-config-notificationd_hu.desktop create mode 100644 config/translations/lxqt-config-notificationd_id_ID.desktop create mode 100644 config/translations/lxqt-config-notificationd_it.desktop create mode 100644 config/translations/lxqt-config-notificationd_it_IT.desktop create mode 100644 config/translations/lxqt-config-notificationd_ja.desktop create mode 100644 config/translations/lxqt-config-notificationd_lt.desktop create mode 100644 config/translations/lxqt-config-notificationd_nl.desktop create mode 100644 config/translations/lxqt-config-notificationd_pl.desktop create mode 100644 config/translations/lxqt-config-notificationd_pl_PL.desktop create mode 100644 config/translations/lxqt-config-notificationd_pt.desktop create mode 100644 config/translations/lxqt-config-notificationd_pt.ts create mode 100644 config/translations/lxqt-config-notificationd_pt_BR.desktop create mode 100644 config/translations/lxqt-config-notificationd_ro_RO.desktop create mode 100644 config/translations/lxqt-config-notificationd_ru.desktop create mode 100644 config/translations/lxqt-config-notificationd_ru.ts create mode 100644 config/translations/lxqt-config-notificationd_ru_RU.desktop create mode 100644 config/translations/lxqt-config-notificationd_ru_RU.ts create mode 100644 config/translations/lxqt-config-notificationd_sl.desktop create mode 100644 config/translations/lxqt-config-notificationd_sr@latin.desktop create mode 100644 config/translations/lxqt-config-notificationd_th_TH.desktop create mode 100644 config/translations/lxqt-config-notificationd_tr.desktop create mode 100644 config/translations/lxqt-config-notificationd_uk.desktop create mode 100644 config/translations/lxqt-config-notificationd_zh_CN.desktop create mode 100644 config/translations/lxqt-config-notificationd_zh_TW.desktop create mode 100644 docs/notification-spec-latest.html create mode 100644 src/CMakeLists.txt create mode 100644 src/main.cpp create mode 100644 src/notification.cpp create mode 100644 src/notification.h create mode 100644 src/notification.ui create mode 100644 src/notificationarea.cpp create mode 100644 src/notificationarea.h create mode 100644 src/notificationlayout.cpp create mode 100644 src/notificationlayout.h create mode 100644 src/notificationwidgets.cpp create mode 100644 src/notificationwidgets.h create mode 100644 src/notifyd.cpp create mode 100644 src/notifyd.h create mode 100644 src/org.freedesktop.Notifications.xml create mode 100644 src/translations/lxqt-notificationd.ts create mode 100644 src/translations/lxqt-notificationd_pt.ts create mode 100644 src/translations/lxqt-notificationd_ru.ts create mode 100644 src/translations/lxqt-notificationd_ru_RU.ts create mode 100644 test/NotifyTest.pro create mode 100755 test/lxqt-notification-test-multiples.sh create mode 100755 test/lxqt-notification-test.sh create mode 100644 test/main.cpp create mode 100644 test/mainwindow.cpp create mode 100644 test/mainwindow.h create mode 100644 test/mainwindow.ui diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..378eac2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..190d298 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,10 @@ +Upstream Authors: + LXQt team: http://lxqt.org + Razor team: http://razor-qt.org + +Copyright: + Copyright (c) 2010-2012 Razor team + Copyright (c) 2012-2014 LXQt team + +License: GPL-2 and LGPL-2.1+ +The full text of the licenses can be found in the 'COPYING' file. diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..27a896e --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,35 @@ +cmake_minimum_required(VERSION 2.8.11) + +project(lxqt-notificationd) + +option(UPDATE_TRANSLATIONS "Update source translation translations/*.ts files" OFF) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) +set(CMAKE_AUTOMOC ON) + +find_package(Qt5Widgets REQUIRED QUIET) +find_package(Qt5DBus REQUIRED QUIET) +find_package(Qt5LinguistTools REQUIRED QUIET) +find_package(KF5WindowSystem REQUIRED QUIET) + +find_package(lxqt REQUIRED QUIET) +find_package(qt5xdg REQUIRED) + +include(${LXQT_USE_FILE}) +include(${QTXDG_USE_FILE}) + +include(LXQtTranslate) + +add_subdirectory(src) +add_subdirectory(config) + +# building tarball with CPack ------------------------------------------------- +include(InstallRequiredSystemLibraries) +set(CPACK_PACKAGE_VERSION_MAJOR ${LXQT_MAJOR_VERSION}) +set(CPACK_PACKAGE_VERSION_MINOR ${LXQT_MINOR_VERSION}) +set(CPACK_PACKAGE_VERSION_PATCH ${LXQT_PATCH_VERSION}) +set(CPACK_GENERATOR TBZ2) +set(CPACK_SOURCE_GENERATOR TBZ2) +set(CPACK_SOURCE_IGNORE_FILES /build/;.gitignore;.*~;.git;.kdev4;temp) +include(CPack) diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..a8dd823 --- /dev/null +++ b/COPYING @@ -0,0 +1,461 @@ + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations +below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it +becomes a de-facto standard. To achieve this, non-free programs must +be allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control +compilation and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at least + three years, to give the same user the materials specified in + Subsection 6a, above, for a charge no more than the cost of + performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply, and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License +may add an explicit geographical distribution limitation excluding those +countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS diff --git a/config/CMakeLists.txt b/config/CMakeLists.txt new file mode 100644 index 0000000..c727e7c --- /dev/null +++ b/config/CMakeLists.txt @@ -0,0 +1,51 @@ +project(lxqt-config-notificationd) + +include_directories ( + "${CMAKE_CURRENT_BINARY_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}" +) + +set(NOTIFICATIONS_CONF_SRC + advancedsettings.cpp + basicsettings.cpp + mainwindow.cpp + main.cpp +) + +set(NOTIFICATIONS_CONF_UI + advancedsettings.ui + basicsettings.ui +) + + +# Translations ********************************** +lxqt_translate_ts(NOTIFICATIONS_CONF_QM SOURCES + UPDATE_TRANSLATIONS ${UPDATE_TRANSLATIONS} + ${NOTIFICATIONS_CONF_MOC} + ${NOTIFICATIONS_CONF_SRC} + ${NOTIFICATIONS_CONF_UI} + INSTALL_DIR "${LXQT_TRANSLATIONS_DIR}/${PROJECT_NAME}" +) + +lxqt_app_translation_loader(QM_LOADER ${PROJECT_NAME}) +lxqt_translate_desktop(DESKTOP_FILES SOURCES lxqt-config-notificationd.desktop.in) +#************************************************ + +qt5_wrap_ui(NOTIFICATIONS_CONF_UI_CPP ${NOTIFICATIONS_CONF_UI}) + +add_executable(${PROJECT_NAME} + ${NOTIFICATIONS_CONF_SRC} + ${NOTIFICATIONS_CONF_UI_CPP} + ${NOTIFICATIONS_CONF_QM} + ${DESKTOP_FILES} + ${QM_LOADER} +) + +target_link_libraries(${PROJECT_NAME} + KF5::WindowSystem + Qt5::Widgets + ${LXQT_LIBRARIES} +) + +install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) +install(FILES ${DESKTOP_FILES} DESTINATION "${CMAKE_INSTALL_PREFIX}/share/applications") diff --git a/config/advancedsettings.cpp b/config/advancedsettings.cpp new file mode 100644 index 0000000..beb0a74 --- /dev/null +++ b/config/advancedsettings.cpp @@ -0,0 +1,66 @@ +/* BEGIN_COMMON_COPYRIGHT_HEADER + * (c)LGPL2+ + * + * LXDE-Qt - a lightweight, Qt based, desktop toolset + * http://razor-qt.org + * + * Copyright: 2010-2011 Razor team + * Authors: + * Petr Vanek + * + * This program or library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 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 + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * END_COMMON_COPYRIGHT_HEADER */ + +#include + +#include "advancedsettings.h" +#include "mainwindow.h" + + +AdvancedSettings::AdvancedSettings(LxQt::Settings* settings, QWidget *parent): + QWidget(parent), + mSettings(settings) +{ + setupUi(this); + restoreSettings(); + + connect(serverDecidesBox, SIGNAL(valueChanged(int)), this, SLOT(save())); + connect(spacingBox, SIGNAL(valueChanged(int)), this, SLOT(save())); + connect(widthBox, SIGNAL(valueChanged(int)), this, SLOT(save())); +} + +AdvancedSettings::~AdvancedSettings() +{ +} + +void AdvancedSettings::restoreSettings() +{ + int serverDecides = mSettings->value("server_decides", 10).toInt(); + if (serverDecides <= 0) + serverDecides = 10; + serverDecidesBox->setValue(serverDecides); + + spacingBox->setValue(mSettings->value("spacing", 6).toInt()); + widthBox->setValue(mSettings->value("width", 300).toInt()); +} + +void AdvancedSettings::save() +{ + mSettings->setValue("server_decides", serverDecidesBox->value()); + mSettings->setValue("spacing", spacingBox->value()); + mSettings->setValue("width", widthBox->value()); +} diff --git a/config/advancedsettings.h b/config/advancedsettings.h new file mode 100644 index 0000000..5798b84 --- /dev/null +++ b/config/advancedsettings.h @@ -0,0 +1,54 @@ +/* BEGIN_COMMON_COPYRIGHT_HEADER + * (c)LGPL2+ + * + * LXDE-Qt - a lightweight, Qt based, desktop toolset + * http://razor-qt.org + * + * Copyright: 2010-2011 Razor team + * Authors: + * Petr Vanek + * + * This program or library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 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 + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * END_COMMON_COPYRIGHT_HEADER */ + +#ifndef ADVANCEDSETTINGS_H +#define ADVANCEDSETTINGS_H + +#include +#include +#include "ui_advancedsettings.h" + +class AdvancedSettings : public QWidget, public Ui::AdvancedSettings +{ + Q_OBJECT + +public: + explicit AdvancedSettings(LxQt::Settings* settings, QWidget* parent = 0); + ~AdvancedSettings(); + +public slots: + void restoreSettings(); + +private: + LxQt::Settings* mSettings; + +private slots: + void save(); + +}; + +#endif // MENUCONFIG_H diff --git a/config/advancedsettings.ui b/config/advancedsettings.ui new file mode 100644 index 0000000..a2de59f --- /dev/null +++ b/config/advancedsettings.ui @@ -0,0 +1,119 @@ + + + AdvancedSettings + + + + 0 + 0 + 340 + 284 + + + + + + + Sizes + + + + + + + + Width: + + + + + + + px + + + 10 + + + 2000 + + + + + + + + + + + Spacing: + + + + + + + px + + + + + + + + + + + + Duration + + + + + + Some notifications set their own on-screen duration. + + + true + + + + + + + + + Default duration: + + + + + + + sec + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + diff --git a/config/basicsettings.cpp b/config/basicsettings.cpp new file mode 100644 index 0000000..7604d8c --- /dev/null +++ b/config/basicsettings.cpp @@ -0,0 +1,102 @@ +/* BEGIN_COMMON_COPYRIGHT_HEADER + * (c)LGPL2+ + * + * LXDE-Qt - a lightweight, Qt based, desktop toolset + * http://razor-qt.org + * + * Copyright: 2010-2011 Razor team + * Authors: + * Petr Vanek + * + * This program or library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 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 + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * END_COMMON_COPYRIGHT_HEADER */ + +#include + +#include "basicsettings.h" +#include "mainwindow.h" + + +BasicSettings::BasicSettings(LxQt::Settings* settings, QWidget *parent) : + QWidget(parent), + mSettings(settings) +{ + setupUi(this); + + restoreSettings(); + + connect(topLeftButton, SIGNAL(clicked()), this, SLOT(updateNotification())); + connect(topRightButton, SIGNAL(clicked()), this, SLOT(updateNotification())); + connect(bottomRightButton, SIGNAL(clicked()), this, SLOT(updateNotification())); + connect(bottomLeftButton, SIGNAL(clicked()), this, SLOT(updateNotification())); + + LxQt::Notification serverTest; + QString serverName = serverTest.serverInfo().name; + if (serverName != "lxqt-notificationd") + { + if (serverName.isEmpty()) + { + warningLabel->setText(tr( + "Warning: No notifications daemon is running.\n" + "A fallback will be used.")); + } + else + { + warningLabel->setText(tr( + "Warning: A third-party notifications daemon (%1) is running.\n" + "These settings won't have any effect on it!" + ).arg(serverName)); + } + } +} + +BasicSettings::~BasicSettings() +{ +} + +void BasicSettings::restoreSettings() +{ + QString placement = mSettings->value("placement", "bottom-right").toString().toLower(); + if (placement == "bottom-right") + bottomRightButton->setChecked(true); + else if (placement == "bottom-left") + bottomLeftButton->setChecked(true); + else if (placement == "top-right") + topRightButton->setChecked(true); + else if (placement == "top-left") + topLeftButton->setChecked(true); + else + bottomRightButton->setChecked(true); +} + +void BasicSettings::updateNotification() +{ + if (bottomRightButton->isChecked()) + mSettings->setValue("placement", "bottom-right"); + else if (bottomLeftButton->isChecked()) + mSettings->setValue("placement", "bottom-left"); + else if (topRightButton->isChecked()) + mSettings->setValue("placement", "top-right"); + else if (topLeftButton->isChecked()) + mSettings->setValue("placement", "top-left"); + + LxQt::Notification::notify(//"lxqt-config-notificationd", + tr("Notification demo"), + tr("This is a test notification.\n" + "All notifications will now appear here on LXQt."), + "lxqt-logo.png"); +} diff --git a/config/basicsettings.h b/config/basicsettings.h new file mode 100644 index 0000000..8344e87 --- /dev/null +++ b/config/basicsettings.h @@ -0,0 +1,53 @@ +/* BEGIN_COMMON_COPYRIGHT_HEADER + * (c)LGPL2+ + * + * LXDE-Qt - a lightweight, Qt based, desktop toolset + * http://razor-qt.org + * + * Copyright: 2010-2011 Razor team + * Authors: + * Petr Vanek + * + * This program or library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 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 + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * END_COMMON_COPYRIGHT_HEADER */ + +#ifndef BASICSETTINGS_H +#define BASICSETTINGS_H + +#include +#include +#include "ui_basicsettings.h" + + +class BasicSettings : public QWidget, public Ui::BasicSettings +{ + Q_OBJECT +public: + explicit BasicSettings(LxQt::Settings* settings, QWidget* parent = 0); + ~BasicSettings(); + +public slots: + void restoreSettings(); + +private slots: + void updateNotification(); + +private: + LxQt::Settings* mSettings; +}; + +#endif // BASICSETTINGS_H diff --git a/config/basicsettings.ui b/config/basicsettings.ui new file mode 100644 index 0000000..f1ed060 --- /dev/null +++ b/config/basicsettings.ui @@ -0,0 +1,88 @@ + + + BasicSettings + + + + 0 + 0 + 244 + 218 + + + + + + + + 75 + true + + + + Basic Settings + + + + + + + Position on screen + + + + + + Top/Left + + + + + + + Top/Right + + + + + + + Bottom/Left + + + + + + + Bottom/Right + + + + + + + + + + Qt::Vertical + + + + 105 + 51 + + + + + + + + true + + + + + + + + diff --git a/config/lxqt-config-notificationd.desktop.in b/config/lxqt-config-notificationd.desktop.in new file mode 100644 index 0000000..9515e9d --- /dev/null +++ b/config/lxqt-config-notificationd.desktop.in @@ -0,0 +1,11 @@ +[Desktop Entry] +Type=Application +Name=Desktop Notifications +GenericName=LXQt Notification Settings +Comment=Configure desktop notifications +Exec=lxqt-config-notificationd +Icon=preferences-desktop-theme +Categories=Settings;DesktopSettings;Qt;LXQt; +OnlyShowIn=LXQt;LXDE; + +#TRANSLATIONS_DIR=translations diff --git a/config/main.cpp b/config/main.cpp new file mode 100644 index 0000000..ce26b78 --- /dev/null +++ b/config/main.cpp @@ -0,0 +1,46 @@ +/* BEGIN_COMMON_COPYRIGHT_HEADER + * (c)LGPL2+ + * + * LXDE-Qt - a lightweight, Qt based, desktop toolset + * http://razor-qt.org + * + * Copyright: 2010-2011 Razor team + * Authors: + * Petr Vanek + * + * This program or library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 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 + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * END_COMMON_COPYRIGHT_HEADER */ + +#include + +#include +#include + +#include "mainwindow.h" + + +int main(int argc, char** argv) +{ + LxQt::SingleApplication a(argc, argv); + + MainWindow w; + w.setWindowIcon(QIcon::fromTheme("preferences-desktop-theme")); + a.setActivationWindow(&w); + w.show(); + + return a.exec(); +} diff --git a/config/mainwindow.cpp b/config/mainwindow.cpp new file mode 100644 index 0000000..53cc49a --- /dev/null +++ b/config/mainwindow.cpp @@ -0,0 +1,54 @@ +/* BEGIN_COMMON_COPYRIGHT_HEADER + * (c)LGPL2+ + * + * LXDE-Qt - a lightweight, Qt based, desktop toolset + * http://razor-qt.org + * + * Copyright: 2010-2011 Razor team + * Authors: + * Petr Vanek + * + * This program or library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 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 + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * END_COMMON_COPYRIGHT_HEADER */ + +#include +#include +#include +#include +#include + +#include "mainwindow.h" +#include "basicsettings.h" +#include "advancedsettings.h" + + +MainWindow::MainWindow(QWidget *parent) : + LxQt::ConfigDialog(tr("Desktop Notifications"), new LxQt::Settings("notifications"), parent) +{ + BasicSettings* basic = new BasicSettings(mSettings, this); + addPage(basic, tr("Basic Settings"), "preferences-desktop-notification"); + connect(this, SIGNAL(reset()), basic, SLOT(restoreSettings())); + + AdvancedSettings* menu = new AdvancedSettings(mSettings, this); + addPage(menu, tr("Advanced Settings"), "preferences-desktop-notification-bell"); + connect(this, SIGNAL(reset()), menu, SLOT(restoreSettings())); +} + +MainWindow::~MainWindow() +{ + delete mSettings; +} diff --git a/config/mainwindow.h b/config/mainwindow.h new file mode 100644 index 0000000..e38c643 --- /dev/null +++ b/config/mainwindow.h @@ -0,0 +1,44 @@ +/* BEGIN_COMMON_COPYRIGHT_HEADER + * (c)LGPL2+ + * + * LXDE-Qt - a lightweight, Qt based, desktop toolset + * http://razor-qt.org + * + * Copyright: 2010-2011 Razor team + * Authors: + * Petr Vanek + * + * This program or library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 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 + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * END_COMMON_COPYRIGHT_HEADER */ + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + + +class MainWindow : public LxQt::ConfigDialog +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget* parent = 0); + ~MainWindow(); + +}; + +#endif diff --git a/config/translations/lxqt-config-notificationd.ts b/config/translations/lxqt-config-notificationd.ts new file mode 100644 index 0000000..312c575 --- /dev/null +++ b/config/translations/lxqt-config-notificationd.ts @@ -0,0 +1,107 @@ + + + + + AdvancedSettings + + Menu Configuration + + + + Notification Duration + + + + For some the notification's expiration time is dependent on the notification server's settings. + + + + "Server Decides" Time: + + + + sec + + + + Sizes + + + + Notification Spacing: + + + + px + + + + Notification Width: + + + + + BasicSettings + + Basic Settings + + + + Display Notifications + + + + Top/Left + + + + Top/Right + + + + Bottom/Left + + + + Bottom/Right + + + + Test Notification + + + + <b>Warning:</b> No notifications daemon is running. +A fallback will be used. + + + + <b>Warning:</b> A third-party notifications daemon (%1) is running. +These settings won't have an effect on it! + + + + Notification Summary + + + + Notification Body + + + + + MainWindow + + Desktop Notifications + + + + Basic Settings + + + + Advanced Settings + + + + diff --git a/config/translations/lxqt-config-notificationd_ar.desktop b/config/translations/lxqt-config-notificationd_ar.desktop new file mode 100644 index 0000000..9427452 --- /dev/null +++ b/config/translations/lxqt-config-notificationd_ar.desktop @@ -0,0 +1,4 @@ +# Translations +GenericName[ar]=قائمة التطبيقات +Name[ar]=أداة تهيئة جلسة ريزر +Comment[ar]=إعداد إشعارات سطح المكتب المفتوح في سطح مكتب ريزر diff --git a/config/translations/lxqt-config-notificationd_cs.desktop b/config/translations/lxqt-config-notificationd_cs.desktop new file mode 100644 index 0000000..d775148 --- /dev/null +++ b/config/translations/lxqt-config-notificationd_cs.desktop @@ -0,0 +1,4 @@ +# Translations +GenericName[cs]=Nastavení oznamování v LxQtu +Name[cs]=Nastavení oznamování v LxQtu +Comment[cs]=Nastavit oznamování na ploše LxQt diff --git a/config/translations/lxqt-config-notificationd_cs_CZ.desktop b/config/translations/lxqt-config-notificationd_cs_CZ.desktop new file mode 100644 index 0000000..3cbddc0 --- /dev/null +++ b/config/translations/lxqt-config-notificationd_cs_CZ.desktop @@ -0,0 +1,4 @@ +# Translations +GenericName[cs_CZ]=Nastavení oznamování v LxQtu +Name[cs_CZ]=Nastavení oznamování v LxQtu +Comment[cs_CZ]=Nastavit oznamování na ploše LxQt diff --git a/config/translations/lxqt-config-notificationd_da.desktop b/config/translations/lxqt-config-notificationd_da.desktop new file mode 100644 index 0000000..43c2a0d --- /dev/null +++ b/config/translations/lxqt-config-notificationd_da.desktop @@ -0,0 +1,4 @@ +# Translations +GenericName[da]=Notesblok +Name[da]=Strømstyring +Comment[da]=Indstil freedesktop meddelelser på LxQt skrivebord diff --git a/config/translations/lxqt-config-notificationd_da_DK.desktop b/config/translations/lxqt-config-notificationd_da_DK.desktop new file mode 100644 index 0000000..6aad209 --- /dev/null +++ b/config/translations/lxqt-config-notificationd_da_DK.desktop @@ -0,0 +1,4 @@ +# Translations +GenericName[da_DK]=LxQt freedesktop Meddelelsesindstillinger +Name[da_DK]=LxQt freedesktop Meddelelsesindstillinger +Comment[da_DK]=Indstil freedesktop meddelelser på LxQt skrivebord diff --git a/config/translations/lxqt-config-notificationd_de.desktop b/config/translations/lxqt-config-notificationd_de.desktop new file mode 100644 index 0000000..ed6016c --- /dev/null +++ b/config/translations/lxqt-config-notificationd_de.desktop @@ -0,0 +1,3 @@ +# Translations +GenericName[de]=LxQt Konfigurations Center +Name[de]=LxQt Konfiguration diff --git a/config/translations/lxqt-config-notificationd_de_DE.desktop b/config/translations/lxqt-config-notificationd_de_DE.desktop new file mode 100644 index 0000000..a6dc2b9 --- /dev/null +++ b/config/translations/lxqt-config-notificationd_de_DE.desktop @@ -0,0 +1,4 @@ +# Translations +GenericName[de_DE]=Anwendungsmenü +Name[de_DE]=LxQt Freedesktop Mitteilungen Konfiguration +Comment[de_DE]=Freedesktop Mitteilungen für LxQt Desktop konfigurieren diff --git a/config/translations/lxqt-config-notificationd_el_GR.desktop b/config/translations/lxqt-config-notificationd_el_GR.desktop new file mode 100644 index 0000000..bf19e0d --- /dev/null +++ b/config/translations/lxqt-config-notificationd_el_GR.desktop @@ -0,0 +1,4 @@ +# Translations +GenericName[el_GR]=Διαμόρφωση ειδοποιήσεων LxQt +Name[el_GR]=Διαμόρφωση ειδοποιήσεων LxQt +Comment[el_GR]=Διαμόρφωση ειδοποιήσεων στην επιφάνεια εργασίας LxQt diff --git a/config/translations/lxqt-config-notificationd_eo.desktop b/config/translations/lxqt-config-notificationd_eo.desktop new file mode 100644 index 0000000..3bb2b2b --- /dev/null +++ b/config/translations/lxqt-config-notificationd_eo.desktop @@ -0,0 +1,4 @@ +# Translations +GenericName[eo]=Agordoj de muso por LxQto +Name[eo]=Agordoj de muso por LxQto +Comment[eo]=Agordi atentigojn de freedesktop en LxQt-labortablo diff --git a/config/translations/lxqt-config-notificationd_es.desktop b/config/translations/lxqt-config-notificationd_es.desktop new file mode 100644 index 0000000..4332546 --- /dev/null +++ b/config/translations/lxqt-config-notificationd_es.desktop @@ -0,0 +1,4 @@ +# Translations +GenericName[es]=Administrador de tareas +Name[es]=Configuración de sesiones LxQt +Comment[es]=Configure las notificacionde de freedesktop en el escritorio LxQt diff --git a/config/translations/lxqt-config-notificationd_es_VE.desktop b/config/translations/lxqt-config-notificationd_es_VE.desktop new file mode 100644 index 0000000..f8dc49b --- /dev/null +++ b/config/translations/lxqt-config-notificationd_es_VE.desktop @@ -0,0 +1,4 @@ +# Translations +GenericName[es_VE]=Configuracion de notificaciones de Escritorio LxQt +Name[es_VE]=Configuracion de notificaciones de Escritorio LxQt +Comment[es_VE]=Configura las notificacones en el Escritoro LxQt diff --git a/config/translations/lxqt-config-notificationd_eu.desktop b/config/translations/lxqt-config-notificationd_eu.desktop new file mode 100644 index 0000000..2c31310 --- /dev/null +++ b/config/translations/lxqt-config-notificationd_eu.desktop @@ -0,0 +1,4 @@ +# Translations +GenericName[eu]=LxQt Freedesktop jakinarazpenen konfigurazioa +Name[eu]=LxQt Freedesktop jakinarazpenen konfigurazioa +Comment[eu]=Konfiguratu LxQt mahaigaineko Freedesktop jakinarazpenak diff --git a/config/translations/lxqt-config-notificationd_fi.desktop b/config/translations/lxqt-config-notificationd_fi.desktop new file mode 100644 index 0000000..7c8ce3f --- /dev/null +++ b/config/translations/lxqt-config-notificationd_fi.desktop @@ -0,0 +1,4 @@ +# Translations +GenericName[fi]=LxQt-työpöydän ilmoitusasetukset +Name[fi]=LxQt-työpöydän ilmoitusasetukset +Comment[fi]=Muokkaa LxQt-työpöydän ilmoituksia diff --git a/config/translations/lxqt-config-notificationd_fr_FR.desktop b/config/translations/lxqt-config-notificationd_fr_FR.desktop new file mode 100644 index 0000000..db31011 --- /dev/null +++ b/config/translations/lxqt-config-notificationd_fr_FR.desktop @@ -0,0 +1,3 @@ +# Translations +GenericName[fr_FR]=Bloc-notes +Name[fr_FR]=Paramétreur de session LxQt diff --git a/config/translations/lxqt-config-notificationd_hu.desktop b/config/translations/lxqt-config-notificationd_hu.desktop new file mode 100644 index 0000000..317b8e0 --- /dev/null +++ b/config/translations/lxqt-config-notificationd_hu.desktop @@ -0,0 +1,4 @@ +# Translations +GenericName[hu]=Alkalmazásmenü +Name[hu]=LxQt beállítóközpont +Comment[hu]=A Freedesktop értesítések beállítása diff --git a/config/translations/lxqt-config-notificationd_id_ID.desktop b/config/translations/lxqt-config-notificationd_id_ID.desktop new file mode 100644 index 0000000..1b792c3 --- /dev/null +++ b/config/translations/lxqt-config-notificationd_id_ID.desktop @@ -0,0 +1,3 @@ +# Translations +GenericName[id_ID]=Hell World +Name[id_ID]=Konfigurator Desktop LxQt diff --git a/config/translations/lxqt-config-notificationd_it.desktop b/config/translations/lxqt-config-notificationd_it.desktop new file mode 100644 index 0000000..29d9a92 --- /dev/null +++ b/config/translations/lxqt-config-notificationd_it.desktop @@ -0,0 +1,3 @@ +# Translations +GenericName[it]=Centro di Configurazione LxQt +Name[it]=Configura LxQt diff --git a/config/translations/lxqt-config-notificationd_it_IT.desktop b/config/translations/lxqt-config-notificationd_it_IT.desktop new file mode 100644 index 0000000..7746944 --- /dev/null +++ b/config/translations/lxqt-config-notificationd_it_IT.desktop @@ -0,0 +1,4 @@ +# Translations +GenericName[it_IT]=Esci +Name[it_IT]=Esci dal sistema +Comment[it_IT]=Configura le notifiche freedesktop nel desktop LxQt diff --git a/config/translations/lxqt-config-notificationd_ja.desktop b/config/translations/lxqt-config-notificationd_ja.desktop new file mode 100644 index 0000000..d4a3ca0 --- /dev/null +++ b/config/translations/lxqt-config-notificationd_ja.desktop @@ -0,0 +1,4 @@ +# Translations +GenericName[ja]=LxQtフリーデスクトップ通知の設定 +Name[ja]=LxQtフリーデスクトップ通知の設定 +Comment[ja]=LxQtデスクトップでフリーデスクトップ通知を設定 diff --git a/config/translations/lxqt-config-notificationd_lt.desktop b/config/translations/lxqt-config-notificationd_lt.desktop new file mode 100644 index 0000000..e0937c4 --- /dev/null +++ b/config/translations/lxqt-config-notificationd_lt.desktop @@ -0,0 +1,4 @@ +# Translations +GenericName[lt]=Qlipper +Name[lt]=Energijos naudojimo nustatymai +Comment[lt]=Konfigūruoti freedesktop pranešimus LxQt darbalaukyje diff --git a/config/translations/lxqt-config-notificationd_nl.desktop b/config/translations/lxqt-config-notificationd_nl.desktop new file mode 100644 index 0000000..17c7b55 --- /dev/null +++ b/config/translations/lxqt-config-notificationd_nl.desktop @@ -0,0 +1,4 @@ +# Translations +GenericName[nl]=Notepad +Name[nl]=Energiebeheer +Comment[nl]=Configureren freedesktop meldingen in LxQt desktop diff --git a/config/translations/lxqt-config-notificationd_pl.desktop b/config/translations/lxqt-config-notificationd_pl.desktop new file mode 100644 index 0000000..3e48f01 --- /dev/null +++ b/config/translations/lxqt-config-notificationd_pl.desktop @@ -0,0 +1,3 @@ +# Translations +GenericName[pl]=Menu +Name[pl]=Panel sterowania LxQt diff --git a/config/translations/lxqt-config-notificationd_pl_PL.desktop b/config/translations/lxqt-config-notificationd_pl_PL.desktop new file mode 100644 index 0000000..d264218 --- /dev/null +++ b/config/translations/lxqt-config-notificationd_pl_PL.desktop @@ -0,0 +1,4 @@ +# Translations +GenericName[pl_PL]=Konfiguracja wyglądu LxQt +Name[pl_PL]=Konfiguracja wyglądu LxQt +Comment[pl_PL]=Konfiguruj powiadomienia freedesktop w LxQt diff --git a/config/translations/lxqt-config-notificationd_pt.desktop b/config/translations/lxqt-config-notificationd_pt.desktop new file mode 100644 index 0000000..73cb693 --- /dev/null +++ b/config/translations/lxqt-config-notificationd_pt.desktop @@ -0,0 +1,4 @@ +# Translations +Name[pt]=Notificações do ambiente de trabalho +GenericName[pt]=Definições das notificações do LXQt +Comment[pt]=Configurar notificações do sistema diff --git a/config/translations/lxqt-config-notificationd_pt.ts b/config/translations/lxqt-config-notificationd_pt.ts new file mode 100644 index 0000000..a685818 --- /dev/null +++ b/config/translations/lxqt-config-notificationd_pt.ts @@ -0,0 +1,109 @@ + + + + + AdvancedSettings + + Menu Configuration + Configuração do menu + + + Notification Duration + Duração da notificação + + + For some the notification's expiration time is dependent on the notification server's settings. + Para algumas notificações, o tempo limite depende das definições das notificações do servidor. + + + "Server Decides" Time: + Tempo para "Decisão do servidor": + + + sec + seg + + + Sizes + Tamanhos + + + Notification Spacing: + Espaçamento da notificação: + + + px + px + + + Notification Width: + Largura da notificaçao: + + + + BasicSettings + + Basic Settings + Definições básicas + + + Display Notifications + Mostrar notificações + + + Top/Left + Cima/Esquerda + + + Top/Right + Cima/Direita + + + Bottom/Left + Baixo/Esquerda + + + Bottom/Right + Baixo/Direita + + + Test Notification + Testar notificação + + + <b>Warning:</b> No notifications daemon is running. +A fallback will be used. + <b>Aviso:</b> o serviço de notificaçoes não está em execução. +Será utilizada uma solução alternativa. + + + <b>Warning:</b> A third-party notifications daemon (%1) is running. +These settings won't have an effect on it! + <b>Aviso:</b> já está a ser executado um serviço de notificações (%1). +Estas definições não produzirão qualquer efeito! + + + Notification Summary + Resumo da notificação + + + Notification Body + Corpo da notificação + + + + MainWindow + + Desktop Notifications + Notificações do ambiente de trabalho + + + Basic Settings + Definições básicas + + + Advanced Settings + Definições avançadas + + + diff --git a/config/translations/lxqt-config-notificationd_pt_BR.desktop b/config/translations/lxqt-config-notificationd_pt_BR.desktop new file mode 100644 index 0000000..d1c2da6 --- /dev/null +++ b/config/translations/lxqt-config-notificationd_pt_BR.desktop @@ -0,0 +1,4 @@ +# Translations +GenericName[pt_BR]=Suspender Automaticamente +Name[pt_BR]=Gerenciamento de energia +Comment[pt_BR]=Configurar as notificações do freedesktop na área de trabalho do LxQt diff --git a/config/translations/lxqt-config-notificationd_ro_RO.desktop b/config/translations/lxqt-config-notificationd_ro_RO.desktop new file mode 100644 index 0000000..83640ad --- /dev/null +++ b/config/translations/lxqt-config-notificationd_ro_RO.desktop @@ -0,0 +1,4 @@ +# Translations +GenericName[ro_RO]=Părăsește +Name[ro_RO]=Părăsește sistemul +Comment[ro_RO]=Configurează notificările freedesktop în desktop-ul LxQt diff --git a/config/translations/lxqt-config-notificationd_ru.desktop b/config/translations/lxqt-config-notificationd_ru.desktop new file mode 100644 index 0000000..ddec0f4 --- /dev/null +++ b/config/translations/lxqt-config-notificationd_ru.desktop @@ -0,0 +1,4 @@ +# Translations +GenericName[ru]=Настройки уведомлений LxQt +Name[ru]=Уведомления рабочего стола +Comment[ru]=Настроить уведомления рабочего стола \ No newline at end of file diff --git a/config/translations/lxqt-config-notificationd_ru.ts b/config/translations/lxqt-config-notificationd_ru.ts new file mode 100644 index 0000000..022a2ca --- /dev/null +++ b/config/translations/lxqt-config-notificationd_ru.ts @@ -0,0 +1,125 @@ + + + + + AdvancedSettings + + + Sizes + Размеры + + + + Width: + Ширина: + + + + + px + пикс + + + + Spacing: + Расстояние: + + + + Duration + Длительность + + + + Some notifications set their own on-screen duration. + Некоторые уведомления сами устанавливают свою длительность на экране. + + + + Default duration: + Длительность по умолчанию: + + + + sec + сек + + + + BasicSettings + + + Basic Settings + Основные настройки + + + + Position on screen + Расположение на экране + + + + Top/Left + Вверху слева + + + + Top/Right + Вверху справа + + + + Bottom/Left + Внизу слева + + + + Bottom/Right + Внизу справа + + + + <b>Warning:</b> No notifications daemon is running. +A fallback will be used. + <b>Внимание:</b> Демон уведомлений не запущен. +Будет использован резервный вариант. + + + + <b>Warning:</b> A third-party notifications daemon (%1) is running. +These settings won't have any effect on it! + <b>Внимание:</b> Демон уведомлений третьей сторон (%1) запущен. +Эти настройки не будут иметь никакого эффекта для него! + + + + Notification demo + Демонстрация уведомления + + + + This is a test notification. +All notifications will now appear here on LXQt. + Это тестовое уведомление. +Все уведомления на LXQt будут появляться здесь. + + + + MainWindow + + + Desktop Notifications + Системные уведомления + + + + Basic Settings + Основные настройки + + + + Advanced Settings + Расширенные настройки + + + diff --git a/config/translations/lxqt-config-notificationd_ru_RU.desktop b/config/translations/lxqt-config-notificationd_ru_RU.desktop new file mode 100644 index 0000000..ddec0f4 --- /dev/null +++ b/config/translations/lxqt-config-notificationd_ru_RU.desktop @@ -0,0 +1,4 @@ +# Translations +GenericName[ru]=Настройки уведомлений LxQt +Name[ru]=Уведомления рабочего стола +Comment[ru]=Настроить уведомления рабочего стола \ No newline at end of file diff --git a/config/translations/lxqt-config-notificationd_ru_RU.ts b/config/translations/lxqt-config-notificationd_ru_RU.ts new file mode 100644 index 0000000..7e05fb6 --- /dev/null +++ b/config/translations/lxqt-config-notificationd_ru_RU.ts @@ -0,0 +1,125 @@ + + + + + AdvancedSettings + + + Sizes + Размеры + + + + Width: + Ширина: + + + + + px + пикс + + + + Spacing: + Расстояние: + + + + Duration + Длительность + + + + Some notifications set their own on-screen duration. + Некоторые уведомления сами устанавливают свою длительность на экране. + + + + Default duration: + Длительность по умолчанию: + + + + sec + сек + + + + BasicSettings + + + Basic Settings + Основные настройки + + + + Position on screen + Расположение на экране + + + + Top/Left + Вверху слева + + + + Top/Right + Вверху справа + + + + Bottom/Left + Внизу слева + + + + Bottom/Right + Внизу справа + + + + <b>Warning:</b> No notifications daemon is running. +A fallback will be used. + <b>Внимание:</b> Демон уведомлений не запущен. +Будет использован резервный вариант. + + + + <b>Warning:</b> A third-party notifications daemon (%1) is running. +These settings won't have any effect on it! + <b>Внимание:</b> Демон уведомлений третьей сторон (%1) запущен. +Эти настройки не будут иметь никакого эффекта для него! + + + + Notification demo + Демонстрация уведомления + + + + This is a test notification. +All notifications will now appear here on LXQt. + Это тестовое уведомление. +Все уведомления на LXQt будут появляться здесь. + + + + MainWindow + + + Desktop Notifications + Системные уведомления + + + + Basic Settings + Основные настройки + + + + Advanced Settings + Расширенные настройки + + + diff --git a/config/translations/lxqt-config-notificationd_sl.desktop b/config/translations/lxqt-config-notificationd_sl.desktop new file mode 100644 index 0000000..e5c9c69 --- /dev/null +++ b/config/translations/lxqt-config-notificationd_sl.desktop @@ -0,0 +1,4 @@ +# Translations +GenericName[sl]=Nastavitve obvestil +Name[sl]=Nastavitve obvestil na namizju +Comment[sl]=Nastavite obvestila na namizju LxQt diff --git a/config/translations/lxqt-config-notificationd_sr@latin.desktop b/config/translations/lxqt-config-notificationd_sr@latin.desktop new file mode 100644 index 0000000..0b2584b --- /dev/null +++ b/config/translations/lxqt-config-notificationd_sr@latin.desktop @@ -0,0 +1,3 @@ +# Translations +GenericName[sr@latin]=Automatsko suspendovanje +Name[sr@latin]=Upravljanje napajanjem diff --git a/config/translations/lxqt-config-notificationd_th_TH.desktop b/config/translations/lxqt-config-notificationd_th_TH.desktop new file mode 100644 index 0000000..a512fb8 --- /dev/null +++ b/config/translations/lxqt-config-notificationd_th_TH.desktop @@ -0,0 +1,4 @@ +# Translations +GenericName[th_TH]=การตั้งค่าการเตือนต่างๆ ของ LxQt Freedesktop +Name[th_TH]=การตั้งค่าการเตือนต่างๆ ของ LxQt Freedesktop +Comment[th_TH]=ตั้งค่าการเตือนต่างๆ ของ freedesktop ในเดสก์ท็อป LxQt diff --git a/config/translations/lxqt-config-notificationd_tr.desktop b/config/translations/lxqt-config-notificationd_tr.desktop new file mode 100644 index 0000000..d26c216 --- /dev/null +++ b/config/translations/lxqt-config-notificationd_tr.desktop @@ -0,0 +1,4 @@ +# Translations +GenericName[tr]=Not Defteri +Name[tr]=Güç yönetimi +Comment[tr]=LxQt masaüstünde freedesktop bildirimlerini ayarla diff --git a/config/translations/lxqt-config-notificationd_uk.desktop b/config/translations/lxqt-config-notificationd_uk.desktop new file mode 100644 index 0000000..e641d85 --- /dev/null +++ b/config/translations/lxqt-config-notificationd_uk.desktop @@ -0,0 +1,4 @@ +# Translations +GenericName[uk]=Налаштування Freedesktop сповіщень LxQt +Name[uk]=Налаштування Freedesktop сповіщень LxQt +Comment[uk]=Налаштувати Freedesktop сповіщення в стільниці LxQt diff --git a/config/translations/lxqt-config-notificationd_zh_CN.desktop b/config/translations/lxqt-config-notificationd_zh_CN.desktop new file mode 100644 index 0000000..92eb7ba --- /dev/null +++ b/config/translations/lxqt-config-notificationd_zh_CN.desktop @@ -0,0 +1,4 @@ +# Translations +GenericName[zh_CN]=qxkb +Name[zh_CN]=LxQt 通知配置 +Comment[zh_CN]=配置 LxQt 桌面的通知 diff --git a/config/translations/lxqt-config-notificationd_zh_TW.desktop b/config/translations/lxqt-config-notificationd_zh_TW.desktop new file mode 100644 index 0000000..03d460b --- /dev/null +++ b/config/translations/lxqt-config-notificationd_zh_TW.desktop @@ -0,0 +1,4 @@ +# Translations +GenericName[zh_TW]=LxQt通知設定 +Name[zh_TW]=LxQt通知設定 +Comment[zh_TW]=LxQt桌面上的FreeDesktop通知設定 diff --git a/docs/notification-spec-latest.html b/docs/notification-spec-latest.html new file mode 100644 index 0000000..23073f9 --- /dev/null +++ b/docs/notification-spec-latest.html @@ -0,0 +1,538 @@ + + +Desktop Notifications Specification

Desktop Notifications Specification

Mike Hearn


+      
+     

Christian Hammond


+      
+     

William Jon McCann


+      
+     

Version 1.2


Introduction

+ This is a draft standard for a desktop notifications service, + through which applications can generate passive popups to notify + the user in an asynchronous manner of events. +

+ This specification explicitly does not include other types of + notification presentation such as modal message boxes, window manager + decorations or window list annotations. +

+ Example use cases include: +

  • Messages from chat programs

  • Scheduled alarm

  • Completed file transfer

  • New mail notification

  • Low disk space/battery warnings

Basic Design

+ In order to ensure that multiple notifications can easily be + displayed at once, and to provide a convenient implementation, all + notifications are controlled by a single session-scoped service which + exposes a D-BUS interface. +

+ On startup, a conforming implementation should take the + org.freedesktop.Notifications service on + the session bus. This service will be referred to as the "notification + server" or just "the server" in this document. It can optionally be + activated automatically by the bus process, however this is not required + and notification server clients must not assume that it is available. +

+ The server should implement the + org.freedesktop.Notifications interface on + an object with the path "/org/freedesktop/Notifications". + This is the only interface required by this version of the specification. +

+ A notification has the following components: +

Table 1. Notification Components

ComponentDescription
Application Name + This is the optional name of the application sending the notification. + This should be the application's formal name, rather than some sort + of ID. An example would be "FredApp E-Mail Client," rather than + "fredapp-email-client." +
Replaces ID + An optional ID of an existing notification that this + notification is intended to replace. +
Notification Icon + The notification icon. See Icons and Images Formats. +
Summary + This is a single line overview of the notification. For instance, + "You have mail" or "A friend has come online". It should generally + not be longer than 40 characters, though this is not a requirement, + and server implementations should word wrap if necessary. The summary + must be encoded using UTF-8. +
Body +

+ This is a multi-line body of text. Each line is a paragraph, server + implementations are free to word wrap them as they see fit. +

+

+ The body may contain simple markup as specified in + Markup. It must be encoded using UTF-8. +

+

+ If the body is omitted, just the summary is displayed. +

+
Actions +

+ The actions send a request message back to the notification client + when invoked. This functionality may not be implemented by the + notification server, conforming clients should check if it is available + before using it (see the GetCapabilities message in + Protocol). An implementation is free to ignore any + requested by the client. As an example one possible rendering of + actions would be as buttons in the notification popup. +

+

+ Actions are sent over as a list of pairs. Each even element in the + list (starting at index 0) represents the identifier for the action. + Each odd element in the list is the localized string that will be + displayed to the user. +

+

+ The default action (usually invoked my clicking the notification) + should have a key named "default". The name can + be anything, though implementations are free not to display it. +

+
Hints +

+ Hints are a way to provide extra data to a notification server that + the server may be able to make use of. +

+

See Hints for a list of available hints.

+
Expiration Timeout +

+ The timeout time in milliseconds since the display of the notification + at which the notification should automatically close. +

+

+ If -1, the notification's expiration time is dependent on the + notification server's settings, and may vary for the type of + notification. +

+

+ If 0, the notification never expires. +

+

+ Each notification displayed is allocated a unique ID by the server. + This is unique within the session. While the notification server is + running, the ID will not be recycled unless the capacity of a uint32 is + exceeded. +

+ This can be used to hide the notification before the expiration timeout + is reached. It can also be used to atomically replace the notification + with another. This allows you to (for instance) modify the contents of + a notification while it's on-screen. +

Backwards Compatibility

+ Clients should try and avoid making assumptions about the presentation and + abilities of the notification server. The message content is the most + important thing. +

+ Clients can check with the server what capabilities are supported + using the GetCapabilities message. See + Protocol. +

+ If a client requires a response from a passive popup, it should be + coded such that a non-focus-stealing message box can be used in the + case that the notification server does not support this feature. +

Markup

+ Body text may contain markup. The markup is XML-based, and consists + of a small subset of HTML along with a few additional tags. +

+ The following tags should be supported by the notification server. + Though it is optional, it is recommended. Notification servers that do + not support these tags should filter them out. +

+ <b> ... + </b> + Bold
+ <i> ... + </i> + Italic
+ <u> ... + </u> + Underline
+ <a href="..."> ... + </a> + Hyperlink
+ <img src="..." alt="..."/> + Image

+ A full-blown HTML implementation is not required of this spec, and + notifications should never take advantage of tags that are not listed + above. As notifications are not a substitute for web browsers or complex + dialogs, advanced layout is not necessary, and may in fact limit the + number of systems that notification services can run on, due to memory + usage and screen space. Such examples are PDAs, certain cell phones, and + slow PCs or laptops with little memory. +

+ For the same reason, a full XML or XHTML implementation using XSLT or + CSS stylesheets is not part of this specification. Information that + must be presented in a more complex form should use an application-specific + dialog, a web browser, or some other display mechanism. +

+ The tags specified above mark up the content in a way that allows them + to be stripped out on some implementations without impacting the actual + content. +

Hyperlinks

+ Hyperlinks allow for linking one or more words to a URI. There is no + requirement to allow for images to be linked, and it is highly suggested + that implementations do not allow this, as there is no clean-looking, + standard visual indicator for a hyperlinked image. +

+ Hyperlinked text should appear in the standard blue underline format. +

+ Hyperlinks cannot function as a replacement for actions. They are + used to link to local directories or remote sites using standard URI + schemes. +

+ Implementations are not required to support hyperlinks. +

Images

+ Images may be placed in the notification, but this should be done with + caution. The image should never exceed 200x100, but this should be thought + of as a maximum size. Images should always have alternative text + provided through the alt="..." attribute. +

+ Image data cannot be embedded in the message itself. Images referenced + must always be local files. +

+ Implementations are not required to support images. +

Icons and Images

+ A notification can optionally have an associated icon and/or image. +

+ The icon is defined by the "app_icon" parameter. + The image can be defined by the "image-path", the "image-data" hint or the + deprecated "icon_data" hint. +

Priorities

+ An implementation which only displays one image or icon must choose which one + to display using the following order: +

  1. "image-data"

  2. "image-path"

  3. app_icon parameter

  4. for compatibility reason, "icon_data"

+

+ An implementation which can display both the image and icon must show the + icon from the "app_icon" parameter and choose which image to display using + the following order: +

  1. "image-data"

  2. "image-path"

  3. for compatibility reason, "icon_data"

+

Formats

+ The "image-data" and "icon_data" hints should be a raw image data structure + of signature (iiibiiay) which describes the width, height, rowstride, has + alpha, bits per sample, channels and image data respectively. +

+ The "app_icon" parameter and "image-path" hint should be either an URI + (file:// is the only URI schema supported right now) or a name in a + freedesktop.org-compliant icon theme (not a GTK+ stock ID). +

Categories

+ Notifications can optionally have a type indicator. Although neither + client or nor server must support this, some may choose to. Those servers + implementing categories may use them to intelligently display + the notification in a certain way, or group notifications of similar + types. +

+ Categories are in + class.specific form. + class specifies the generic type of notification, and + specific specifies the more specific type of + notification. +

+ If a specific type of notification does not exist for your notification, + but the generic kind does, a notification of type + class is acceptable. +

+ Third parties, when defining their own categories, should discuss + the possibility of standardizing on the hint with other parties, preferably + in a place such as the + xdg + mailing list at + freedesktop.org. If it + warrants a standard, it will be added to the table above. If no + consensus is reached, the category should be in the form of + "x-vendor.class.name." +

+ The following table lists standard notifications as defined by this spec. + More will be added in time. +

Table 2. Categories

TypeDescription
"device" + A generic device-related notification that doesn't fit into + any other category. +
"device.added"A device, such as a USB device, was added to the system.
"device.error"A device had some kind of error.
"device.removed" + A device, such as a USB device, was removed from the system. +
"email" + A generic e-mail-related notification that doesn't fit into any + other category. +
"email.arrived"A new e-mail notification.
"email.bounced"A notification stating that an e-mail has bounced.
"im" + A generic instant message-related notification that doesn't fit + into any other category. +
"im.error"An instant message error notification.
"im.received"A received instant message notification.
"network" + A generic network notification that doesn't fit into any other + category. +
"network.connected" + A network connection notification, such as successful sign-on to a + network service. This should not be confused with + device.added for new network devices. +
"network.disconnected" + A network disconnected notification. This should not be confused with + device.removed for disconnected network devices. +
"network.error" + A network-related or connection-related error. +
"presence" + A generic presence change notification that doesn't fit into + any other category, such as going away or idle. +
"presence.offline"An offline presence change notification.
"presence.online"An online presence change notification.
"transfer" + A generic file transfer or download notification that doesn't fit + into any other category. +
"transfer.complete"A file transfer or download complete notification.
"transfer.error"A file transfer or download error.

Urgency Levels

+ Notifications have an urgency level associated with them. This defines + the importance of the notification. For example, "Joe Bob signed on" + would be a low urgency. "You have new mail" or "A USB device was unplugged" + would be a normal urgency. "Your computer is on fire" would be a critical + urgency. +

Urgency levels are defined as follows:

Table 3. Urgency Levels

TypeDescription
0Low
1Normal
2Critical

+ Developers must use their own judgement when deciding the urgency of a + notification. Typically, if the majority of programs are using the same + level for a specific type of urgency, other applications should follow + them. +

+ For low and normal urgencies, server implementations may display the + notifications how they choose. They should, however, have a sane + expiration timeout dependent on the urgency level. +

+ Critical notifications should not automatically expire, as they are + things that the user will most likely want to know about. They should + only be closed when the user dismisses them, for example, by clicking on + the notification. +

Hints

+ Hints are a way to provide extra data to a notification server that + the server may be able to make use of. +

+ Neither clients nor notification servers are required to support any + hints. Both sides should assume that hints are not passed, and should + ignore any hints they do not understand. +

+ Third parties, when defining their own hints, should discuss the + possibility of standardizing on the hint with other parties, preferably + in a place such as the + xdg + mailing list at + freedesktop.org. If it + warrants a standard, it will be added to the table above. If no + consensus is reached, the hint name should be in the form of + "x-vendor-name." +

+ The value type for the hint dictionary in D-BUS is of the + DBUS_TYPE_VARIANT container type. This allows different + data types (string, integer, boolean, etc.) to be used for hints. When + adding a dictionary of hints, this type must be used, rather than putting + the actual hint value in as the dictionary value. +

+ The following table lists the standard hints as defined by this + specification. Future hints may be proposed and added to this list + over time. Once again, implementations are not required to support these. +

Table 4. Standard Hints

NameValue TypeDescriptionSpec Version
"action-icons"boolean + When set, a server that has the "action-icons" capability will + attempt to interpret any action identifier as a named icon. + The localized display name will be used to annotate the icon + for accessibility purposes. The icon name should be compliant + with the Freedesktop.org Icon Naming Specification. + >= 1.2
"category"string + The type of notification this is. +  
"desktop-entry"string + This specifies the name of the desktop filename representing the + calling program. This should be the same as the prefix used for the + application's .desktop file. An example would be "rhythmbox" from + "rhythmbox.desktop". This can be used by the daemon to retrieve the + correct icon for the application, for logging purposes, etc. +  
"image-data"(iiibiiay) + This is a raw data image format which describes the width, height, + rowstride, has alpha, bits per sample, channels and image data + respectively. + >= 1.2
"image_data"(iiibiiay) + Deprecated. Use image-data instead. + = 1.1
"image-path"string + Alternative way to define the notification image. See Icons and Images. + >= 1.2
"image_path"string + Deprecated. Use image-path instead. + = 1.1
"icon_data"(iiibiiay) + Deprecated. Use image-data instead. + < 1.1
"resident"boolean + When set the server will not automatically remove the + notification when an action has been invoked. The notification + will remain resident in the server until it is explicitly + removed by the user or by the sender. This hint is likely only + useful when the server has the "persistence" capability. + >= 1.2
"sound-file"string + The path to a sound file to play when the notification pops up. +  
"sound-name"string + A themeable named sound from the freedesktop.org + sound naming specification + to play when the notification pops up. Similar to icon-name, only for + sounds. An example would be "message-new-instant". +  
"suppress-sound"boolean + Causes the server to suppress playing any sounds, if it has that + ability. This is usually set when the client itself is going to + play its own sound. +  
"transient"boolean + When set the server will treat the notification as transient + and by-pass the server's persistence capability, if it should + exist. + >= 1.2
"x"int + Specifies the X location on the screen that the notification should + point to. The "y" hint must also be specified. +  
"y"int + Specifies the Y location on the screen that the notification should + point to. The "x" hint must also be specified. +  
"urgency"byte + The urgency level. +  

D-BUS Protocol

+ The following messages must be supported by all + implementations. +

Message commands

org.freedesktop.Notifications.GetCapabilities

STRING_ARRAY + org.freedesktop.Notifications.GetCapabilities + (); 
 

+ This message takes no parameters. +

+ It returns an array of strings. Each string describes an optional + capability implemented by the server. The following values are + defined by this spec: +

Table 5. Server Capabilities

"action-icons" + Supports using icons instead of text for displaying actions. + Using icons for actions must be enabled on a per-notification + basis using the "action-icons" hint. +
"actions" + The server will provide the specified actions to the user. Even if + this cap is missing, actions may still be specified by the client, + however the server is free to ignore them. +
"body" + Supports body text. Some implementations may only show the + summary (for instance, onscreen displays, marquee/scrollers) +
"body-hyperlinks" + The server supports hyperlinks in the notifications. +
"body-images" + The server supports images in the notifications. +
"body-markup" + Supports markup in the body text. If marked up text is sent + to a server that does not give this cap, the markup will show + through as regular text so must be stripped clientside. +
"icon-multi" + The server will render an animation of all the frames in a given + image array. The client may still specify multiple frames even if + this cap and/or "icon-static" is missing, however + the server is free to ignore them and use only the primary frame. +
"icon-static" + Supports display of exactly 1 frame of any given image array. + This value is mutually exclusive with + "icon-multi", it is a protocol error for the + server to specify both. +
"persistence" + The server supports persistence of notifications. + Notifications will be retained until they are acknowledged or + removed by the user or recalled by the sender. The presence + of this capability allows clients to depend on the server to + ensure a notification is seen and eliminate the need for + the client to display a reminding function (such as a status + icon) of its own. +
"sound" + The server supports sounds on notifications. If returned, the + server must support the "sound-file" and + "suppress-sound" hints. +

+ New vendor-specific caps may be specified as long as they start with + "x-vendor". For instance, + "x-gnome-foo-cap". Capability names must not + contain spaces. They are limited to alpha-numeric characters and dashes + ("-"). +

org.freedesktop.Notifications.Notify

UINT32 + org.freedesktop.Notifications.Notify + (app_name,  
 replaces_id,  
 app_icon,  
 summary,  
 body,  
 actions,  
 hints,  
 expire_timeout); 
STRING app_name;
UINT32 replaces_id;
STRING app_icon;
STRING summary;
STRING body;
ARRAY actions;
DICT hints;
INT32 expire_timeout;
 

+ Sends a notification to the notification server. +

Table 6. Notify Parameters

NameTypeDescription
app_nameSTRING + The optional name of the application sending the notification. + Can be blank. +
replaces_idUINT32 + The optional notification ID that this notification replaces. The + server must atomically (ie with no flicker or other visual cues) + replace the given notification with this one. This allows clients to + effectively modify the notification while it's active. A value of + value of 0 means that this notification won't replace any + existing notifications. +
app_iconSTRING + The optional program icon of the calling application. See Icons and Images. + Can be an empty string, indicating no icon. +
summarySTRINGThe summary text briefly describing the notification.
bodySTRINGThe optional detailed body text. Can be empty.
actionsARRAY + Actions are sent over as a list of pairs. Each even element in + the list (starting at index 0) represents the identifier for the + action. Each odd element in the list is the localized string + that will be displayed to the user. +
hintsDICT + Optional hints that can be passed to the server from the client + program. Although clients and servers should never assume each other + supports any specific hints, they can be used to pass along + information, such as the process PID or window ID, that the server + may be able to make use of. See Hints. Can be + empty. +
expire_timeoutINT32 +

+ The timeout time in milliseconds since the display of the notification at + which the notification should automatically close. +

+

+ If -1, the notification's expiration time is dependent on the + notification server's settings, and may vary for the type of + notification. + + If 0, never expire. +

+

+ If replaces_id is 0, the return value is a + UINT32 that represent the notification. It is unique, and will not be + reused unless a MAXINT number of notifications + have been generated. An acceptable implementation may just use an + incrementing counter for the ID. The returned ID is always greater than + zero. Servers must make sure not to return zero as an ID. +

+ If replaces_id is not 0, the returned value + is the same value as replaces_id. +

org.freedesktop.Notifications.CloseNotification

void + org.freedesktop.Notifications.CloseNotification + (); 
UINT32 id;
 

+ Causes a notification to be forcefully closed and removed from the user's + view. It can be used, for example, in the event that what the + notification pertains to is no longer relevant, or to cancel a + notification with no expiration time. +

+ The NotificationClosed signal is emitted by this + method. +

+ If the notification no longer exists, an empty D-BUS Error message is + sent back. +

org.freedesktop.Notifications.GetServerInformation

+ void + org.freedesktop.Notifications.GetServerInformation + (name,  
 vendor,  
 version,  
 spec_version); 
out STRING name;
out STRING vendor;
out STRING version;
out STRING spec_version;
 

+ This message returns the information on the server. Specifically, + the server name, vendor, and version number. +

Table 7. GetServerInformation Return Values

NameTypeDescription
nameSTRINGThe product name of the server.
vendorSTRING + The vendor name. For example, "KDE," "GNOME," + "freedesktop.org," or "Microsoft." +
versionSTRINGThe server's version number.
spec_versionSTRINGThe specification version the server is compliant with.

Signals

org.freedesktop.Notifications.NotificationClosed

+ org.freedesktop.Notifications.NotificationClosed + (id,  
 reason); 
UINT32 id;
UINT32 reason;
 

+ A completed notification is one that has timed out, or has been + dismissed by the user. +

Table 8. NotificationClosed Parameters

NameTypeDescription
idUINT32The ID of the notification that was closed.
reasonUINT32 +

The reason the notification was closed.

+

1 - The notification expired.

+

2 - The notification was dismissed by the user.

+

3 - The notification was closed by a call to + CloseNotification.

+

4 - Undefined/reserved reasons.

+

+ The ID specified in the signal is invalidated + before the signal is sent and may not be used + in any further communications with the server. +

org.freedesktop.Notifications.ActionInvoked

+ org.freedesktop.Notifications.ActionInvoked + (id,  
 action_key); 
UINT32 id;
STRING action_key;
 

+ This signal is emitted when one of the following occurs: +

  • + The user performs some global "invoking" action upon a notification. + For instance, clicking somewhere on the notification itself. +

  • + The user invokes a specific action as specified in the original + Notify request. For example, clicking on an action button. +

Table 9. ActionInvoked Parameters

NameTypeDescription
idUINT32 + The ID of the notification emitting the ActionInvoked signal. +
action_keySTRING + The key of the action invoked. These match the keys sent over + in the list of actions. +

Note

+ Clients should not assume the server will generate this signal. Some + servers may not support user interaction at all, or may not support + the concept of being able to "invoke" a notification. +

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..998243d --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,51 @@ +include_directories( + "${CMAKE_CURRENT_SOURCE_DIR}" + "${CMAKE_CURRENT_BINARY_DIR}" +) + +set(NOTIFICATIONS_SRC + main.cpp + notificationarea.cpp + notification.cpp + notificationlayout.cpp + notificationwidgets.cpp + notifyd.cpp +) + +set(NOTIFICATIONS_UI + notification.ui +) + +qt5_wrap_ui(NOTIFICATIONS_UI_CPP ${NOTIFICATIONS_UI}) +qt5_add_dbus_adaptor(NOTIFICATIONS_SRC + org.freedesktop.Notifications.xml + notifyd.h Notifyd +) + +# Translations ********************************** +lxqt_translate_ts(NOTIFICATIONS_QM_FILES SOURCES + UPDATE_TRANSLATIONS ${UPDATE_TRANSLATIONS} + ${NOTIFICATIONS_SRC} + ${NOTIFICATIONS_UI} + INSTALL_DIR "${LXQT_TRANSLATIONS_DIR}/${PROJECT_NAME}" +) + +lxqt_app_translation_loader(QM_LOADER ${PROJECT_NAME}) +#************************************************ + +add_executable(lxqt-notificationd + ${NOTIFICATIONS_SRC} + ${NOTIFICATIONS_UI_CPP} + ${NOTIFICATIONS_QM_FILES} + ${QM_LOADER} +) + +target_link_libraries(lxqt-notificationd + Qt5::Widgets + Qt5::DBus + ${QTXDG_LIBRARIES} + ${LXQT_LIBRARIES} + KF5::WindowSystem +) + +install(TARGETS lxqt-notificationd RUNTIME DESTINATION bin) diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..39e4fba --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,89 @@ +/* BEGIN_COMMON_COPYRIGHT_HEADER + * (c)LGPL2+ + * + * LXDE-Qt - a lightweight, Qt based, desktop toolset + * http://razor-qt.org + * + * Copyright: 2012 Razor team + * Authors: + * Petr Vanek + * + * This program or library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 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 + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * END_COMMON_COPYRIGHT_HEADER */ + +#include +#include + +#include + +#include "notificationsadaptor.h" +#include "notifyd.h" + + +/*! \mainpage LXDE-Qt notification daemon + * + * Running in user session; implementing standard as described in: + * docs/nodification-spec-latest.html + * + * Implementation notes: + * + * Class \c Notifyd implements the main "server" part, a DBUS + * interface. Displaying of notifications is handled by these + * classes: + * + * - \c NotificationArea: a QScrollArea object with transparency. + * It ensures tha no action is unreachable (user can scroll + * over notifications) + * - \c NotificationLayout: a \c NotificationArea's main widget, + * (QWidget instance) holding instances of \c Notification. + * Layouting (in real QLayout) is done here. + * - \c Notification: a QWidget with one notification. Icon, texts, + * user interaction, etc. is handled in it. + * + * \c Notification can be extended with widgets located in files + * notificationwidgets.*. Currently there is only one extension: + * + * - \c NotificationActionsWidget holding user interface for + * interactive actions (buttons or combobox). + * + * Other extensions for e.g. "x-cannonical-*" can be implemented too. + * + */ +int main(int argc, char** argv) +{ + LxQt::Application a(argc, argv); + + a.setQuitOnLastWindowClosed(false); + + // Ensure the helper widgets are hidden + a.setStyleSheet(a.styleSheet() + + "NotificationArea {background: transparent;}" + "NotificationLayout {background: transparent;}" + ); + + Notifyd* daemon = new Notifyd(); + new NotificationsAdaptor(daemon); + + QDBusConnection connection = QDBusConnection::sessionBus(); + if (!connection.registerService("org.freedesktop.Notifications")) + qDebug() << "registerService failed: another service with 'org.freedesktop.Notifications' runs already"; + if (!connection.registerObject("/org/freedesktop/Notifications", daemon)) + qDebug() << "registerObject failed: another object with '/org/freedesktop/Notifications' runs already"; + + + return a.exec(); +} diff --git a/src/notification.cpp b/src/notification.cpp new file mode 100644 index 0000000..bc0fd25 --- /dev/null +++ b/src/notification.cpp @@ -0,0 +1,322 @@ +/* BEGIN_COMMON_COPYRIGHT_HEADER + * (c)LGPL2+ + * + * LXDE-Qt - a lightweight, Qt based, desktop toolset + * http://razor-qt.org + * + * Copyright: 2012 Razor team + * Authors: + * Petr Vanek + * + * This program or library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 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 + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * END_COMMON_COPYRIGHT_HEADER */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "notification.h" +#include "notificationwidgets.h" + +#define ICONSIZE QSize(32, 32) + +Notification::Notification(const QString &application, + const QString &summary, const QString &body, + const QString &icon, int timeout, + const QStringList& actions, const QVariantMap& hints, + QWidget *parent) + : QWidget(parent), + m_timer(0), + m_actionWidget(0) +{ + setupUi(this); + setObjectName("Notification"); + setMouseTracking(true); + + setMaximumWidth(parent->width()); + setMinimumWidth(parent->width()); + + setValues(application, summary, body, icon, timeout, actions, hints); + + connect(closeButton, SIGNAL(clicked()), this, SLOT(closeButton_clicked())); +} + +void Notification::setValues(const QString &application, + const QString &summary, const QString &body, + const QString &icon, int timeout, + const QStringList& actions, const QVariantMap& hints) +{ + // Basic properties ********************* + + // Notifications spec set real order here: + // An implementation which only displays one image or icon must + // choose which one to display using the following order: + // - "image-data" + // - "image-path" + // - app_icon parameter + // - for compatibility reason, "icon_data" + if (!hints["image_data"].isNull()) + { + m_pixmap = getPixmapFromHint(hints["image_data"]); +// qDebug() << application << "from image_data" << m_pixmap.isNull(); + } + else if (!hints["image_path"].isNull()) + { + m_pixmap = getPixmapFromString(hints["image_path"].toString()); +// qDebug() << application << "from image_path" << m_pixmap.isNull(); + } + else if (!icon.isEmpty()) + { + m_pixmap = getPixmapFromString(icon); +// qDebug() << application << "from icon" << icon << m_pixmap.isNull(); + } + else if (!hints["icon_data"].isNull()) + { + m_pixmap = getPixmapFromHint(hints["icon_data"]); +// qDebug() << application << "from icon_data" << m_pixmap.isNull(); + } + // issue #325: Do not display icon if it's not found... + if (m_pixmap.isNull()) + { + iconLabel->hide(); + } + else + { + if (m_pixmap.size().width() > ICONSIZE.width() + || m_pixmap.size().height() > ICONSIZE.height()) + { + m_pixmap = m_pixmap.scaled(ICONSIZE, Qt::KeepAspectRatio, Qt::SmoothTransformation); + } + iconLabel->setPixmap(m_pixmap); + iconLabel->show(); + } + + // application + appLabel->setVisible(!application.isEmpty()); + appLabel->setText(application); + + // summary + summaryLabel->setVisible(!summary.isEmpty()); + summaryLabel->setText(summary); + + if (application == summary) + summaryLabel->setVisible(false); + + // body + bodyLabel->setVisible(!body.isEmpty()); + bodyLabel->setText(body); + + // Timeout + // Special values: + // < 0: server decides timeout + // 0: infifite + if (m_timer) + { + m_timer->stop(); + m_timer->deleteLater(); + } + + // -1 for server decides is handled in notifyd to save QSettings instance + if (timeout > 0) + { + m_timer = new NotificationTimer(this); + connect(m_timer, SIGNAL(timeout()), this, SIGNAL(timeout())); + m_timer->start(timeout); + } + + // Categories ********************* + // TODO/FIXME: Categories - how to handle it? + if (!hints["category"].isNull()) + { + qDebug() << "Notification" << application << "category" << hints["category"]; + } + + // Urgency Levels ********************* + // Type Description + // 0 Low + // 1 Normal + // 2 Critical + // TODO/FIXME: Urgencies - how to handle it? + if (!hints["urgency"].isNull()) + { + qDebug() << "Notification" << application << "urgency" << hints["urgency"]; + } + + // Actions + if (actions.count() && m_actionWidget == 0) + { + if (actions.count()/2 < 4) + m_actionWidget = new NotificationActionsButtonsWidget(actions, this); + else + m_actionWidget = new NotificationActionsComboWidget(actions, this); + connect(m_actionWidget, SIGNAL(actionTriggered(const QString &)), + this, SIGNAL(actionTriggered(const QString &))); + actionsLayout->addWidget(m_actionWidget); + m_actionWidget->show(); + } + + adjustSize(); + // ensure layout expansion + setMinimumHeight(qMax(rect().height(), childrenRect().height())); +} + +QString Notification::application() const +{ + return appLabel->text(); +} + +QString Notification::summary() const +{ + return summaryLabel->text(); +} + +QString Notification::body() const +{ + return bodyLabel->text(); +} + +void Notification::closeButton_clicked() +{ + if (m_timer) + m_timer->stop(); + emit userCanceled(); +} + +void Notification::paintEvent(QPaintEvent *) +{ + QStyleOption opt; + opt.init(this); + QPainter p(this); + style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); +} + +QPixmap Notification::getPixmapFromHint(const QVariant &argument) const +{ + int width, height, rowstride, bitsPerSample, channels; + bool hasAlpha; + QByteArray data; + + const QDBusArgument arg = argument.value(); + arg.beginStructure(); + arg >> width; + arg >> height; + arg >> rowstride; + arg >> hasAlpha; + arg >> bitsPerSample; + arg >> channels; + arg >> data; + arg.endStructure(); + QImage img = QImage((uchar*)data.constData(), width, height, QImage::Format_ARGB32).rgbSwapped(); + + return QPixmap::fromImage(img); +} + +QPixmap Notification::getPixmapFromString(const QString &str) const +{ + QUrl url(str); + if (url.isValid() && QFile::exists(url.toLocalFile())) + { +// qDebug() << " getPixmapFromString by URL" << url; + return QPixmap(url.toLocalFile()); + } + else + { +// qDebug() << " getPixmapFromString by XdgIcon theme" << str << ICONSIZE << XdgIcon::themeName(); +// qDebug() << " " << XdgIcon::fromTheme(str) << "isnull:" << XdgIcon::fromTheme(str).isNull(); + // They say: do not display an icon if it;s not found - see #325 + return XdgIcon::fromTheme(str/*, XdgIcon::defaultApplicationIcon()*/).pixmap(ICONSIZE); + } +} + +void Notification::enterEvent(QEvent * event) +{ + if (m_timer) + m_timer->pause(); +} + +void Notification::leaveEvent(QEvent * event) +{ + if (m_timer) + m_timer->resume(); +} + +void Notification::mouseReleaseEvent(QMouseEvent * event) +{ +// qDebug() << "CLICKED" << event; + QString appName; + QString windowTitle; + + if (m_actionWidget && m_actionWidget->hasDefaultAction()) + { + emit actionTriggered(m_actionWidget->defaultAction()); + return; + } + + foreach (WId i, KWindowSystem::stackingOrder()) + { + KWindowInfo info = KWindowInfo(i, NET::WMName | NET::WMVisibleName); + appName = info.name(); + windowTitle = info.visibleName(); + // qDebug() << " " << i << "APPNAME" << appName << "TITLE" << windowTitle; + if (appName.isEmpty()) + { + QWidget::mouseReleaseEvent(event); + return; + } + if (appName == appLabel->text() || windowTitle == appLabel->text()) + { + KWindowSystem::raiseWindow(i); + closeButton_clicked(); + return; + } + } +} + +NotificationTimer::NotificationTimer(QObject *parent) + : QTimer(parent), + m_intervalMsec(-1) +{ +} + +void NotificationTimer::start(int msec) +{ + m_startTime = QDateTime::currentDateTime(); + m_intervalMsec = msec; + QTimer::start(msec); +} + +void NotificationTimer::pause() +{ + if (!isActive()) + return; + + stop(); + m_intervalMsec = m_startTime.msecsTo(QDateTime()); +} + +void NotificationTimer::resume() +{ + if (isActive()) + return; + + start(m_intervalMsec); +} diff --git a/src/notification.h b/src/notification.h new file mode 100644 index 0000000..35c69d8 --- /dev/null +++ b/src/notification.h @@ -0,0 +1,134 @@ +/* BEGIN_COMMON_COPYRIGHT_HEADER + * (c)LGPL2+ + * + * LXDE-Qt - a lightweight, Qt based, desktop toolset + * http://razor-qt.org + * + * Copyright: 2012 Razor team + * Authors: + * Petr Vanek + * + * This program or library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 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 + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * END_COMMON_COPYRIGHT_HEADER */ + +#ifndef NOTIFICATION_H +#define NOTIFICATION_H + +#include +#include +#include +#include +#include "ui_notification.h" + + +class NotificationActionsWidget; +class NotificationTimer; + + +/*! Implementation of one notification. + * + * Notification on-click behavior is defined in mouseReleaseEvent() + */ +class Notification : public QWidget, public Ui::Notification +{ + Q_OBJECT +public: + /*! Construct a notification. + * Parameters are described in \c Notifyd::Notify() + */ + explicit Notification(const QString &application, + const QString &summary, const QString &body, + const QString &icon, int timeout, + const QStringList& actions, const QVariantMap& hints, + QWidget *parent = 0); + + /*! Set new values (update) for existing notification. + * Parameters are described in \c Notifyd::Notify() + */ + void setValues(const QString &application, + const QString &summary, const QString &body, + const QString &icon, int timeout, + const QStringList& actions, const QVariantMap& hints); + + QString application() const; + QString summary() const; + QString body() const; + +signals: + //! the server set timeout passed. Notification should close itself. + void timeout(); + //! User clicked the "close" button + void userCanceled(); + /*! User selected some of actions provided + * \param actionKey an action key + */ + void actionTriggered(const QString &actionKey); + +protected: + void enterEvent(QEvent * event); + void leaveEvent(QEvent * event); + /*! Define on-click behavior in the notification area. + Currently it implements: + - if there is one action or at least one default action, this + default action is triggered on click. + \see NotificationActionsWidget::hasDefaultAction() + \see NotificationActionsWidget::defaultAction() + - it tries to find caller window by + a) application name. \see XfitMan::getApplicationName() + b) window title. \see XfitMan::getWindowTitle() + if it can be found the window is raised and the notification is closed + - leave notification as-is. + */ + void mouseReleaseEvent(QMouseEvent * event); + +private: + NotificationTimer *m_timer; + + QPixmap m_pixmap; + + NotificationActionsWidget *m_actionWidget; + + // mandatory for stylesheets + void paintEvent(QPaintEvent *); + QPixmap getPixmapFromHint(const QVariant &argument) const; + QPixmap getPixmapFromString(const QString &str) const; + +private slots: + void closeButton_clicked(); +}; + + +/*! A timer with pause/resume functionality + * + */ +class NotificationTimer : public QTimer +{ + Q_OBJECT +public: + NotificationTimer(QObject *parent=0); + +public slots: + void start(int msec); + void pause(); + void resume(); + +private: + QDateTime m_startTime; + qint64 m_intervalMsec; +}; + +#endif // NOTIFICATION_H diff --git a/src/notification.ui b/src/notification.ui new file mode 100644 index 0000000..f67c952 --- /dev/null +++ b/src/notification.ui @@ -0,0 +1,163 @@ + + + Notification + + + + 0 + 0 + 209 + 77 + + + + + 9 + + + 11 + + + + + 4 + + + 2 + + + + + + 0 + 0 + + + + + 32 + 32 + + + + + 32 + 32 + + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + 6 + + + + + + 75 + true + + + + TextLabel + + + Qt::RichText + + + false + + + + + + + TextLabel + + + Qt::RichText + + + true + + + + + + + + 0 + 0 + + + + TextLabel + + + Qt::RichText + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + true + + + + + + + + + + + x + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + diff --git a/src/notificationarea.cpp b/src/notificationarea.cpp new file mode 100644 index 0000000..7314e64 --- /dev/null +++ b/src/notificationarea.cpp @@ -0,0 +1,128 @@ +/* BEGIN_COMMON_COPYRIGHT_HEADER + * (c)LGPL2+ + * + * LXDE-Qt - a lightweight, Qt based, desktop toolset + * http://razor-qt.org + * + * Copyright: 2012 Razor team + * Authors: + * Petr Vanek + * + * This program or library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 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 + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * END_COMMON_COPYRIGHT_HEADER */ + +#include +#include +#include +#include "notificationarea.h" + + +NotificationArea::NotificationArea(QWidget *parent) + : QScrollArea(parent), + m_spacing(-1) +{ + setObjectName("NotificationArea"); + + setWindowFlags(Qt::X11BypassWindowManagerHint + | Qt::FramelessWindowHint + | Qt::WindowStaysOnTopHint); + // Hack to ensure the fully transparent QGraphicsView background + QPalette palette; + palette.setBrush(QPalette::Base, Qt::NoBrush); + setPalette(palette); + // Required to display wallpaper + setAttribute(Qt::WA_TranslucentBackground); + // no border at all finally + setFrameShape(QFrame::NoFrame); + + m_layout = new NotificationLayout(this); + setWidget(m_layout); + + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + + connect(m_layout, SIGNAL(allNotificationsClosed()), this, SLOT(close())); + connect(m_layout, SIGNAL(notificationAvailable()), this, SLOT(show())); + connect(m_layout, SIGNAL(heightChanged(int)), this, SLOT(setHeight(int))); + connect(qApp->desktop(), SIGNAL(workAreaResized(int)), SLOT(setHeight())); +} + +void NotificationArea::setHeight(int contentHeight) +{ + if (contentHeight == 0) + { + resize(width(), 0); + hide(); + return; + } + + if (contentHeight == -1) + contentHeight = height(); + + // FIXME: Qt does not seem to update QDesktopWidget::primaryScreen(). + // After we change the primary screen with xrandr, Qt still returns the same value. + // I think it's a bug of Qt. + QRect workArea = qApp->desktop()->availableGeometry(qApp->desktop()->primaryScreen()); + + int h = workArea.height(); + int safeHeight = contentHeight > h ? h : contentHeight; + int x, y; + + if (m_placement == "bottom-right") + { + x = workArea.right() - width() - m_spacing; + y = workArea.bottom() - safeHeight - m_spacing; + } + else if (m_placement == "bottom-left") + { + x = workArea.x() + m_spacing; + y = workArea.bottom() - safeHeight - m_spacing; + } + else if (m_placement == "top-right") + { + x = workArea.right() - width() - m_spacing; + y = workArea.y() + m_spacing; + } + else if (m_placement == "top-left") + { + x = workArea.x() + m_spacing; + y = workArea.y() + m_spacing; + } + else + { + x = workArea.right() - width() - m_spacing; + y = workArea.bottom() - safeHeight; + } + + move(x, y); + resize(width(), safeHeight); + // always show the latest notification + ensureVisible(0, contentHeight, 0, 0); +} + +void NotificationArea::setSettings(const QString &placement, int width, int spacing) +{ + m_placement = placement; + + setMaximumWidth(width); + setMinimumWidth(width); + + m_spacing = spacing; + m_layout->setSizes(m_spacing, width); + + this->setHeight(widget()->height()); +} diff --git a/src/notificationarea.h b/src/notificationarea.h new file mode 100644 index 0000000..8912939 --- /dev/null +++ b/src/notificationarea.h @@ -0,0 +1,70 @@ +/* BEGIN_COMMON_COPYRIGHT_HEADER + * (c)LGPL2+ + * + * LXDE-Qt - a lightweight, Qt based, desktop toolset + * http://razor-qt.org + * + * Copyright: 2012 Razor team + * Authors: + * Petr Vanek + * + * This program or library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 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 + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * END_COMMON_COPYRIGHT_HEADER */ + +#ifndef NOTIFICATIONAREA_H +#define NOTIFICATIONAREA_H + +#include +#include "notificationlayout.h" + + +/*! Top level widget. Scroll area is used to ensure access + * of all \c Notification instances (scrollable with mouse). + */ +class NotificationArea : public QScrollArea +{ + Q_OBJECT +public: + + explicit NotificationArea(QWidget *parent = 0); + + /*! An access to \c NotificationLayout to connect signals and slots in \c Notifyd + */ + NotificationLayout* layout() { return m_layout; } + + /*! Set new settings value from \c Notifyd. There are only one settings + * used - in \c Notifyd. + * \param placement a string name for notification location "top-level" etc. + * \param width set with of notifications + * \param spacing a spacing in the \NotificationLayout + */ + void setSettings(const QString &placement, int width, int spacing); + +private: + NotificationLayout *m_layout; + + QString m_placement; + int m_spacing; + +private slots: + /*! Recalculate widget size and visibility. Slot is called from \c Notificationlayout + * on demand (notification appear or is closed). + */ + void setHeight(int contentHeight = -1); +}; + +#endif // NOTIFICATIONAREA_H diff --git a/src/notificationlayout.cpp b/src/notificationlayout.cpp new file mode 100644 index 0000000..63f9efb --- /dev/null +++ b/src/notificationlayout.cpp @@ -0,0 +1,200 @@ +/* BEGIN_COMMON_COPYRIGHT_HEADER + * (c)LGPL2+ + * + * LXDE-Qt - a lightweight, Qt based, desktop toolset + * http://razor-qt.org + * + * Copyright: 2012 Razor team + * Authors: + * Petr Vanek + * + * This program or library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 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 + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * END_COMMON_COPYRIGHT_HEADER */ + +#include "notificationlayout.h" +#include +#include + + +NotificationLayout::NotificationLayout(QWidget *parent) + : QWidget(parent) +{ + setObjectName("NotificationLayout"); + + // Hack to ensure the fully transparent background + QPalette palette; + palette.setBrush(QPalette::Base, Qt::NoBrush); + setPalette(palette); + // Required to display wallpaper + setAttribute(Qt::WA_TranslucentBackground); + + // Make the window stay on top + setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint); + + m_layout = new QVBoxLayout(this); + m_layout->setMargin(0); + setLayout(m_layout); +} + +void NotificationLayout::setSizes(int space, int width) +{ + m_layout->setSpacing(space); + setMaximumWidth(width); + setMinimumWidth(width); + + QHashIterator it(m_notifications); + while (it.hasNext()) + { + it.next(); + it.value()->setMinimumWidth(width); + it.value()->setMaximumWidth(width); + } +} + +void NotificationLayout::addNotification(uint id, const QString &application, + const QString &summary, const QString &body, + const QString &icon, int timeout, + const QStringList& actions, const QVariantMap& hints) +{ +// qDebug() << "NotificationLayout::addNotification" << id << application << summary << body << icon << timeout; + if (m_notifications.contains(id)) + { + // TODO/FIXME: it can be deleted by timer in this block. Locking? + Notification *n = m_notifications[id]; + n->setValues(application, summary, body, icon, timeout, actions, hints); + } + else + { + Notification *n = new Notification(application, summary, body, icon, timeout, actions, hints, this); + + // NOTE: it's hard to use == operator for Notification* in QList... + QHashIterator it(m_notifications); + while (it.hasNext()) + { + it.next(); + if (it.value()->application() == application + && it.value()->summary() == summary + && it.value()->body() == body) + { + qDebug() << "Notification app" << application << "summary" << summary << "is already registered but this request is not an update. Broken app?"; + delete n; + return; + } + } + + connect(n, SIGNAL(timeout()), this, SLOT(removeNotificationTimeout())); + connect(n, SIGNAL(userCanceled()), this, SLOT(removeNotificationUser())); + connect(n, SIGNAL(actionTriggered(QString)), + this, SLOT(notificationActionCalled(QString))); + m_notifications[id] = n; + m_layout->addWidget(n); + n->show(); + } + + checkHeight(); + emit notificationAvailable(); + + // NOTE by pcman: + // This dirty hack is used to workaround a weird and annoying repainting bug caused by Qt. + // See https://github.com/Razor-qt/razor-qt/issues/536 + // razot-qt bug #536 - Notifications do not repaint under certain conditions + // When we create the first notification and are about to show the widget, force repaint() here. + // FIXME: there should be better ways to do this, or it should be fixed in Qt instead. + if(m_notifications.count() == 1) + repaint(); +} + +void NotificationLayout::removeNotificationTimeout() +{ + Notification *n = qobject_cast(sender()); + if (!n) + { + qDebug() << "Oooook! TIMEOUT Expecting instance of notification, got:" << sender(); + return; + } + + removeNotification(m_notifications.key(n), 1); +} + +void NotificationLayout::removeNotificationUser() +{ + Notification *n = qobject_cast(sender()); + if (!n) + { + qDebug() << "Oooook! USERCANCEL Expecting instance of notification, got:" << sender(); + return; + } + + removeNotification(m_notifications.key(n), 2); +} + +void NotificationLayout::removeNotification(uint key, uint reason) +{ + Notification *n = m_notifications.take(key); + if (!n) + { + qDebug() << "Oooook! Expecting instance of notification, got:" << key; + return; + } + + int ix = m_layout->indexOf(n); + if (ix == -1) + { + qDebug() << "Qooook! Widget not in layout. Impossible!" << n; + return; + } + + delete m_layout->takeAt(ix); + n->deleteLater(); + emit notificationClosed(key, reason); + + if (m_notifications.count() == 0) + emit allNotificationsClosed(); + + checkHeight(); +} + +void NotificationLayout::notificationActionCalled(const QString &actionKey) +{ + Notification *n = qobject_cast(sender()); + if (!n) + { + qDebug() << "Oooook! USERACTION Expecting instance of notification, got:" << sender(); + return; + } + + emit actionInvoked(m_notifications.key(n), actionKey); +} + +void NotificationLayout::checkHeight() +{ + int h = 0; + QHashIterator it(m_notifications); + while (it.hasNext()) + { + it.next(); + // *2 is mandatory here to prevent cropping of widgets + // with enforced small height + h += it.value()->height() + m_layout->spacing() * 2; + } + + setMinimumSize(width(), h); + setMaximumSize(width(), h); + + emit heightChanged(h); +} + diff --git a/src/notificationlayout.h b/src/notificationlayout.h new file mode 100644 index 0000000..0f4c577 --- /dev/null +++ b/src/notificationlayout.h @@ -0,0 +1,104 @@ +/* BEGIN_COMMON_COPYRIGHT_HEADER + * (c)LGPL2+ + * + * LXDE-Qt - a lightweight, Qt based, desktop toolset + * http://razor-qt.org + * + * Copyright: 2012 Razor team + * Authors: + * Petr Vanek + * + * This program or library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 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 + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * END_COMMON_COPYRIGHT_HEADER */ + +#ifndef NotificationLayout_H +#define NotificationLayout_H + +#include "notification.h" + + +class NotificationLayout : public QWidget +{ + Q_OBJECT +public: + explicit NotificationLayout(QWidget *parent); + + /*! Set various properties for self and child \c Notification instances. + * \param space a layout spacing + * \param width new width for notifications + */ + void setSizes(int space, int width); + +signals: + //! All \c Notification instances are closed + void allNotificationsClosed(); + //! At least one \c Notification instance is available and needs to be shown + void notificationAvailable(); + //! Height of this widget changed so parent's \c NotificationArea needs to change its size too. + void heightChanged(int); + + /*! Promote the internal change of notification closing into the \c Notifyd + * \param id an notification ID (obtained from \c Notify) + * \param reason a reason for closing code. See specification for more info. + */ + void notificationClosed(uint id, uint reason); + + /*! Inform the external application that user chose one of provided action via the \c Notifyd + * \param in0 a notification ID (obtained from \c Notify) + * \param in1 a selected action key from the (key - display value) pair + */ + void actionInvoked(uint id, const QString &actionKey); + +public slots: + /*! Add new notification + * See \c Notifyd::Notify() for params meanings. + */ + void addNotification(uint id, const QString &application, + const QString &summary, const QString &body, + const QString &icon, int timeout, + const QStringList& actions, const QVariantMap& hints); + + /*! Notification id should be removed because of reason + */ + void removeNotification(uint id, uint reason); + +private: + QHash m_notifications; + QVBoxLayout *m_layout; + + /*! Calculate required height based on height of each \c Notification + * in the m_notifications map. + * Also heightChanged() is emitted here. + */ + void checkHeight(); + +private slots: + /*! \c Notification's timer timeouted, so closing the notifiaction + */ + void removeNotificationTimeout(); + + /*! \c User cancelled the notifiation manually + */ + void removeNotificationUser(); + + /*! User clicked on one of actions (if provioded). + * \param actionKey an action's key (not the display value) + */ + void notificationActionCalled(const QString &actionKey); +}; + +#endif // NotificationLayout_H diff --git a/src/notificationwidgets.cpp b/src/notificationwidgets.cpp new file mode 100644 index 0000000..418a9e8 --- /dev/null +++ b/src/notificationwidgets.cpp @@ -0,0 +1,134 @@ +/* BEGIN_COMMON_COPYRIGHT_HEADER + * (c)LGPL2+ + * + * LXDE-Qt - a lightweight, Qt based, desktop toolset + * http://razor-qt.org + * + * Copyright: 2012 Razor team + * Authors: + * Petr Vanek + * + * This program or library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 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 + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * END_COMMON_COPYRIGHT_HEADER */ + +#include +#include +#include +#include +#include + +#include "notificationwidgets.h" + +#include + + +NotificationActionsWidget::NotificationActionsWidget(const QStringList& actions, QWidget *parent) + : QWidget(parent) +{ + for (int i = 0; i < actions.count(); ++i) + { + if (i == actions.count()-1) + { + qDebug() << "NotificationActionsWidget actions has contains pairs (id, value, id, value...) got odd count:" << actions.count() << "Actions:" << actions; + m_actionMap[actions.at(i)] = actions.at(i); + } + else + { + m_actionMap[actions.at(i)] = actions.at(i+1); + } + ++i; // move to the next ID + } + + // if there is only one action let's take it as a default one + if (m_actionMap.count() == 1) + m_defaultAction = m_actionMap[m_actionMap.keys().at(0)]; + + qDebug() << "NotificationActionsWidget processed actions:" << m_actionMap; +} + + +NotificationActionsButtonsWidget::NotificationActionsButtonsWidget(const QStringList& actions, QWidget *parent) + : NotificationActionsWidget(actions, parent) +{ + QHashIterator it(m_actionMap); + QHBoxLayout *l = new QHBoxLayout(); + setLayout(l); + + QButtonGroup *group = new QButtonGroup(this); + + while (it.hasNext()) + { + it.next(); + QPushButton *b = new QPushButton(it.value(), this); + l->addWidget(b); + group->addButton(b); + if (it.key() == "default") + { + b->setFocus(Qt::OtherFocusReason); + m_defaultAction = it.key(); + } + } + connect(group, SIGNAL(buttonClicked(QAbstractButton*)), + this, SLOT(actionButtonActivated(QAbstractButton*))); +} + +void NotificationActionsButtonsWidget::actionButtonActivated(QAbstractButton* button) +{ + emit actionTriggered(m_actionMap.key(button->text())); +} + + +NotificationActionsComboWidget::NotificationActionsComboWidget(const QStringList& actions, QWidget *parent) + : NotificationActionsWidget(actions, parent) +{ + QHashIterator it(m_actionMap); + QHBoxLayout *l = new QHBoxLayout(); + setLayout(l); + + l->addWidget(new QLabel(tr("Actions:"), this)); + m_comboBox = new QComboBox(this); + int currentIndex = -1; + while (it.hasNext()) + { + it.next(); + m_comboBox->addItem(it.value(), it.key()); + if (it.key() == "default") + { + currentIndex = m_comboBox->count()-1; + m_defaultAction = it.key(); + } + } + l->addWidget(m_comboBox); + + if (currentIndex != -1) + m_comboBox->setCurrentIndex(currentIndex); + + QPushButton *b = new QPushButton(tr("OK"), this); + l->addWidget(b); + connect(b, SIGNAL(clicked()), + this, SLOT(actionComboBoxActivated())); +} + +void NotificationActionsComboWidget::actionComboBoxActivated() +{ + if (!m_comboBox) + return; + int ix = m_comboBox->currentIndex(); + if (ix == -1) + return; + emit actionTriggered(m_actionMap.key(m_comboBox->itemText(ix))); +} diff --git a/src/notificationwidgets.h b/src/notificationwidgets.h new file mode 100644 index 0000000..4673b47 --- /dev/null +++ b/src/notificationwidgets.h @@ -0,0 +1,102 @@ +/* BEGIN_COMMON_COPYRIGHT_HEADER + * (c)LGPL2+ + * + * LXDE-Qt - a lightweight, Qt based, desktop toolset + * http://razor-qt.org + * + * Copyright: 2012 Razor team + * Authors: + * Petr Vanek + * + * This program or library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 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 + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * END_COMMON_COPYRIGHT_HEADER */ + +#ifndef NOTIFICATIONWIDGETS_H +#define NOTIFICATIONWIDGETS_H + +#include +#include +#include + +class QComboBox; + + +/*! A helper widgets for actions handling. + * See specification for information what actions are. + * + * Let's be a little bit tricky here. Let's allow only few + * buttons in the layout. We will use a combobox if there + * are more actions. I think it's more user friendly. + * + * If there are only few actions the layout with buttons is used. + * If there are more actions the combo box with confirm button is created. + */ +class NotificationActionsWidget : public QWidget +{ + Q_OBJECT + +public: + NotificationActionsWidget(const QStringList& actions, QWidget *parent); + + //! Notification holds exactly one action or at least one action is marked as "default" + bool hasDefaultAction() { return !m_defaultAction.isEmpty(); } + //! The key for default action + QString defaultAction() { return m_defaultAction; } + +signals: + /*! User clicks/chose an actio + * \param actionKey a key of selected action + */ + void actionTriggered(const QString &actionKey); + +protected: + QString m_defaultAction; + QHash m_actionMap; +}; + +class NotificationActionsButtonsWidget : public NotificationActionsWidget +{ + Q_OBJECT + +public: + /*! Create new widget. + * \param actions a list of actions in form: (key1, display1, key2, display2, ..., keyN, displayN) + */ + NotificationActionsButtonsWidget(const QStringList& actions, QWidget *parent); +private slots: + void actionButtonActivated(QAbstractButton* button); +}; + +class NotificationActionsComboWidget : public NotificationActionsWidget +{ + Q_OBJECT + +public: + /*! Create new widget. + * \param actions a list of actions in form: (key1, display1, key2, display2, ..., keyN, displayN) + */ + NotificationActionsComboWidget(const QStringList& actions, QWidget *parent); + +private: + QComboBox *m_comboBox; + +private slots: + void actionComboBoxActivated(); +}; + + +#endif diff --git a/src/notifyd.cpp b/src/notifyd.cpp new file mode 100644 index 0000000..ef0312c --- /dev/null +++ b/src/notifyd.cpp @@ -0,0 +1,148 @@ +/* BEGIN_COMMON_COPYRIGHT_HEADER + * (c)LGPL2+ + * + * LXQt - a lightweight, Qt based, desktop toolset + * http://lxqt.org + * + * Copyright: 2012 Razor team + * Authors: + * Alec Moskvin + * Petr Vanek + * + * This program or library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 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 + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * END_COMMON_COPYRIGHT_HEADER */ + +#include "notifyd.h" + +#include + + +/* + * Implementation of class Notifyd + */ + +Notifyd::Notifyd(QObject* parent) + : QObject(parent), + mId(0) +{ + m_area = new NotificationArea(); + m_settings = new LxQt::Settings("notifications"); + reloadSettings(); + + connect(this, SIGNAL(notificationAdded(uint,QString,QString,QString,QString,int,QStringList,QVariantMap)), + m_area->layout(), SLOT(addNotification(uint,QString,QString,QString,QString,int,QStringList,QVariantMap))); + connect(this, SIGNAL(notificationClosed(uint, uint)), + m_area->layout(), SLOT(removeNotification(uint, uint))); + // feedback for original caller + connect(m_area->layout(), SIGNAL(notificationClosed(uint,uint)), + this, SIGNAL(NotificationClosed(uint,uint))); + connect(m_area->layout(), SIGNAL(actionInvoked(uint, QString)), + this, SIGNAL(ActionInvoked(uint,QString))); + + connect(m_settings, SIGNAL(settingsChanged()), + this, SLOT(reloadSettings())); + +} + +Notifyd::~Notifyd() +{ + m_area->deleteLater(); +} + +void Notifyd::CloseNotification(uint id) +{ + emit notificationClosed(id, 3); +} + +QStringList Notifyd::GetCapabilities() +{ + QStringList caps; + caps + << "actions" + // << "action-icons" + << "body" + << "body-hyperlinks" + << "body-images" + << "body-markup" + // << "icon-multi" + // << "icon-static" + << "persistence" + // << "sound" + ; + return caps; +} + +QString Notifyd::GetServerInformation(QString& vendor, + QString& version, + QString& spec_version) +{ + spec_version = QString("1.2"); + version = QString(LXQT_VERSION); + vendor = QString("lxqt.org"); + return QString("lxqt-notificationd"); +} + +uint Notifyd::Notify(const QString& app_name, + uint replaces_id, + const QString& app_icon, + const QString& summary, + const QString& body, + const QStringList& actions, + const QVariantMap& hints, + int expire_timeout + ) +{ + uint ret; + if (replaces_id == 0) + { + mId++; + ret = mId; + } + else + ret = replaces_id; +#if 0 + qDebug() << QString("Notify(\n" + " app_name = %1\n" + " replaces_id = %2\n" + " app_icon = %3\n" + " summary = %4\n" + " body = %5\n" + ).arg(app_name, QString::number(replaces_id), app_icon, summary, body) + << " actions =" << actions << endl + << " hints =" << hints << endl + << QString(" expire_timeout = %1\n) => %2").arg(QString::number(expire_timeout), QString::number(mId)); +#endif + + // handling the "server decides" timeout + if (expire_timeout == -1) { + expire_timeout = m_serverTimeout; + expire_timeout *= 1000; + } + + emit notificationAdded(ret, app_name, summary, body, app_icon, expire_timeout, actions, hints); + + return ret; +} + +void Notifyd::reloadSettings() +{ + m_serverTimeout = m_settings->value("server_decides", 10).toInt(); + m_area->setSettings( + m_settings->value("placement", "bottom-right").toString().toLower(), + m_settings->value("width", 300).toInt(), + m_settings->value("spacing", 6).toInt()); +} diff --git a/src/notifyd.h b/src/notifyd.h new file mode 100644 index 0000000..353eeb4 --- /dev/null +++ b/src/notifyd.h @@ -0,0 +1,138 @@ +/* BEGIN_COMMON_COPYRIGHT_HEADER + * (c)LGPL2+ + * + * LXDE-Qt - a lightweight, Qt based, desktop toolset + * http://razor-qt.org + * + * Copyright: 2012 Razor team + * Authors: + * Alec Moskvin + * Petr Vanek + * + * This program or library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 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 + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * END_COMMON_COPYRIGHT_HEADER */ + +#ifndef NOTIFYD_H +#define NOTIFYD_H + +#include +#include +#include +#include + +#include "notificationarea.h" +#include + +/* + * Class for interface org.freedesktop.Notifications + */ +class Notifyd: public QObject +{ + Q_OBJECT + +public: + explicit Notifyd(QObject* parent = 0); + virtual ~Notifyd(); + +public slots: + + /*! External application requested to close one notification + * \param id an id obtained by previous \c Notify() call + */ + void CloseNotification(uint id); + + /*! List supported features as required by specification + * \retval QStringList with features. + */ + QStringList GetCapabilities(); + + /*! Provide a server/deamon info about version etc. + * \param vendor outbound string. It's filled with lxde-qt credits + * \param version outbound string. lxde-qt DE version is used (from CMakeLists.txt) + * \param spec_version outbound string. Currently used specification version. + * \retval QString daemon binary name + */ + QString GetServerInformation(QString& vendor, QString& version, QString& spec_version); + + /*! Daemon is requested to display the notification. + * \retval uint an unique notification ID. It should be used for tracking action feedback. + * \param app_name name of the calling application + * \param replaces_id if it's provided (!= 0) the already posted notification is "replaced" + * or updated with new content. + * \param app_icon an icon to show. See specification for more info. + * \param summary an overview text + * \param body a notification body + * \param actions User selectable action list. See specification for more info. + * \param hints Notification hints. See specification for more info. + * \param expire_timeout how long should be this notification displayed (-1 = server decides; 0 forever; >0timeout in milliseconds) + */ + uint Notify(const QString& app_name, + uint replaces_id, + const QString& app_icon, + const QString& summary, + const QString& body, + const QStringList& actions, + const QVariantMap& hints, + int expire_timeout); + +signals: + // signals for DBUS API specs - going outside + + /*! Inform the external application that user chose one of provided action + * \param in0 a notification ID (obtained from \c Notify) + * \param in1 a selected action key from the (key - display value) pair + */ + void ActionInvoked(uint in0, const QString& in1); + /*! Inform the external application that notification has been closed. + * \param in0 a notification ID (obtained from \c Notify) + * \param in1 a closing reason. See specification for more info. + * + * + 1 - The notification expired. + 2 - The notification was dismissed by the user. + 3 - The notification was closed by a call to CloseNotification. + 4 - Undefined/reserved reasons. + */ + void NotificationClosed(uint in0, uint in1); + + // singals for our implementation - internal usage + + /*! Promote the external request for notification closing into the display engine. + * \param id an notification ID (obtained from \c Notify) + * \param reason a reason for closing code. See specification for more info. + */ + void notificationClosed(uint id, uint reason); + + /*! Promote the external request for notification displaying into the engine. + * Parameters are the same as in \c Notify() slot. + */ + void notificationAdded(uint id, const QString &application, const QString &title, + const QString &description, const QString &icon, + int timeout, const QStringList& actions, const QVariantMap& hints); + +private: + uint mId; + NotificationArea *m_area; + int m_serverTimeout; + + LxQt::Settings *m_settings; + +private slots: + void reloadSettings(); +}; + +#endif // NOTIFYD_H diff --git a/src/org.freedesktop.Notifications.xml b/src/org.freedesktop.Notifications.xml new file mode 100644 index 0000000..5cf538e --- /dev/null +++ b/src/org.freedesktop.Notifications.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/translations/lxqt-notificationd.ts b/src/translations/lxqt-notificationd.ts new file mode 100644 index 0000000..93eb244 --- /dev/null +++ b/src/translations/lxqt-notificationd.ts @@ -0,0 +1,15 @@ + + + + + NotificationActionsComboWidget + + Actions: + + + + OK + + + + diff --git a/src/translations/lxqt-notificationd_pt.ts b/src/translations/lxqt-notificationd_pt.ts new file mode 100644 index 0000000..75103ec --- /dev/null +++ b/src/translations/lxqt-notificationd_pt.ts @@ -0,0 +1,15 @@ + + + + + NotificationActionsComboWidget + + Actions: + Ações: + + + OK + OK + + + diff --git a/src/translations/lxqt-notificationd_ru.ts b/src/translations/lxqt-notificationd_ru.ts new file mode 100644 index 0000000..855e405 --- /dev/null +++ b/src/translations/lxqt-notificationd_ru.ts @@ -0,0 +1,17 @@ + + + + + NotificationActionsComboWidget + + + Actions: + Действия: + + + + OK + OK + + + diff --git a/src/translations/lxqt-notificationd_ru_RU.ts b/src/translations/lxqt-notificationd_ru_RU.ts new file mode 100644 index 0000000..4fd718d --- /dev/null +++ b/src/translations/lxqt-notificationd_ru_RU.ts @@ -0,0 +1,17 @@ + + + + + NotificationActionsComboWidget + + + Actions: + Действия: + + + + OK + OK + + + diff --git a/test/NotifyTest.pro b/test/NotifyTest.pro new file mode 100644 index 0000000..9a5b8a3 --- /dev/null +++ b/test/NotifyTest.pro @@ -0,0 +1,20 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2012-06-05T22:26:57 +# +#------------------------------------------------- + +QT += core gui dbus + +TARGET = NotifyTest +TEMPLATE = app +INCLUDEPATH += ../../libraries/ + +SOURCES += main.cpp \ + mainwindow.cpp + +HEADERS += mainwindow.h + +FORMS += mainwindow.ui + +LIBS += -llxqt diff --git a/test/lxqt-notification-test-multiples.sh b/test/lxqt-notification-test-multiples.sh new file mode 100755 index 0000000..66711fb --- /dev/null +++ b/test/lxqt-notification-test-multiples.sh @@ -0,0 +1,12 @@ +#!/bin/sh +# +# required: notify-send app installed (part of libnotify, or libnotify-tools) +# + + +# basic notifications +notify-send -u low -t 3000 --icon="document-open" "simple notification" "expires in 3s. No action there" & +notify-send -u normal -t 4000 --icon="document-close" "simple notification" "expires in 4s. No action there" & +notify-send -u low -t 3000 --icon="document-open" "simple notification" "expires in 3s. No action there" & +notify-send -u low -t 3000 --icon="document-open" "simple notification" "expires in 3s. No action there" & + diff --git a/test/lxqt-notification-test.sh b/test/lxqt-notification-test.sh new file mode 100755 index 0000000..d260938 --- /dev/null +++ b/test/lxqt-notification-test.sh @@ -0,0 +1,15 @@ +#!/bin/sh +# +# required: notify-send app installed (part of libnotify, or libnotify-tools) +# + + +# basic notifications +notify-send -u low -t 3000 --icon="document-open" "simple notification" "expires in 3s. No action there" & +notify-send -u normal -t 4000 --icon="document-close" "simple notification" "expires in 4s. No action there" & +notify-send -u critical -t 5000 --icon="application-exit" "simple notification" "expires in 5s. No action there" & +notify-send -u normal -t -1 --icon="go-next" "simple notification" "expires when server decies. No action there" & +notify-send -u normal -t 0 --icon="go-up" "simple notification" "never expires. No action there" & + +notify-send -u low -t 3000 --icon="document-open" "simple notification with a very long text inside it" "expires in 3s. No action there. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras vel leo quam. Morbi sit amet lorem vel dui commodo porttitor nec ut libero. Maecenas risus mauris, faucibus id tempus eu, auctor id purus. Vestibulum eget sapien non sem fermentum fermentum id sed turpis. Morbi pretium sem at turpis faucibus facilisis vel lacinia ante. Quisque a turpis lectus, quis posuere magna. Etiam magna velit, sagittis sed tincidunt et, adipiscing rutrum est. Aliquam aliquam aliquet tortor non varius. Quisque sollicitudin, ligula ac pulvinar laoreet, lacus metus sagittis nulla, ac sodales felis diam sed urna. In hac habitasse platea dictumst. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas." & + diff --git a/test/main.cpp b/test/main.cpp new file mode 100644 index 0000000..950cf04 --- /dev/null +++ b/test/main.cpp @@ -0,0 +1,35 @@ +/* BEGIN_COMMON_COPYRIGHT_HEADER + * (c)LGPL2+ + * + * LXDE-Qt - a lightweight, Qt based, desktop toolset + * http://razor-qt.org + * + * Copyright (C) 2012 Alec Moskvin + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 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 + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * END_COMMON_COPYRIGHT_HEADER */ + +#include +#include +#include "mainwindow.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + return a.exec(); +} diff --git a/test/mainwindow.cpp b/test/mainwindow.cpp new file mode 100644 index 0000000..ac89baf --- /dev/null +++ b/test/mainwindow.cpp @@ -0,0 +1,73 @@ +/* BEGIN_COMMON_COPYRIGHT_HEADER + * (c)LGPL2+ + * + * LXDE-Qt - a lightweight, Qt based, desktop toolset + * http://razor-qt.org + * + * Copyright (C) 2012 Alec Moskvin + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 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 + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * END_COMMON_COPYRIGHT_HEADER */ + +#include "mainwindow.h" +#include "ui_mainwindow.h" +#include +#include + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); + connect(ui->pushButton, SIGNAL(clicked()), SLOT(createNotification())); + LxQtNotification::notify("1"); + LxQtNotification::notify("2"); + LxQtNotification::notify("3"); +} + +void MainWindow::createNotification() +{ + LxQtNotification* n = new LxQtNotification("Notification!"); + nlist.append(n); + connect(n, SIGNAL(actionActivated(int)), this, SLOT(clickEvent(int))); + n->setActions(QStringList() << "Hi" << "Bye" << "foo" << "bar" << "lorem" << "ipsum", 1); + n->setIcon("preferences-desktop-launch-feedback"); + n->update(); +} + +void MainWindow::clickEvent(int button) +{ + LxQtNotification* n = qobject_cast(sender()); + if (n) + { + if (button == 0) + { + n->setBody("Hello!"); + } + else + { + n->setBody("Closing..."); + n->setTimeout(1000); + } + n->update(); + } +} + +MainWindow::~MainWindow() +{ + delete ui; + qDeleteAll(nlist); +} diff --git a/test/mainwindow.h b/test/mainwindow.h new file mode 100644 index 0000000..5f7f596 --- /dev/null +++ b/test/mainwindow.h @@ -0,0 +1,53 @@ +/* BEGIN_COMMON_COPYRIGHT_HEADER + * (c)LGPL2+ + * + * LXDE-Qt - a lightweight, Qt based, desktop toolset + * http://razor-qt.org + * + * Copyright (C) 2012 Alec Moskvin + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 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 + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * END_COMMON_COPYRIGHT_HEADER */ + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +class LxQtNotification; + +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget* parent = 0); + ~MainWindow(); + +public slots: + void createNotification(); + void clickEvent(int button); + +private: + Ui::MainWindow* ui; + QList nlist; +}; + +#endif // MAINWINDOW_H diff --git a/test/mainwindow.ui b/test/mainwindow.ui new file mode 100644 index 0000000..1f573d7 --- /dev/null +++ b/test/mainwindow.ui @@ -0,0 +1,76 @@ + + + MainWindow + + + + 0 + 0 + 400 + 300 + + + + MainWindow + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + PushButton + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 0 + 0 + 400 + 23 + + + + + + TopToolBarArea + + + false + + + + + + + +