├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── COPYING ├── IQButton.qml ├── IQExpirationBar.qml ├── IQExtraNotifications.qml ├── IQFancyContainer.qml ├── IQHistoryNotification.qml ├── IQHistoryWindow.qml ├── IQNotification.qml ├── IQNotificationBar.qml ├── IQNotificationContainer.qml ├── IQPopup.qml ├── README.md ├── X11-plugin ├── CMakeLists.txt ├── x11fullscreendetector.cpp ├── x11fullscreendetector.h ├── x11fullscreendetectorprivate.cpp └── x11fullscreendetectorprivate.h ├── config.example ├── dbusnotification.h ├── etc ├── .lint.swp ├── format └── lint ├── img ├── close.png ├── closeAll.png ├── closeVisible.png └── warning.png ├── iq-notifier.desktop ├── iq-notifier.spec ├── iqconfig.cpp ├── iqconfig.h ├── iqdbusservice.cpp ├── iqdbusservice.h ├── iqdisposition.cpp ├── iqdisposition.h ├── iqexpirationcontroller.cpp ├── iqexpirationcontroller.h ├── iqfullscreendetector.h ├── iqhistory.cpp ├── iqhistory.h ├── iqnotification.cpp ├── iqnotification.h ├── iqnotificationmodifiers.cpp ├── iqnotificationmodifiers.h ├── iqnotificationreceiver.cpp ├── iqnotificationreceiver.h ├── iqnotifications.cpp ├── iqnotifications.h ├── iqthemes.cpp ├── iqthemes.h ├── iqtopdown.cpp ├── iqtopdown.h ├── iqtrayicon.cpp ├── iqtrayicon.h ├── main.cpp ├── main.qml ├── org.freedesktop.Notifications.xml ├── packages ├── iq-notifier-0.1.0-amd64.deb ├── iq-notifier-0.1.1-amd64.deb ├── iq-notifier-0.2.0-amd64.deb ├── iq-notifier-0.2.1-amd64.deb ├── iq-notifier-0.3.0-amd64.deb ├── iq-notifier-0.3.1-amd64.deb ├── iq-notifier-0.4.0-amd64.deb └── iq-notifier-0.4.1-amd64.deb ├── qml.qrc ├── screenshots ├── 0.png ├── 1.png ├── 2.png ├── 3.png ├── 4.png └── h_0.png └── themes ├── default ├── close.png ├── closeAll.png ├── closeVisible.png ├── theme └── tray.png └── pony ├── bg.png ├── close.png ├── closeAll.png ├── closeExtra.png ├── closeVisible.png ├── history_bg.png ├── theme └── tray.png /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Compiled Dynamic libraries 12 | *.so 13 | *.dylib 14 | *.dll 15 | 16 | # Fortran module files 17 | *.mod 18 | *.smod 19 | 20 | # Compiled Static libraries 21 | *.lai 22 | *.la 23 | *.a 24 | *.lib 25 | 26 | # Executables 27 | *.exe 28 | *.out 29 | *.app 30 | 31 | build 32 | 33 | *.user* 34 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "GSL"] 2 | path = GSL 3 | url = https://github.com/Microsoft/GSL 4 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | project(iq-notifier) 4 | 5 | set(VERSION_MAJOR 0) 6 | set(VERSION_MINOR 4) 7 | set(VERSION_PATCH 1) 8 | 9 | set(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}") 10 | 11 | add_definitions(-DIQ_VERSION_MAJOR=${VERSION_MAJOR}) 12 | add_definitions(-DIQ_VERSION_MINOR=${VERSION_MINOR}) 13 | add_definitions(-DIQ_VERSION_PATCH=${VERSION_PATCH}) 14 | add_definitions(-DIQ_VERSION=${VERSION}) 15 | add_definitions(-DIQ_APP_NAME=${PROJECT_NAME}) 16 | 17 | set(CMAKE_CXX_STANDARD 14) 18 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") 19 | 20 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 21 | set(CMAKE_AUTOMOC ON) 22 | set(CMAKE_AUTORCC ON) 23 | 24 | find_package(Qt5Qml) 25 | find_package(Qt5Quick) 26 | find_package(Qt5DBus) 27 | find_package(QT5XDG) 28 | 29 | include_directories(./GSL/include) 30 | 31 | aux_source_directory(. SRC_LIST) 32 | 33 | qt5_add_dbus_adaptor(SRC_LIST 34 | org.freedesktop.Notifications.xml 35 | iqdbusservice.h IQDBusService 36 | ) 37 | 38 | if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") 39 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weverything \ 40 | -Wno-exit-time-destructors -Wno-global-constructors \ 41 | -Wno-padded -Wno-c++98-compat") 42 | set_source_files_properties(notificationsadaptor.cpp PROPERTIES COMPILE_FLAGS 43 | "-Wno-sign-conversion -Wno-undefined-reinterpret-cast") 44 | else() 45 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-pragmas") 46 | endif() 47 | 48 | set(RESOURCE_FILE qml.qrc) 49 | 50 | add_executable(${PROJECT_NAME} ${SRC_LIST} ${RESOURCE_FILE}) 51 | 52 | target_link_libraries(${PROJECT_NAME} Qt5::Qml) 53 | target_link_libraries(${PROJECT_NAME} Qt5::Quick) 54 | target_link_libraries(${PROJECT_NAME} Qt5::DBus) 55 | target_link_libraries(${PROJECT_NAME} Qt5Xdg) 56 | 57 | if (X11) 58 | add_definitions(-DIQ_X11=1) 59 | add_subdirectory(X11-plugin) 60 | target_link_libraries(${PROJECT_NAME} X11-plugin) 61 | endif() # X11 62 | 63 | install(TARGETS ${PROJECT_NAME} DESTINATION bin) 64 | install(FILES "${CMAKE_SOURCE_DIR}/config.example" DESTINATION share/${PROJECT_NAME}) 65 | install(DIRECTORY "${CMAKE_SOURCE_DIR}/themes" DESTINATION share/${PROJECT_NAME}) 66 | 67 | ### CPack 68 | 69 | set(CPACK_GENERATOR "DEB") 70 | 71 | set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "IQ Notifier") 72 | set(CPACK_PACKAGE_VENDOR "Viktor Filinkov") 73 | set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING") 74 | set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR}) 75 | set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR}) 76 | set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH}) 77 | set(CPACK_STRIP_FILES TRUE) 78 | set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64") 79 | set(CPACK_PACKAGE_EXECUTABLES "${PROJECT_NAME};IQ Notifier") 80 | set(CPACK_PACKAGE_FILE_NAME ${PROJECT_NAME}-${VERSION}-${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}) 81 | 82 | set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt5network5 (>=5.5), libqt5dbus5 (>=5.5), libqt5gui5 (>=5.5), libqt5core5a (>=5.5), libqt5qml5 (>=5.5), libqt5quick5 (>=5.5), libqt5xdg1 (>=1.3)") 83 | set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Viktor Filinkov ") 84 | set(CPACK_DEBIAN_PACKAGE_SECTION "x11") 85 | 86 | include(CPack) 87 | 88 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /IQButton.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | import QtQuick 2.5 19 | 20 | Rectangle { 21 | id: root 22 | radius: height/5 23 | height: 64 24 | width: 128 25 | 26 | property alias text: buttonText.text 27 | property alias textColor: buttonText.color 28 | 29 | signal clicked() 30 | 31 | Text { 32 | id: buttonText 33 | color: "#ffffff" 34 | font.pointSize: height/4 35 | anchors.fill: parent 36 | wrapMode: Text.WrapAnywhere 37 | verticalAlignment: Text.AlignVCenter 38 | horizontalAlignment: Text.AlignHCenter 39 | } 40 | MouseArea { 41 | id: mouseArea 42 | anchors.fill: parent 43 | onClicked: root.clicked() 44 | hoverEnabled: true 45 | } 46 | states: [ 47 | State { 48 | name: "hovered"; when: mouseArea.containsMouse && !mouseArea.pressed 49 | PropertyChanges { target: root; opacity: 0.9 } 50 | }, 51 | State { 52 | name: "pressed"; when: mouseArea.containsMouse && mouseArea.pressed 53 | PropertyChanges { target: buttonText; opacity: 0.5 } 54 | } 55 | ] 56 | } 57 | -------------------------------------------------------------------------------- /IQExpirationBar.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | import QtQuick 2.5 19 | 20 | Rectangle { 21 | id: root 22 | width: initialWidth 23 | 24 | property bool runnig: false 25 | property int expireTimeout: 0 26 | property int initialWidth: parent.width 27 | 28 | function restart() { 29 | anim.restart(); 30 | } 31 | 32 | visible: runnig 33 | 34 | PropertyAnimation { 35 | id: anim 36 | target: root; property: "width"; from: initialWidth; to: 0 37 | duration: expireTimeout < 0 ? 0 : expireTimeout 38 | running: root.runnig && expireTimeout > 0 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /IQExtraNotifications.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | import QtQuick 2.5 19 | import QtQuick.Window 2.1 20 | import IQNotifier 1.0 21 | 22 | IQPopup { 23 | id: root 24 | visible: IQNotifications.extraNotifications > 0 25 | x: IQNotifications.extraWindowPos.x 26 | y: IQNotifications.extraWindowPos.y 27 | width: IQNotifications.extraWindowSize.width 28 | height: IQNotifications.extraWindowSize.height 29 | 30 | property real buttonImageScale: IQThemes.notificationsTheme.extraButtonImageScale 31 | property real unreadCircleScale: 0.6 32 | property color bgColor: IQThemes.notificationsTheme.extraBgColor 33 | 34 | IQFancyContainer { 35 | id: iQFancyContainer 36 | anchors.fill: parent 37 | Rectangle { 38 | id: bg 39 | color: bgColor 40 | anchors.fill: parent 41 | } 42 | Rectangle { 43 | id: circle 44 | scale: unreadCircleScale 45 | color: IQThemes.notificationsTheme.extraUreadCircleColor 46 | height: parent.height 47 | width: height 48 | radius: width 49 | anchors.verticalCenter: parent.verticalCenter 50 | anchors.left: parent.left 51 | Text { 52 | id: count 53 | color: IQThemes.notificationsTheme.extraUreadTextColor 54 | font.pointSize: parent.height/2.5 55 | text: IQNotifications.extraNotifications 56 | verticalAlignment: Text.AlignVCenter 57 | horizontalAlignment: Text.AlignHCenter 58 | anchors.horizontalCenter: parent.horizontalCenter 59 | anchors.verticalCenter: parent.verticalCenter 60 | } 61 | } 62 | 63 | MouseArea { 64 | id: closeVisible 65 | anchors.top: parent.top 66 | anchors.bottom: parent.bottom 67 | anchors.right: closeExtra.left 68 | height: root.height 69 | anchors.rightMargin: 0 70 | width: height 71 | hoverEnabled: true 72 | Image { 73 | scale: buttonImageScale 74 | anchors.fill: parent 75 | source: IQThemes.notificationsTheme.extraCloseVisibleButtonImage 76 | opacity: parent.containsMouse ? 0.85 : 1 77 | } 78 | onClicked: IQNotifications.onDropVisible() 79 | } 80 | 81 | MouseArea { 82 | id: closeExtra 83 | anchors.top: parent.top 84 | anchors.bottom: parent.bottom 85 | anchors.right: closeAll.left 86 | height: root.height 87 | anchors.rightMargin: 0 88 | width: height 89 | hoverEnabled: true 90 | Image { 91 | scale: buttonImageScale 92 | anchors.fill: parent 93 | source: IQThemes.notificationsTheme.extraCloseButtonImage 94 | opacity: parent.containsMouse ? 0.85 : 1 95 | } 96 | onClicked: IQNotifications.onDropStacked() 97 | } 98 | 99 | MouseArea { 100 | id: closeAll 101 | anchors.top: parent.top 102 | anchors.bottom: parent.bottom 103 | anchors.right: parent.right 104 | width: height 105 | hoverEnabled: true 106 | Image { 107 | scale: buttonImageScale 108 | anchors.fill: parent 109 | source: IQThemes.notificationsTheme.extraCloseAllButtonImage 110 | opacity: parent.containsMouse ? 0.85 : 1 111 | } 112 | onClicked: IQNotifications.onDropAll() 113 | } 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /IQFancyContainer.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | import QtQuick 2.5 19 | import QtQuick.Layouts 1.1 20 | 21 | Item { 22 | id: root 23 | 24 | property real shownOpacity: 0.98 25 | 26 | property int showDuration: 120 27 | property real showScaleDivisor: 1.5 28 | 29 | property int dropDuration: 120 30 | property real dropScaleDivisor: 1.3 31 | 32 | property alias color: bg.color 33 | property alias bgImageSource: bgImage.source 34 | 35 | /* SIGNALS */ 36 | 37 | signal closeClicked() 38 | 39 | /* FUNCTIONS */ 40 | 41 | function animateShow() { 42 | showAnimation.start(); 43 | } 44 | 45 | function animateDrop() { 46 | dropAnimation.start(); 47 | } 48 | 49 | /* COMPONENTS */ 50 | 51 | Rectangle { 52 | id: bg 53 | anchors.fill: parent 54 | Image { 55 | id: bgImage 56 | anchors.fill: parent 57 | visible: source != undefined 58 | } 59 | } 60 | 61 | ParallelAnimation { 62 | id: showAnimation 63 | PropertyAnimation { 64 | target: root; property: "scale"; from: 1/showScaleDivisor; to: 1 65 | duration: showDuration 66 | } 67 | PropertyAnimation { 68 | target: root; property: "opacity"; from: 0; to: shownOpacity 69 | duration: showDuration 70 | } 71 | } 72 | 73 | ParallelAnimation { 74 | id: dropAnimation 75 | PropertyAnimation { 76 | target: root; property: "scale"; to: 1/dropScaleDivisor 77 | duration: dropDuration 78 | } 79 | PropertyAnimation { 80 | target: root.parent; property: "y"; 81 | to: root.parent.y - (root.height -root.height/dropScaleDivisor) 82 | duration: dropDuration 83 | } 84 | PropertyAnimation { 85 | target: root; property: "opacity"; from: shownOpacity; to: 0 86 | duration: dropDuration 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /IQHistoryNotification.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.0 2 | 3 | Rectangle { 4 | id: root 5 | width: parent.width 6 | height: 72 7 | opacity: mouseArea.containsMouse ? 0.9 : 1 8 | 9 | signal removeNotification(int index) 10 | 11 | property int sideMargin: height / 10 12 | property int topMargin: sideMargin / 2 13 | property alias appColor: appText.color 14 | property alias titleColor: titleText.color 15 | property alias bodyColor: bodyText.color 16 | 17 | property alias appSize: appText.font.pointSize 18 | property alias titleSize: titleText.font.pointSize 19 | property alias bodySize: bodyText.font.pointSize 20 | 21 | Image { 22 | id: icon 23 | width: height 24 | fillMode: Image.PreserveAspectFit 25 | source: iconUrl 26 | anchors.top: parent.top 27 | anchors.bottom: parent.bottom 28 | anchors.left: parent.left 29 | } 30 | 31 | Text { 32 | id: appText 33 | text: application 34 | verticalAlignment: Text.AlignVCenter 35 | horizontalAlignment: Text.AlignRight 36 | anchors.left: parent.left 37 | anchors.rightMargin: sideMargin 38 | anchors.leftMargin: sideMargin 39 | anchors.bottomMargin: topMargin 40 | anchors.bottom: parent.bottom 41 | anchors.right: parent.right 42 | } 43 | 44 | Text { 45 | id: titleText 46 | text: title 47 | anchors.right: parent.right 48 | wrapMode: Text.WordWrap 49 | anchors.leftMargin: sideMargin 50 | anchors.rightMargin: sideMargin 51 | anchors.topMargin: topMargin 52 | anchors.top: parent.top 53 | anchors.left: icon.right 54 | } 55 | Text { 56 | id: bodyText 57 | text: body 58 | anchors.top: titleText.bottom 59 | anchors.right: parent.right 60 | anchors.bottom: parent.bottom 61 | anchors.leftMargin: sideMargin 62 | anchors.rightMargin: sideMargin 63 | anchors.topMargin: topMargin 64 | anchors.left: icon.right 65 | wrapMode: Text.WordWrap 66 | } 67 | 68 | MouseArea { 69 | id: mouseArea 70 | anchors.fill: parent 71 | hoverEnabled: true 72 | onClicked: removeNotification(index) 73 | } 74 | 75 | ListView.onAdd: ParallelAnimation { 76 | NumberAnimation { target: root; property: "scale"; from: 0; to: 1; duration: 250; easing.type: Easing.InOutQuad } 77 | NumberAnimation { target: root; property: "height"; from: 0; to: height; duration: 250; easing.type: Easing.InOutQuad } 78 | } 79 | 80 | ListView.onRemove: SequentialAnimation { 81 | PropertyAction { target: root; property: "ListView.delayRemove"; value: true } 82 | ParallelAnimation{ 83 | NumberAnimation { target: root; property: "scale"; to: 0; duration: 250; easing.type: Easing.InOutQuad } 84 | NumberAnimation { target: root; property: "height"; to: 0; duration: 250; easing.type: Easing.InOutQuad } 85 | } 86 | 87 | // Make sure delayRemove is set back to false so that the item can be destroyed 88 | PropertyAction { target: root; property: "ListView.delayRemove"; value: false } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /IQHistoryWindow.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | import QtQuick 2.5 19 | import QtQuick.Window 2.1 20 | import IQNotifier 1.0 21 | 22 | IQPopup { 23 | id: root 24 | dropDuration: container.dropDuration 25 | height: IQThemes.historyWindowTheme.height ? 26 | IQThemes.historyWindowTheme.height : 27 | calcHeight 28 | width: IQThemes.historyWindowTheme.width ? 29 | IQThemes.historyWindowTheme.width : 30 | calcWidth 31 | x: IQThemes.historyWindowTheme.x 32 | y: IQThemes.historyWindowTheme.y 33 | 34 | property var closeCallback: function () { 35 | console.log("No close callback provided!") 36 | } 37 | 38 | property int calcHeight: Screen.height 39 | property int calcWidth: Screen.desktopAvailableWidth / 4 40 | 41 | property int barHeight: 32 42 | 43 | IQFancyContainer { 44 | id: container 45 | anchors.fill: parent 46 | 47 | color: IQThemes.historyWindowTheme.bgColor 48 | bgImageSource: IQThemes.historyWindowTheme.bgImage 49 | 50 | 51 | IQNotificationBar { 52 | id: bar 53 | z: 1 54 | visible: height 55 | height: IQThemes.historyWindowTheme.barHeight 56 | closeButtonImageSource: IQThemes.historyWindowTheme.closeIcon 57 | anchors.top: parent.top 58 | anchors.left: parent.left 59 | anchors.right: parent.right 60 | color: IQThemes.historyWindowTheme.barBgColor 61 | text: IQThemes.historyWindowTheme.windowTitle 62 | textFontSize: IQThemes.historyWindowTheme.barFontSize 63 | textColor: IQThemes.historyWindowTheme.barTextColor 64 | onCloseClicked: { 65 | closeCallback(); 66 | root.drop(); 67 | } 68 | } 69 | 70 | ListView { 71 | id: listView 72 | highlightFollowsCurrentItem: false 73 | focus: true 74 | anchors.top: bar.bottom 75 | anchors.left: parent.left 76 | anchors.right: parent.right 77 | anchors.bottom: parent.bottom 78 | 79 | model: IQHistory.model 80 | delegate: IQHistoryNotification{ 81 | height: IQThemes.historyWindowTheme.notificationHeight ? 82 | IQThemes.historyWindowTheme.notificationHeight : 70 83 | color: IQThemes.historyWindowTheme.nbgColor 84 | appColor: IQThemes.historyWindowTheme.nappTextColor 85 | titleColor: IQThemes.historyWindowTheme.ntitleTextColor 86 | bodyColor: IQThemes.historyWindowTheme.nbodyTextColor 87 | 88 | appSize: IQThemes.historyWindowTheme.nappFontSize? 89 | IQThemes.historyWindowTheme.nappFontSize : 90 | height * 0.08333333333333333333 91 | titleSize: IQThemes.historyWindowTheme.ntitleFontSize ? 92 | IQThemes.historyWindowTheme.ntitleFontSize : 93 | height * 0.125 94 | bodySize: IQThemes.historyWindowTheme.nbodyFontSize ? 95 | IQThemes.historyWindowTheme.nbodyFontSize : 96 | height * 0.11111111111111111111 97 | onRemoveNotification: IQHistory.remove(index) 98 | } 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /IQNotification.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | import QtQuick 2.5 19 | import QtQuick.Window 2.1 20 | import IQNotifier 1.0 21 | 22 | IQPopup { 23 | id: root 24 | dropDuration: container.dropDuration 25 | 26 | property int notification_id: 0 27 | property alias appName: container.appName 28 | property alias body: container.body 29 | property alias iconUrl: container.iconUrl 30 | property alias buttons: container.buttons 31 | property alias expireTimeout: expiration_controller.timeout 32 | 33 | IQExpirationController{ 34 | id: expiration_controller 35 | onExpired: IQNotifications.onExpired(notification_id) 36 | expiration: alive && !mouseArea.containsMouse 37 | } 38 | 39 | MouseArea { 40 | id: mouseArea 41 | anchors.fill: parent 42 | hoverEnabled: true 43 | acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton 44 | onClicked: { 45 | var rightPressed = mouse.button & Qt.RightButton; 46 | if (rightPressed && IQNotifications.closeAllByRightClick) { 47 | IQNotifications.onDropAll() 48 | } 49 | var middlePressed = mouse.button & Qt.MiddleButton; 50 | if (middlePressed && IQNotifications.closeVisibleByLeftClick) { 51 | return IQNotifications.onDropVisible() 52 | } 53 | var leftPressed = mouse.button & Qt.LeftButton; 54 | if (leftPressed && IQNotifications.closeByLeftClick) { 55 | return IQNotifications.onCloseButtonPressed(notification_id) 56 | } 57 | } 58 | } 59 | 60 | IQNotificationContainer { 61 | id: container 62 | referenceHeight: root.height 63 | expireTimeout: expiration_controller.timeout - showDuration 64 | expiration: expiration_controller.expiration 65 | title: root.title 66 | anchors.fill: parent 67 | onCloseClicked: IQNotifications.onCloseButtonPressed(notification_id) 68 | onButtonClicked: IQNotifications.onActionButtonPressed(notification_id, button) 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /IQNotificationBar.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | import QtQuick 2.5 19 | 20 | Item { 21 | id: root 22 | signal closeClicked() 23 | 24 | property real elementsScale: 0.4 25 | property alias color: bg.color 26 | property alias closeButtonImageSource: closeImage.source 27 | property alias textColor: barText.color 28 | property alias textFontSize: barText.font.pointSize 29 | property string text: "" 30 | 31 | Rectangle { 32 | id: bg 33 | anchors.fill: parent 34 | } 35 | 36 | Text { 37 | id: barText 38 | text: root.text.length === 0 ? qsTr("Notification") : root.text 39 | renderType: Text.NativeRendering 40 | verticalAlignment: Text.AlignVCenter 41 | horizontalAlignment: Text.AlignLeft 42 | anchors.fill: parent 43 | anchors.leftMargin: closeImage.width*0.4 44 | } 45 | 46 | MouseArea { 47 | id: closeBtn 48 | height: root.height 49 | width: height 50 | anchors.bottom: parent.bottom 51 | anchors.top: parent.top 52 | anchors.right: parent.right 53 | hoverEnabled: true 54 | 55 | Image { 56 | id: closeImage 57 | scale: elementsScale 58 | anchors.fill: parent 59 | opacity: parent.containsMouse ? 0.85 : 1 60 | } 61 | onClicked: closeClicked() 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /IQNotificationContainer.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | import QtQuick 2.5 19 | import QtQuick.Layouts 1.1 20 | import IQNotifier 1.0 21 | 22 | IQFancyContainer { 23 | id: root 24 | 25 | showDuration: IQThemes.notificationsTheme.showAnimationDuration 26 | dropDuration: IQThemes.notificationsTheme.dropAnimationDuration 27 | color: IQThemes.notificationsTheme.bgColor 28 | bgImageSource: IQThemes.notificationsTheme.bgImage 29 | 30 | signal buttonClicked(string button) 31 | 32 | property int referenceHeight: 0 33 | 34 | property alias appName: bar.text 35 | property alias title: titleText.text 36 | property alias body: bodyText.text 37 | property url iconUrl: "" 38 | property variant buttons: "" 39 | 40 | property alias expireTimeout: expirationBar.expireTimeout 41 | property bool expiration: false 42 | 43 | property int barHeight: IQThemes.notificationsTheme.barHeight ? 44 | IQThemes.notificationsTheme.barHeight : 45 | referenceHeight * barFactor 46 | property int expirationBarHeight: IQThemes.notificationsTheme.expirationBarHeight 47 | 48 | property int contentMargin: referenceHeight*spacingFactor*2 49 | property int fontPointSize: IQThemes.notificationsTheme.fontSize ? 50 | IQThemes.notificationsTheme.fontSize : 51 | referenceHeight * fontPointSizeFactor 52 | property int iconSize: IQThemes.notificationsTheme.iconSize ? 53 | IQThemes.notificationsTheme.iconSize : 54 | referenceHeight * iconFactor 55 | 56 | property real barFactor: 0.148; 57 | property real iconFactor: 0.3; 58 | property real spacingFactor: 0.04; 59 | property real buttonFactor: 0.13; 60 | property real fontPointSizeFactor: 0.045; 61 | 62 | IQNotificationBar { 63 | id: bar 64 | color: IQThemes.notificationsTheme.barBgColor 65 | textColor: IQThemes.notificationsTheme.barTextColor 66 | textFontSize: IQThemes.notificationsTheme.barFontSize ? 67 | IQThemes.notificationsTheme.barFontSize : 68 | height*0.4 69 | closeButtonImageSource: IQThemes.notificationsTheme.closeButtonImage 70 | elementsScale: IQThemes.notificationsTheme.closeButtonImageScale 71 | height: barHeight; 72 | visible: height 73 | anchors.top: parent.top 74 | anchors.left: parent.left 75 | anchors.right: parent.right 76 | onCloseClicked: root.closeClicked() 77 | } 78 | 79 | IQExpirationBar { 80 | id: expirationBar 81 | anchors.top: bar.bottom 82 | anchors.left: parent.left 83 | color: IQThemes.notificationsTheme.expirationBarColor 84 | height: expirationBarHeight 85 | // Crutch to run animation after object created 86 | runnig: expiration && root.height == root.referenceHeight && root.height > 0 87 | } 88 | 89 | Component { 90 | id: iconComponent 91 | Image { 92 | id: icon 93 | source: iconUrl 94 | sourceSize.width: iconSize 95 | sourceSize.height: iconSize 96 | fillMode: Image.PreserveAspectFit 97 | visible: source.toString().length 98 | } 99 | } 100 | 101 | Loader { 102 | id: iconAtLeftSideLoader 103 | anchors.bottom: parent.bottom 104 | anchors.left: parent.left 105 | anchors.top: bar.bottom 106 | anchors.leftMargin: contentMargin 107 | visible: sourceComponent != undefined 108 | sourceComponent: IQThemes.notificationsTheme.iconPosition ? iconComponent : undefined 109 | } 110 | 111 | ColumnLayout { 112 | id: column 113 | spacing: referenceHeight * spacingFactor 114 | anchors.rightMargin: contentMargin 115 | anchors.leftMargin: contentMargin 116 | anchors.bottomMargin: contentMargin 117 | anchors.topMargin: contentMargin 118 | anchors.top: bar.bottom 119 | anchors.right: parent.right 120 | anchors.bottom: parent.bottom 121 | anchors.left: iconAtLeftSideLoader.right 122 | 123 | Loader { 124 | visible: sourceComponent != undefined 125 | sourceComponent: !IQThemes.notificationsTheme.iconPosition ? iconComponent : undefined 126 | Layout.fillWidth: !buttonsLayout.visible 127 | Layout.fillHeight: Layout.fillWidth 128 | Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter 129 | } 130 | 131 | Text { 132 | id: titleText 133 | visible: text.length 134 | color: IQThemes.notificationsTheme.titleTextColor 135 | verticalAlignment: Text.AlignVCenter 136 | horizontalAlignment: Text.AlignHCenter 137 | font.pointSize: root.fontPointSize 138 | font.weight: Font.Medium 139 | wrapMode: Text.WordWrap 140 | Layout.fillWidth: true 141 | Layout.fillHeight: false 142 | Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter 143 | } 144 | Text { 145 | id: bodyText 146 | color: IQThemes.notificationsTheme.bodyTextColor 147 | visible: text.length 148 | horizontalAlignment: Text.AlignHCenter 149 | wrapMode: Text.WrapAtWordBoundaryOrAnywhere 150 | font.pointSize: titleText.font.pointSize 151 | Layout.fillWidth: true 152 | Layout.fillHeight: false 153 | Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter 154 | } 155 | 156 | RowLayout { 157 | id: buttonsLayout 158 | visible: buttons.length 159 | Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter 160 | Layout.fillWidth: true 161 | Layout.fillHeight: false 162 | Repeater { 163 | model: buttons 164 | IQButton { 165 | height: referenceHeight * buttonFactor 166 | color: IQThemes.notificationsTheme.buttonBgColor 167 | textColor: IQThemes.notificationsTheme.buttonTextColor 168 | Layout.fillHeight: true 169 | Layout.fillWidth: true 170 | text: modelData.text 171 | onClicked: buttonClicked(modelData.action) 172 | } 173 | } 174 | } 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /IQPopup.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | import QtQuick 2.5 19 | import QtQuick.Window 2.1 20 | 21 | Window { 22 | id: root 23 | visible: true 24 | color: "transparent" 25 | flags: Qt.Popup 26 | 27 | property alias dropDuration: destroyTimer.interval 28 | property int moveDuration: dropDuration 29 | property bool alive: false 30 | 31 | property int _newX: x 32 | property int _newY: y 33 | 34 | /* FUNCTIONS */ 35 | 36 | function show() { 37 | alive = true; 38 | container.animateShow(); 39 | } 40 | 41 | function drop() { 42 | alive = false; 43 | container.animateDrop(); 44 | destroyTimer.start(); 45 | } 46 | 47 | function move(newX, newY) { 48 | _newX = newX; 49 | _newY = newY; 50 | moveAnimation.start(); 51 | } 52 | 53 | /* COMPONENTS */ 54 | 55 | Timer { 56 | id: destroyTimer 57 | running: false 58 | repeat: false 59 | onTriggered: close() 60 | } 61 | 62 | ParallelAnimation { 63 | id: moveAnimation 64 | PropertyAnimation { 65 | target: root; property: "x"; to: _newX 66 | duration: moveDuration 67 | } 68 | PropertyAnimation { 69 | target: root; property: "y"; to: _newY 70 | duration: moveDuration 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # IQ Notifier 2 | IQ Notifier is fancy and flexible notification daemon. 3 | 4 | ## Screenshots 5 | ![0](/screenshots/0.png?raw=true) 6 | ![1](/screenshots/1.png?raw=true) 7 | ![2](/screenshots/2.png?raw=true) 8 | 9 | ![3](/screenshots/3.png?raw=true) 10 | ![4](/screenshots/4.png?raw=true) 11 | 12 | ## Features 13 | ### History 14 | IQ Notifier will store notifications until restart. 15 | 16 | ![h_0](/screenshots/h_0.png?raw=true) 17 | 18 | ### TitleToIcon 19 | If icon not presented, IQ Notifier will compare title and app name; if its equals, IQ Notifier will try to find and set app icon. 20 | 21 | ### URL icons support 22 | Icon can be simple link to image. 23 | 24 | ### ReplaceMinusToDash 25 | IQ Notifier will replace all occurrences of `-` to `—`. 26 | 27 | ### BodyToTitleWhenTitleIsAppName 28 | If icon not presented, IQ Notifier will compare title and app name; if its equals, IQ Notifier will move all text from body to title. 29 | 30 | ### All fields are optional 31 | Unused parts of notifications will not shown. 32 | 33 | ### Mouse control 34 | Right click to close all notifications, middle for all visible. 35 | 36 | ### Multiple actions 37 | Buttons row at the bottom. :) 38 | 39 | ### Theming support 40 | Pony theme in default package: just change `theme_name` to `pony` in config file! 41 | 42 | ### Flexidble 43 | You can configure most parts of IQ Notifier. Look at config file. 44 | 45 | # Compositing 46 | To make opacity [of popups] works you need compositing. Try `compton -CG `, that should work. 47 | 48 | # TODO 49 | - Multiple monitor support 50 | - More features 51 | - ?????? 52 | 53 | Use `ag TODO` or your favorite IDE to find TODOs in code. 54 | 55 | # Build deps 56 | ```bash 57 | sudo apt install cmake qtbase5-dev qtdeclarative5-dev libqt5xdg-dev 58 | ``` 59 | 60 | For X11 plugin you also need: 61 | ```bash 62 | sudo apt install libx11-dev 63 | ``` 64 | 65 | # Build 66 | To clone this repo with dependencies (GSL) use `--recursive` flag: 67 | ```bash 68 | git clone --recursive git@github.com:RussianBruteForce/iq-notifier.git 69 | mkdir iq-notifier/build; cd iq-notifier/build 70 | # set X11 if you want X11 plugin 71 | cmake -DCMAKE_BUILD_TYPE=Release -DX11 .. 72 | make 73 | ``` 74 | 75 | Tested on ubuntu 16.04, GCC 5.4.0 and Clang 3.8.0. 76 | 77 | # Config 78 | Config path: `$XDG_CONFIG_HOME/iq-notifier/config` (`~/.config/iq-notifier/config`) 79 | 80 | All 'modules' of IQ Notifier should be enabled in config file explicitly. To copy example config execute from repo root: 81 | ```bash 82 | cp config.example ~/.config/iq-notifier/config 83 | ``` 84 | 85 | Or, if you installed IQ Notifier from package jut run it. Config will be copied to your home dir automatically at first start. 86 | 87 | 88 | # Themes 89 | Theme is a directory with `theme` file which is simple text. For default themes look at `/usr/share/iq-notifier/themes` dir. They will be copied to your home dir automatically at first start. 90 | Themes must be placed in `$XDG_CONFIG_HOME/iq-notifier/themes` (`~/.config/iq-notifier/themes`) directory. 91 | 92 | # Deb package 93 | ```bash 94 | cpack 95 | sudo apt update 96 | sudo dpkg -i iq-notifier-*-amd64.deb 97 | sudo apt installf -f 98 | ``` 99 | 100 | # RMP repository 101 | [Repo by ZaWertun](https://copr.fedorainfracloud.org/coprs/zawertun/scrapyard/) 102 | 103 | # Contributions 104 | Feel free to make pull requests/fork this project. You can also contact me via e-mail: [bruteforce@sigil.tk](mailto:bruteforce@sigil.tk) 105 | 106 | You also need `clang-format` and `cpplint`. 107 | 108 | # License 109 | Look at COPYING file. 110 | 111 | ## Spec 112 | [Version 1.2](https://people.gnome.org/~mccann/docs/notification-spec/notification-spec-latest.html) 113 | 114 | ## Capabilities 115 | - actions 116 | - body 117 | - body-markup 118 | - icon-static 119 | - persistence 120 | -------------------------------------------------------------------------------- /X11-plugin/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(PLUGIN_NAME X11-plugin) 2 | 3 | include_directories(..) 4 | 5 | aux_source_directory(. X11_SRC_LIST) 6 | 7 | add_library(${PLUGIN_NAME} ${X11_SRC_LIST}) 8 | 9 | target_link_libraries(${PLUGIN_NAME} X11) 10 | -------------------------------------------------------------------------------- /X11-plugin/x11fullscreendetector.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | #include "x11fullscreendetector.h" 19 | 20 | #include "x11fullscreendetectorprivate.h" 21 | 22 | X11FullscreenDetector::X11FullscreenDetector() 23 | : detectorPrivate{std::make_unique()} 24 | { 25 | } 26 | 27 | bool X11FullscreenDetector::fullscreenWindowsOnCurrentDesktop() const 28 | { 29 | return detectorPrivate->fullscreenWindowsOnCurrentDesktop(); 30 | } 31 | 32 | bool X11FullscreenDetector::fullscreenWindows() const 33 | { 34 | return detectorPrivate->fullscreenWindows(); 35 | } 36 | -------------------------------------------------------------------------------- /X11-plugin/x11fullscreendetector.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #include 21 | 22 | #include 23 | 24 | class X11FullscreenDetector final : public IQFullscreenDetector 25 | { 26 | public: 27 | X11FullscreenDetector(); 28 | 29 | bool fullscreenWindowsOnCurrentDesktop() const final; 30 | bool fullscreenWindows() const final; 31 | 32 | private: 33 | std::unique_ptr detectorPrivate; 34 | }; 35 | -------------------------------------------------------------------------------- /X11-plugin/x11fullscreendetectorprivate.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | #include "x11fullscreendetectorprivate.h" 19 | 20 | extern "C" { 21 | #include 22 | } 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | X11Property::X11Property(gsl::not_null data_ptr, size_t size, 29 | size_t items, bool autoXFree) 30 | : items_count{items} 31 | { 32 | data.resize(size); 33 | std::memcpy(data.data(), data_ptr, size); 34 | if (autoXFree) 35 | XFree(data_ptr); 36 | } 37 | 38 | X11FullscreenDetectorPrivate::X11FullscreenDetectorPrivate() 39 | : disp{XOpenDisplay(nullptr)}, 40 | CLIENT_LIST{disp ? internAtom(CLIENT_LIST_STR) : 0}, 41 | WM_DESKTOP{disp ? internAtom(WM_DESKTOP_STR) : 0}, 42 | WM_STATE{disp ? internAtom(WM_STATE_STR) : 0}, 43 | WM_STATE_FULLSCREEN{disp ? internAtom(WM_STATE_FULLSCREEN_STR) : 0}, 44 | CURRENT_DESKTOP{disp ? internAtom(CURRENT_DESKTOP_STR) : 0} 45 | { 46 | if (!disp) { 47 | throw std::runtime_error{ 48 | "X11FullscreenDetector: Cannot open display."}; 49 | } 50 | auto net_sup = internAtom("_NET_SUPPORTED"); 51 | auto sup = getProperty(DefaultRootWindow(disp), XA_ATOM, net_sup); 52 | if (sup) { 53 | auto as = sup->to(); 54 | for (auto i : as) { 55 | auto n = getAtomName(i); 56 | if (n) 57 | std::cout << "Supported: " << *n << "\n"; 58 | } 59 | } 60 | } 61 | 62 | X11FullscreenDetectorPrivate::~X11FullscreenDetectorPrivate() 63 | { 64 | XCloseDisplay(disp); 65 | } 66 | 67 | bool X11FullscreenDetectorPrivate::fullscreenWindowsOnCurrentDesktop() const 68 | { 69 | auto current_desktop = *currentDesktop(); 70 | auto windows = getClientList(); 71 | for (auto w : windows) { 72 | auto wm_state_prop = getProperty(w, XA_ATOM, WM_STATE); 73 | if (wm_state_prop) { 74 | auto as = wm_state_prop->to(); 75 | for (auto &a : as) { 76 | if (a == WM_STATE_FULLSCREEN) { 77 | auto win_desktop_o = windowDesktop(w); 78 | if (win_desktop_o && 79 | *win_desktop_o == current_desktop) { 80 | return true; 81 | } 82 | } 83 | } 84 | } 85 | } 86 | return false; 87 | } 88 | 89 | bool X11FullscreenDetectorPrivate::fullscreenWindows() const 90 | { 91 | auto windows = getClientList(); 92 | for (auto w : windows) { 93 | auto wm_state_prop = getProperty(w, XA_ATOM, WM_STATE); 94 | if (wm_state_prop) { 95 | auto as = wm_state_prop->to(); 96 | for (auto &a : as) { 97 | if (a == WM_STATE_FULLSCREEN) { 98 | return true; 99 | } 100 | } 101 | } 102 | } 103 | return false; 104 | } 105 | 106 | X11FullscreenDetectorPrivate::optional 107 | X11FullscreenDetectorPrivate::getProperty(Window win, Atom expectedType, 108 | Atom propertyAtom) const 109 | { 110 | static constexpr auto MAX_PROPERTY_VALUE_LEN = 1024; 111 | 112 | Atom prop_type; 113 | int prop_format; 114 | size_t items_count; 115 | size_t prop_bytes_after; 116 | unsigned char *prop_ptr; 117 | 118 | if (XGetWindowProperty(disp, win, propertyAtom, 0, 119 | MAX_PROPERTY_VALUE_LEN, False, expectedType, 120 | &prop_type, &prop_format, &items_count, 121 | &prop_bytes_after, &prop_ptr) != Success) { 122 | std::cerr << "X11FullscreenDetector: can't get property" 123 | << std::endl; 124 | return {}; 125 | } 126 | if (prop_ptr == nullptr) { 127 | std::cerr << "X11FullscreenDetector: no property" << std::endl; 128 | return {}; 129 | } 130 | if (prop_type != expectedType) { 131 | XFree(prop_ptr); 132 | std::cerr << "X11FullscreenDetector: invalid type, expected " 133 | << expectedType << " got " << prop_type << std::endl; 134 | return {}; 135 | } 136 | 137 | auto size = (prop_format / (32 / sizeof(Atom))) * items_count; 138 | X11Property prop{prop_ptr, size, items_count}; 139 | 140 | return {prop}; 141 | } 142 | 143 | std::vector X11FullscreenDetectorPrivate::getClientList() const 144 | { 145 | auto client_list = 146 | getProperty(DefaultRootWindow(disp), XA_WINDOW, CLIENT_LIST); 147 | if (!client_list) 148 | throw std::runtime_error{ 149 | "X11FullscreenDetector: cannot get windows."}; 150 | 151 | return client_list->to(); 152 | } 153 | 154 | X11FullscreenDetectorPrivate::optional 155 | X11FullscreenDetectorPrivate::getAtomName(Atom atom) const 156 | { 157 | auto n = XGetAtomName(disp, atom); 158 | if (n == nullptr) { 159 | return {}; 160 | } else { 161 | optional ret{std::string{n}}; 162 | XFree(n); 163 | return ret; 164 | } 165 | } 166 | 167 | Atom X11FullscreenDetectorPrivate::internAtom(const char *atomName, 168 | bool onlyIfExists) const 169 | { 170 | return XInternAtom(disp, atomName, onlyIfExists ? True : False); 171 | } 172 | 173 | X11FullscreenDetectorPrivate::optional 174 | X11FullscreenDetectorPrivate::windowDesktop(Window win) const 175 | { 176 | auto win_desktop_prop = getProperty(win, XA_CARDINAL, WM_DESKTOP); 177 | if (win_desktop_prop) { 178 | return win_desktop_prop->toSingle(); 179 | } 180 | return {}; 181 | } 182 | 183 | X11FullscreenDetectorPrivate::optional 184 | X11FullscreenDetectorPrivate::currentDesktop() const 185 | { 186 | auto cur_desktop_prop = 187 | getProperty(DefaultRootWindow(disp), XA_CARDINAL, CURRENT_DESKTOP); 188 | if (cur_desktop_prop) { 189 | return cur_desktop_prop->toSingle(); 190 | } 191 | return {}; 192 | } 193 | -------------------------------------------------------------------------------- /X11-plugin/x11fullscreendetectorprivate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | extern "C" { 21 | #include 22 | } 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #include 29 | 30 | #include 31 | 32 | class X11Property 33 | { 34 | using byte = unsigned char; 35 | 36 | public: 37 | template using optional = std::experimental::optional; 38 | 39 | X11Property(gsl::not_null data_ptr, size_t size, size_t items, 40 | bool autoXFree = true); 41 | 42 | template std::vector to() const 43 | { 44 | auto calculated_items_count = data.size() / sizeof(T); 45 | if (items_count != calculated_items_count) 46 | throw std::invalid_argument{ 47 | "X11Property: can't convert X11Property"}; 48 | std::vector ret; 49 | ret.resize(items_count); 50 | std::memcpy(ret.data(), data.data(), data.size()); 51 | return ret; 52 | } 53 | 54 | template optional toSingle() const 55 | { 56 | auto v = to(); 57 | return v.empty() ? optional{} : optional{v.front()}; 58 | } 59 | 60 | private: 61 | std::vector data; 62 | size_t items_count; 63 | }; 64 | 65 | class X11FullscreenDetectorPrivate final : public IQFullscreenDetector 66 | { 67 | template using optional = X11Property::optional; 68 | 69 | public: 70 | X11FullscreenDetectorPrivate(); 71 | ~X11FullscreenDetectorPrivate() final; 72 | 73 | bool fullscreenWindowsOnCurrentDesktop() const final; 74 | bool fullscreenWindows() const final; 75 | 76 | private: 77 | static constexpr auto CLIENT_LIST_STR = "_NET_CLIENT_LIST"; 78 | static constexpr auto WM_DESKTOP_STR = "_NET_WM_DESKTOP"; 79 | static constexpr auto WM_STATE_STR = "_NET_WM_STATE"; 80 | static constexpr auto WM_STATE_FULLSCREEN_STR = 81 | "_NET_WM_STATE_FULLSCREEN"; 82 | static constexpr auto CURRENT_DESKTOP_STR = "_NET_CURRENT_DESKTOP"; 83 | 84 | mutable Display *disp{nullptr}; 85 | const Atom CLIENT_LIST; 86 | const Atom WM_DESKTOP; 87 | const Atom WM_STATE; 88 | const Atom WM_STATE_FULLSCREEN; 89 | const Atom CURRENT_DESKTOP; 90 | 91 | optional getProperty(Window win, Atom expetedType, 92 | Atom propertyAtom) const; 93 | std::vector getClientList() const; 94 | 95 | optional getAtomName(Atom atom) const; 96 | 97 | Atom internAtom(const char *atomName, bool onlyIfExists = true) const; 98 | 99 | optional windowDesktop(Window win) const; 100 | optional currentDesktop() const; 101 | }; 102 | -------------------------------------------------------------------------------- /config.example: -------------------------------------------------------------------------------- 1 | ; IQ Notifier config 2 | ; 3 | ; 'enabled' is false by default everywhere 4 | 5 | [theme] 6 | theme_name = default 7 | 8 | [popup_notifications] 9 | ; you can disable floating notifications 10 | enabled = true 11 | 12 | close_all_by_right_click = true 13 | close_visible_by_middle_click = true 14 | close_by_left_click = false 15 | 16 | ; spacing between notifications 17 | spacing = 5 18 | ; margins between screen borders and notification area 19 | global_margins = 0,20,20,0 20 | 21 | ; you should set both width and height to see changes 22 | width = 400 23 | height = 132 24 | 25 | ; you should set both width and height to see changes 26 | extra_window_width = 400 27 | extra_window_height = 32 28 | 29 | ;;;; next X11 only 30 | 31 | ; when set, IQ Notifier will try to detect fullscreen windows on current desktop 32 | ; and will not show popups in this case 33 | ; disabled by default 34 | dont_show_when_fullscreen_current_desktop = false 35 | ; don't show popups if any fullscreen windows found 36 | ; for wms which not support '_NET_WM_DESKTOP' such as old i3wm (from defaultUbuntu repo) 37 | ; disabled by default 38 | dont_show_when_fullscreen_any = false 39 | 40 | 41 | 42 | [history] 43 | enabled = true 44 | 45 | ;;;;;;;;;; modifiers ;;;;;;;;;; 46 | 47 | [default_timeout] 48 | ; be careful disabling this modifier! 49 | enabled = true 50 | ; 0 for default (3500) 51 | ;default_timeout = 1000 52 | 53 | ; try to find app icon when title is same as application name 54 | [title_to_icon] 55 | enabled = true 56 | 57 | [body_to_title_when_title_is_app_name] 58 | enabled = true 59 | 60 | [replace_minus_to_dash] 61 | enabled = true 62 | title = true 63 | body = false 64 | 65 | -------------------------------------------------------------------------------- /dbusnotification.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | struct DBusNotification { 8 | using id_t = uint; 9 | 10 | enum ClosingReason : uint { 11 | CR_NOTIFICATION_EXPIRED = 1, 12 | CR_NOTIFICATION_DISMISSED, 13 | CR_NOTIFICATION_CLOSED, 14 | CR_NOTIFICATION_CLOSED_REASON_UNDEFINED 15 | }; 16 | 17 | enum ExpireTimeout : int { ET_SERVER_DECIDES = -1, ET_FOREVER = 0 }; 18 | 19 | id_t id; 20 | QString app_name; 21 | id_t replaces_id; 22 | QString app_icon; 23 | QString summary; 24 | QString body; 25 | QStringList actions; 26 | QVariantMap hints; 27 | ExpireTimeout expire_timeout; 28 | }; 29 | -------------------------------------------------------------------------------- /etc/.lint.swp: -------------------------------------------------------------------------------- 1 | b0nano 2.5.3Muserpc/home/user/dev/iq-notifier/etc/lintU -------------------------------------------------------------------------------- /etc/format: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | SRC=. 4 | 5 | #exclude 6 | GIT=$SRC/.git 7 | GSL=$SRC/GSL 8 | 9 | STYLE="{BasedOnStyle: LLVM, IndentWidth: 8, UseTab: Always, BreakBeforeBraces: Linux, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: false}" 10 | 11 | CLANG_FORMAT=/usr/bin/clang-format 12 | 13 | find $SRC -regex '.*\(h\|cpp\)$' -exec \ 14 | $CLANG_FORMAT -style="$STYLE" -i {} \; \ 15 | -o \ 16 | \( -path $GIT -o -path $GSL \) -prune 17 | -------------------------------------------------------------------------------- /etc/lint: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | CPPLINT=cpplint 4 | 5 | FILTER=\ 6 | -legal/copyright,\ 7 | +build/header_guard,\ 8 | +build/namespaces,\ 9 | +build/include,\ 10 | +build/include_what_you_use,\ 11 | -build/include_subdir,\ 12 | -build/include_order,\ 13 | -build/include_subdir,\ 14 | -whitespace/comments,\ 15 | -whitespace/braces,\ 16 | -whitespace/tab,\ 17 | -whitespace/semicolon,\ 18 | -whitespace/indent,\ 19 | +readability/alt_tokens,\ 20 | -readability/todo,\ 21 | -runtime/references 22 | 23 | SRC=. 24 | 25 | #exclude 26 | GIT=$SRC/.git 27 | GSL=$SRC/GSL 28 | ETC=$SRC/etc 29 | CMAKE_FILES=$SRC/CMakeFiles 30 | 31 | find $SRC -regex '.*\.\(h\|cpp\|c\)$' -exec $CPPLINT --filter=$FILTER {} \; \ 32 | -o -type d \( -path $GIT -o -path $GSL -o -path $ETC \) -prune 33 | -------------------------------------------------------------------------------- /img/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RussianBruteForce/iq-notifier/0feee9cb755a9ae2221d16c92d98c8710a345e61/img/close.png -------------------------------------------------------------------------------- /img/closeAll.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RussianBruteForce/iq-notifier/0feee9cb755a9ae2221d16c92d98c8710a345e61/img/closeAll.png -------------------------------------------------------------------------------- /img/closeVisible.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RussianBruteForce/iq-notifier/0feee9cb755a9ae2221d16c92d98c8710a345e61/img/closeVisible.png -------------------------------------------------------------------------------- /img/warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RussianBruteForce/iq-notifier/0feee9cb755a9ae2221d16c92d98c8710a345e61/img/warning.png -------------------------------------------------------------------------------- /iq-notifier.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Type=Application 3 | Version=1.1 4 | Name=iq-notifier 5 | GenericName=Notification daemon 6 | Comment=Fancy and flexible notification daemon 7 | Exec=iq-notifier 8 | Terminal=false 9 | Implements=org.freedesktop.Notifications 10 | -------------------------------------------------------------------------------- /iq-notifier.spec: -------------------------------------------------------------------------------- 1 | Name: iq-notifier 2 | Version: 0.4.0 3 | Release: 1%{?dist} 4 | Summary: Fancy and flexible notification daemon 5 | 6 | License: GPLv3 7 | URL: https://github.com/RussianBruteForce/iq-notifier 8 | Source0: iq-notifier-%{version}.tar.gz 9 | Source1: iq-notifier.desktop 10 | 11 | BuildRequires: cmake 12 | BuildRequires: libqtxdg-devel 13 | BuildRequires: qt5-qtbase-devel 14 | BuildRequires: desktop-file-utils 15 | BuildRequires: qt5-qtdeclarative-devel 16 | 17 | %description 18 | IQ Notifier is fancy and flexible notification daemon. 19 | 20 | 21 | %prep 22 | %setup -q 23 | 24 | 25 | %build 26 | %cmake 27 | make %{?_smp_mflags} 28 | 29 | 30 | %install 31 | %make_install 32 | install -m 644 -D %{SOURCE1} %{buildroot}/%{_datadir}/applications/iq-notifier.desktop 33 | 34 | 35 | %files 36 | %doc COPYING README.md 37 | %{_bindir}/iq-notifier 38 | %{_datadir}/iq-notifier 39 | %{_datadir}/applications/iq-notifier.desktop 40 | 41 | 42 | %changelog 43 | * Mon Jul 24 2017 Yaroslav Sidlovsky - 0.4.0-1 44 | - first spec version 45 | 46 | -------------------------------------------------------------------------------- /iqconfig.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | #include "iqconfig.h" 19 | 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace 27 | { 28 | // TODO: refactor; taken from here: https://gist.github.com/ssendeavour/7324701 29 | static bool copyRecursively(const QString &srcFilePath, 30 | const QString &tgtFilePath) 31 | { 32 | QFileInfo srcFileInfo(srcFilePath); 33 | if (srcFileInfo.isDir()) { 34 | QDir targetDir(tgtFilePath); 35 | targetDir.cdUp(); 36 | if (!targetDir.mkdir(QFileInfo(tgtFilePath).fileName())) 37 | return false; 38 | QDir sourceDir(srcFilePath); 39 | QStringList fileNames = sourceDir.entryList( 40 | QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | 41 | QDir::Hidden | QDir::System); 42 | for (const QString &fileName : fileNames) { 43 | const QString newSrcFilePath = 44 | srcFilePath + QLatin1Char('/') + fileName; 45 | const QString newTgtFilePath = 46 | tgtFilePath + QLatin1Char('/') + fileName; 47 | if (!copyRecursively(newSrcFilePath, newTgtFilePath)) 48 | return false; 49 | } 50 | } else { 51 | if (!QFile::copy(srcFilePath, tgtFilePath)) // NOLINT 52 | return false; 53 | } 54 | return true; 55 | } 56 | } // anonymouse namespace 57 | 58 | IQConfig::IQConfig(const QString &category_, const QString &fileName_) 59 | : category{category_.isEmpty() ? "" : category_ + '/'}, fileName{fileName_}, 60 | settings{std::make_unique(getConfigFileName(), 61 | QSettings::IniFormat)} 62 | { 63 | } 64 | 65 | QVariant IQConfig::value(const QString &key, const QVariant &defaultValue) const 66 | { 67 | return settings->value(category + key, defaultValue); 68 | } 69 | 70 | void IQConfig::setValue(const QString &key, const QVariant &value) 71 | { 72 | settings->setValue(category + key, value); 73 | } 74 | 75 | #define IQ_MACRO_STRING(S) IQ_MACRO_STRING__(S) 76 | #define IQ_MACRO_STRING__(S) #S 77 | QString IQConfig::applicationName() 78 | { 79 | return QStringLiteral(IQ_MACRO_STRING(IQ_APP_NAME)); 80 | } 81 | 82 | QString IQConfig::configDir() 83 | { 84 | static auto configDir = XdgDirs::configHome() + '/' + applicationName(); 85 | return configDir; 86 | } 87 | 88 | QString IQConfig::applicationVersion() 89 | { 90 | return QStringLiteral(IQ_MACRO_STRING(IQ_VERSION)); 91 | } 92 | #undef IQ_MACRO_STRING__ 93 | #undef IQ_MACRO_STRING 94 | 95 | QString IQConfig::getConfigFileName() const 96 | { 97 | auto config = configDir() + '/' + fileName; 98 | QFileInfo config_file{config}; 99 | 100 | if (config_file.exists()) { 101 | if (!config_file.isFile()) 102 | throw std::runtime_error{config.toStdString() + 103 | " is not a valid config file"}; 104 | } else { 105 | QDir dir; 106 | dir.mkpath(configDir()); 107 | if (config.contains("/themes/default/theme")) 108 | copyThemesFromShare( 109 | QString{config}.replace("/default/theme", "")); 110 | else 111 | copyConfigFileFromExample(config); 112 | } 113 | return config; 114 | } 115 | 116 | bool IQConfig::copyConfigFileFromExample(const QString &destination) const 117 | { 118 | auto config_example_path = 119 | "/usr/share/" + applicationName() + '/' + fileName + ".example"; 120 | QFile config_example_file{config_example_path}; 121 | if (!config_example_file.exists()) 122 | return false; 123 | return config_example_file.copy(destination); 124 | } 125 | 126 | bool IQConfig::copyThemesFromShare(const QString &destination) const 127 | { 128 | auto shareThemesPath = "/usr/share/" + applicationName() + "/themes"; 129 | return copyRecursively(shareThemesPath, destination); 130 | } 131 | 132 | IQConfigurable::IQConfigurable(const QString &name) : name_{name}, config{name_} 133 | { 134 | } 135 | 136 | const QString &IQConfigurable::name() const { return name_; } 137 | 138 | bool IQConfigurable::isEnabled() const 139 | { 140 | return config.value("enabled", false).toBool(); 141 | } 142 | -------------------------------------------------------------------------------- /iqconfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | #define IQ_CONF_VAR(VAR__, NAME__, DEFAULT__) \ 26 | static constexpr auto CONFIG_##VAR__ = NAME__; \ 27 | static constexpr auto CONFIG_##VAR__##_DEFAULT = DEFAULT__; 28 | 29 | #define IQ_CONF_FACTOR(VAR__, NAME__, DEFAULT__) \ 30 | static constexpr auto CONFIG_##VAR__ = NAME__; \ 31 | static constexpr auto VAR__##_DEFAULT_FACTOR = DEFAULT__; 32 | 33 | class IQConfig 34 | { 35 | public: 36 | static QString applicationVersion(); 37 | static QString applicationName(); 38 | static QString configDir(); 39 | 40 | explicit IQConfig(const QString &category_, 41 | const QString &fileName_ = "config"); 42 | 43 | QVariant value(const QString &key, 44 | const QVariant &defaultValue = QVariant()) const; 45 | void setValue(const QString &key, const QVariant &value); 46 | 47 | private: 48 | const QString category; 49 | const QString fileName; 50 | std::unique_ptr settings; 51 | 52 | QString getConfigFileName() const; 53 | bool copyConfigFileFromExample(const QString &destination) const; 54 | bool copyThemesFromShare(const QString &destination) const; 55 | }; 56 | 57 | struct IQConfigurable { 58 | IQConfigurable() = delete; 59 | const QString &name() const; 60 | bool isEnabled() const; 61 | 62 | protected: 63 | explicit IQConfigurable(const QString &name); 64 | const QString name_; 65 | IQConfig config; 66 | }; 67 | -------------------------------------------------------------------------------- /iqdbusservice.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | #include "iqdbusservice.h" 19 | 20 | #include "iqconfig.h" 21 | 22 | QString IQDBusService::versionString() 23 | { 24 | return IQConfig::applicationVersion(); 25 | } 26 | 27 | QString IQDBusService::appString() { return IQConfig::applicationName(); } 28 | 29 | gsl::not_null 30 | IQDBusService::connectReceiver(IQNotificationReceiver *receiver) 31 | { 32 | connect(this, &IQDBusService::createNotificationSignal, receiver, 33 | &IQNotificationReceiver::onCreateNotification); 34 | connect(this, &IQDBusService::dropNotificationSignal, receiver, 35 | &IQNotificationReceiver::onDropNotification); 36 | connect(receiver, &IQNotificationReceiver::actionInvokedSignal, this, 37 | &IQDBusService::onActionInvoked); 38 | connect(receiver, &IQNotificationReceiver::notificationDroppedSignal, 39 | this, &IQDBusService::onNotificationDropped); 40 | return this; 41 | } 42 | 43 | QStringList IQDBusService::GetCapabilities() 44 | { 45 | auto caps = QStringList{} << "actions" 46 | // << "action-icons" 47 | << "body" 48 | // << "body-hyperlinks" 49 | // << "body-images" 50 | << "body-markup" 51 | // << "icon-multi" 52 | << "icon-static" 53 | << "persistence" 54 | // << "sound" 55 | ; 56 | return caps; 57 | } 58 | 59 | QString IQDBusService::GetServerInformation(QString &vendor, QString &version, 60 | QString &spec_version) 61 | { 62 | spec_version = QString("1.2"); 63 | version = versionString(); 64 | vendor = QString("viktor.filnkov"); 65 | return QString("iq-notifier"); 66 | } 67 | 68 | uint32_t IQDBusService::Notify(const QString &app_name, uint32_t replaces_id, 69 | const QString &app_icon, const QString &summary, 70 | const QString &body, const QStringList &actions, 71 | const QVariantMap &hints, 72 | uint32_t expire_timeout) 73 | { 74 | auto notification = modify( 75 | {replaces_id, app_name, body, summary, app_icon, actions, hints, 76 | static_cast(expire_timeout), 77 | replaces_id}); 78 | emit createNotificationSignal(notification); 79 | return notification.id; 80 | } 81 | 82 | void IQDBusService::CloseNotification(uint32_t id) 83 | { 84 | emit dropNotificationSignal(id); 85 | } 86 | 87 | void IQDBusService::onNotificationDropped(IQNotification::id_t id, 88 | IQNotification::ClosingReason reason) 89 | { 90 | emit NotificationClosed(id, reason); 91 | } 92 | 93 | void IQDBusService::onActionInvoked(IQNotification::id_t id, 94 | const QString &action_key) 95 | { 96 | emit ActionInvoked(id, action_key); 97 | } 98 | 99 | IQNotification IQDBusService::modify(IQNotification notification) 100 | { 101 | for (auto &m : modifers) 102 | m->modify(notification); 103 | return notification; 104 | } 105 | -------------------------------------------------------------------------------- /iqdbusservice.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | #include "iqconfig.h" 30 | #include "iqnotificationreceiver.h" 31 | 32 | class IQDBusService : public QObject 33 | { 34 | Q_OBJECT 35 | 36 | public: 37 | static QString versionString(); 38 | static QString appString(); 39 | 40 | using QObject::QObject; 41 | 42 | // TODO: use not_null 43 | gsl::not_null 44 | connectReceiver(IQNotificationReceiver *receiver); 45 | 46 | /* 47 | * For configurable modifiers we should check is it enabled in config 48 | */ 49 | template 50 | typename std::enable_if_t::value, 51 | gsl::not_null> 52 | addModifier(std::unique_ptr modifier) 53 | { 54 | if (modifier->isEnabled()) 55 | modifers.push_back(std::move(modifier)); 56 | return this; 57 | } 58 | 59 | template 60 | typename std::enable_if_t::value, 61 | gsl::not_null> 62 | addModifier(std::unique_ptr modifier) 63 | { 64 | modifers.push_back(std::move(modifier)); 65 | return this; 66 | } 67 | 68 | // DBus interface 69 | QStringList GetCapabilities(); 70 | 71 | QString GetServerInformation(QString &vendor, QString &version, 72 | QString &spec_version); 73 | 74 | uint32_t Notify(const QString &app_name, uint32_t replaces_id, 75 | const QString &app_icon, const QString &summary, 76 | const QString &body, const QStringList &actions, 77 | const QVariantMap &hints, uint32_t expire_timeout); 78 | 79 | void CloseNotification(uint32_t id); 80 | 81 | signals: 82 | // DBus signals 83 | void ActionInvoked(uint32_t notification_id, const QString &action_key); 84 | 85 | void NotificationClosed(uint32_t notification_id, uint32_t reason); 86 | 87 | // Internal signals 88 | void createNotificationSignal(const IQNotification ¬ification); 89 | void dropNotificationSignal(IQNotification::id_t id); 90 | 91 | public slots: 92 | void onNotificationDropped(IQNotification::id_t id, 93 | IQNotification::ClosingReason reason); 94 | void onActionInvoked(IQNotification::id_t id, 95 | const QString &action_key); 96 | 97 | private: 98 | std::vector modifers; 99 | 100 | IQNotification modify(IQNotification notification); 101 | }; 102 | -------------------------------------------------------------------------------- /iqdisposition.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | #include "iqdisposition.h" 19 | 20 | #include 21 | 22 | IQDisposition::IQDisposition(QObject *parent) 23 | : QObject{parent}, screen_{QApplication::screens().at(0)} 24 | { 25 | connect(screen_, &QScreen::availableGeometryChanged, this, 26 | &IQDisposition::recalculateAvailableScreenGeometry); 27 | } 28 | 29 | const QScreen *IQDisposition::screen() const { return screen_; } 30 | 31 | void IQDisposition::setExtraWindowSize(const QSize &value) 32 | { 33 | extraWindowSize = value; 34 | } 35 | 36 | void IQDisposition::setMargins(const QMargins &value) 37 | { 38 | margins = value; 39 | recalculateAvailableScreenGeometry(); 40 | } 41 | 42 | void IQDisposition::setSpacing(int value) { spacing = value; } 43 | 44 | void IQDisposition::recalculateAvailableScreenGeometry() 45 | { 46 | auto screenGeometry = screen()->availableGeometry(); 47 | availableScreenGeometry = screenGeometry - margins; 48 | } 49 | -------------------------------------------------------------------------------- /iqdisposition.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | class IQDisposition : public QObject 32 | { 33 | Q_OBJECT 34 | public: 35 | using ptr_t = std::unique_ptr; 36 | template using optional = std::experimental::optional; 37 | 38 | explicit IQDisposition(QObject *parent = nullptr); 39 | virtual ~IQDisposition() = default; 40 | 41 | virtual optional poses(IQNotification::id_t id, QSize size) = 0; 42 | 43 | virtual QPoint externalWindowPos() const = 0; 44 | 45 | const QScreen *screen() const; 46 | 47 | virtual void setExtraWindowSize(const QSize &value); 48 | 49 | virtual void setMargins(const QMargins &value); 50 | 51 | virtual void setSpacing(int value); 52 | 53 | public slots: 54 | virtual void remove(IQNotification::id_t id) = 0; 55 | virtual void removeAll() = 0; 56 | 57 | signals: 58 | void moveNotification(IQNotification::id_t id, QPoint pos); 59 | 60 | protected: 61 | int spacing; 62 | QMargins margins; 63 | QSize extraWindowSize{0, 0}; 64 | QRect availableScreenGeometry; 65 | 66 | virtual void recalculateAvailableScreenGeometry(); 67 | 68 | private: 69 | const QScreen *screen_; 70 | }; 71 | -------------------------------------------------------------------------------- /iqexpirationcontroller.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | #include "iqexpirationcontroller.h" 19 | 20 | bool IQExpirationController::expiration() const 21 | { 22 | return t ? t->isActive() : false; 23 | } 24 | 25 | void IQExpirationController::setExpiration(bool expiration) 26 | { 27 | if (t) { 28 | if (expiration) { 29 | t->start(); 30 | } else { 31 | t->stop(); 32 | } 33 | } 34 | 35 | emit expirationChanged(); 36 | } 37 | 38 | int IQExpirationController::timeout() const { return t ? t->interval() : 0; } 39 | 40 | void IQExpirationController::setTimeout(int timeout) 41 | { 42 | if (timeout) { 43 | if (!t) { 44 | t = std::make_unique(); 45 | t->setSingleShot(true); 46 | connect(t.get(), &QTimer::timeout, 47 | [this] { emit expired(); }); 48 | } 49 | 50 | t->setInterval(timeout); 51 | } else { 52 | t.reset(nullptr); 53 | } 54 | 55 | emit timeoutChanged(); 56 | } 57 | -------------------------------------------------------------------------------- /iqexpirationcontroller.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | class IQExpirationController : public QObject 26 | { 27 | Q_OBJECT 28 | 29 | Q_PROPERTY(bool expiration READ expiration WRITE setExpiration NOTIFY 30 | expirationChanged) 31 | Q_PROPERTY( 32 | int timeout READ timeout WRITE setTimeout NOTIFY timeoutChanged) 33 | public: 34 | using QObject::QObject; 35 | 36 | bool expiration() const; 37 | void setExpiration(bool expiration); 38 | 39 | int timeout() const; 40 | void setTimeout(int timeout); 41 | 42 | signals: 43 | void expired(); 44 | void expirationChanged(); 45 | void timeoutChanged(); 46 | 47 | public slots: 48 | 49 | private: 50 | std::unique_ptr t; 51 | }; 52 | -------------------------------------------------------------------------------- /iqfullscreendetector.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | struct IQFullscreenDetector { 21 | IQFullscreenDetector() = default; 22 | virtual ~IQFullscreenDetector() = default; 23 | 24 | virtual bool fullscreenWindowsOnCurrentDesktop() const = 0; 25 | virtual bool fullscreenWindows() const = 0; 26 | }; 27 | -------------------------------------------------------------------------------- /iqhistory.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | #include "iqhistory.h" 19 | 20 | #include 21 | 22 | IQHistory::IQHistory() 23 | : IQConfigurable{"history"}, model_{std::make_unique(this)} 24 | { 25 | qmlRegisterType("IQNotifier", 1, 0, 26 | "HistoryNotification"); 27 | } 28 | 29 | void IQHistory::onCreateNotification(const IQNotification ¬ification) 30 | { 31 | historyList.push_front( 32 | std::make_unique(notification)); 33 | emit rowInserted(); 34 | } 35 | 36 | void IQHistory::onDropNotification(IQNotification::id_t id) { Q_UNUSED(id) } 37 | 38 | void IQHistory::remove(uint index) { model_->removeRow(index); } 39 | 40 | QAbstractListModel *IQHistory::model() const { return model_.get(); } 41 | 42 | void IQHistory::removeHistoryNotification(uint index) 43 | { 44 | auto it = historyList.begin(); 45 | std::advance(it, index); 46 | historyList.erase(it); 47 | } 48 | 49 | IQHistoryNotification::IQHistoryNotification(const IQNotification &n, 50 | QObject *parent) 51 | : QObject(parent), id__{n.id}, application_{n.application}, title_{n.title}, 52 | body_{n.body}, iconUrl_{n.icon_url} 53 | { 54 | } 55 | 56 | uint IQHistoryNotification::id_() const { return id__; } 57 | 58 | QString IQHistoryNotification::application() const { return application_; } 59 | 60 | QString IQHistoryNotification::title() const { return title_; } 61 | 62 | QString IQHistoryNotification::body() const { return body_; } 63 | 64 | QString IQHistoryNotification::iconUrl() const { return iconUrl_; } 65 | 66 | IQHistoryModel::IQHistoryModel(IQHistory::ptr_t history_) : iqHistory{history_} 67 | { 68 | connect(iqHistory, &IQHistory::rowInserted, this, 69 | &IQHistoryModel::onHistoryRowInserted); 70 | } 71 | 72 | int IQHistoryModel::rowCount(const QModelIndex &parent) const 73 | { 74 | if (!iqHistory) 75 | return 0; 76 | 77 | Q_UNUSED(parent); 78 | return iqHistory->historyList.size(); 79 | } 80 | 81 | QVariant IQHistoryModel::data(const QModelIndex &index, int role) const 82 | { 83 | if (!iqHistory) 84 | return {}; 85 | 86 | if (!index.isValid()) 87 | return QVariant(); 88 | 89 | auto &n = iqHistory->historyList[index.row()]; 90 | switch (role) { 91 | case Id_Role: 92 | return n->id_(); 93 | break; 94 | case ApplicationRole: 95 | return n->application(); 96 | break; 97 | case TitleRole: 98 | return n->title(); 99 | break; 100 | case BodyRole: 101 | return n->body(); 102 | break; 103 | case IconUrlRole: 104 | return n->iconUrl(); 105 | break; 106 | default: 107 | break; 108 | } 109 | return {}; 110 | } 111 | 112 | bool IQHistoryModel::insertRows(int row, int count, const QModelIndex &parent) 113 | { 114 | if (row || count > 1) 115 | return false; 116 | 117 | beginInsertRows(parent, 0, 0); 118 | endInsertRows(); 119 | return true; 120 | } 121 | 122 | bool IQHistoryModel::removeRows(int row, int count, const QModelIndex &parent) 123 | { 124 | if (!iqHistory) 125 | return false; 126 | 127 | auto &list = iqHistory->historyList; 128 | if (static_cast(row) >= list.size() || row + count <= 0) 129 | return false; 130 | 131 | auto beginRow = qMax(0, row); 132 | auto endRow = qMin(row + count - 1, static_cast(list.size() - 1)); 133 | 134 | beginRemoveRows(parent, beginRow, endRow); 135 | 136 | while (beginRow <= endRow) { 137 | iqHistory->removeHistoryNotification(beginRow); 138 | ++beginRow; 139 | } 140 | 141 | endRemoveRows(); 142 | return true; 143 | } 144 | 145 | QHash IQHistoryModel::roleNames() const 146 | { 147 | QHash roles; 148 | roles[Id_Role] = "id_"; 149 | roles[ApplicationRole] = "application"; 150 | roles[TitleRole] = "title"; 151 | roles[BodyRole] = "body"; 152 | roles[IconUrlRole] = "iconUrl"; 153 | return roles; 154 | } 155 | 156 | void IQHistoryModel::onHistoryRowInserted() { insertRow(0); } 157 | -------------------------------------------------------------------------------- /iqhistory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | #include "iqconfig.h" 29 | #include "iqnotificationreceiver.h" 30 | class IQHistoryModel; 31 | 32 | class IQHistoryNotification : public QObject 33 | { 34 | Q_OBJECT 35 | Q_PROPERTY(uint id_ READ id_ CONSTANT) 36 | Q_PROPERTY(QString application READ application CONSTANT) 37 | Q_PROPERTY(QString title READ title CONSTANT) 38 | Q_PROPERTY(QString body READ body CONSTANT) 39 | Q_PROPERTY(QString iconUrl READ iconUrl CONSTANT) 40 | public: 41 | IQHistoryNotification() = default; 42 | IQHistoryNotification(const IQNotification &n, 43 | QObject *parent = nullptr); 44 | 45 | uint id_() const; 46 | QString application() const; 47 | QString title() const; 48 | QString body() const; 49 | QString iconUrl() const; 50 | 51 | private: 52 | const uint id__{0}; 53 | const QString application_; 54 | const QString title_; 55 | const QString body_; 56 | const QString iconUrl_; 57 | }; 58 | 59 | class IQHistory : public IQNotificationReceiver, public IQConfigurable 60 | { 61 | friend class IQHistoryModel; 62 | 63 | Q_OBJECT 64 | Q_PROPERTY(bool isEnabled READ isEnabled CONSTANT) 65 | Q_PROPERTY(QAbstractItemModel *model READ model CONSTANT) 66 | public: 67 | IQHistory(); 68 | QAbstractListModel *model() const; 69 | 70 | public slots: 71 | /* 72 | * External slots 73 | */ 74 | void onCreateNotification(const IQNotification ¬ification) final; 75 | void onDropNotification(IQNotification::id_t id) final; 76 | 77 | /* 78 | * QML slots 79 | */ 80 | void remove(uint index); 81 | 82 | signals: 83 | void rowInserted(); 84 | 85 | private: 86 | using ptr_t = gsl::not_null; 87 | std::deque> historyList; 88 | std::unique_ptr model_; 89 | 90 | void removeHistoryNotification(uint index); 91 | }; 92 | 93 | class IQHistoryModel : public QAbstractListModel 94 | { 95 | Q_OBJECT 96 | public: 97 | enum HistoryRoles { 98 | Id_Role = Qt::UserRole + 1, 99 | ApplicationRole, 100 | TitleRole, 101 | BodyRole, 102 | IconUrlRole 103 | }; 104 | explicit IQHistoryModel(IQHistory::ptr_t history_); 105 | int rowCount(const QModelIndex &parent) const final; 106 | QVariant data(const QModelIndex &index, int role) const final; 107 | bool insertRows(int row, int count, const QModelIndex &parent) final; 108 | bool removeRows(int row, int count, const QModelIndex &parent) final; 109 | QHash roleNames() const final; 110 | 111 | private slots: 112 | void onHistoryRowInserted(); 113 | 114 | private: 115 | IQHistory *iqHistory; 116 | }; 117 | -------------------------------------------------------------------------------- /iqnotification.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | #include "iqnotification.h" 19 | 20 | IQNotification::operator QString() const 21 | { 22 | QString ret; 23 | ret += "#" + QString::number(id); 24 | if (replaces_id) 25 | ret += "→" + QString::number(replaces_id); 26 | ret += '|' + application; 27 | ret += '|' + body; 28 | ret += '|' + title; 29 | ret += '|' + icon_url; 30 | ret += "|t" + QString::number(expire_timeout); 31 | return ret; 32 | } 33 | 34 | IQNotificationModifier::~IQNotificationModifier() {} 35 | -------------------------------------------------------------------------------- /iqnotification.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | struct IQNotification { 27 | using id_t = uint32_t; 28 | 29 | enum ClosingReason : uint32_t { 30 | CR_NOTIFICATION_EXPIRED = 1, 31 | CR_NOTIFICATION_DISMISSED, 32 | CR_NOTIFICATION_CLOSED, 33 | CR_NOTIFICATION_CLOSED_REASON_UNDEFINED 34 | }; 35 | 36 | enum ExpireTimeout : int { ET_SERVER_DECIDES = -1, ET_FOREVER = 0 }; 37 | 38 | id_t id; 39 | QString application; 40 | QString body; 41 | QString title; 42 | QString icon_url; 43 | QStringList actions; 44 | QVariantMap hints; 45 | ExpireTimeout expire_timeout; 46 | 47 | id_t replaces_id; 48 | 49 | operator QString() const; 50 | }; 51 | 52 | struct IQNotificationModifier { 53 | using ptr_t = std::unique_ptr; 54 | 55 | virtual ~IQNotificationModifier(); 56 | virtual void modify(IQNotification ¬ification) = 0; 57 | }; 58 | -------------------------------------------------------------------------------- /iqnotificationmodifiers.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | #include "iqnotificationmodifiers.h" 19 | 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | #include 29 | 30 | /* 31 | * Best way found 32 | * Using private pointers for notification fields 33 | * in base class lead to sex with '(*ptr)' 34 | */ 35 | #define N_TO_REFS(N__) \ 36 | id_t &id = N__.id; \ 37 | Q_UNUSED(id); \ 38 | QString &application = N__.application; \ 39 | Q_UNUSED(application); \ 40 | QString &body = N__.body; \ 41 | Q_UNUSED(body); \ 42 | QString &title = N__.title; \ 43 | Q_UNUSED(title); \ 44 | QString &icon_url = N__.icon_url; \ 45 | Q_UNUSED(icon_url); \ 46 | QStringList &actions = N__.actions; \ 47 | Q_UNUSED(actions); \ 48 | QVariantMap &hints = N__.hints; \ 49 | Q_UNUSED(hints); \ 50 | IQNotification::ExpireTimeout &expire_timeout = N__.expire_timeout; \ 51 | Q_UNUSED(expire_timeout); \ 52 | id_t &replaces_id = N__.replaces_id; \ 53 | Q_UNUSED(replaces_id); 54 | 55 | namespace 56 | { 57 | 58 | template using map_t = std::map; 59 | static map_t cached_images; 60 | 61 | bool isCached(uintmax_t hash) 62 | { 63 | return cached_images.find(hash) != cached_images.end(); 64 | } 65 | 66 | QString imageFilenameFromHash(uintmax_t hash) 67 | { 68 | auto ret = XdgDirs::cacheHome() + "/iq-cached_" + 69 | QString::number(hash) + ".png"; 70 | return ret; 71 | } 72 | 73 | /* 74 | * No ret due to we want to reuse var 75 | */ 76 | void toQmlAbsolutePath(QString &path) 77 | { 78 | if (path.isEmpty()) 79 | return; 80 | if (path[0] == '/') 81 | path.insert(0, "file://"); 82 | } 83 | 84 | template bool cacheImage(const T &img, uintmax_t hash) 85 | { 86 | auto fname = imageFilenameFromHash(hash); 87 | if (img.save(fname)) 88 | cached_images[hash] = std::move(fname); 89 | else 90 | return false; 91 | return true; 92 | } 93 | 94 | QString getImageUrlFromHint(const QVariant &argument) 95 | { 96 | int width, height, rowstride, bitsPerSample, channels; 97 | bool hasAlpha; 98 | QByteArray data; 99 | 100 | const QDBusArgument arg = argument.value(); 101 | arg.beginStructure(); 102 | arg >> width; 103 | arg >> height; 104 | arg >> rowstride; 105 | arg >> hasAlpha; 106 | arg >> bitsPerSample; 107 | arg >> channels; 108 | arg >> data; 109 | arg.endStructure(); 110 | 111 | auto hash = qHash(data); 112 | 113 | if (!isCached(hash)) { 114 | bool rgb = !hasAlpha && channels == 3 && bitsPerSample == 8; 115 | QImage::Format imageFormat = 116 | rgb ? QImage::Format_RGB888 : QImage::Format_ARGB32; 117 | 118 | QImage img = 119 | QImage(reinterpret_cast(data.constData()), 120 | width, height, imageFormat); 121 | 122 | if (!rgb) 123 | img = img.rgbSwapped(); 124 | 125 | if (!cacheImage(img, hash)) { 126 | return {}; 127 | } 128 | } 129 | return cached_images[hash]; 130 | } 131 | 132 | QString getImageUrlFromString(const QString &str) 133 | { 134 | static constexpr auto PIXMAP_SIZE = 256; 135 | 136 | QUrl url(str); 137 | if (url.isValid() && QFile::exists(url.toLocalFile())) { 138 | return url.toLocalFile(); 139 | } else { 140 | // TODO: OMFG???????? 141 | auto icon = XdgIcon::fromTheme(str); 142 | auto hash = static_cast(icon.cacheKey()); 143 | 144 | if (!isCached(hash)) { 145 | auto pixmap = icon.pixmap({PIXMAP_SIZE, PIXMAP_SIZE}); 146 | if (!cacheImage(pixmap, hash)) { 147 | return {}; 148 | } 149 | } 150 | return cached_images[hash]; 151 | } 152 | } 153 | 154 | } // anonymouse namespace 155 | 156 | void IQNotificationModifiers::IDGenerator::modify(IQNotification ¬ification) 157 | { 158 | N_TO_REFS(notification); 159 | if (replaces_id == 0) 160 | id = ++last_id; 161 | } 162 | 163 | /* 164 | * Based on lxqt notification daemon 165 | */ 166 | void IQNotificationModifiers::IconHandler::modify(IQNotification ¬ification) 167 | { 168 | N_TO_REFS(notification); 169 | if (!hints["image_data"].isNull()) { 170 | icon_url = getImageUrlFromHint(hints["image_data"]); 171 | } else if (!hints["image_path"].isNull()) { 172 | icon_url = 173 | getImageUrlFromString(hints["image_path"].toString()); 174 | } else if (!icon_url.isEmpty()) { 175 | /* 176 | * Check, is it web URL 177 | */ 178 | { 179 | static const QString http{"http://"}; 180 | static const QString https{"https://"}; 181 | if (icon_url.startsWith(http, Qt::CaseInsensitive) || 182 | icon_url.startsWith(https, Qt::CaseInsensitive)) 183 | return; 184 | } 185 | icon_url = getImageUrlFromString(icon_url); 186 | } else if (!hints["icon_data"].isNull()) { 187 | icon_url = getImageUrlFromHint(hints["icon_data"]); 188 | } 189 | 190 | toQmlAbsolutePath(icon_url); 191 | } 192 | 193 | IQNotificationModifiers::DefaultTimeout::DefaultTimeout() 194 | : IQConfigurable{"default_timeout"} 195 | { 196 | static constexpr auto real_default{3500}; 197 | defaultTimeout = static_cast( 198 | config.value("default_timeout", real_default).toUInt()); 199 | if (defaultTimeout == 0) 200 | defaultTimeout = real_default; 201 | } 202 | 203 | void IQNotificationModifiers::DefaultTimeout::modify( 204 | IQNotification ¬ification) 205 | { 206 | N_TO_REFS(notification); 207 | if (expire_timeout < 0) 208 | expire_timeout = static_cast< 209 | std::remove_reference_t>( 210 | defaultTimeout); 211 | } 212 | 213 | IQNotificationModifiers::TitleToIcon::TitleToIcon() 214 | : IQConfigurable{"title_to_icon"} 215 | { 216 | } 217 | 218 | void IQNotificationModifiers::TitleToIcon::modify(IQNotification ¬ification) 219 | { 220 | N_TO_REFS(notification); 221 | // Do nothing if icon presented 222 | if (!icon_url.isEmpty()) 223 | return; 224 | 225 | if (application.compare(title, Qt::CaseInsensitive) == 0) { 226 | icon_url = application.toLower().replace(' ', '-'); 227 | } 228 | } 229 | 230 | IQNotificationModifiers::ReplaceMinusToDash::ReplaceMinusToDash() 231 | : IQConfigurable{"replace_minus_to_dash"} 232 | { 233 | fixTitle = config.value("title", true).toBool(); 234 | fixBody = config.value("body", true).toBool(); 235 | } 236 | 237 | void IQNotificationModifiers::ReplaceMinusToDash::modify( 238 | IQNotification ¬ification) 239 | { 240 | N_TO_REFS(notification); 241 | if (fixTitle) 242 | replaceMinusToDash(title); 243 | if (fixBody) 244 | replaceMinusToDash(body); 245 | } 246 | 247 | void IQNotificationModifiers::ReplaceMinusToDash::replaceMinusToDash( 248 | QString &str) 249 | { 250 | static QString minus{minusPattern}, dash{replaceTo}; 251 | str.replace(minus, dash); 252 | } 253 | 254 | IQNotificationModifiers::BodyToTitleWhenTitleIsAppName:: 255 | BodyToTitleWhenTitleIsAppName() 256 | : IQConfigurable{"body_to_title_when_title_is_app_name"} 257 | { 258 | } 259 | 260 | void IQNotificationModifiers::BodyToTitleWhenTitleIsAppName::modify( 261 | IQNotification ¬ification) 262 | { 263 | N_TO_REFS(notification); 264 | if (application.compare(title, Qt::CaseInsensitive) == 0) { 265 | title = body; 266 | body = QString{}; 267 | } 268 | } 269 | 270 | #undef N_TO_REFS 271 | -------------------------------------------------------------------------------- /iqnotificationmodifiers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #include "iqconfig.h" 21 | #include "iqnotification.h" 22 | 23 | namespace IQNotificationModifiers 24 | { 25 | 26 | template std::unique_ptr make(A &&... args) 27 | { 28 | return std::make_unique(std::forward(args)...); 29 | } 30 | 31 | struct IDGenerator final : public IQNotificationModifier { 32 | IQNotification::id_t last_id{0}; 33 | 34 | void modify(IQNotification ¬ification) final; 35 | }; 36 | 37 | struct IconHandler final : public IQNotificationModifier { 38 | void modify(IQNotification ¬ification) final; 39 | }; 40 | 41 | struct DefaultTimeout final : public IQNotificationModifier, 42 | public IQConfigurable { 43 | DefaultTimeout(); 44 | void modify(IQNotification ¬ification) final; 45 | 46 | private: 47 | uint16_t defaultTimeout; 48 | }; 49 | 50 | struct TitleToIcon final : public IQNotificationModifier, 51 | public IQConfigurable { 52 | TitleToIcon(); 53 | void modify(IQNotification ¬ification) final; 54 | }; 55 | 56 | struct BodyToTitleWhenTitleIsAppName final : public IQNotificationModifier, 57 | public IQConfigurable { 58 | BodyToTitleWhenTitleIsAppName(); 59 | void modify(IQNotification ¬ification) final; 60 | }; 61 | 62 | struct ReplaceMinusToDash final : public IQNotificationModifier, 63 | public IQConfigurable { 64 | ReplaceMinusToDash(); 65 | 66 | void modify(IQNotification ¬ification) final; 67 | 68 | private: 69 | bool fixTitle, fixBody; 70 | 71 | static void replaceMinusToDash(QString &str); 72 | 73 | static constexpr auto minusPattern{" - "}; 74 | static constexpr auto replaceTo{" — "}; 75 | }; 76 | 77 | } // namespace IQNotificationModifiers 78 | -------------------------------------------------------------------------------- /iqnotificationreceiver.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | #include "iqnotificationreceiver.h" 19 | -------------------------------------------------------------------------------- /iqnotificationreceiver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #include 21 | 22 | #include "iqnotification.h" 23 | 24 | class IQNotificationReceiver : public QObject 25 | { 26 | Q_OBJECT 27 | 28 | public: 29 | using QObject::QObject; 30 | virtual ~IQNotificationReceiver() = default; 31 | 32 | signals: 33 | void notificationDroppedSignal(IQNotification::id_t id, 34 | IQNotification::ClosingReason reason); 35 | void actionInvokedSignal(IQNotification::id_t id, 36 | const QString &action_key); 37 | 38 | public slots: 39 | virtual void 40 | onCreateNotification(const IQNotification ¬ification) = 0; 41 | virtual void onDropNotification(IQNotification::id_t id) = 0; 42 | }; 43 | -------------------------------------------------------------------------------- /iqnotifications.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | #include "iqnotifications.h" 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | template using optional = std::experimental::optional; 29 | 30 | IQNotifications::IQNotifications(IQDisposition::ptr_t disposition_, 31 | QObject *parent) 32 | : IQNotificationReceiver(parent), IQConfigurable{"popup_notifications"}, 33 | disposition{std::move(disposition_)} 34 | { 35 | if (!disposition) 36 | throw std::invalid_argument{ 37 | "IQNotifications: provide disposition"}; 38 | disposition->setExtraWindowSize(extraWindowSize()); 39 | disposition->setSpacing(spacing()); 40 | disposition->setMargins(margins()); 41 | 42 | connect(this, &IQNotifications::dropNotification, disposition.get(), 43 | &IQDisposition::remove); 44 | connect(disposition.get(), &IQDisposition::moveNotification, 45 | [this](IQNotification::id_t id, QPoint pos) { 46 | emit moveNotification(static_cast(id), pos); 47 | checkExtraNotifications(); 48 | }); 49 | } 50 | 51 | gsl::not_null 52 | IQNotifications::get(IQDisposition::ptr_t disposition) 53 | { 54 | static IQNotifications *ptr_{nullptr}; 55 | if (!ptr_) { 56 | if (!disposition) 57 | throw std::invalid_argument("IQDisposition: call get " 58 | "with valid disposition " 59 | "first"); 60 | 61 | ptr_ = new IQNotifications{std::move(disposition)}; 62 | } 63 | return {ptr_}; 64 | } 65 | 66 | void IQNotifications::setFullscreenDetector( 67 | std::unique_ptr detector) 68 | { 69 | fullscreenDetector = std::move(detector); 70 | } 71 | 72 | int IQNotifications::extraNotificationsCount() const 73 | { 74 | return static_cast(extraNotifications.size()); 75 | } 76 | 77 | bool IQNotifications::closeAllByRightClick() const 78 | { 79 | return config 80 | .value(CONFIG_CLOSE_ALL_BY_RIGHT_CLICK, 81 | CONFIG_CLOSE_ALL_BY_RIGHT_CLICK_DEFAULT) 82 | .toBool(); 83 | } 84 | 85 | bool IQNotifications::closeVisibleByLeftClick() const 86 | { 87 | return config 88 | .value(CONFIG_CLOSE_VISIBLE_BY_MIDDLE_CLICK, 89 | CONFIG_CLOSE_VISIBLE_BY_MIDDLE_CLICK_DEFAULT) 90 | .toBool(); 91 | } 92 | 93 | bool IQNotifications::closeByLeftClick() const 94 | { 95 | return config 96 | .value(CONFIG_CLOSE_BY_LEFT_CLICK, 97 | CONFIG_CLOSE_BY_LEFT_CLICK_DEFAULT) 98 | .toBool(); 99 | } 100 | 101 | bool IQNotifications::dontShowWhenFullscreenAny() const 102 | { 103 | return config 104 | .value(CONFIG_DONT_SHOW_WHEN_FULLSCREEN_ANY, 105 | CONFIG_DONT_SHOW_WHEN_FULLSCREEN_ANY_DEFAULT) 106 | .toBool(); 107 | } 108 | 109 | bool IQNotifications::dontShowWhenFullscreenCurrentDesktop() const 110 | { 111 | return config 112 | .value(CONFIG_DONT_SHOW_WHEN_FULLSCREEN_CURRENT_DESKTOP, 113 | CONFIG_DONT_SHOW_WHEN_FULLSCREEN_CURRENT_DESKTOP_DEFAULT) 114 | .toBool(); 115 | } 116 | 117 | void IQNotifications::setDontShowWhenFullscreenCurrentDesktop(bool value) 118 | { 119 | config.setValue(CONFIG_DONT_SHOW_WHEN_FULLSCREEN_CURRENT_DESKTOP, 120 | value); 121 | emit dontShowWhenFullscreenCurrentDesktopChanged(); 122 | } 123 | 124 | void IQNotifications::onCreateNotification(const IQNotification &n) 125 | { 126 | if (!shouldShowPopup()) 127 | return; 128 | if (!createNotificationIfSpaceAvailable(n)) { 129 | extraNotifications.push(n); 130 | emit extraNotificationsCountChanged(); 131 | } 132 | } 133 | 134 | void IQNotifications::onDropNotification(IQNotification::id_t id) 135 | { 136 | emit dropNotification(static_cast(id)); 137 | emit notificationDroppedSignal(id, 138 | IQNotification::CR_NOTIFICATION_CLOSED); 139 | } 140 | 141 | void IQNotifications::onCloseButtonPressed(int id) 142 | { 143 | emit dropNotification(id); 144 | emit notificationDroppedSignal( 145 | static_cast(id), 146 | IQNotification::CR_NOTIFICATION_DISMISSED); 147 | checkExtraNotifications(); 148 | } 149 | 150 | void IQNotifications::onActionButtonPressed(int id, const QString &action) 151 | { 152 | emit dropNotification(id); 153 | emit actionInvokedSignal(static_cast(id), action); 154 | emit notificationDroppedSignal( 155 | static_cast(id), 156 | IQNotification::CR_NOTIFICATION_DISMISSED); 157 | } 158 | 159 | void IQNotifications::onExpired(int id) 160 | { 161 | emit dropNotification(id); 162 | emit notificationDroppedSignal(static_cast(id), 163 | IQNotification::CR_NOTIFICATION_EXPIRED); 164 | } 165 | 166 | void IQNotifications::onDropAll() 167 | { 168 | onDropStacked(); 169 | onDropVisible(); 170 | } 171 | 172 | void IQNotifications::onDropStacked() 173 | { 174 | decltype(extraNotifications) empty; 175 | std::swap(extraNotifications, empty); 176 | emit extraNotificationsCountChanged(); 177 | } 178 | 179 | void IQNotifications::onDropVisible() 180 | { 181 | emit dropAllVisible(); 182 | disposition->removeAll(); 183 | checkExtraNotifications(); 184 | } 185 | 186 | int IQNotifications::spacing() const 187 | { 188 | return config.value(CONFIG_SPACING, CONFIG_SPACING_DEFAULT).toInt(); 189 | } 190 | 191 | QMargins IQNotifications::margins() const 192 | { 193 | static auto string_list_to_margins = 194 | [](QStringList list) -> optional { 195 | enum Sides { LEFT = 0, TOP, RIGHT, BOTTOM, SIZE }; 196 | 197 | if (list.size() != SIZE) 198 | return {}; 199 | 200 | auto get = [&list](auto index) { 201 | bool ok{true}; 202 | auto value = list[index].toInt(&ok); 203 | if (!ok) 204 | throw std::logic_error{"IQConfig: " 205 | "ui::global_margins " 206 | "wrong value!"}; 207 | return value; 208 | }; 209 | 210 | QMargins ret; 211 | ret.setLeft(get(LEFT)); 212 | ret.setTop(get(TOP)); 213 | ret.setRight(get(RIGHT)); 214 | ret.setBottom(get(BOTTOM)); 215 | return {ret}; 216 | }; 217 | 218 | auto config_field = config.value(CONFIG_GLOBAL_MARGINS); 219 | auto config_margin = 220 | string_list_to_margins(config_field.toStringList()); 221 | if (config_margin) { 222 | return *config_margin; 223 | } else { 224 | auto screen = disposition->screen()->availableSize(); 225 | auto margin = GLOBAL_MARGINS_DEFAULT_FACTOR * screen.height(); 226 | auto m = static_cast(margin); 227 | return {m, m, m, m}; 228 | } 229 | } 230 | 231 | QSize IQNotifications::windowSize() const 232 | { 233 | return windowSize(CONFIG_WIDTH, CONFIG_HEIGHT, WIDTH_DEFAULT_FACTOR, 234 | HEIGHT_DEFAULT_FACTOR); 235 | } 236 | 237 | QSize IQNotifications::windowSize(const QString &width_key, 238 | const QString &height_key, 239 | double width_factor, 240 | double height_factor) const 241 | { 242 | // TODO: cache values 243 | 244 | auto get_window_size_from_config = 245 | [width_key, height_key](const auto &config) -> optional { 246 | auto get = [&config](auto key) { 247 | bool ok{true}; 248 | auto value = config.value(key, 0).toInt(&ok); 249 | if (!ok || value < 0) 250 | throw std::logic_error{"IQConfig: window or " 251 | "extra_window size " 252 | "wrong value!"}; 253 | return value; 254 | }; 255 | 256 | auto w = get(width_key); 257 | auto h = get(height_key); 258 | 259 | if (!w || !h) 260 | return {}; 261 | else 262 | return {QSize{w, h}}; 263 | }; 264 | 265 | auto config_size = get_window_size_from_config(config); 266 | if (config_size) { 267 | return *config_size; 268 | } else { 269 | auto screen = disposition->screen()->availableSize(); 270 | auto w = width_factor * screen.width(); 271 | auto h = height_factor * screen.height(); 272 | return QSize{static_cast(w), static_cast(h)}; 273 | } 274 | } 275 | 276 | QSize IQNotifications::extraWindowSize() const 277 | { 278 | return windowSize(CONFIG_EXTRA_WINDOW_WIDTH, CONFIG_EXTRA_WINDOW_HEIGHT, 279 | EXTRA_WINDOW_WIDTH_DEFAULT_FACTOR, 280 | EXTRA_WINDOW_HEIGHT_DEFAULT_FACTOR); 281 | } 282 | 283 | QPoint IQNotifications::extraWindowPos() const 284 | { 285 | return disposition->externalWindowPos(); 286 | } 287 | 288 | bool IQNotifications::createNotificationIfSpaceAvailable( 289 | const IQNotification &n) 290 | { 291 | auto size = windowSize(); 292 | auto pos = disposition->poses(n.id, size); 293 | if (pos) { 294 | auto id = n.replaces_id ? n.replaces_id : n.id; 295 | emit createNotification(static_cast(id), size, *pos, 296 | n.expire_timeout, n.application, n.body, 297 | n.title, n.icon_url, n.actions); 298 | return true; 299 | } else { 300 | return false; 301 | } 302 | } 303 | 304 | void IQNotifications::checkExtraNotifications() 305 | { 306 | while (!extraNotifications.empty() && 307 | createNotificationIfSpaceAvailable(extraNotifications.front())) { 308 | extraNotifications.pop(); 309 | emit extraNotificationsCountChanged(); 310 | } 311 | } 312 | 313 | bool IQNotifications::shouldShowPopup() const 314 | { 315 | if (fullscreenDetector) { 316 | if (dontShowWhenFullscreenCurrentDesktop()) { 317 | auto cd = fullscreenDetector 318 | ->fullscreenWindowsOnCurrentDesktop(); 319 | if (cd) 320 | return false; 321 | } 322 | if (dontShowWhenFullscreenAny()) { 323 | auto any = fullscreenDetector->fullscreenWindows(); 324 | if (any) 325 | return false; 326 | } 327 | } 328 | return true; 329 | } 330 | -------------------------------------------------------------------------------- /iqnotifications.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #pragma clang diagnostic push 27 | #pragma clang diagnostic ignored "-Wweak-vtables" 28 | #include 29 | #pragma clang diagnostic pop 30 | 31 | #include "iqconfig.h" 32 | #include "iqdisposition.h" 33 | #include "iqfullscreendetector.h" 34 | #include "iqnotificationreceiver.h" 35 | 36 | class IQNotifications final : public IQNotificationReceiver, 37 | public IQConfigurable 38 | { 39 | Q_OBJECT 40 | Q_PROPERTY(int extraNotifications READ extraNotificationsCount NOTIFY 41 | extraNotificationsCountChanged) 42 | Q_PROPERTY(QSize extraWindowSize READ extraWindowSize CONSTANT) 43 | Q_PROPERTY(QPoint extraWindowPos READ extraWindowPos CONSTANT) 44 | Q_PROPERTY(bool closeAllByRightClick READ closeAllByRightClick CONSTANT) 45 | Q_PROPERTY( 46 | bool closeVisibleByLeftClick READ closeVisibleByLeftClick CONSTANT) 47 | Q_PROPERTY(bool closeByLeftClick READ closeByLeftClick CONSTANT) 48 | Q_PROPERTY(bool dontShowWhenFullscreenAny READ dontShowWhenFullscreenAny 49 | CONSTANT) 50 | 51 | /* 52 | * Changable on-the-fly 53 | */ 54 | Q_PROPERTY(bool dontShowWhenFullscreenCurrentDesktop READ 55 | dontShowWhenFullscreenCurrentDesktop WRITE 56 | setDontShowWhenFullscreenCurrentDesktop NOTIFY 57 | dontShowWhenFullscreenCurrentDesktopChanged) 58 | 59 | IQNotifications(IQDisposition::ptr_t disposition_, 60 | QObject *parent = nullptr); 61 | 62 | public: 63 | static gsl::not_null 64 | get(IQDisposition::ptr_t disposition = nullptr); 65 | 66 | void 67 | setFullscreenDetector(std::unique_ptr detector_); 68 | 69 | QSize extraWindowSize() const; 70 | QPoint extraWindowPos() const; 71 | int extraNotificationsCount() const; 72 | bool closeAllByRightClick() const; 73 | bool closeVisibleByLeftClick() const; 74 | bool closeByLeftClick() const; 75 | bool dontShowWhenFullscreenAny() const; 76 | 77 | bool dontShowWhenFullscreenCurrentDesktop() const; 78 | void setDontShowWhenFullscreenCurrentDesktop(bool value); 79 | 80 | signals: 81 | // Signals to QML 82 | void extraNotificationsCountChanged(); 83 | void createNotification(int notification_id, QSize size, QPoint pos, 84 | int expire_timeout, const QString &appName, 85 | const QString &body, 86 | const QString &title = QString{}, 87 | const QString &iconUrl = QString{}, 88 | const QStringList &actions = {}); 89 | void dropNotification(int notification_id); 90 | void dropAllVisible(); 91 | void moveNotification(int notification_id, QPoint pos); 92 | 93 | /* 94 | * Property changed signals 95 | */ 96 | void dontShowWhenFullscreenCurrentDesktopChanged(); 97 | 98 | public slots: 99 | void onCreateNotification(const IQNotification ¬ification) final; 100 | void onDropNotification(IQNotification::id_t id) final; 101 | 102 | // QML slots 103 | void onCloseButtonPressed(int id); 104 | void onActionButtonPressed(int id, const QString &action); 105 | void onExpired(int id); 106 | void onDropAll(); 107 | void onDropStacked(); 108 | void onDropVisible(); 109 | 110 | private: 111 | IQ_CONF_VAR(CLOSE_ALL_BY_RIGHT_CLICK, "close_all_by_right_click", true) 112 | IQ_CONF_VAR(CLOSE_VISIBLE_BY_MIDDLE_CLICK, 113 | "close_visible_by_middle_click", true) 114 | IQ_CONF_VAR(CLOSE_BY_LEFT_CLICK, "close_by_left_click", false) 115 | IQ_CONF_VAR(SPACING, "spacing", 0) 116 | IQ_CONF_FACTOR(GLOBAL_MARGINS, "global_margins", 0.02610966057441253264) 117 | IQ_CONF_FACTOR(EXTRA_WINDOW_WIDTH, "extra_window_width", 118 | 0.21961932650073206442) 119 | IQ_CONF_FACTOR(EXTRA_WINDOW_HEIGHT, "extra_window_height", 120 | 0.08355091383812010444 / 2) 121 | IQ_CONF_FACTOR(WIDTH, "width", 0.21961932650073206442) 122 | IQ_CONF_FACTOR(HEIGHT, "height", 0.28198433420365535248) 123 | IQ_CONF_VAR(DONT_SHOW_WHEN_FULLSCREEN_ANY, 124 | "dont_show_when_fullscreen_any", false) 125 | 126 | /* 127 | * Changable on-the-fly 128 | */ 129 | IQ_CONF_VAR(DONT_SHOW_WHEN_FULLSCREEN_CURRENT_DESKTOP, 130 | "dont_show_when_fullscreen_current_desktop", false) 131 | 132 | IQDisposition::ptr_t disposition; 133 | std::queue extraNotifications; 134 | std::unique_ptr fullscreenDetector; 135 | 136 | int spacing() const; 137 | QMargins margins() const; 138 | QSize windowSize() const; 139 | QSize windowSize(const QString &width_key, const QString &height_key, 140 | double width_factor, double height_factor) const; 141 | bool createNotificationIfSpaceAvailable(const IQNotification &n); 142 | void checkExtraNotifications(); 143 | bool shouldShowPopup() const; 144 | }; 145 | -------------------------------------------------------------------------------- /iqthemes.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | #include "iqthemes.h" 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | namespace 25 | { 26 | static QRect availableGeometry() 27 | { 28 | QScreen *screen = QApplication::screens().at(0); 29 | return screen->availableGeometry(); 30 | } 31 | } // anonymouse namespace 32 | 33 | IQThemes::IQThemes() 34 | : config{"theme"}, 35 | themeName{ 36 | config.value(CONFIG_THEME_NAME, CONFIG_THEME_NAME_DEFAULT).toString()} 37 | { 38 | registerThemeTypes(); 39 | loadTheme(themeConfigFile()); 40 | auto themeDir = IQConfig::configDir() + '/' + themeConfigDir(); 41 | notificationsTheme_ = 42 | std::make_unique(themeConfig, themeDir); 43 | trayIconTheme_ = std::make_unique(themeConfig, themeDir); 44 | historyWindowTheme_ = 45 | std::make_unique(themeConfig, themeDir); 46 | } 47 | 48 | NotificationsTheme *IQThemes::notificationsTheme() const 49 | { 50 | return notificationsTheme_.get(); 51 | } 52 | 53 | TrayIconTheme *IQThemes::trayIconTheme() const { return trayIconTheme_.get(); } 54 | 55 | HistoryWindowTheme *IQThemes::historyWindowTheme() const 56 | { 57 | return historyWindowTheme_.get(); 58 | } 59 | 60 | QString IQThemes::themeConfigDir() const { return "themes/" + themeName; } 61 | 62 | QString IQThemes::themeConfigFile() const 63 | { 64 | return themeConfigDir() + "/theme"; 65 | } 66 | 67 | void IQThemes::loadTheme(const QString &fileName) 68 | { 69 | themeConfig = std::make_shared(QString{}, fileName); 70 | } 71 | 72 | void IQThemes::registerThemeTypes() const 73 | { 74 | qmlRegisterType("IQNotifier", 1, 0, 75 | "NotificationsTheme"); 76 | qmlRegisterType("IQNotifier", 1, 0, "TrayIconTheme"); 77 | qmlRegisterType("IQNotifier", 1, 0, 78 | "HistoryWindowTheme"); 79 | } 80 | 81 | IQTheme::IQTheme(const std::shared_ptr &config_, 82 | const QString &themeDir_, QObject *parent) 83 | : QObject(parent), themeConfig{config_}, themeDir{themeDir_} 84 | { 85 | } 86 | 87 | QUrl IQTheme::toRelativeUrl(const QString &str) const 88 | { 89 | return "file:///" + themeDir + '/' + str; 90 | } 91 | 92 | /* 93 | * 94 | * THEMES NEXT 95 | * 96 | */ 97 | 98 | #define IQ_THEME_UINT(KEY__) themeConfig->value(KEY__, KEY__##_DEFAULT).toUInt() 99 | 100 | #define IQ_THEME_DOUBLE(KEY__) \ 101 | themeConfig->value(KEY__, KEY__##_DEFAULT).toDouble() 102 | 103 | #define IQ_THEME_STRING(KEY__) \ 104 | themeConfig->value(KEY__, KEY__##_DEFAULT).toString() 105 | 106 | #define IQ_THEME_COLOR(KEY__) IQ_THEME_STRING(KEY__) 107 | 108 | #define IQ_THEME_IMAGE(KEY__) \ 109 | auto str = IQ_THEME_STRING(KEY__); \ 110 | if (str == KEY__##_DEFAULT) \ 111 | return str; \ 112 | auto url = toRelativeUrl(str); \ 113 | if (url.isValid()) \ 114 | return url; \ 115 | else \ 116 | return QString{KEY__##_DEFAULT}; 117 | 118 | bool NotificationsTheme::iconPosition() const 119 | { 120 | auto pos = 121 | themeConfig 122 | ->value(CONFIG_ICON_POSITION, CONFIG_ICON_POSITION_DEFAULT) 123 | .toString(); 124 | return pos.compare("left", Qt::CaseInsensitive) == 0; 125 | } 126 | 127 | uint NotificationsTheme::fontSize() const 128 | { 129 | return IQ_THEME_UINT(CONFIG_FONT_SIZE); 130 | } 131 | 132 | uint NotificationsTheme::barFontSize() const 133 | { 134 | return IQ_THEME_UINT(CONFIG_BAR_FONT_SIZE); 135 | } 136 | 137 | uint NotificationsTheme::iconSize() const 138 | { 139 | return IQ_THEME_UINT(CONFIG_ICON_SIZE); 140 | } 141 | 142 | uint NotificationsTheme::barHeight() const 143 | { 144 | return IQ_THEME_UINT(CONFIG_BAR_HEIGHT); 145 | } 146 | 147 | uint NotificationsTheme::expirationBarHeight() const 148 | { 149 | return IQ_THEME_UINT(CONFIG_EXPIRATION_BAR_HEIGHT); 150 | } 151 | 152 | uint NotificationsTheme::showAnimationDuration() const 153 | { 154 | return IQ_THEME_UINT(CONFIG_SHOW_DURATION); 155 | } 156 | 157 | uint NotificationsTheme::dropAnimationDuration() const 158 | { 159 | return IQ_THEME_UINT(CONFIG_DROP_DURATION); 160 | } 161 | 162 | double NotificationsTheme::closeButtonImageScale() const 163 | { 164 | return IQ_THEME_DOUBLE(CONFIG_CLOSE_BUTTON_IMAGE_SCALE); 165 | } 166 | 167 | double NotificationsTheme::extraButtonImageScale() const 168 | { 169 | return IQ_THEME_DOUBLE(CONFIG_EXTRA_BUTTON_IMAGE_SCALE); 170 | } 171 | 172 | QColor NotificationsTheme::bgColor() const 173 | { 174 | return IQ_THEME_COLOR(CONFIG_BG_COLOR); 175 | } 176 | 177 | QColor NotificationsTheme::barBgColor() const 178 | { 179 | return IQ_THEME_COLOR(CONFIG_BAR_BG_COLOR); 180 | } 181 | 182 | QColor NotificationsTheme::barTextColor() const 183 | { 184 | return IQ_THEME_COLOR(CONFIG_BAR_TEXT_COLOR); 185 | } 186 | 187 | QColor NotificationsTheme::expirationBarColor() const 188 | { 189 | return IQ_THEME_COLOR(CONFIG_EXPIRATION_BAR_COLOR); 190 | } 191 | 192 | QColor NotificationsTheme::titleTextColor() const 193 | { 194 | return IQ_THEME_COLOR(CONFIG_TITLE_TEXT_COLOR); 195 | } 196 | 197 | QColor NotificationsTheme::bodyTextColor() const 198 | { 199 | return IQ_THEME_COLOR(CONFIG_BODY_TEXT_COLOR); 200 | } 201 | 202 | QColor NotificationsTheme::buttonBgColor() const 203 | { 204 | return IQ_THEME_COLOR(CONFIG_BUTTON_BG_COLOR); 205 | } 206 | 207 | QColor NotificationsTheme::buttonTextColor() const 208 | { 209 | return IQ_THEME_COLOR(CONFIG_BUTTON_TEXT_COLOR); 210 | } 211 | 212 | QColor NotificationsTheme::extraBgColor() const 213 | { 214 | return IQ_THEME_COLOR(CONFIG_EXTRA_BG_COLOR); 215 | } 216 | 217 | QColor NotificationsTheme::extraUreadCircleColor() const 218 | { 219 | return IQ_THEME_COLOR(CONFIG_EXTRA_UNREAD_CIRCLE_COLOR); 220 | } 221 | 222 | QColor NotificationsTheme::extraUreadTextColor() const 223 | { 224 | return IQ_THEME_COLOR(CONFIG_EXTRA_UNREAD_TEXT_COLOR); 225 | } 226 | 227 | QUrl NotificationsTheme::bgImage() const { IQ_THEME_IMAGE(CONFIG_BG_IMAGE) } 228 | 229 | QUrl NotificationsTheme::closeButtonImage() const 230 | { 231 | IQ_THEME_IMAGE(CONFIG_CLOSE_BUTTON_IMAGE) 232 | } 233 | 234 | QUrl NotificationsTheme::extraCloseButtonImage() const 235 | { 236 | IQ_THEME_IMAGE(CONFIG_EXTRA_CLOSE_BUTTON_IMAGE) 237 | } 238 | 239 | QUrl NotificationsTheme::extraCloseAllButtonImage() const 240 | { 241 | IQ_THEME_IMAGE(CONFIG_EXTRA_CLOSE_ALL_BUTTON_IMAGE) 242 | } 243 | 244 | QUrl NotificationsTheme::extraCloseVisibleButtonImage() const 245 | { 246 | IQ_THEME_IMAGE(CONFIG_EXTRA_CLOSE_VISIBLE_BUTTON_IMAGE) 247 | } 248 | 249 | QUrl TrayIconTheme::icon() const { IQ_THEME_IMAGE(CONFIG_ICON) } 250 | 251 | QUrl HistoryWindowTheme::closeIcon() const { IQ_THEME_IMAGE(CONFIG_CLOSE_ICON) } 252 | 253 | QUrl HistoryWindowTheme::bgImage() const { IQ_THEME_IMAGE(CONFIG_BG_IMAGE) } 254 | 255 | QString HistoryWindowTheme::windowTitle() const 256 | { 257 | return IQ_THEME_STRING(CONFIG_WINDOW_TITLE); 258 | } 259 | 260 | uint HistoryWindowTheme::x() const 261 | { 262 | switch (windowPosition()) { 263 | case LEFT_BOT: 264 | case LEFT_TOP: 265 | return availableGeometry().left(); 266 | break; 267 | case RIGHT_BOT: 268 | case RIGHT_TOP: 269 | return availableGeometry().x() + availableGeometry().width() - 270 | width(); 271 | break; 272 | default: 273 | break; 274 | } 275 | return IQ_THEME_UINT(CONFIG_X); 276 | } 277 | 278 | uint HistoryWindowTheme::y() const 279 | { 280 | switch (windowPosition()) { 281 | case RIGHT_TOP: 282 | case LEFT_TOP: 283 | return availableGeometry().top(); 284 | break; 285 | case RIGHT_BOT: 286 | case LEFT_BOT: 287 | return availableGeometry().y() + availableGeometry().height() - 288 | height(); 289 | break; 290 | default: 291 | break; 292 | } 293 | return IQ_THEME_UINT(CONFIG_Y); 294 | } 295 | 296 | uint HistoryWindowTheme::height() const { return IQ_THEME_UINT(CONFIG_HEIGHT); } 297 | 298 | uint HistoryWindowTheme::width() const { return IQ_THEME_UINT(CONFIG_WIDTH); } 299 | 300 | uint HistoryWindowTheme::barHeight() const 301 | { 302 | return IQ_THEME_UINT(CONFIG_BAR_HEIGHT); 303 | } 304 | 305 | uint HistoryWindowTheme::notificationHeight() const 306 | { 307 | return IQ_THEME_UINT(CONFIG_NOTIFICATION_HEIGHT); 308 | } 309 | 310 | uint HistoryWindowTheme::barFontSize() const 311 | { 312 | return IQ_THEME_UINT(CONFIG_BAR_FONT_SIZE); 313 | } 314 | 315 | uint HistoryWindowTheme::nappFontSize() const 316 | { 317 | return IQ_THEME_UINT(CONFIG_NAPP_FONT_SIZE); 318 | } 319 | 320 | uint HistoryWindowTheme::ntitleFontSize() const 321 | { 322 | return IQ_THEME_UINT(CONFIG_NTITLE_FONT_SIZE); 323 | } 324 | 325 | uint HistoryWindowTheme::nbodyFontSize() const 326 | { 327 | return IQ_THEME_UINT(CONFIG_NBODY_FONT_SIZE); 328 | } 329 | 330 | QString HistoryWindowTheme::bgColor() const 331 | { 332 | return IQ_THEME_STRING(CONFIG_BG_COLOR); 333 | } 334 | 335 | QString HistoryWindowTheme::barBgColor() const 336 | { 337 | return IQ_THEME_STRING(CONFIG_BAR_BG_COLOR); 338 | } 339 | 340 | QString HistoryWindowTheme::barTextColor() const 341 | { 342 | return IQ_THEME_STRING(CONFIG_BAR_TEXT_COLOR); 343 | } 344 | 345 | QString HistoryWindowTheme::nbgColor() const 346 | { 347 | return IQ_THEME_STRING(CONFIG_NBG_COLOR); 348 | } 349 | 350 | QString HistoryWindowTheme::nappTextColor() const 351 | { 352 | return IQ_THEME_STRING(CONFIG_NAPP_TEXT_COLOR); 353 | } 354 | 355 | QString HistoryWindowTheme::ntitleTextColor() const 356 | { 357 | return IQ_THEME_STRING(CONFIG_NTITLE_TEXT_COLOR); 358 | } 359 | 360 | QString HistoryWindowTheme::nbodyTextColor() const 361 | { 362 | return IQ_THEME_STRING(CONFIG_NBODY_TEXT_COLOR); 363 | } 364 | 365 | HistoryWindowTheme::pos_t HistoryWindowTheme::windowPosition() const 366 | { 367 | return static_cast( 368 | IQ_THEME_UINT(CONFIG_WINDOW_POSITION)); 369 | } 370 | 371 | #undef IQ_THEME_IMAGE 372 | #undef IQ_THEME_STRING 373 | #undef IQ_THEME_COLOR 374 | #undef IQ_THEME_DOUBLE 375 | #undef IQ_THEME_UINT 376 | -------------------------------------------------------------------------------- /iqthemes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "iqconfig.h" 27 | 28 | class NotificationsTheme; 29 | class TrayIconTheme; 30 | class HistoryWindowTheme; 31 | 32 | class IQThemes : public QObject 33 | { 34 | Q_OBJECT 35 | Q_PROPERTY(NotificationsTheme *notificationsTheme READ 36 | notificationsTheme CONSTANT) 37 | Q_PROPERTY(TrayIconTheme *trayIconTheme READ trayIconTheme CONSTANT) 38 | Q_PROPERTY(HistoryWindowTheme *historyWindowTheme READ 39 | historyWindowTheme CONSTANT) 40 | 41 | public: 42 | IQThemes(); 43 | 44 | NotificationsTheme *notificationsTheme() const; 45 | TrayIconTheme *trayIconTheme() const; 46 | HistoryWindowTheme *historyWindowTheme() const; 47 | 48 | private: 49 | IQ_CONF_VAR(THEME_NAME, "theme_name", "default") 50 | 51 | IQConfig config; 52 | const QString themeName; 53 | std::shared_ptr themeConfig; 54 | std::unique_ptr notificationsTheme_; 55 | std::unique_ptr trayIconTheme_; 56 | std::unique_ptr historyWindowTheme_; 57 | 58 | QString themeConfigDir() const; 59 | QString themeConfigFile() const; 60 | void loadTheme(const QString &fileName); 61 | void registerThemeTypes() const; 62 | }; 63 | 64 | class IQTheme : public QObject 65 | { 66 | Q_OBJECT 67 | public: 68 | IQTheme() = default; 69 | IQTheme(const std::shared_ptr &config_, 70 | const QString &themeDir_, QObject *parent = nullptr); 71 | 72 | protected: 73 | std::shared_ptr themeConfig; 74 | const QString themeDir; 75 | 76 | QUrl toRelativeUrl(const QString &str) const; 77 | }; 78 | 79 | class NotificationsTheme : public IQTheme 80 | { 81 | Q_OBJECT 82 | 83 | Q_PROPERTY(bool iconPosition READ iconPosition CONSTANT) 84 | Q_PROPERTY(uint fontSize READ fontSize CONSTANT) 85 | Q_PROPERTY(uint barFontSize READ barFontSize CONSTANT) 86 | Q_PROPERTY(uint iconSize READ iconSize CONSTANT) 87 | Q_PROPERTY(uint barHeight READ barHeight CONSTANT) 88 | Q_PROPERTY(uint expirationBarHeight READ expirationBarHeight CONSTANT) 89 | Q_PROPERTY( 90 | uint showAnimationDuration READ showAnimationDuration CONSTANT) 91 | Q_PROPERTY( 92 | uint dropAnimationDuration READ dropAnimationDuration CONSTANT) 93 | Q_PROPERTY( 94 | double closeButtonImageScale READ closeButtonImageScale CONSTANT) 95 | Q_PROPERTY( 96 | double extraButtonImageScale READ extraButtonImageScale CONSTANT) 97 | Q_PROPERTY(QColor bgColor READ bgColor CONSTANT) 98 | Q_PROPERTY(QColor barBgColor READ barBgColor CONSTANT) 99 | Q_PROPERTY(QColor barTextColor READ barTextColor CONSTANT) 100 | Q_PROPERTY(QColor expirationBarColor READ expirationBarColor CONSTANT) 101 | Q_PROPERTY(QColor titleTextColor READ titleTextColor CONSTANT) 102 | Q_PROPERTY(QColor bodyTextColor READ bodyTextColor CONSTANT) 103 | Q_PROPERTY(QColor buttonBgColor READ buttonBgColor CONSTANT) 104 | Q_PROPERTY(QColor buttonTextColor READ buttonTextColor CONSTANT) 105 | Q_PROPERTY(QColor extraBgColor READ extraBgColor CONSTANT) 106 | Q_PROPERTY( 107 | QColor extraUreadCircleColor READ extraUreadCircleColor CONSTANT) 108 | Q_PROPERTY(QColor extraUreadTextColor READ extraUreadTextColor CONSTANT) 109 | Q_PROPERTY(QUrl bgImage READ bgImage CONSTANT) 110 | Q_PROPERTY(QUrl closeButtonImage READ closeButtonImage CONSTANT) 111 | Q_PROPERTY( 112 | QUrl extraCloseButtonImage READ extraCloseButtonImage CONSTANT) 113 | Q_PROPERTY(QUrl extraCloseAllButtonImage READ extraCloseAllButtonImage 114 | CONSTANT) 115 | Q_PROPERTY(QUrl extraCloseVisibleButtonImage READ 116 | extraCloseVisibleButtonImage CONSTANT) 117 | 118 | public: 119 | using IQTheme::IQTheme; 120 | 121 | // True to move to left side, false for top 122 | bool iconPosition() const; 123 | uint fontSize() const; 124 | uint barFontSize() const; 125 | uint iconSize() const; 126 | uint barHeight() const; 127 | uint expirationBarHeight() const; 128 | uint showAnimationDuration() const; 129 | uint dropAnimationDuration() const; 130 | double closeButtonImageScale() const; 131 | double extraButtonImageScale() const; 132 | QColor bgColor() const; 133 | QColor barBgColor() const; 134 | QColor barTextColor() const; 135 | QColor expirationBarColor() const; 136 | QColor titleTextColor() const; 137 | QColor bodyTextColor() const; 138 | QColor buttonBgColor() const; 139 | QColor buttonTextColor() const; 140 | QColor extraBgColor() const; 141 | QColor extraUreadCircleColor() const; 142 | QColor extraUreadTextColor() const; 143 | QUrl bgImage() const; 144 | QUrl closeButtonImage() const; 145 | QUrl extraCloseButtonImage() const; 146 | QUrl extraCloseAllButtonImage() const; 147 | QUrl extraCloseVisibleButtonImage() const; 148 | 149 | private: 150 | IQ_CONF_VAR(ICON_POSITION, "popup_notifications/icon_position", "top") 151 | 152 | IQ_CONF_VAR(FONT_SIZE, "popup_notifications/font_size", 0) 153 | IQ_CONF_VAR(BAR_FONT_SIZE, "popup_notifications/bar_font_size", 0) 154 | IQ_CONF_VAR(ICON_SIZE, "popup_notifications/icon_size", 0) 155 | IQ_CONF_VAR(BAR_HEIGHT, "popup_notifications/bar_height", 0) 156 | IQ_CONF_VAR(EXPIRATION_BAR_HEIGHT, 157 | "popup_notifications/expiration_bar_height", 0) 158 | IQ_CONF_VAR(SHOW_DURATION, 159 | "popup_notifications/show_animation_duration", 120) 160 | IQ_CONF_VAR(DROP_DURATION, 161 | "popup_notifications/drop_animation_duration", 120) 162 | IQ_CONF_VAR(CLOSE_BUTTON_IMAGE_SCALE, 163 | "popup_notifications/close_button_image_scale", 0.4) 164 | IQ_CONF_VAR(EXTRA_BUTTON_IMAGE_SCALE, 165 | "popup_notifications/extra_button_image_scale", 0.6) 166 | 167 | IQ_CONF_VAR(BG_COLOR, "popup_notifications/bg_color", "#19202d") 168 | IQ_CONF_VAR(BAR_BG_COLOR, "popup_notifications/bar_bg_color", "#262d3a") 169 | IQ_CONF_VAR(BAR_TEXT_COLOR, "popup_notifications/bar_text_color", 170 | "#92969c") 171 | IQ_CONF_VAR(EXPIRATION_BAR_COLOR, 172 | "popup_notifications/expiration_bar_color", "#30394a") 173 | IQ_CONF_VAR(TITLE_TEXT_COLOR, "popup_notifications/title_text_color", 174 | "#ffffff") 175 | IQ_CONF_VAR(BODY_TEXT_COLOR, "popup_notifications/body_text_color", 176 | "#92969c") 177 | IQ_CONF_VAR(BUTTON_BG_COLOR, "popup_notifications/button_bg_color", 178 | "#343b4d") 179 | IQ_CONF_VAR(BUTTON_TEXT_COLOR, "popup_notifications/button_text_color", 180 | "#ffffff") 181 | IQ_CONF_VAR(EXTRA_BG_COLOR, "popup_notifications/extra_bg_color", 182 | "#262d3a") 183 | IQ_CONF_VAR(EXTRA_UNREAD_CIRCLE_COLOR, 184 | "popup_notifications/extra_unread_circle_color", "#d74a37") 185 | IQ_CONF_VAR(EXTRA_UNREAD_TEXT_COLOR, 186 | "popup_notifications/extra_unread_text_color", "#ffffff") 187 | 188 | IQ_CONF_VAR(BG_IMAGE, "popup_notifications/bg_image", "") 189 | IQ_CONF_VAR(CLOSE_BUTTON_IMAGE, 190 | "popup_notifications/close_button_image", "img/close.png") 191 | IQ_CONF_VAR(EXTRA_CLOSE_BUTTON_IMAGE, 192 | "popup_notifications/extra_close_button_image", 193 | "img/close.png") 194 | IQ_CONF_VAR(EXTRA_CLOSE_ALL_BUTTON_IMAGE, 195 | "popup_notifications/extra_close_all_button_image", 196 | "img/closeAll.png") 197 | IQ_CONF_VAR(EXTRA_CLOSE_VISIBLE_BUTTON_IMAGE, 198 | "popup_notifications/extra_close_visible_button_image", 199 | "img/closeVisible.png") 200 | }; 201 | 202 | class TrayIconTheme : public IQTheme 203 | { 204 | Q_OBJECT 205 | Q_PROPERTY(QUrl icon READ icon CONSTANT) 206 | public: 207 | using IQTheme::IQTheme; 208 | 209 | QUrl icon() const; 210 | 211 | private: 212 | IQ_CONF_VAR(ICON, "tray/icon", "img/warning.png") 213 | }; 214 | 215 | class HistoryWindowTheme : public IQTheme 216 | { 217 | Q_OBJECT 218 | Q_PROPERTY(QUrl closeIcon READ closeIcon CONSTANT) 219 | Q_PROPERTY(QUrl bgImage READ bgImage CONSTANT) 220 | Q_PROPERTY(QString windowTitle READ windowTitle CONSTANT) 221 | Q_PROPERTY(uint x READ x CONSTANT) 222 | Q_PROPERTY(uint y READ y CONSTANT) 223 | Q_PROPERTY(uint height READ height CONSTANT) 224 | Q_PROPERTY(uint width READ width CONSTANT) 225 | Q_PROPERTY(uint barHeight READ barHeight CONSTANT) 226 | Q_PROPERTY(uint notificationHeight READ notificationHeight CONSTANT) 227 | Q_PROPERTY(uint barFontSize READ barFontSize CONSTANT) 228 | Q_PROPERTY(uint nappFontSize READ nappFontSize CONSTANT) 229 | Q_PROPERTY(uint ntitleFontSize READ ntitleFontSize CONSTANT) 230 | Q_PROPERTY(uint nbodyFontSize READ nbodyFontSize CONSTANT) 231 | Q_PROPERTY(QString bgColor READ bgColor CONSTANT) 232 | Q_PROPERTY(QString barBgColor READ barBgColor CONSTANT) 233 | Q_PROPERTY(QString barTextColor READ barTextColor CONSTANT) 234 | Q_PROPERTY(QString nbgColor READ nbgColor CONSTANT) 235 | Q_PROPERTY(QString nappTextColor READ nappTextColor CONSTANT) 236 | Q_PROPERTY(QString ntitleTextColor READ ntitleTextColor CONSTANT) 237 | Q_PROPERTY(QString nbodyTextColor READ nbodyTextColor CONSTANT) 238 | 239 | public: 240 | using IQTheme::IQTheme; 241 | QUrl closeIcon() const; 242 | QUrl bgImage() const; 243 | QString windowTitle() const; 244 | 245 | uint x() const; 246 | uint y() const; 247 | uint height() const; 248 | uint width() const; 249 | uint barHeight() const; 250 | uint notificationHeight() const; 251 | uint barFontSize() const; 252 | uint nappFontSize() const; 253 | uint ntitleFontSize() const; 254 | uint nbodyFontSize() const; 255 | 256 | QString bgColor() const; 257 | QString barBgColor() const; 258 | QString barTextColor() const; 259 | QString nbgColor() const; 260 | QString nappTextColor() const; 261 | QString ntitleTextColor() const; 262 | QString nbodyTextColor() const; 263 | 264 | private: 265 | enum pos_t { UNDEFINED = 0, LEFT_TOP, LEFT_BOT, RIGHT_BOT, RIGHT_TOP }; 266 | pos_t windowPosition() const; 267 | 268 | IQ_CONF_VAR(CLOSE_ICON, "history_window/close_icon", "img/close.png") 269 | IQ_CONF_VAR(BG_IMAGE, "history_window/bg_image", "") 270 | IQ_CONF_VAR(WINDOW_TITLE, "history_window/window_title", "IQ Notifier") 271 | IQ_CONF_VAR(WINDOW_POSITION, "history_window/window_position", 272 | UNDEFINED) 273 | 274 | IQ_CONF_VAR(X, "history_window/x", 0) 275 | IQ_CONF_VAR(Y, "history_window/y", 0) 276 | IQ_CONF_VAR(HEIGHT, "history_window/height", 0) 277 | IQ_CONF_VAR(WIDTH, "history_window/width", 0) 278 | IQ_CONF_VAR(BAR_HEIGHT, "history_window/bar_height", 32) 279 | IQ_CONF_VAR(NOTIFICATION_HEIGHT, "history_window/notification_height", 280 | 0) 281 | IQ_CONF_VAR(BAR_FONT_SIZE, "history_window/bar_font_size", 0) 282 | IQ_CONF_VAR(NAPP_FONT_SIZE, "history_window/napp_font_size", 0) 283 | IQ_CONF_VAR(NTITLE_FONT_SIZE, "history_window/ntitle_font_size", 0) 284 | IQ_CONF_VAR(NBODY_FONT_SIZE, "history_window/nbody_font_size", 0) 285 | 286 | IQ_CONF_VAR(BG_COLOR, "history_window/bg_color", "#262d3a") 287 | IQ_CONF_VAR(BAR_BG_COLOR, "history_window/bar_bg_color", "#262d3a") 288 | IQ_CONF_VAR(BAR_TEXT_COLOR, "history_window/bar_text_color", "#92969c") 289 | IQ_CONF_VAR(NBG_COLOR, "history_window/nbg_color", "#19202d") 290 | IQ_CONF_VAR(NAPP_TEXT_COLOR, "history_window/napp_text_color", 291 | "#92969c") 292 | IQ_CONF_VAR(NTITLE_TEXT_COLOR, "history_window/ntitle_text_color", 293 | "white") 294 | IQ_CONF_VAR(NBODY_TEXT_COLOR, "history_window/nbody_text_color", 295 | "#92969c") 296 | }; 297 | -------------------------------------------------------------------------------- /iqtopdown.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | #include "iqtopdown.h" 19 | 20 | IQTopDown::IQTopDown(QObject *parent) : IQDisposition(parent) 21 | { 22 | recalculateAvailableScreenGeometry(); 23 | } 24 | 25 | IQTopDown::optional IQTopDown::poses(IQNotification::id_t id, 26 | QSize size) 27 | { 28 | // Already here, must be replaced 29 | auto current_pos_it = dispositions.find(id); 30 | if (current_pos_it != dispositions.end()) 31 | return current_pos_it->second.topLeft(); 32 | 33 | // Okay, lets calc new position 34 | auto avail = availableGeometry(); 35 | 36 | auto pos_point = avail.topRight() - 37 | QPoint{size.width() - 1 38 | // topRigth returns not correct coordinates 39 | // So we add 1 to result (-(-1)) 40 | // Look at Qt's docs for more 41 | , 42 | 0}; 43 | QRect pos{pos_point, size}; 44 | if (avail.contains(pos)) { 45 | dispositions[id] = pos; 46 | return {pos_point}; 47 | } else { 48 | return {}; 49 | } 50 | } 51 | 52 | QPoint IQTopDown::externalWindowPos() const 53 | { 54 | auto pos_point = availableScreenGeometry.bottomRight() - 55 | QPoint{extraWindowSize.width() - 1 56 | // topRigth returns not correct coordinates 57 | // So we add 1 to result (-(-1)) 58 | // Look at Qt's docs for more 59 | , 60 | 0}; 61 | return pos_point; 62 | } 63 | 64 | void IQTopDown::setExtraWindowSize(const QSize &value) 65 | { 66 | IQDisposition::setExtraWindowSize(value); 67 | recalculateAvailableScreenGeometry(); 68 | } 69 | 70 | void IQTopDown::setSpacing(int value) 71 | { 72 | IQDisposition::setSpacing(value); 73 | recalculateAvailableScreenGeometry(); 74 | } 75 | 76 | void IQTopDown::remove(IQNotification::id_t id) 77 | { 78 | static auto recalculateDispositions = [this](const auto &to_remove_it) 79 | -> std::map { 80 | auto end = dispositions.end(); 81 | const QRect &to_remove = to_remove_it->second; 82 | auto move_up_for = spacing + to_remove.height(); 83 | 84 | auto it = std::next(to_remove_it); 85 | if (it == end) { 86 | return {}; // Nothing to move up 87 | } 88 | std::map posToMove; 89 | for (; it != end; ++it) { 90 | auto d_id = it->first; 91 | auto &d_pos = it->second; 92 | d_pos.moveTop(d_pos.top() - move_up_for); 93 | posToMove.emplace(d_id, d_pos.topLeft()); 94 | } 95 | return posToMove; 96 | }; 97 | 98 | auto pos_it = dispositions.find(id); 99 | if (pos_it != dispositions.end()) { 100 | // Just calculate all 101 | auto posToMove = recalculateDispositions(pos_it); 102 | // Now move 103 | for (auto &p : posToMove) 104 | emit moveNotification(p.first, p.second); 105 | 106 | // pos_it will not be invalidated even 107 | // if posess will be called before next line 108 | dispositions.erase(pos_it); 109 | } else { 110 | // throw std::runtime_error{ 111 | // "IQTopDown: can't find old disposition"}; 112 | } 113 | } 114 | 115 | void IQTopDown::removeAll() { dispositions.clear(); } 116 | 117 | void IQTopDown::recalculateAvailableScreenGeometry() 118 | { 119 | IQDisposition::recalculateAvailableScreenGeometry(); 120 | auto extra_bottom_margin = extraWindowSize.height() + spacing; 121 | availableScreenGeometry -= QMargins{0, 0, 0, extra_bottom_margin}; 122 | } 123 | 124 | QRect IQTopDown::availableGeometry() const 125 | { 126 | auto ret = availableScreenGeometry; 127 | ret.adjust(0, dispositions.empty() ? 0 : spacing, 0, 0); 128 | 129 | if (dispositions.empty()) 130 | return ret; 131 | 132 | const auto &last_object = *std::crbegin(dispositions); 133 | 134 | // Top margin already included in availableScreenGeometry 135 | auto bot_margin = last_object.second.bottom() - margins.top(); 136 | ret.adjust(0, bot_margin, 0, 0); 137 | return ret; 138 | } 139 | -------------------------------------------------------------------------------- /iqtopdown.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | class IQTopDown final : public IQDisposition 28 | { 29 | Q_OBJECT 30 | 31 | public: 32 | using IQDisposition::optional; 33 | 34 | explicit IQTopDown(QObject *parent = nullptr); 35 | 36 | optional poses(IQNotification::id_t id, QSize size) final; 37 | 38 | QPoint externalWindowPos() const final; 39 | 40 | void setExtraWindowSize(const QSize &value) final; 41 | 42 | void setSpacing(int value) final; 43 | 44 | public slots: 45 | void remove(IQNotification::id_t id) final; 46 | void removeAll() final; 47 | 48 | private: 49 | std::map dispositions; 50 | 51 | void recalculateAvailableScreenGeometry() final; 52 | QRect availableGeometry() const; 53 | }; 54 | -------------------------------------------------------------------------------- /iqtrayicon.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | #include "iqtrayicon.h" 19 | 20 | namespace 21 | { 22 | QIcon urlToIcon(const QUrl &url) 23 | { 24 | auto iconFileName = url.toString(); 25 | iconFileName.replace("file:///", ""); 26 | return QIcon{iconFileName}; 27 | } 28 | } // anonymouse namespace 29 | 30 | IQTrayIcon::IQTrayIcon(QObject *parent) : QSystemTrayIcon(parent) 31 | { 32 | connect(this, &IQTrayIcon::iconUrlChanged, 33 | [this] { setIcon(urlToIcon(iconUrl_)); }); 34 | connect(this, &IQTrayIcon::activated, [this](ActivationReason reason) { 35 | if (reason == Trigger) 36 | emit leftClick(); 37 | }); 38 | } 39 | 40 | QUrl IQTrayIcon::iconUrl() const { return iconUrl_; } 41 | 42 | void IQTrayIcon::setIconUrl(const QUrl &iconUrl) 43 | { 44 | iconUrl_ = iconUrl; 45 | emit iconUrlChanged(); 46 | } 47 | -------------------------------------------------------------------------------- /iqtrayicon.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | #pragma once 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | class IQTrayIcon : public QSystemTrayIcon 25 | { 26 | Q_OBJECT 27 | Q_PROPERTY( 28 | QUrl iconUrl READ iconUrl WRITE setIconUrl NOTIFY iconUrlChanged) 29 | public: 30 | explicit IQTrayIcon(QObject *parent = nullptr); 31 | 32 | QUrl iconUrl() const; 33 | void setIconUrl(const QUrl &iconUrl); 34 | 35 | signals: 36 | void iconUrlChanged(); 37 | void leftClick(); 38 | 39 | private: 40 | QUrl iconUrl_; 41 | }; 42 | -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include "notificationsadaptor.h" 24 | 25 | #include "iqdbusservice.h" 26 | #include "iqexpirationcontroller.h" 27 | #include "iqhistory.h" 28 | #include "iqnotificationmodifiers.h" 29 | #include "iqnotifications.h" 30 | #include "iqthemes.h" 31 | #include "iqtopdown.h" 32 | #include "iqtrayicon.h" 33 | 34 | #ifdef IQ_X11 35 | #include "X11-plugin/x11fullscreendetector.h" 36 | #endif 37 | 38 | /* 39 | * Should be called first 40 | */ 41 | static gsl::not_null get_service(); 42 | static gsl::not_null get_history(); 43 | static QDBusConnection 44 | connect_to_session_bus(gsl::not_null service); 45 | static QObject *iqnotifications_provider(QQmlEngine *engine, 46 | QJSEngine *scriptEngine); 47 | static QObject *iqthemes_provider(QQmlEngine *engine, QJSEngine *scriptEngine); 48 | 49 | gsl::not_null get_service() 50 | { 51 | using namespace IQNotificationModifiers; // NOLINT 52 | 53 | auto disposition = std::make_unique(); 54 | auto dbus_service = 55 | (new IQDBusService) 56 | ->addModifier(make()) 57 | ->addModifier(make()) 58 | ->addModifier(make()) 59 | ->addModifier(make()) 60 | ->addModifier(make()) 61 | ->addModifier(make()); 62 | 63 | auto notifications = IQNotifications::get(std::move(disposition)); 64 | if (notifications->isEnabled()) 65 | dbus_service->connectReceiver(notifications); 66 | if (get_history()->isEnabled()) 67 | dbus_service->connectReceiver(get_history().get()); 68 | 69 | std::unique_ptr fullscreenDetector; 70 | #ifdef IQ_X11 71 | fullscreenDetector = std::make_unique(); 72 | #endif // IQ_X11 73 | notifications->setFullscreenDetector(std::move(fullscreenDetector)); 74 | return dbus_service; 75 | } 76 | 77 | gsl::not_null get_history() 78 | { 79 | static IQHistory history; 80 | return {&history}; 81 | } 82 | 83 | QObject *iqnotifications_provider(QQmlEngine *engine, QJSEngine *scriptEngine) 84 | { 85 | Q_UNUSED(engine); 86 | Q_UNUSED(scriptEngine); 87 | return IQNotifications::get(); 88 | } 89 | 90 | QObject *iqthemes_provider(QQmlEngine *engine, QJSEngine *scriptEngine) 91 | { 92 | Q_UNUSED(engine); 93 | Q_UNUSED(scriptEngine); 94 | static IQThemes theme; 95 | return &theme; 96 | } 97 | 98 | QObject *iqhistory_provider(QQmlEngine *engine, QJSEngine *scriptEngine) 99 | { 100 | Q_UNUSED(engine); 101 | Q_UNUSED(scriptEngine); 102 | return get_history().get(); 103 | } 104 | 105 | QDBusConnection connect_to_session_bus(gsl::not_null service) 106 | { 107 | auto connection = QDBusConnection::sessionBus(); 108 | if (!connection.registerService("org.freedesktop.Notifications")) { 109 | throw std::runtime_error{"DBus Service already registered!"}; 110 | } 111 | new NotificationsAdaptor(service); 112 | if (!connection.registerObject("/org/freedesktop/Notifications", 113 | service)) { 114 | throw std::runtime_error{"Can't register DBus service object!"}; 115 | } 116 | return connection; 117 | } 118 | 119 | int main(int argc, char *argv[]) 120 | { 121 | QApplication app(argc, argv); 122 | app.setQuitOnLastWindowClosed(false); 123 | 124 | auto dbus_service = get_service(); 125 | connect_to_session_bus(dbus_service); 126 | 127 | qmlRegisterSingletonType("IQNotifier", 1, 0, "IQThemes", 128 | iqthemes_provider); 129 | qmlRegisterType("IQNotifier", 1, 0, 130 | "IQExpirationController"); 131 | qmlRegisterType("IQNotifier", 1, 0, "IQTrayIcon"); 132 | qmlRegisterSingletonType( 133 | "IQNotifier", 1, 0, "IQNotifications", iqnotifications_provider); 134 | qmlRegisterSingletonType("IQNotifier", 1, 0, "IQHistory", 135 | iqhistory_provider); 136 | 137 | QQmlApplicationEngine engine; 138 | engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); 139 | if (engine.rootObjects().isEmpty()) 140 | return -1; 141 | 142 | return app.exec(); 143 | } 144 | -------------------------------------------------------------------------------- /main.qml: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of IQ Notifier. 3 | * 4 | * IQ Notifier is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * any later version. 8 | * 9 | * IQ Notifier is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with IQ Notifier. If not, see . 16 | */ 17 | 18 | import QtQuick.Window 2.1 19 | import QtQuick 2.5 20 | import IQNotifier 1.0 21 | 22 | QtObject { 23 | id: root 24 | property var notificationsMap: {'-1': Object} // that's ok 25 | property var cons: Connections { 26 | target: IQNotifications 27 | onCreateNotification: { 28 | if (notificationsMap[notification_id]) { 29 | // notificationsMap[notification_id].body = body; 30 | // notificationsMap[notification_id].title = title; 31 | // return; 32 | notification_id.expiration_timeout = 0; 33 | dropNotification(notification_id); 34 | } 35 | 36 | var n = root.createNotification(notification_id, 37 | size, pos, 38 | expire_timeout, 39 | appName, 40 | body, title, 41 | iconUrl, actions); 42 | n.show(); 43 | root.addNotification(notification_id, n); 44 | } 45 | onDropNotification: 46 | root.dropNotification(notification_id); 47 | onDropAllVisible: root.dropAllVisible() 48 | onMoveNotification: 49 | root.moveNotification(notification_id, pos); 50 | } 51 | 52 | Component.onCompleted: { 53 | initExtraNotifications(); 54 | } 55 | 56 | function actionsToButtons(actions) { 57 | var buttons = []; 58 | for (var i = 0; i < actions.length; i += 2) { 59 | buttons.push({ 60 | "action": actions[i], 61 | "text": actions[i+1] 62 | }); 63 | } 64 | return buttons; 65 | } 66 | 67 | function createNotification(notification_id, 68 | size, pos, 69 | expire_timeout, 70 | appName, 71 | body,title, 72 | iconUrl, actions) { 73 | var component = Qt.createComponent("IQNotification.qml"); 74 | if (component.status !== Component.Ready) { 75 | if(component.status === Component.Error) 76 | console.debug("Error: "+ component.errorString()); 77 | throw "Can't create notification!"; 78 | } 79 | var options = { 80 | "notification_id": notification_id, 81 | "width": size.width, 82 | "height": size.height, 83 | "x": pos.x, "y": pos.y, 84 | "expireTimeout": expire_timeout, 85 | "appName": appName, 86 | "body": body, 87 | "title": title, 88 | "iconUrl": iconUrl, 89 | "buttons": actionsToButtons(actions) 90 | }; 91 | var notification = component.createObject(root, 92 | options); 93 | if (notification === null) 94 | throw "Error creating notification object"; 95 | return notification; 96 | } 97 | 98 | function addNotification(notification_id, notification) { 99 | notificationsMap[notification_id] = notification; 100 | } 101 | 102 | function dropNotification(notification_id) { 103 | if (notificationsMap[notification_id] !== undefined) { 104 | notificationsMap[notification_id].drop(); 105 | notificationsMap[notification_id] = undefined; 106 | } 107 | } 108 | 109 | function dropAllVisible() { 110 | Object.keys(notificationsMap).forEach(function(key) { 111 | if( key != '-1') { 112 | // IQNotifications.onDropNotification(key); 113 | dropNotification(key); 114 | } 115 | 116 | }); 117 | } 118 | 119 | function moveNotification(notification_id, pos) { 120 | if (notificationsMap[notification_id] !== undefined) { 121 | notificationsMap[notification_id].move(pos.x, pos.y); 122 | } 123 | } 124 | 125 | function initExtraNotifications () { 126 | var component = Qt.createComponent("IQExtraNotifications.qml"); 127 | if (component.status !== Component.Ready) { 128 | if(component.status === Component.Error) 129 | console.debug("Error: "+ component.errorString()); 130 | throw "Can't create extra notifications window!"; 131 | } 132 | var extraNotifications = component.createObject(root, 133 | {}); 134 | } 135 | 136 | /* TRAY STUFF */ 137 | 138 | property var trayIconLoader__: Loader{ 139 | id: trayIconLoader 140 | sourceComponent: IQHistory.isEnabled ? tray : undefined 141 | } 142 | 143 | function createHistoryWindow(cb) { 144 | var component = Qt.createComponent("IQHistoryWindow.qml"); 145 | if (component.status !== Component.Ready) { 146 | if(component.status === Component.Error) 147 | console.debug("Error: "+ component.errorString()); 148 | throw "Can't create history window!"; 149 | } 150 | return component.createObject(root, {closeCallback: cb}); 151 | } 152 | 153 | property var tray__: Component{ 154 | id: tray 155 | IQTrayIcon { 156 | property IQHistoryWindow history 157 | iconUrl: IQThemes.trayIconTheme.icon 158 | visible: iconUrl != undefined 159 | onLeftClick: { 160 | if (history == null || history == undefined) { 161 | history = createHistoryWindow(function () { 162 | history = null; 163 | }); 164 | history.show() 165 | } else { 166 | history.drop(); 167 | history = null; 168 | } 169 | } 170 | } 171 | } 172 | } 173 | 174 | -------------------------------------------------------------------------------- /org.freedesktop.Notifications.xml: -------------------------------------------------------------------------------- 1 | 3 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /packages/iq-notifier-0.1.0-amd64.deb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RussianBruteForce/iq-notifier/0feee9cb755a9ae2221d16c92d98c8710a345e61/packages/iq-notifier-0.1.0-amd64.deb -------------------------------------------------------------------------------- /packages/iq-notifier-0.1.1-amd64.deb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RussianBruteForce/iq-notifier/0feee9cb755a9ae2221d16c92d98c8710a345e61/packages/iq-notifier-0.1.1-amd64.deb -------------------------------------------------------------------------------- /packages/iq-notifier-0.2.0-amd64.deb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RussianBruteForce/iq-notifier/0feee9cb755a9ae2221d16c92d98c8710a345e61/packages/iq-notifier-0.2.0-amd64.deb -------------------------------------------------------------------------------- /packages/iq-notifier-0.2.1-amd64.deb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RussianBruteForce/iq-notifier/0feee9cb755a9ae2221d16c92d98c8710a345e61/packages/iq-notifier-0.2.1-amd64.deb -------------------------------------------------------------------------------- /packages/iq-notifier-0.3.0-amd64.deb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RussianBruteForce/iq-notifier/0feee9cb755a9ae2221d16c92d98c8710a345e61/packages/iq-notifier-0.3.0-amd64.deb -------------------------------------------------------------------------------- /packages/iq-notifier-0.3.1-amd64.deb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RussianBruteForce/iq-notifier/0feee9cb755a9ae2221d16c92d98c8710a345e61/packages/iq-notifier-0.3.1-amd64.deb -------------------------------------------------------------------------------- /packages/iq-notifier-0.4.0-amd64.deb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RussianBruteForce/iq-notifier/0feee9cb755a9ae2221d16c92d98c8710a345e61/packages/iq-notifier-0.4.0-amd64.deb -------------------------------------------------------------------------------- /packages/iq-notifier-0.4.1-amd64.deb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RussianBruteForce/iq-notifier/0feee9cb755a9ae2221d16c92d98c8710a345e61/packages/iq-notifier-0.4.1-amd64.deb -------------------------------------------------------------------------------- /qml.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | main.qml 4 | IQPopup.qml 5 | IQNotificationContainer.qml 6 | IQNotificationBar.qml 7 | img/close.png 8 | IQButton.qml 9 | IQFancyContainer.qml 10 | IQNotification.qml 11 | img/warning.png 12 | IQExpirationBar.qml 13 | IQExtraNotifications.qml 14 | img/closeVisible.png 15 | img/closeAll.png 16 | IQHistoryWindow.qml 17 | IQHistoryNotification.qml 18 | 19 | 20 | -------------------------------------------------------------------------------- /screenshots/0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RussianBruteForce/iq-notifier/0feee9cb755a9ae2221d16c92d98c8710a345e61/screenshots/0.png -------------------------------------------------------------------------------- /screenshots/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RussianBruteForce/iq-notifier/0feee9cb755a9ae2221d16c92d98c8710a345e61/screenshots/1.png -------------------------------------------------------------------------------- /screenshots/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RussianBruteForce/iq-notifier/0feee9cb755a9ae2221d16c92d98c8710a345e61/screenshots/2.png -------------------------------------------------------------------------------- /screenshots/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RussianBruteForce/iq-notifier/0feee9cb755a9ae2221d16c92d98c8710a345e61/screenshots/3.png -------------------------------------------------------------------------------- /screenshots/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RussianBruteForce/iq-notifier/0feee9cb755a9ae2221d16c92d98c8710a345e61/screenshots/4.png -------------------------------------------------------------------------------- /screenshots/h_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RussianBruteForce/iq-notifier/0feee9cb755a9ae2221d16c92d98c8710a345e61/screenshots/h_0.png -------------------------------------------------------------------------------- /themes/default/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RussianBruteForce/iq-notifier/0feee9cb755a9ae2221d16c92d98c8710a345e61/themes/default/close.png -------------------------------------------------------------------------------- /themes/default/closeAll.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RussianBruteForce/iq-notifier/0feee9cb755a9ae2221d16c92d98c8710a345e61/themes/default/closeAll.png -------------------------------------------------------------------------------- /themes/default/closeVisible.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RussianBruteForce/iq-notifier/0feee9cb755a9ae2221d16c92d98c8710a345e61/themes/default/closeVisible.png -------------------------------------------------------------------------------- /themes/default/theme: -------------------------------------------------------------------------------- 1 | ; IQ Notifier Default theme 2 | ; 3 | ; if size properties are not set, IQ Notifier will try to automatically adjust their values 4 | 5 | [popup_notifications] 6 | ; default 120 7 | drop_animation_duration = 120 8 | 9 | ; default 120 10 | show_animation_duration = 120 11 | 12 | ; set to 'left' if you want to show icon at left side 13 | icon_position = left 14 | 15 | bar_height = 32 16 | 17 | ; default value: 0 (invisible) 18 | ; fancy trick: make expiration_bar_height same as window height 19 | expiration_bar_height = 100 20 | 21 | font_size = 12 22 | 23 | ;bar_font_size = 10 24 | 25 | ; if not set, IQ Notifier will try to automatically adjust icon size 26 | icon_size = 72 27 | 28 | ; size scale of button images 29 | ;close_button_image_scale = 0.4 30 | ;extra_button_image_scale = 0.6 31 | 32 | ; color name or HTML code 33 | bg_color = #19202d 34 | bar_bg_color = #262d3a 35 | bar_text_color = #92969c 36 | expiration_bar_color = #30394a 37 | title_text_color = white 38 | body_text_color = #92969c 39 | button_bg_color = #343b4d 40 | button_text_color = white 41 | extra_bg_color = #262d3a 42 | extra_unread_circle_color = #d74a37 43 | extra_unread_text_color = white 44 | 45 | ; relative to this file directory 46 | ;bg_image = bg.png 47 | close_button_image = close.png 48 | extra_close_button_image = close.png 49 | extra_close_all_button_image = closeAll.png 50 | extra_close_visible_button_image = closeVisible.png 51 | 52 | [tray] 53 | icon = tray.png 54 | 55 | [history_window] 56 | ; icon for button on bar 57 | close_icon = close.png 58 | 59 | window_title = IQ Notifier 60 | 61 | ; 0 for full height 62 | height = 0 63 | ; 0 for ¼ of width 64 | width = 0 65 | 66 | ; window position 67 | ; UNDEFINED : 0 68 | ; LEFT_TOP : 1 69 | ; LEFT_BOT : 2 70 | ; RIGHT_BOT : 3 71 | ; RIGHT_TOP : 4 72 | window_position = 1 73 | 74 | ; works only if window_position is 0 or not defined 75 | ;x = 0 76 | ;y = 0 77 | 78 | 79 | ; can'not be deduced auto: 0 is for invisible bar 80 | bar_height = 32 81 | 82 | ; 0 for auto 83 | notification_height = 0 84 | bar_font_size = 0 85 | napp_font_size = 0 86 | ntitle_font_size = 0 87 | nbody_font_size = 0 88 | 89 | bg_color = #262d3a 90 | bar_bg_color = #262d3a 91 | bar_text_color = #92969c 92 | nbg_color = #19202d 93 | napp_text_color = #92969c 94 | ntitle_text_color = white 95 | nbody_text_color = #92969c 96 | -------------------------------------------------------------------------------- /themes/default/tray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RussianBruteForce/iq-notifier/0feee9cb755a9ae2221d16c92d98c8710a345e61/themes/default/tray.png -------------------------------------------------------------------------------- /themes/pony/bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RussianBruteForce/iq-notifier/0feee9cb755a9ae2221d16c92d98c8710a345e61/themes/pony/bg.png -------------------------------------------------------------------------------- /themes/pony/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RussianBruteForce/iq-notifier/0feee9cb755a9ae2221d16c92d98c8710a345e61/themes/pony/close.png -------------------------------------------------------------------------------- /themes/pony/closeAll.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RussianBruteForce/iq-notifier/0feee9cb755a9ae2221d16c92d98c8710a345e61/themes/pony/closeAll.png -------------------------------------------------------------------------------- /themes/pony/closeExtra.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RussianBruteForce/iq-notifier/0feee9cb755a9ae2221d16c92d98c8710a345e61/themes/pony/closeExtra.png -------------------------------------------------------------------------------- /themes/pony/closeVisible.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RussianBruteForce/iq-notifier/0feee9cb755a9ae2221d16c92d98c8710a345e61/themes/pony/closeVisible.png -------------------------------------------------------------------------------- /themes/pony/history_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RussianBruteForce/iq-notifier/0feee9cb755a9ae2221d16c92d98c8710a345e61/themes/pony/history_bg.png -------------------------------------------------------------------------------- /themes/pony/theme: -------------------------------------------------------------------------------- 1 | ; IQ Notifier My Little Pony theme 2 | ; 3 | ; if size properties are not set, IQ Notifier will try to automatically adjust their values 4 | 5 | [popup_notifications] 6 | ; default 120 7 | drop_animation_duration = 120 8 | 9 | ; default 120 10 | show_animation_duration = 120 11 | 12 | ; set to 'left' if you want to show icon at left side 13 | icon_position = left 14 | 15 | bar_height = 32 16 | 17 | ; default value: 0 (invisible) 18 | ; fancy trick: make expiration_bar_height same as window height 19 | expiration_bar_height = 1 20 | 21 | font_size = 12 22 | 23 | bar_font_size = 10 24 | 25 | ; if not set, IQ Notifier will try to automatically adjust icon size 26 | icon_size = 72 27 | 28 | ; size scale of button images 29 | close_button_image_scale = 0.7 30 | extra_button_image_scale = 0.7 31 | 32 | ; color name or HTML code 33 | bg_color = #488295 34 | bar_bg_color = #54909d 35 | bar_text_color = #33001b 36 | expiration_bar_color = #6f80a5 37 | title_text_color = #33001b 38 | body_text_color = #074552 39 | button_bg_color = #75a9b6 40 | button_text_color = #074552 41 | extra_bg_color = #54909d 42 | extra_unread_circle_color = #d74a37 43 | extra_unread_text_color = white 44 | 45 | ; relative to this file directory 46 | bg_image = bg.png 47 | close_button_image = close.png 48 | extra_close_button_image = closeExtra.png 49 | extra_close_all_button_image = closeAll.png 50 | extra_close_visible_button_image = closeVisible.png 51 | 52 | [tray] 53 | icon = tray.png 54 | 55 | [history_window] 56 | ; icon for button on bar 57 | close_icon = close.png 58 | bg_image = history_bg.png 59 | 60 | window_title = IQ Notifier 61 | 62 | ; 0 for full height 63 | height = 0 64 | ; 0 for ¼ of width 65 | width = 0 66 | 67 | ; window position 68 | ; UNDEFINED : 0 69 | ; LEFT_TOP : 1 70 | ; LEFT_BOT : 2 71 | ; RIGHT_BOT : 3 72 | ; RIGHT_TOP : 4 73 | window_position = 1 74 | 75 | ; works only if window_position is 0 or not defined 76 | ;x = 0 77 | ;y = 0 78 | 79 | 80 | ; can'not be deduced auto: 0 is for invisible bar 81 | bar_height = 32 82 | 83 | ; 0 for auto 84 | notification_height = 0 85 | bar_font_size = 0 86 | napp_font_size = 0 87 | ntitle_font_size = 0 88 | nbody_font_size = 0 89 | 90 | bg_color = #488295 91 | bar_bg_color = #54909d 92 | bar_text_color = #33001b 93 | nbg_color = #488295 94 | napp_text_color = #074552 95 | ntitle_text_color = #33001b 96 | nbody_text_color = #074552 97 | -------------------------------------------------------------------------------- /themes/pony/tray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RussianBruteForce/iq-notifier/0feee9cb755a9ae2221d16c92d98c8710a345e61/themes/pony/tray.png --------------------------------------------------------------------------------