Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:wolfi323:branches:KDE:Unstable:Frameworks
kjobwidgets
_service:obs_scm:kjobwidgets-VERSIONgit.2020011...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:kjobwidgets-VERSIONgit.20200112T115258~0fea2a7.obscpio of Package kjobwidgets
07070100000000000081A40000000200000002000000015E1AFA8A00000039000000000000000000000000000000000000003A00000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/.arcconfig{ "phabricator.uri" : "https://phabricator.kde.org/" } 07070100000001000081A40000000200000002000000015E1AFA8A00000CF5000000000000000000000000000000000000003E00000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/CMakeLists.txtcmake_minimum_required(VERSION 3.5) set(KF5_VERSION "5.67.0") # handled by release scripts set(KF5_DEP_VERSION "5.66.0") # handled by release scripts project(KJobWidgets VERSION ${KF5_VERSION}) include(FeatureSummary) find_package(ECM 5.66.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) include(KDEInstallDirs) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(KDECMakeSettings) include(ECMQtDeclareLoggingCategory) include(ECMPoQmTools) set(REQUIRED_QT_VERSION 5.12.0) find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Widgets DBus) if (NOT APPLE) find_package(X11) endif() set(HAVE_X11 ${X11_FOUND}) find_package(KF5CoreAddons ${KF5_DEP_VERSION} REQUIRED) find_package(KF5WidgetsAddons ${KF5_DEP_VERSION} REQUIRED) include(GenerateExportHeader) include(ECMSetupVersion) include(ECMGenerateHeaders) include(ECMAddQch) option(BUILD_QCH "Build API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)" OFF) add_feature_info(QCH ${BUILD_QCH} "API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)") ecm_setup_version(PROJECT VARIABLE_PREFIX KJOBWIDGETS VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kjobwidgets_version.h" PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5JobWidgetsConfigVersion.cmake" SOVERSION 5) add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050d00) add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x054200) add_definitions(-DQT_NO_FOREACH) if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/po") ecm_install_po_files_as_qm(po) endif() add_subdirectory(src) if (BUILD_TESTING) add_subdirectory(tests) add_subdirectory(autotests) endif() # create a Config.cmake and a ConfigVersion.cmake file and install them set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5JobWidgets") if (BUILD_QCH) ecm_install_qch_export( TARGETS KF5JobWidgets_QCH FILE KF5JobWidgetsQchTargets.cmake DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel ) set(PACKAGE_INCLUDE_QCHTARGETS "include(\"\${CMAKE_CURRENT_LIST_DIR}/KF5JobWidgetsQchTargets.cmake\")") endif() include(CMakePackageConfigHelpers) configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/KF5JobWidgetsConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/KF5JobWidgetsConfig.cmake" PATH_VARS KDE_INSTALL_DBUSINTERFACEDIR INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR} ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/KF5JobWidgetsConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/KF5JobWidgetsConfigVersion.cmake" DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel ) install(EXPORT KF5JobWidgetsTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KF5JobWidgetsTargets.cmake NAMESPACE KF5:: ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kjobwidgets_version.h DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5} COMPONENT Devel ) install(FILES kjobwidgets.categories DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR}) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) 07070100000002000081A40000000200000002000000015E1AFA8A0000679F000000000000000000000000000000000000003B00000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/COPYING.LIB GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. <one line to give the library's name and a brief idea of what it does.> Copyright (C) <year> <name of author> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. <signature of Ty Coon>, 1 April 1990 Ty Coon, President of Vice That's all there is to it! 07070100000003000081A40000000200000002000000015E1AFA8A00000144000000000000000000000000000000000000004C00000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/KF5JobWidgetsConfig.cmake.in@PACKAGE_INIT@ set(KJOBWIDGETS_DBUS_INTERFACES_DIR "@PACKAGE_KDE_INSTALL_DBUSINTERFACEDIR@") include(CMakeFindDependencyMacro) find_dependency(Qt5Widgets @REQUIRED_QT_VERSION@) find_dependency(KF5CoreAddons "@KF5_DEP_VERSION@") include("${CMAKE_CURRENT_LIST_DIR}/KF5JobWidgetsTargets.cmake") @PACKAGE_INCLUDE_QCHTARGETS@ 07070100000004000081A40000000200000002000000015E1AFA8A0000009C000000000000000000000000000000000000003900000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/README.md# KJobWidgets Widgets for showing progress of asynchronous jobs ## Introduction KJobWIdgets provides widgets for showing progress of asynchronous jobs. 07070100000005000041ED0000000200000002000000025E1AFA8A00000000000000000000000000000000000000000000003900000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/autotests07070100000006000081A40000000200000002000000015E1AFA8A000000A7000000000000000000000000000000000000004800000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/autotests/CMakeLists.txt find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Test) include(ECMAddTests) #TODO: add tests #ecm_add_tests( # footest.cpp # LINK_LIBRARIES Qt5::Test #) 07070100000007000081A40000000200000002000000015E1AFA8A00000171000000000000000000000000000000000000004700000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/autotests/pythontest.py#!/usr/bin/env python #-*- coding: utf-8 -*- import sys sys.path.append(sys.argv[1]) from PyQt5 import QtWidgets from PyKF5 import KJobWidgets def main(): app = QtWidgets.QApplication(sys.argv) jt = KJobWidgets.KStatusBarJobTracker() jt.setStatusBarMode(KJobWidgets.KStatusBarJobTracker.NoInformation) if __name__ == '__main__': sys.exit(main()) 07070100000008000081A40000000200000002000000015E1AFA8A00000036000000000000000000000000000000000000004600000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/kjobwidgets.categorieskf5.kjobwidgets kfilewidgets IDENTIFIER [KJOBWIDGETS] 07070100000009000081A40000000200000002000000015E1AFA8A0000016B000000000000000000000000000000000000003D00000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/metainfo.yamlmaintainer: description: Widgets for tracking KJob instances tier: 2 type: functional platforms: - name: Linux - name: FreeBSD - name: Windows - name: MacOSX portingAid: false deprecated: false release: true libraries: - qmake: KJobWidgets cmake: "KF5::JobWidgets" cmakename: KF5JobWidgets public_lib: true group: Frameworks subgroup: Tier 2 0707010000000A000041ED0000000200000002000000025E1AFA8A00000000000000000000000000000000000000000000003300000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/src0707010000000B000081A40000000200000002000000015E1AFA8A00000F28000000000000000000000000000000000000004200000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/src/CMakeLists.txtconfigure_file(config-kjobwidgets.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kjobwidgets.h ) ecm_create_qm_loader(kjobwidgets_QM_LOADER kjobwidgets5_qt) set(kjobwidgets_SRCS kabstractwidgetjobtracker.cpp kdialogjobuidelegate.cpp kjobtrackerformatters.cpp kuiserverjobtracker.cpp kjobwidgets.cpp kstatusbarjobtracker.cpp kwidgetjobtracker.cpp ${kjobwidgets_QM_LOADER} ) ecm_qt_declare_logging_category(kjobwidgets_SRCS HEADER debug.h IDENTIFIER KJOBWIDGETS CATEGORY_NAME kf5.kjobwidgets) qt5_add_dbus_interfaces(kjobwidgets_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/org.kde.JobViewServer.xml ) qt5_add_dbus_interface(kjobwidgets_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/org.kde.JobView.xml jobviewiface ) add_library(KF5JobWidgets ${kjobwidgets_SRCS}) generate_export_header(KF5JobWidgets BASE_NAME KJobWidgets) add_library(KF5::JobWidgets ALIAS KF5JobWidgets) target_include_directories(KF5JobWidgets INTERFACE "$<INSTALL_INTERFACE:${KDE_INSTALL_INCLUDEDIR_KF5}/KJobWidgets>") target_link_libraries(KF5JobWidgets PUBLIC Qt5::Widgets KF5::CoreAddons # KJob PRIVATE Qt5::DBus KF5::WidgetsAddons # KSqueezedTextLabel ) if (HAVE_X11) find_package(Qt5X11Extras ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE) target_link_libraries(KF5JobWidgets PRIVATE Qt5::X11Extras) endif () set_target_properties(KF5JobWidgets PROPERTIES VERSION ${KJOBWIDGETS_VERSION_STRING} SOVERSION ${KJOBWIDGETS_SOVERSION} EXPORT_NAME JobWidgets ) ecm_generate_headers(KJobWidgets_HEADERS HEADER_NAMES KAbstractWidgetJobTracker KDialogJobUiDelegate KUiServerJobTracker KJobWidgets KStatusBarJobTracker KWidgetJobTracker REQUIRED_HEADERS KJobWidgets_HEADERS ) find_package(PythonModuleGeneration) if (PythonModuleGeneration_FOUND) ecm_generate_python_binding( TARGET KF5::JobWidgets PYTHONNAMESPACE PyKF5 MODULENAME KJobWidgets SIP_DEPENDS QtWidgets/QtWidgetsmod.sip PyKF5/KCoreAddons/KCoreAddonsmod.sip HEADERS kabstractwidgetjobtracker.h kdialogjobuidelegate.h kuiserverjobtracker.h kjobwidgets.h kstatusbarjobtracker.h kwidgetjobtracker.h ) endif() install(TARGETS KF5JobWidgets EXPORT KF5JobWidgetsTargets ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) install(FILES org.kde.JobViewServer.xml DESTINATION ${KDE_INSTALL_DBUSINTERFACEDIR} RENAME kf5_org.kde.JobViewServer.xml) install(FILES org.kde.JobView.xml DESTINATION ${KDE_INSTALL_DBUSINTERFACEDIR} RENAME kf5_org.kde.JobView.xml) install(FILES org.kde.JobViewV2.xml DESTINATION ${KDE_INSTALL_DBUSINTERFACEDIR} RENAME kf5_org.kde.JobViewV2.xml) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kjobwidgets_export.h ${KJobWidgets_HEADERS} DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/KJobWidgets COMPONENT Devel ) if(BUILD_QCH) ecm_add_qch( KF5JobWidgets_QCH NAME KJobWidgets BASE_NAME KF5JobWidgets VERSION ${KF5_VERSION} ORG_DOMAIN org.kde SOURCES # using only public headers, to cover only public API ${KJobWidgets_HEADERS} MD_MAINPAGE "${CMAKE_SOURCE_DIR}/README.md" LINK_QCHS KF5CoreAddons_QCH Qt5Widgets_QCH Qt5Gui_QCH Qt5Core_QCH INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR} BLANK_MACROS KJOBWIDGETS_EXPORT TAGFILE_INSTALL_DESTINATION ${KDE_INSTALL_QTQCHDIR} QCH_INSTALL_DESTINATION ${KDE_INSTALL_QTQCHDIR} COMPONENT Devel ) endif() include(ECMGeneratePriFile) ecm_generate_pri_file(BASE_NAME KJobWidgets LIB_NAME KF5JobWidgets DEPS "widgets KCoreAddons" FILENAME_VAR PRI_FILENAME INCLUDE_INSTALL_DIR ${KDE_INSTALL_INCLUDEDIR_KF5}/KJobWidgets) install(FILES ${PRI_FILENAME} DESTINATION ${ECM_MKSPECS_INSTALL_DIR}) 0707010000000C000081ED0000000200000002000000015E1AFA8A00000106000000000000000000000000000000000000003F00000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/src/Messages.sh#!/bin/sh # Extract strings from all source files. # EXTRACT_TR_STRINGS extracts strings with lupdate and convert them to .pot with # lconvert. $EXTRACT_TR_STRINGS `find . -name \*.cpp -o -name \*.h -o -name \*.ui -o -name \*.qml` -o $podir/kjobwidgets5_qt.pot 0707010000000D000081A40000000200000002000000015E1AFA8A00000019000000000000000000000000000000000000004E00000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/src/config-kjobwidgets.h.cmake#cmakedefine01 HAVE_X11 0707010000000E000081A40000000200000002000000015E1AFA8A000009B6000000000000000000000000000000000000005100000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/src/kabstractwidgetjobtracker.cpp/* This file is part of the KDE project Copyright (C) 2000 Matej Koss <koss@miesto.sk> Copyright (C) 2007 Kevin Ottens <ervin@kde.org> Copyright (C) 2007 Rafael Fernández López <ereslibre@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "kabstractwidgetjobtracker.h" #include "kabstractwidgetjobtracker_p.h" #include <QWidget> KAbstractWidgetJobTracker::KAbstractWidgetJobTracker(QWidget *parent) : KJobTrackerInterface(parent) , d(new Private(this)) { } KAbstractWidgetJobTracker::~KAbstractWidgetJobTracker() { delete d; } void KAbstractWidgetJobTracker::registerJob(KJob *job) { KJobTrackerInterface::registerJob(job); } void KAbstractWidgetJobTracker::unregisterJob(KJob *job) { KJobTrackerInterface::unregisterJob(job); } void KAbstractWidgetJobTracker::setStopOnClose(KJob *job, bool stopOnClose) { d->setStopOnClose(job, stopOnClose); } bool KAbstractWidgetJobTracker::stopOnClose(KJob *job) const { return d->stopOnClose(job); } void KAbstractWidgetJobTracker::setAutoDelete(KJob *job, bool autoDelete) { d->setAutoDelete(job, autoDelete); } bool KAbstractWidgetJobTracker::autoDelete(KJob *job) const { return d->autoDelete(job); } void KAbstractWidgetJobTracker::finished(KJob *job) { Q_UNUSED(job); } void KAbstractWidgetJobTracker::slotStop(KJob *job) { if (job) { job->kill(KJob::EmitResult); // notify that the job has been killed emit stopped(job); } } void KAbstractWidgetJobTracker::slotSuspend(KJob *job) { if (job) { job->suspend(); emit suspend(job); } } void KAbstractWidgetJobTracker::slotResume(KJob *job) { if (job) { job->resume(); emit resume(job); } } void KAbstractWidgetJobTracker::slotClean(KJob *job) { Q_UNUSED(job); } 0707010000000F000081A40000000200000002000000015E1AFA8A00001689000000000000000000000000000000000000004F00000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/src/kabstractwidgetjobtracker.h/* This file is part of the KDE project Copyright (C) 2000 Matej Koss <koss@miesto.sk> Copyright (C) 2007 Kevin Ottens <ervin@kde.org> Copyright (C) 2008 Rafael Fernández López <ereslibre@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KABSTRACTWIDGETJOBTRACKER_H #define KABSTRACTWIDGETJOBTRACKER_H #include <kjobwidgets_export.h> #include <kjobtrackerinterface.h> class KJob; class QWidget; /** * @class KAbstractWidgetJobTracker kabstractwidgetjobtracker.h KAbstractWidgetJobTracker * * The base class for widget based job trackers. */ class KJOBWIDGETS_EXPORT KAbstractWidgetJobTracker : public KJobTrackerInterface { Q_OBJECT public: /** * Creates a new KAbstractWidgetJobTracker * * @param parent the parent of this object and of the widget displaying the job progresses */ explicit KAbstractWidgetJobTracker(QWidget *parent = nullptr); /** * Destroys a KAbstractWidgetJobTracker */ ~KAbstractWidgetJobTracker() override; // KDE5: move this two virtual methods to be placed correctly (ereslibre) public Q_SLOTS: /** * Register a new job in this tracker. * Note that job trackers inheriting from this class can have only one job * registered at a time. * * @param job the job to register */ void registerJob(KJob *job) override; /** * Unregister a job from this tracker. * * @param job the job to unregister */ void unregisterJob(KJob *job) override; public: /** * The widget associated to this tracker. * * @param job the job that is assigned the widget we want to return * @return the widget displaying the job progresses */ virtual QWidget *widget(KJob *job) = 0; /** * This controls whether the job should be canceled if the dialog is closed. * * @param job the job's widget that will be stopped when closing * @param stopOnClose If true the job will be stopped if the dialog is closed, * otherwise the job will continue even on close. * @see stopOnClose() */ void setStopOnClose(KJob *job, bool stopOnClose); /** * Checks whether the job will be killed when the dialog is closed. * * @param job the job's widget that will be stopped when closing * @return true if the job is killed on close event, false otherwise. * @see setStopOnClose() */ bool stopOnClose(KJob *job) const; /** * This controls whether the dialog should be deleted or only cleaned when * the KJob is finished (or canceled). * * If your dialog is an embedded widget and not a separate window, you should * setAutoDelete(false) in the constructor of your custom dialog. * * @param job the job's widget that is going to be auto-deleted * @param autoDelete If false the dialog will only call method slotClean. * If true the dialog will be deleted. * @see autoDelete() */ void setAutoDelete(KJob *job, bool autoDelete); /** * Checks whether the dialog should be deleted or cleaned. * * @param job the job's widget that will be auto-deleted * @return false if the dialog only calls slotClean, true if it will be * deleted * @see setAutoDelete() */ bool autoDelete(KJob *job) const; protected Q_SLOTS: /** * Called when a job is finished, in any case. It is used to notify * that the job is terminated and that progress UI (if any) can be hidden. * * @param job the job that emitted this signal */ void finished(KJob *job) override; /** * This method should be called for correct cancellation of IO operation * Connect this to the progress widgets buttons etc. * * @param job The job that is being stopped */ virtual void slotStop(KJob *job); /** * This method should be called for pause/resume * Connect this to the progress widgets buttons etc. * * @param job The job that is being suspended */ virtual void slotSuspend(KJob *job); /** * This method should be called for pause/resume * Connect this to the progress widgets buttons etc. * * @param job The job that is being resumed */ virtual void slotResume(KJob *job); /** * This method is called when the widget should be cleaned (after job is finished). * redefine this for custom behavior. * * @param job The job that is being cleaned */ virtual void slotClean(KJob *job); Q_SIGNALS: /** * Emitted when the user aborted the operation * * @param job The job that has been stopped */ void stopped(KJob *job); /** * Emitted when the user suspended the operation * * @param job The job that has been suspended */ void suspend(KJob *job); /** * Emitted when the user resumed the operation * * @param job The job that has been resumed */ void resume(KJob *job); protected: class Private; Private *const d; }; #endif 07070100000010000081A40000000200000002000000015E1AFA8A0000076F000000000000000000000000000000000000005100000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/src/kabstractwidgetjobtracker_p.h/* This file is part of the KDE project Copyright (C) 2000 Matej Koss <koss@miesto.sk> Copyright (C) 2007 Kevin Ottens <ervin@kde.org> Copyright (C) 2007 Rafael Fernández López <ereslibre@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KABSTRACTWIDGETJOBTRACKER_P #define KABSTRACTWIDGETJOBTRACKER_P #include "kabstractwidgetjobtracker.h" class Q_DECL_HIDDEN KAbstractWidgetJobTracker::Private { public: Private(KAbstractWidgetJobTracker *parent) : q(parent) { } virtual ~Private() { } KAbstractWidgetJobTracker *const q; //### KDE 5: make this methods virtual on KAbstractWidgetJobTracker and get rid out of this // workaround. (ereslibre) virtual void setStopOnClose(KJob *job, bool stopOnClose) { Q_UNUSED(job); Q_UNUSED(stopOnClose); } virtual bool stopOnClose(KJob *job) const { Q_UNUSED(job); return true; } virtual void setAutoDelete(KJob *job, bool autoDelete) { Q_UNUSED(job); Q_UNUSED(autoDelete); } virtual bool autoDelete(KJob *job) const { Q_UNUSED(job); return true; } }; #endif // KABSTRACTWIDGETJOBTRACKER_P 07070100000011000081A40000000200000002000000015E1AFA8A000010DA000000000000000000000000000000000000004C00000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/src/kdialogjobuidelegate.cpp/* This file is part of the KDE libraries Copyright (C) 2000 Stephan Kulow <coolo@kde.org> David Faure <faure@kde.org> Copyright (C) 2006,2007 Kevin Ottens <ervin@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "kdialogjobuidelegate.h" #include <QWidget> #include <QQueue> #include <QPointer> #include <kmessagebox.h> #include <kjob.h> #include <kjobwidgets.h> #include <config-kjobwidgets.h> #if HAVE_X11 #include <QX11Info> #endif struct MessageBoxData { QWidget *widget; KMessageBox::DialogType type; QString msg; }; class Q_DECL_HIDDEN KDialogJobUiDelegate::Private : public QObject { Q_OBJECT public: explicit Private(QObject *parent = nullptr); virtual ~Private(); void queuedMessageBox(QWidget *widget, KMessageBox::DialogType type, const QString &msg); QWidget *window; public Q_SLOTS: void next(); private: bool running; QQueue<QSharedPointer<MessageBoxData> > queue; }; KDialogJobUiDelegate::Private::Private(QObject *parent) : QObject(parent) , window(nullptr) , running(false) { } KDialogJobUiDelegate::Private::~Private() { queue.clear(); } void KDialogJobUiDelegate::Private::next() { if (queue.isEmpty()) { running = false; return; } QSharedPointer<MessageBoxData> data = queue.dequeue(); //kmessagebox starts a new event loop which can cause this to get deleted //https://bugs.kde.org/show_bug.cgi?id=356321#c16 QPointer<KDialogJobUiDelegate::Private> thisGuard(this); KMessageBox::messageBox(data->widget, data->type, data->msg); if (!thisGuard) { return; } QMetaObject::invokeMethod(this, "next", Qt::QueuedConnection); } void KDialogJobUiDelegate::Private::queuedMessageBox(QWidget *widget, KMessageBox::DialogType type, const QString &msg) { QSharedPointer<MessageBoxData> data(new MessageBoxData); data->type = type; data->widget = widget; data->msg = msg; queue.enqueue(data); if (!running) { running = true; QMetaObject::invokeMethod(this, "next", Qt::QueuedConnection); } } KDialogJobUiDelegate::KDialogJobUiDelegate() : d(new KDialogJobUiDelegate::Private) { } KDialogJobUiDelegate::~KDialogJobUiDelegate() { delete d; } bool KDialogJobUiDelegate::setJob(KJob *job) { bool ret = KJobUiDelegate::setJob(job); #if HAVE_X11 if (ret) { unsigned long time = QX11Info::appUserTime(); KJobWidgets::updateUserTimestamp(job, time); } #endif return ret; } void KDialogJobUiDelegate::setWindow(QWidget *window) { if (job()) { KJobWidgets::setWindow(job(), window); } d->window = window; } QWidget *KDialogJobUiDelegate::window() const { if (d->window) { return d->window; } else if (job()) { return KJobWidgets::window(job()); } return nullptr; } void KDialogJobUiDelegate::updateUserTimestamp(unsigned long time) { KJobWidgets::updateUserTimestamp(job(), time); } unsigned long KDialogJobUiDelegate::userTimestamp() const { return KJobWidgets::userTimestamp(job()); } void KDialogJobUiDelegate::showErrorMessage() { if (job()->error() != KJob::KilledJobError) { d->queuedMessageBox(window(), KMessageBox::Error, job()->errorString()); } } void KDialogJobUiDelegate::slotWarning(KJob * /*job*/, const QString &plain, const QString &/*rich*/) { if (isAutoWarningHandlingEnabled()) { d->queuedMessageBox(window(), KMessageBox::Information, plain); } } #include "kdialogjobuidelegate.moc" 07070100000012000081A40000000200000002000000015E1AFA8A000009DF000000000000000000000000000000000000004A00000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/src/kdialogjobuidelegate.h/* This file is part of the KDE libraries Copyright (C) 2000 Stephan Kulow <coolo@kde.org> David Faure <faure@kde.org> Copyright (C) 2006,2007 Kevin Ottens <ervin@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KDIALOGJOBUIDELEGATE_H #define KDIALOGJOBUIDELEGATE_H #include <kjobuidelegate.h> #include <kjobwidgets_export.h> /** * @class KDialogJobUiDelegate kdialogjobuidelegate.h KDialogJobUiDelegate * * A UI delegate using KMessageBox for interaction (showing errors and warnings). * * The KMessageBox will use window as a parent in an application-modal. */ class KJOBWIDGETS_EXPORT KDialogJobUiDelegate : public KJobUiDelegate { Q_OBJECT public: /** * Constructs a new KDialogJobUiDelegate. */ KDialogJobUiDelegate(); /** * Destroys the KDialogJobUiDelegate. */ ~KDialogJobUiDelegate() override; public: /** * @reimp */ bool setJob(KJob *job) override; /** * Associate this job with a window given by @p window. * @param window the window to associate to * @see window() */ virtual void setWindow(QWidget *window); /** * Returns the window this job is associated with. * @return the associated window * @see setWindow() */ QWidget *window() const; /** * Updates the last user action timestamp to the given time. * See KApplication::updateUserTimestamp(). */ void updateUserTimestamp(unsigned long time); /** * @internal */ unsigned long userTimestamp() const; void showErrorMessage() override; protected Q_SLOTS: void slotWarning(KJob *job, const QString &plain, const QString &rich) override; private: class Private; Private *const d; }; #endif 07070100000013000081A40000000200000002000000015E1AFA8A00000D83000000000000000000000000000000000000004D00000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/src/kjobtrackerformatters.cpp/* This file is part of the KDE project Copyright (c) 1997,2001 Stephan Kulow <coolo@kde.org> Copyright (c) 1999 Preston Brown <pbrown@kde.org> Copyright (c) 1999-2002 Hans Petter Bieker <bieker@kde.org> Copyright (c) 2002 Lukas Tinkl <lukas@kde.org> Copyright (C) 2007 Bernhard Loos <nhuh.put@web.de> Copyright (C) 2009, 2010 John Layt <john@layt.net> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "kjobtrackerformatters_p.h" #include <kformat.h> #include <QCoreApplication> QString KJobTrackerFormatters::byteSize(double size) { return KFormat().formatByteSize(size); } QString KJobTrackerFormatters::daysDuration(int n) { //~ singular %n day //~ plural %n days return QCoreApplication::translate("KJobTrackerFormatters", "%n day(s)", "@item:intext", n); } QString KJobTrackerFormatters::hoursDuration(int n) { //~ singular %n hour //~ plural %n hours return QCoreApplication::translate("KJobTrackerFormatters", "%n hour(s)", "@item:intext", n); } QString KJobTrackerFormatters::minutesDuration(int n) { //~ singular %n minute //~ plural %n minutes return QCoreApplication::translate("KJobTrackerFormatters", "%n minute(s)", "@item:intext", n); } QString KJobTrackerFormatters::secondsDuration(int n) { //~ singular %n second //~ plural %n seconds return QCoreApplication::translate("KJobTrackerFormatters", "%n second(s)", "@item:intext", n); } QString KJobTrackerFormatters::duration(unsigned long mSec) { unsigned long ms = mSec; int days = ms / (24 * 3600000); ms = ms % (24 * 3600000); int hours = ms / 3600000; ms = ms % 3600000; int minutes = ms / 60000; ms = ms % 60000; int seconds = qRound(ms / 1000.0); // Handle correctly problematic case #1 (look at KLocaleTest::prettyFormatDuration() // at klocaletest.cpp) if (seconds == 60) { return duration(mSec - ms + 60000); } if (days && hours) { return QCoreApplication::translate("KJobTrackerFormatters", "%1 and %2", "@item:intext days and hours.").arg(daysDuration(days), hoursDuration(hours)); } else if (days) { return daysDuration(days); } else if (hours && minutes) { return QCoreApplication::translate("KJobTrackerFormatters", "%1 and %2", "@item:intext hours and minutes.").arg(hoursDuration(hours), minutesDuration(minutes)); } else if (hours) { return hoursDuration(hours); } else if (minutes && seconds) { return QCoreApplication::translate("KJobTrackerFormatters", "%1 and %2", "@item:intext minutes and seconds.").arg(minutesDuration(minutes), secondsDuration(seconds)); } else if (minutes) { return minutesDuration(minutes); } else { return secondsDuration(seconds); } } 07070100000014000081A40000000200000002000000015E1AFA8A00000590000000000000000000000000000000000000004D00000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/src/kjobtrackerformatters_p.h/* This file is part of the KDE project Copyright (c) 1997,2001 Stephan Kulow <coolo@kde.org> Copyright (c) 1999 Preston Brown <pbrown@kde.org> Copyright (c) 1999-2002 Hans Petter Bieker <bieker@kde.org> Copyright (c) 2002 Lukas Tinkl <lukas@kde.org> Copyright (C) 2007 Bernhard Loos <nhuh.put@web.de> Copyright (C) 2009, 2010 John Layt <john@layt.net> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KJOBTRACKERFORMATTERS_P_H #define KJOBTRACKERFORMATTERS_P_H #include <QString> namespace KJobTrackerFormatters { QString byteSize(double size); QString daysDuration(int n); QString hoursDuration(int n); QString minutesDuration(int n); QString secondsDuration(int n); QString duration(unsigned long mSec); } #endif 07070100000015000081A40000000200000002000000015E1AFA8A0000098A000000000000000000000000000000000000004300000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/src/kjobwidgets.cpp/* This file is part of the KDE libraries * Copyright (c) 2013 David Faure <faure@kde.org> * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2 of the License or ( at * your option ) version 3 or, at the discretion of KDE e.V. ( which shall * act as a proxy as in section 14 of the GPLv3 ), any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "kjobwidgets.h" #include <kjob.h> #include <QVariant> #include <QWidget> #include <QWindow> void KJobWidgets::setWindow(KJob *job, QWidget *widget) { job->setProperty("widget", QVariant::fromValue(widget)); KJobWindows::setWindow(job, widget ? widget->windowHandle() : nullptr); } QWidget *KJobWidgets::window(KJob *job) { return job->property("widget").value<QWidget *>(); } // duplicated from kwindowsystem static int timestampCompare(unsigned long time1_, unsigned long time2_) // like strcmp() { quint32 time1 = time1_; quint32 time2 = time2_; if (time1 == time2) { return 0; } return quint32(time1 - time2) < 0x7fffffffU ? 1 : -1; // time1 > time2 -> 1, handle wrapping } void KJobWidgets::updateUserTimestamp(KJob *job, unsigned long time) { unsigned long currentTimestamp = userTimestamp(job); if (currentTimestamp == 0 || timestampCompare(time, currentTimestamp) > 0) { job->setProperty("userTimestamp", qulonglong(time)); } } unsigned long KJobWidgets::userTimestamp(KJob *job) { return job->property("userTimestamp").toULongLong(); } void KJobWindows::setWindow(KJob *job, QWindow *window) { job->setProperty("window", QVariant::fromValue(window)); if (window) { job->setProperty("window-id", QVariant::fromValue(window->winId())); } } QWindow *KJobWindows::window(KJob *job) { return job->property("window").value<QWindow *>(); } 07070100000016000081A40000000200000002000000015E1AFA8A00000ACD000000000000000000000000000000000000004100000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/src/kjobwidgets.h/* This file is part of the KDE libraries * Copyright (c) 2013 David Faure <faure@kde.org> * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2 of the License or ( at * your option ) version 3 or, at the discretion of KDE e.V. ( which shall * act as a proxy as in section 14 of the GPLv3 ), any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KJOBWIDGETS_H #define KJOBWIDGETS_H #include <kjobwidgets_export.h> class QWidget; class QWindow; class KJob; /** * KJobWidgets namespace */ namespace KJobWidgets { /** * Associate this job with a window given by @p window. * This is used: * @li by KDialogJobUiDelegate as parent widget for error messages * @li by KWidgetJobTracker as parent widget for progress dialogs * @li by KIO::AbstractJobInteractionInterface as parent widget for rename/skip dialogs * and possibly more. * @li by KIO::DropJob as parent widget of popup menus. * This is required on Wayland to properly position the menu. * @since 5.0 */ KJOBWIDGETS_EXPORT void setWindow(KJob *job, QWidget *widget); /** * Return the window associated with this job. * @since 5.0 */ KJOBWIDGETS_EXPORT QWidget *window(KJob *job); /** * Updates the last user action timestamp to the given time. * @since 5.0 */ KJOBWIDGETS_EXPORT void updateUserTimestamp(KJob *job, unsigned long time); /** * Returns the last user action timestamp * @since 5.0 */ KJOBWIDGETS_EXPORT unsigned long userTimestamp(KJob *job); } namespace KJobWindows { /** * Associate this job with a window given by @p window. * This is used: * @li by KDialogJobUiDelegate as parent widget for error messages * @li by KWidgetJobTracker as parent widget for progress dialogs * @li by KIO::AbstractJobInteractionInterface as parent widget for rename/skip dialogs * and possibly more. * @li by KIO::DropJob as parent widget of popup menus. * This is required on Wayland to properly position the menu. * @since 5.42 */ KJOBWIDGETS_EXPORT void setWindow(KJob *job, QWindow *window); /** * Return the window associated with this job. * @since 5.42 */ KJOBWIDGETS_EXPORT QWindow *window(KJob *job); } #endif 07070100000017000081A40000000200000002000000015E1AFA8A00001EB4000000000000000000000000000000000000004C00000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/src/kstatusbarjobtracker.cpp/* This file is part of the KDE project Copyright (C) 2000 Matej Koss <koss@miesto.sk> Copyright (C) 2007 Kevin Ottens <ervin@kde.org> Copyright (C) 2007 Rafael Fernández López <ereslibre@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "kstatusbarjobtracker.h" #include "kstatusbarjobtracker_p.h" #include "kjobtrackerformatters_p.h" #include <QCoreApplication> #include <QObject> #include <QWidget> #include <QPushButton> #include <QProgressBar> #include <QLabel> #include <QStackedWidget> #include <QMouseEvent> KStatusBarJobTracker::KStatusBarJobTracker(QWidget *parent, bool button) : KAbstractWidgetJobTracker(parent), d(new Private(parent, button)) { } KStatusBarJobTracker::~KStatusBarJobTracker() { delete d; } void KStatusBarJobTracker::registerJob(KJob *job) { KAbstractWidgetJobTracker::registerJob(job); if (d->progressWidget.contains(job)) { return; } Private::ProgressWidget *vi = new Private::ProgressWidget(job, this, d->parent); d->currentProgressWidget = vi; d->progressWidget.insert(job, vi); } void KStatusBarJobTracker::unregisterJob(KJob *job) { KAbstractWidgetJobTracker::unregisterJob(job); if (!d->progressWidget.contains(job)) { return; } if (d->currentProgressWidget == d->progressWidget[job]) { d->currentProgressWidget = nullptr; } if (!d->progressWidget[job]->beingDeleted) { delete d->progressWidget[job]; } d->progressWidget.remove(job); } QWidget *KStatusBarJobTracker::widget(KJob *job) { if (!d->progressWidget.contains(job)) { return nullptr; } return d->progressWidget[job]; } void KStatusBarJobTracker::setStatusBarMode(StatusBarModes statusBarMode) { if (!d->currentProgressWidget) { return; } d->currentProgressWidget->setMode(statusBarMode); } void KStatusBarJobTracker::description(KJob *job, const QString &title, const QPair<QString, QString> &field1, const QPair<QString, QString> &field2) { if (!d->progressWidget.contains(job)) { return; } d->progressWidget[job]->description(title, field1, field2); } void KStatusBarJobTracker::totalAmount(KJob *job, KJob::Unit unit, qulonglong amount) { if (!d->progressWidget.contains(job)) { return; } d->progressWidget[job]->totalAmount(unit, amount); } void KStatusBarJobTracker::percent(KJob *job, unsigned long percent) { if (!d->progressWidget.contains(job)) { return; } d->progressWidget[job]->percent(percent); } void KStatusBarJobTracker::speed(KJob *job, unsigned long value) { if (!d->progressWidget.contains(job)) { return; } d->progressWidget[job]->speed(value); } void KStatusBarJobTracker::slotClean(KJob *job) { if (!d->progressWidget.contains(job)) { return; } d->progressWidget[job]->slotClean(); } void KStatusBarJobTracker::Private::ProgressWidget::killJob() { job->kill(KJob::EmitResult); // notify that the job has been killed } void KStatusBarJobTracker::Private::ProgressWidget::init(KJob *job, QWidget *parent) { widget = new QWidget(parent); int w = fontMetrics().horizontalAdvance(QStringLiteral(" 999.9 kB/s 00:00:01 ")) + 8; box = new QHBoxLayout(widget); box->setContentsMargins(0, 0, 0, 0); box->setSpacing(0); widget->setLayout(box); stack = new QStackedWidget(widget); box->addWidget(stack); if (q->d->showStopButton) { button = new QPushButton(QCoreApplication::translate("KStatusBarJobTracker", "Stop"), widget); box->addWidget(button); connect(button, &QPushButton::clicked, this, &KStatusBarJobTracker::Private::ProgressWidget::killJob); } else { button = nullptr; } progressBar = new QProgressBar(widget); progressBar->installEventFilter(this); progressBar->setMinimumWidth(w); stack->insertWidget(1, progressBar); label = new QLabel(widget); label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); label->installEventFilter(this); label->setMinimumWidth(w); stack->insertWidget(2, label); setMinimumSize(sizeHint()); setMode(KStatusBarJobTracker::LabelOnly); q->setAutoDelete(job, true); QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(widget); setLayout(layout); } void KStatusBarJobTracker::Private::ProgressWidget::setMode(StatusBarModes newMode) { mode = newMode; if (newMode == KStatusBarJobTracker::NoInformation) { stack->hide(); return; } if (newMode & KStatusBarJobTracker::LabelOnly) { stack->show(); stack->setCurrentWidget(label); return; // TODO: we should make possible to show an informative label and the progress bar } if (newMode & KStatusBarJobTracker::ProgressOnly) { stack->show(); stack->setCurrentWidget(progressBar); } } void KStatusBarJobTracker::Private::ProgressWidget::description(const QString &title, const QPair<QString, QString> &field1, const QPair<QString, QString> &field2) { Q_UNUSED(field1); Q_UNUSED(field2); label->setText(title); } void KStatusBarJobTracker::Private::ProgressWidget::totalAmount(KJob::Unit unit, qulonglong amount) { Q_UNUSED(unit); Q_UNUSED(amount); #if 0 // currently unused if (unit == KJob::Bytes) { totalSize = amount; } #endif } void KStatusBarJobTracker::Private::ProgressWidget::percent(unsigned long percent) { progressBar->setValue(percent); } void KStatusBarJobTracker::Private::ProgressWidget::speed(unsigned long value) { if (value == 0) { // speed is measured in bytes-per-second label->setText(QCoreApplication::translate("KStatusBarJobTracker", " Stalled ")); } else { label->setText(QCoreApplication::translate("KStatusBarJobTracker", " %1/s ").arg(KJobTrackerFormatters::byteSize(value))); } } void KStatusBarJobTracker::Private::ProgressWidget::slotClean() { // we don't want to delete this widget, only clean progressBar->setValue(0); label->clear(); setMode(KStatusBarJobTracker::NoInformation); } bool KStatusBarJobTracker::Private::ProgressWidget::eventFilter(QObject *obj, QEvent *event) { if (obj == progressBar || obj == label) { if (event->type() == QEvent::MouseButtonPress) { QMouseEvent *e = static_cast<QMouseEvent *>(event); // TODO: we should make possible to show an informative label and the progress bar if (e->button() == Qt::LeftButton) { // toggle view on left mouse button if (mode == KStatusBarJobTracker::LabelOnly) { setMode(KStatusBarJobTracker::ProgressOnly); } else if (mode == KStatusBarJobTracker::ProgressOnly) { setMode(KStatusBarJobTracker::LabelOnly); } return true; } } return false; } return QWidget::eventFilter(obj, event); } #include "moc_kstatusbarjobtracker.cpp" #include "moc_kstatusbarjobtracker_p.cpp" 07070100000018000081A40000000200000002000000015E1AFA8A00000D46000000000000000000000000000000000000004A00000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/src/kstatusbarjobtracker.h/* This file is part of the KDE project Copyright (C) 2000 Matej Koss <koss@miesto.sk> Copyright (C) 2007 Kevin Ottens <ervin@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KSTATUSBARJOBTRACKER_H #define KSTATUSBARJOBTRACKER_H #include <kabstractwidgetjobtracker.h> /** * @class KStatusBarJobTracker kstatusbarjobtracker.h KStatusBarJobTracker * * This class implements a job tracker with a widget suited for embedding in a * status bar. */ class KJOBWIDGETS_EXPORT KStatusBarJobTracker : public KAbstractWidgetJobTracker { Q_OBJECT public: enum StatusBarMode { NoInformation = 0x0000, ///< Does not show any information LabelOnly = 0x0001, ///< Shows an informative label for job progress ProgressOnly = 0x0002 ///< Shows a progress bar with the job completion }; Q_DECLARE_FLAGS(StatusBarModes, StatusBarMode) /** * Creates a new KStatusBarJobTracker * * @param parent the parent of this object and of the widget displaying the job progresses * @param button true to display a stop button allowing to kill the job, false otherwise */ explicit KStatusBarJobTracker(QWidget *parent = nullptr, bool button = true); /** * Destroys a KStatusBarJobTracker */ ~KStatusBarJobTracker() override; /** * Register a new job in this tracker. * * @param job the job to register */ void registerJob(KJob *job) override; /** * Unregister a job from this tracker. * * @param job the job to unregister */ void unregisterJob(KJob *job) override; /** * The widget associated to this tracker. * * @return the widget displaying the job progresses */ QWidget *widget(KJob *job) override; /** * Sets the mode of the status bar. * * @param statusBarMode what information the status bar will show (see StatusBarMode). * LabelOnly by default */ void setStatusBarMode(StatusBarModes statusBarMode); public Q_SLOTS: /** * The following slots are inherited from KJobTrackerInterface. */ virtual void description(KJob *job, const QString &title, const QPair<QString, QString> &field1, const QPair<QString, QString> &field2) override; void totalAmount(KJob *job, KJob::Unit unit, qulonglong amount) override; void percent(KJob *job, unsigned long percent) override; void speed(KJob *job, unsigned long value) override; void slotClean(KJob *job) override; private: class Private; Private *const d; }; Q_DECLARE_OPERATORS_FOR_FLAGS(KStatusBarJobTracker::StatusBarModes) #endif 07070100000019000081A40000000200000002000000015E1AFA8A00000BC0000000000000000000000000000000000000004C00000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/src/kstatusbarjobtracker_p.h/* This file is part of the KDE project Copyright (C) 2007 Rafael Fernández López <ereslibre@kde.org> Copyright (C) 2007 Kevin Ottens <ervin@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KSTATUSBARJOBTRACKER_P_H #define KSTATUSBARJOBTRACKER_P_H #include "kstatusbarjobtracker.h" #include <QWidget> #include <QMap> #include <QBoxLayout> #include <QStackedWidget> class QPushButton; class QCheckBox; class QLabel; class QProgressBar; class Q_DECL_HIDDEN KStatusBarJobTracker::Private { public: Private(QWidget *parent, bool withStopButton) : parent(parent) , currentProgressWidget(nullptr) , showStopButton(withStopButton) { } ~Private() { } class ProgressWidget; QWidget *parent; QMap<KJob *, ProgressWidget *> progressWidget; ProgressWidget *currentProgressWidget; bool showStopButton; }; class KStatusBarJobTracker::Private::ProgressWidget : public QWidget { Q_OBJECT public: ProgressWidget(KJob *job, KStatusBarJobTracker *object, QWidget *parent) : q(object), job(job), widget(nullptr), progressBar(nullptr), label(nullptr), button(nullptr), box(nullptr), stack(nullptr), /*totalSize(-1),*/ mode(NoInformation), beingDeleted(false) { init(job, parent); } ~ProgressWidget() { beingDeleted = true; delete widget; q->unregisterJob(job); } KStatusBarJobTracker *const q; KJob *const job; QWidget *widget; QProgressBar *progressBar; QLabel *label; QPushButton *button; QBoxLayout *box; QStackedWidget *stack; //qlonglong totalSize; StatusBarModes mode; bool beingDeleted; void init(KJob *job, QWidget *parent); void setMode(StatusBarModes newMode); public Q_SLOTS: virtual void description(const QString &title, const QPair<QString, QString> &field1, const QPair<QString, QString> &field2); virtual void totalAmount(KJob::Unit unit, qulonglong amount); virtual void percent(unsigned long percent); virtual void speed(unsigned long value); virtual void slotClean(); private Q_SLOTS: void killJob(); protected: bool eventFilter(QObject *obj, QEvent *event) override; }; #endif // KSTATUSBARJOBTRACKER_P_H 0707010000001A000081A40000000200000002000000015E1AFA8A00002C17000000000000000000000000000000000000004B00000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/src/kuiserverjobtracker.cpp/* This file is part of the KDE project Copyright (C) 2008 Rafael Fernández López <ereslibre@kde.org> Copyright (C) 2007 Kevin Ottens <ervin@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "kuiserverjobtracker.h" #include "kuiserverjobtracker_p.h" #include "jobviewiface.h" #include "debug.h" #include <kjob.h> #include <QApplication> #include <QDBusConnection> #include <QIcon> Q_GLOBAL_STATIC(KSharedUiServerProxy, serverProxy) class Q_DECL_HIDDEN KUiServerJobTracker::Private { public: Private(KUiServerJobTracker *parent) : q(parent) { } KUiServerJobTracker *const q; void _k_killJob(); static void updateDestUrl(KJob *job, org::kde::JobViewV2 *jobView); QHash<KJob *, org::kde::JobViewV2 *> progressJobView; QMetaObject::Connection serverRegisteredConnection; }; void KUiServerJobTracker::Private::_k_killJob() { org::kde::JobViewV2 *jobView = qobject_cast<org::kde::JobViewV2 *>(q->sender()); if (jobView) { KJob *job = progressJobView.key(jobView); if (job) { job->kill(KJob::EmitResult); } } } void KUiServerJobTracker::Private::updateDestUrl(KJob *job, org::kde::JobViewV2 *jobView) { const QVariant destUrl = job->property("destUrl"); if (destUrl.isValid()) { jobView->setDestUrl(QDBusVariant(destUrl)); } } KUiServerJobTracker::KUiServerJobTracker(QObject *parent) : KJobTrackerInterface(parent), d(new Private(this)) { } KUiServerJobTracker::~KUiServerJobTracker() { if (!d->progressJobView.isEmpty()) { qWarning() << "A KUiServerJobTracker instance contains" << d->progressJobView.size() << "stalled jobs"; } qDeleteAll(d->progressJobView); delete d; } void KUiServerJobTracker::registerJob(KJob *job) { // Already registered job? if (d->progressJobView.contains(job)) { return; } // Watch the server registering/unregistering and re-register the jobs as needed if (!d->serverRegisteredConnection) { d->serverRegisteredConnection = connect(serverProxy(), &KSharedUiServerProxy::serverRegistered, this, [this]() { // Remember the list of jobs to re-register and then delete the old ones const QList<KJob *> staleJobs = d->progressJobView.keys(); qDeleteAll(d->progressJobView); d->progressJobView.clear(); for (KJob *job : staleJobs) { registerJob(job); } }); } const QString appName = QCoreApplication::applicationName(); // This will only work if main() used QIcon::fromTheme. QString programIconName = QApplication::windowIcon().name(); if (programIconName.isEmpty()) { programIconName = appName; } QPointer<KJob> jobWatch = job; QDBusReply<QDBusObjectPath> reply = serverProxy()->uiserver()->requestView(appName, programIconName, job->capabilities()); // If we got a valid reply, register the interface for later usage. if (reply.isValid()) { org::kde::JobViewV2 *jobView = new org::kde::JobViewV2(QStringLiteral("org.kde.JobViewServer"), reply.value().path(), QDBusConnection::sessionBus()); if (!jobWatch) { //qCDebug(KJOBWIDGETS) << "deleted out from under us when asking the server proxy for the view"; jobView->terminate(QString()); delete jobView; return; } QObject::connect(jobView, SIGNAL(cancelRequested()), this, SLOT(_k_killJob())); QObject::connect(jobView, &org::kde::JobViewV2::suspendRequested, job, &KJob::suspend); QObject::connect(jobView, &org::kde::JobViewV2::resumeRequested, job, &KJob::resume); d->updateDestUrl(job, jobView); if (!jobWatch) { //qCDebug(KJOBWIDGETS) << "deleted out from under us when creating the dbus interface"; jobView->terminate(QString()); delete jobView; return; } d->progressJobView.insert(job, jobView); } else if (!jobWatch) { qWarning() << "Uh-oh...KUiServerJobTracker was trying to forward a job, but it was deleted from under us." << "kuiserver *may* have a stranded job. we can't do anything about it because the returned objectPath is invalid."; return; } KJobTrackerInterface::registerJob(job); } void KUiServerJobTracker::unregisterJob(KJob *job) { KJobTrackerInterface::unregisterJob(job); if (!d->progressJobView.contains(job)) { return; } org::kde::JobViewV2 *jobView = d->progressJobView.take(job); d->updateDestUrl(job, jobView); jobView->setError(job->error()); if (job->error()) { jobView->terminate(job->errorText()); } else { jobView->terminate(QString()); } delete jobView; } void KUiServerJobTracker::finished(KJob *job) { if (!d->progressJobView.contains(job)) { return; } org::kde::JobViewV2 *jobView = d->progressJobView.take(job); d->updateDestUrl(job, jobView); jobView->setError(job->error()); if (job->error()) { jobView->terminate(job->errorText()); } else { jobView->terminate(QString()); } } void KUiServerJobTracker::suspended(KJob *job) { if (!d->progressJobView.contains(job)) { return; } org::kde::JobViewV2 *jobView = d->progressJobView[job]; jobView->setSuspended(true); } void KUiServerJobTracker::resumed(KJob *job) { if (!d->progressJobView.contains(job)) { return; } org::kde::JobViewV2 *jobView = d->progressJobView[job]; jobView->setSuspended(false); } void KUiServerJobTracker::description(KJob *job, const QString &title, const QPair<QString, QString> &field1, const QPair<QString, QString> &field2) { if (!d->progressJobView.contains(job)) { return; } org::kde::JobViewV2 *jobView = d->progressJobView[job]; jobView->setInfoMessage(title); if (field1.first.isNull() || field1.second.isNull()) { jobView->clearDescriptionField(0); } else { jobView->setDescriptionField(0, field1.first, field1.second); } if (field2.first.isNull() || field2.second.isNull()) { jobView->clearDescriptionField(1); } else { jobView->setDescriptionField(1, field2.first, field2.second); } } void KUiServerJobTracker::infoMessage(KJob *job, const QString &plain, const QString &rich) { Q_UNUSED(rich) if (!d->progressJobView.contains(job)) { return; } org::kde::JobViewV2 *jobView = d->progressJobView[job]; jobView->setInfoMessage(plain); } void KUiServerJobTracker::totalAmount(KJob *job, KJob::Unit unit, qulonglong amount) { if (!d->progressJobView.contains(job)) { return; } org::kde::JobViewV2 *jobView = d->progressJobView[job]; switch (unit) { case KJob::Bytes: jobView->setTotalAmount(amount, QStringLiteral("bytes")); break; case KJob::Files: jobView->setTotalAmount(amount, QStringLiteral("files")); break; case KJob::Directories: jobView->setTotalAmount(amount, QStringLiteral("dirs")); break; } } void KUiServerJobTracker::processedAmount(KJob *job, KJob::Unit unit, qulonglong amount) { if (!d->progressJobView.contains(job)) { return; } org::kde::JobViewV2 *jobView = d->progressJobView[job]; switch (unit) { case KJob::Bytes: jobView->setProcessedAmount(amount, QStringLiteral("bytes")); break; case KJob::Files: jobView->setProcessedAmount(amount, QStringLiteral("files")); break; case KJob::Directories: jobView->setProcessedAmount(amount, QStringLiteral("dirs")); break; } } void KUiServerJobTracker::percent(KJob *job, unsigned long percent) { if (!d->progressJobView.contains(job)) { return; } org::kde::JobViewV2 *jobView = d->progressJobView[job]; jobView->setPercent(percent); } void KUiServerJobTracker::speed(KJob *job, unsigned long value) { if (!d->progressJobView.contains(job)) { return; } org::kde::JobViewV2 *jobView = d->progressJobView[job]; jobView->setSpeed(value); } KSharedUiServerProxy::KSharedUiServerProxy() : m_uiserver(new org::kde::JobViewServer(QStringLiteral("org.kde.JobViewServer"), QStringLiteral("/JobViewServer"), QDBusConnection::sessionBus())) , m_watcher(new QDBusServiceWatcher(QStringLiteral("org.kde.JobViewServer"), QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForOwnerChange)) { QDBusConnectionInterface *bus = QDBusConnection::sessionBus().interface(); if (!bus->isServiceRegistered(QStringLiteral("org.kde.JobViewServer"))) { QDBusReply<void> reply = bus->startService(QStringLiteral("org.kde.kuiserver")); if (!reply.isValid()) { qCritical() << "Couldn't start kuiserver from org.kde.kuiserver.service:" << reply.error(); return; } if (!bus->isServiceRegistered(QStringLiteral("org.kde.JobViewServer"))) { qCDebug(KJOBWIDGETS) << "The dbus name org.kde.JobViewServer is STILL NOT REGISTERED, even after starting kuiserver. Should not happen."; return; } qCDebug(KJOBWIDGETS) << "kuiserver registered"; } else { qCDebug(KJOBWIDGETS) << "kuiserver found"; } connect(m_watcher.get(), &QDBusServiceWatcher::serviceOwnerChanged, this, &KSharedUiServerProxy::uiserverOwnerChanged); // cleanup early enough to avoid issues with dbus at application exit // see e.g. https://phabricator.kde.org/D2545 qAddPostRoutine([]() { serverProxy->m_uiserver.reset(); serverProxy->m_watcher.reset(); }); } KSharedUiServerProxy::~KSharedUiServerProxy() { } org::kde::JobViewServer *KSharedUiServerProxy::uiserver() { return m_uiserver.get(); } void KSharedUiServerProxy::uiserverOwnerChanged(const QString &serviceName, const QString &oldOwner, const QString &newOwner) { Q_UNUSED(serviceName); Q_UNUSED(oldOwner); if (!newOwner.isEmpty()) { // registered emit serverRegistered(); } else if (newOwner.isEmpty()) { // unregistered emit serverUnregistered(); } } #include "moc_kuiserverjobtracker.cpp" #include "moc_kuiserverjobtracker_p.cpp" 0707010000001B000081A40000000200000002000000015E1AFA8A00000A5C000000000000000000000000000000000000004900000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/src/kuiserverjobtracker.h/* This file is part of the KDE project Copyright (C) 2007 Kevin Ottens <ervin@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KUISERVERJOBTRACKER_H #define KUISERVERJOBTRACKER_H #include <kjobwidgets_export.h> #include <kjobtrackerinterface.h> class KJob; /** * @class KUiServerJobTracker kuiserverjobtracker.h KUiServerJobTracker * * The interface to implement to track the progresses of a job. */ class KJOBWIDGETS_EXPORT KUiServerJobTracker : public KJobTrackerInterface { Q_OBJECT public: /** * Creates a new KJobTrackerInterface * * @param parent the parent object */ explicit KUiServerJobTracker(QObject *parent = nullptr); /** * Destroys a KJobTrackerInterface */ ~KUiServerJobTracker() override; /** * Register a new job in this tracker. * * @param job the job to register */ void registerJob(KJob *job) override; /** * Unregister a job from this tracker. * * @param job the job to unregister */ void unregisterJob(KJob *job) override; protected Q_SLOTS: /** * The following slots are inherited from KJobTrackerInterface. */ void finished(KJob *job) override; void suspended(KJob *job) override; void resumed(KJob *job) override; virtual void description(KJob *job, const QString &title, const QPair<QString, QString> &field1, const QPair<QString, QString> &field2) override; void infoMessage(KJob *job, const QString &plain, const QString &rich) override; void totalAmount(KJob *job, KJob::Unit unit, qulonglong amount) override; void processedAmount(KJob *job, KJob::Unit unit, qulonglong amount) override; void percent(KJob *job, unsigned long percent) override; void speed(KJob *job, unsigned long value) override; private: class Private; Private *const d; Q_PRIVATE_SLOT(d, void _k_killJob()) }; #endif 0707010000001C000081A40000000200000002000000015E1AFA8A000006DE000000000000000000000000000000000000004B00000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/src/kuiserverjobtracker_p.h/* This file is part of the KDE libraries Copyright (C) 2006-2008 Rafael Fernández López <ereslibre@kde.org> Kevin Ottens <ervin@kde.org> Copyright (C) 2000 Matej Koss <koss@miesto.sk> David Faure <faure@kde.org> Stephan Kulow <coolo@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KUISERVERJOBTRACKER_P_H #define KUISERVERJOBTRACKER_P_H #include <memory> #include <QDBusServiceWatcher> #include "jobviewserverinterface.h" class Q_DECL_HIDDEN KSharedUiServerProxy : public QObject { Q_OBJECT public: KSharedUiServerProxy(); ~KSharedUiServerProxy(); org::kde::JobViewServer *uiserver(); Q_SIGNALS: void serverRegistered(); void serverUnregistered(); private: void uiserverOwnerChanged(const QString &serviceName, const QString &oldOwner, const QString &newOwner); std::unique_ptr<org::kde::JobViewServer> m_uiserver; std::unique_ptr<QDBusServiceWatcher> m_watcher; }; #endif 0707010000001D000081A40000000200000002000000015E1AFA8A00005911000000000000000000000000000000000000004900000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/src/kwidgetjobtracker.cpp/* This file is part of the KDE project Copyright (C) 2000 Matej Koss <koss@miesto.sk> Copyright (C) 2007 Kevin Ottens <ervin@kde.org> Copyright (C) 2007 Rafael Fernández López <ereslibre@kde.org> Copyright (C) 2009 Shaun Reich <shaun.reich@kdemail.net> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "kwidgetjobtracker.h" #include "kwidgetjobtracker_p.h" #include "kjobtrackerformatters_p.h" #include <QCoreApplication> #include <QDir> #include <QProcess> #include <QTimer> #include <QLabel> #include <QProgressBar> #include <QPushButton> #include <QVBoxLayout> #include <QGridLayout> #include <QEvent> #include <QStyle> #include <ksqueezedtextlabel.h> #include <kseparator.h> void KWidgetJobTracker::Private::_k_showProgressWidget() { if (progressWidgetsToBeShown.isEmpty()) { return; } KJob *job = progressWidgetsToBeShown.dequeue(); // If the job has been unregistered before reaching this point, widget will // return 0. QWidget *widget = q->widget(job); if (widget) { // Don't steal the focus from the current widget (e. g. Kate) widget->setAttribute(Qt::WA_ShowWithoutActivating); widget->show(); } } KWidgetJobTracker::KWidgetJobTracker(QWidget *parent) : KAbstractWidgetJobTracker(parent), d(new Private(parent, this)) { } KWidgetJobTracker::~KWidgetJobTracker() { delete d; } QWidget *KWidgetJobTracker::widget(KJob *job) { return d->progressWidget.value(job, nullptr); } void KWidgetJobTracker::registerJob(KJob *job) { Private::ProgressWidget *vi = new Private::ProgressWidget(job, this, d->parent); vi->jobRegistered = true; vi->setAttribute(Qt::WA_DeleteOnClose); d->progressWidget.insert(job, vi); d->progressWidgetsToBeShown.enqueue(job); KAbstractWidgetJobTracker::registerJob(job); QTimer::singleShot(500, this, SLOT(_k_showProgressWidget())); } void KWidgetJobTracker::unregisterJob(KJob *job) { KAbstractWidgetJobTracker::unregisterJob(job); d->progressWidgetsToBeShown.removeAll(job); KWidgetJobTracker::Private::ProgressWidget *pWidget = d->progressWidget.value(job, nullptr); if (!pWidget) { return; } pWidget->jobRegistered = false; pWidget->deref(); } bool KWidgetJobTracker::keepOpen(KJob *job) const { KWidgetJobTracker::Private::ProgressWidget *pWidget = d->progressWidget.value(job, nullptr); if (!pWidget) { return false; } return pWidget->keepOpenCheck->isChecked(); } void KWidgetJobTracker::infoMessage(KJob *job, const QString &plain, const QString &rich) { KWidgetJobTracker::Private::ProgressWidget *pWidget = d->progressWidget.value(job, nullptr); if (!pWidget) { return; } pWidget->infoMessage(plain, rich); } void KWidgetJobTracker::description(KJob *job, const QString &title, const QPair<QString, QString> &field1, const QPair<QString, QString> &field2) { KWidgetJobTracker::Private::ProgressWidget *pWidget = d->progressWidget.value(job, nullptr); if (!pWidget) { return; } pWidget->description(title, field1, field2); } void KWidgetJobTracker::totalAmount(KJob *job, KJob::Unit unit, qulonglong amount) { KWidgetJobTracker::Private::ProgressWidget *pWidget = d->progressWidget.value(job, nullptr); if (!pWidget) { return; } pWidget->totalAmount(unit, amount); } void KWidgetJobTracker::processedAmount(KJob *job, KJob::Unit unit, qulonglong amount) { KWidgetJobTracker::Private::ProgressWidget *pWidget = d->progressWidget.value(job, nullptr); if (!pWidget) { return; } pWidget->processedAmount(unit, amount); } void KWidgetJobTracker::percent(KJob *job, unsigned long percent) { KWidgetJobTracker::Private::ProgressWidget *pWidget = d->progressWidget.value(job, nullptr); if (!pWidget) { return; } pWidget->percent(percent); } void KWidgetJobTracker::speed(KJob *job, unsigned long value) { KWidgetJobTracker::Private::ProgressWidget *pWidget = d->progressWidget.value(job, nullptr); if (!pWidget) { return; } pWidget->speed(value); } void KWidgetJobTracker::slotClean(KJob *job) { KWidgetJobTracker::Private::ProgressWidget *pWidget = d->progressWidget.value(job, nullptr); if (!pWidget) { return; } pWidget->slotClean(); } void KWidgetJobTracker::suspended(KJob *job) { KWidgetJobTracker::Private::ProgressWidget *pWidget = d->progressWidget.value(job, nullptr); if (!pWidget) { return; } pWidget->suspended(); } void KWidgetJobTracker::resumed(KJob *job) { KWidgetJobTracker::Private::ProgressWidget *pWidget = d->progressWidget.value(job, nullptr); if (!pWidget) { return; } pWidget->resumed(); } void KWidgetJobTracker::Private::ProgressWidget::ref() { ++refCount; } void KWidgetJobTracker::Private::ProgressWidget::deref() { if (refCount) { --refCount; } if (!refCount) { if (!keepOpenCheck->isChecked()) { closeNow(); } else { slotClean(); } } } void KWidgetJobTracker::Private::ProgressWidget::closeNow() { close(); // It might happen the next scenario: // - Start a job which opens a progress widget. Keep it open. Address job is 0xdeadbeef // - Start a new job, which is given address 0xdeadbeef. A new window is opened. // This one will take much longer to complete. The key 0xdeadbeef on the widget map now // stores the new widget address. // - Close the first progress widget that was opened (and has already finished) while the // last one is still running. We remove its reference on the map. Wrong. // For that reason we have to check if the map stores the widget as the current one. // ereslibre if (tracker->d->progressWidget[job] == this) { tracker->d->progressWidget.remove(job); tracker->d->progressWidgetsToBeShown.removeAll(job); } } bool KWidgetJobTracker::Private::ProgressWidget::eventFilter(QObject *watched, QEvent *event) { // Handle context menu events for the source/dest labels here, so that we are ref()ed while the // menu is exec()ed, to avoid a crash if the job finishes meanwhile. #159621. if ((watched == sourceEdit || watched == destEdit) && event->type() == QEvent::ContextMenu) { ref(); watched->event(event); deref(); return true; } return QWidget::eventFilter(watched, event); } void KWidgetJobTracker::Private::ProgressWidget::infoMessage(const QString &plain, const QString &/*rich*/) { speedLabel->setText(plain); speedLabel->setAlignment(speedLabel->alignment() & ~Qt::TextWordWrap); } void KWidgetJobTracker::Private::ProgressWidget::description(const QString &title, const QPair<QString, QString> &field1, const QPair<QString, QString> &field2) { setWindowTitle(title); caption = title; sourceInvite->setText( QCoreApplication::translate("KWidgetJobTracker", "%1:", "%1 is the label, we add a ':' to it" ).arg(field1.first)); sourceEdit->setText(field1.second); if (field2.first.isEmpty()) { setDestVisible(false); } else { setDestVisible(true); checkDestination(QUrl::fromUserInput(field2.second)); // path or URL destInvite->setText( QCoreApplication::translate("KWidgetJobTracker", "%1:", "%1 is the label, we add a ':' to it" ).arg(field2.first)); destEdit->setText(field2.second); } } void KWidgetJobTracker::Private::ProgressWidget::totalAmount(KJob::Unit unit, qulonglong amount) { switch (unit) { case KJob::Bytes: totalSizeKnown = true; // size is measured in bytes if (totalSize == amount) { return; } totalSize = amount; if (!startTime.isValid()) { startTime.start(); } break; case KJob::Files: if (totalFiles == amount) { return; } totalFiles = amount; showTotals(); break; case KJob::Directories: if (totalDirs == amount) { return; } totalDirs = amount; showTotals(); break; } } void KWidgetJobTracker::Private::ProgressWidget::processedAmount(KJob::Unit unit, qulonglong amount) { QString tmp; switch (unit) { case KJob::Bytes: if (processedSize == amount) { return; } processedSize = amount; if (totalSizeKnown) { //~ singular %1 of %2 complete //~ plural %1 of %2 complete tmp = QCoreApplication::translate("KWidgetJobTracker", "%1 of %2 complete", "", amount) .arg(KJobTrackerFormatters::byteSize(amount), KJobTrackerFormatters::byteSize(totalSize)); } else { tmp = KJobTrackerFormatters::byteSize(amount); } sizeLabel->setText(tmp); if (!totalSizeKnown) { // update jumping progressbar progressBar->setValue(amount); } break; case KJob::Directories: if (processedDirs == amount) { return; } processedDirs = amount; //~ singular %1 / %n folder //~ plural %1 / %n folders tmp = QCoreApplication::translate("KWidgetJobTracker", "%1 / %n folder(s)", "", totalDirs).arg(processedDirs); tmp += QLatin1String(" "); //~ singular %1 / %n file //~ plural %1 / %n files tmp += QCoreApplication::translate("KWidgetJobTracker", "%1 / %n file(s)", "", totalFiles).arg(processedFiles); progressLabel->setText(tmp); break; case KJob::Files: if (processedFiles == amount) { return; } processedFiles = amount; if (totalDirs > 1) { //~ singular %1 / %n folder //~ plural %1 / %n folders tmp = QCoreApplication::translate("KWidgetJobTracker", "%1 / %n folder(s)", "", totalDirs).arg(processedDirs); tmp += QLatin1String(" "); } //~ singular %1 / %n file //~ plural %1 / %n files tmp += QCoreApplication::translate("KWidgetJobTracker", "%1 / %n file(s)", "", totalFiles).arg(processedFiles); progressLabel->setText(tmp); } } void KWidgetJobTracker::Private::ProgressWidget::percent(unsigned long percent) { QString title = caption + QLatin1String(" ("); if (totalSizeKnown) { title += QCoreApplication::translate("KWidgetJobTracker", "%1% of %2").arg(percent).arg( KJobTrackerFormatters::byteSize(totalSize)); } else if (totalFiles) { //~ singular %1% of %n file //~ plural %1% of %n files title += QCoreApplication::translate("KWidgetJobTracker", "%1% of %n file(s)", "", totalFiles).arg(percent); } else { title += QCoreApplication::translate("KWidgetJobTracker", "%1%").arg(percent); } title += QLatin1Char(')'); progressBar->setMaximum(100); progressBar->setValue(percent); setWindowTitle(title); } void KWidgetJobTracker::Private::ProgressWidget::speed(unsigned long value) { if (value == 0) { speedLabel->setText(QCoreApplication::translate("KWidgetJobTracker", "Stalled")); } else { const QString speedStr = KJobTrackerFormatters::byteSize(value); if (totalSizeKnown) { const int remaining = 1000 * (totalSize - processedSize) / value; //~ singular %1/s (%2 remaining) //~ plural %1/s (%2 remaining) speedLabel->setText(QCoreApplication::translate("KWidgetJobTracker", "%1/s (%2 remaining)", "", remaining).arg(speedStr, KJobTrackerFormatters::duration(remaining))); } else { // total size is not known (#24228) speedLabel->setText(QCoreApplication::translate("KWidgetJobTracker", "%1/s", "speed in bytes per second").arg(speedStr)); } } } void KWidgetJobTracker::Private::ProgressWidget::slotClean() { percent(100); cancelClose->setText(QCoreApplication::translate("KWidgetJobTracker", "&Close")); cancelClose->setIcon(QIcon::fromTheme(QStringLiteral("window-close"))); cancelClose->setToolTip(QCoreApplication::translate("KWidgetJobTracker", "Close the current window or document")); openFile->setEnabled(true); if (!totalSizeKnown || totalSize < processedSize) { totalSize = processedSize; } processedAmount(KJob::Bytes, totalSize); keepOpenCheck->setEnabled(false); pauseButton->setEnabled(false); if (startTime.isValid()) { int s = startTime.elapsed(); if (!s) { s = 1; } speedLabel->setText(QCoreApplication::translate("KWidgetJobTracker", "%1/s (done)").arg( KJobTrackerFormatters::byteSize(1000 * totalSize / s))); } } void KWidgetJobTracker::Private::ProgressWidget::suspended() { pauseButton->setText(QCoreApplication::translate("KWidgetJobTracker", "&Resume")); suspendedProperty = true; } void KWidgetJobTracker::Private::ProgressWidget::resumed() { pauseButton->setText(QCoreApplication::translate("KWidgetJobTracker", "&Pause")); suspendedProperty = false; } void KWidgetJobTracker::Private::ProgressWidget::closeEvent(QCloseEvent *event) { if (jobRegistered && tracker->stopOnClose(job)) { tracker->slotStop(job); } QWidget::closeEvent(event); } void KWidgetJobTracker::Private::ProgressWidget::init() { setWindowIcon(QIcon::fromTheme(QStringLiteral("document-save"), windowIcon())); QVBoxLayout *topLayout = new QVBoxLayout(this); QGridLayout *grid = new QGridLayout(); topLayout->addLayout(grid); const int spacingHint = style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing); grid->addItem(new QSpacerItem(spacingHint, 0), 0, 1); // filenames or action name sourceInvite = new QLabel(QCoreApplication::translate("KWidgetJobTracker", "Source:", "The source url of a job"), this); grid->addWidget(sourceInvite, 0, 0); sourceEdit = new KSqueezedTextLabel(this); sourceEdit->setTextInteractionFlags(Qt::TextSelectableByMouse); sourceEdit->installEventFilter(this); grid->addWidget(sourceEdit, 0, 2); destInvite = new QLabel(QCoreApplication::translate("KWidgetJobTracker", "Destination:", "The destination url of a job"), this); grid->addWidget(destInvite, 1, 0); destEdit = new KSqueezedTextLabel(this); destEdit->setTextInteractionFlags(Qt::TextSelectableByMouse); destEdit->installEventFilter(this); grid->addWidget(destEdit, 1, 2); QHBoxLayout *progressHBox = new QHBoxLayout(); topLayout->addLayout(progressHBox); progressBar = new QProgressBar(this); progressBar->setMaximum(0); // want a jumping progress bar if percent is not emitted progressHBox->addWidget(progressBar); suspendedProperty = false; // processed info QHBoxLayout *hBox = new QHBoxLayout(); topLayout->addLayout(hBox); arrowButton = new QPushButton(this); arrowButton->setMaximumSize(QSize(32, 25)); arrowButton->setIcon(QIcon::fromTheme(QStringLiteral("arrow-down"))); arrowButton->setToolTip(QCoreApplication::translate("KWidgetJobTracker", "Click this to expand the dialog, to show details")); arrowState = Qt::DownArrow; connect(arrowButton, &QPushButton::clicked, this, &KWidgetJobTracker::Private::ProgressWidget::arrowClicked); hBox->addWidget(arrowButton); hBox->addStretch(1); KSeparator *separator1 = new KSeparator(Qt::Horizontal, this); topLayout->addWidget(separator1); sizeLabel = new QLabel(this); hBox->addWidget(sizeLabel, 0, Qt::AlignLeft); resumeLabel = new QLabel(this); hBox->addWidget(resumeLabel); pauseButton = new QPushButton(QCoreApplication::translate("KWidgetJobTracker", "&Pause"), this); pauseButton->setVisible(job && (job->capabilities() & KJob::Suspendable)); connect(pauseButton, &QPushButton::clicked, this, &KWidgetJobTracker::Private::ProgressWidget::pauseResumeClicked); hBox->addWidget(pauseButton); hBox = new QHBoxLayout(); topLayout->addLayout(hBox); speedLabel = new QLabel(this); hBox->addWidget(speedLabel, 1); speedLabel->hide(); hBox = new QHBoxLayout(); topLayout->addLayout(hBox); progressLabel = new QLabel(this); progressLabel->setAlignment(Qt::AlignLeft); hBox->addWidget(progressLabel); progressLabel->hide(); keepOpenCheck = new QCheckBox(QCoreApplication::translate("KWidgetJobTracker", "&Keep this window open after transfer is complete"), this); connect(keepOpenCheck, &QCheckBox::toggled, this, &KWidgetJobTracker::Private::ProgressWidget::keepOpenToggled); topLayout->addWidget(keepOpenCheck); keepOpenCheck->hide(); hBox = new QHBoxLayout(); topLayout->addLayout(hBox); openFile = new QPushButton(QCoreApplication::translate("KWidgetJobTracker", "Open &File"), this); connect(openFile, &QPushButton::clicked, this, &KWidgetJobTracker::Private::ProgressWidget::openFileClicked); hBox->addWidget(openFile); openFile->setEnabled(false); openFile->hide(); openLocation = new QPushButton(QCoreApplication::translate("KWidgetJobTracker", "Open &Destination"), this); connect(openLocation, &QPushButton::clicked, this, &KWidgetJobTracker::Private::ProgressWidget::openLocationClicked); hBox->addWidget(openLocation); openLocation->hide(); hBox->addStretch(1); cancelClose = new QPushButton(this); cancelClose->setText(QCoreApplication::translate("KWidgetJobTracker", "&Cancel")); cancelClose->setIcon(QIcon::fromTheme(QStringLiteral("dialog-cancel"))); connect(cancelClose, &QPushButton::clicked, this, &KWidgetJobTracker::Private::ProgressWidget::cancelClicked); hBox->addWidget(cancelClose); resize(sizeHint()); setMaximumHeight(sizeHint().height()); setWindowTitle(QCoreApplication::translate("KWidgetJobTracker", "Progress Dialog")); // show something better than kuiserver } void KWidgetJobTracker::Private::ProgressWidget::showTotals() { // Show the totals in the progress label, if we still haven't // processed anything. This is useful when the stat'ing phase // of CopyJob takes a long time (e.g. over networks). if (processedFiles == 0 && processedDirs == 0) { QString tmps; if (totalDirs > 1) // that we have a singular to translate looks weired but is only logical { //~ singular %n folder //~ plural %n folders tmps = QCoreApplication::translate("KWidgetJobTracker", "%n folder(s)", "", totalDirs) + QLatin1String(" "); } //~ singular %n file //~ plural %n files tmps += QCoreApplication::translate("KWidgetJobTracker", "%n file(s)", "", totalFiles); progressLabel->setText(tmps); } } void KWidgetJobTracker::Private::ProgressWidget::setDestVisible(bool visible) { // We can't hide the destInvite/destEdit labels, // because it screws up the QGridLayout. if (visible) { destInvite->show(); destEdit->show(); } else { destInvite->hide(); destEdit->hide(); destInvite->setText(QString()); destEdit->setText(QString()); } setMaximumHeight(sizeHint().height()); } void KWidgetJobTracker::Private::ProgressWidget::checkDestination(const QUrl &dest) { bool ok = true; if (dest.isLocalFile()) { const QString path = dest.toLocalFile(); if (path.contains(QDir::tempPath())) { ok = false; // it's in the tmp directory } } if (ok) { openFile->show(); openLocation->show(); keepOpenCheck->show(); setMaximumHeight(sizeHint().height()); location = dest; } } void KWidgetJobTracker::Private::ProgressWidget::keepOpenToggled(bool keepOpen) { if (keepOpen) { Q_ASSERT(!tracker->d->eventLoopLocker); tracker->d->eventLoopLocker = new QEventLoopLocker; } else { delete tracker->d->eventLoopLocker; tracker->d->eventLoopLocker = nullptr; } } void KWidgetJobTracker::Private::ProgressWidget::openFileClicked() { QProcess::startDetached(QStringLiteral("kde-open"), QStringList() << location.toDisplayString()); } void KWidgetJobTracker::Private::ProgressWidget::openLocationClicked() { QProcess::startDetached(QStringLiteral("kde-open"), QStringList() << location.adjusted(QUrl::RemoveFilename).toString()); } void KWidgetJobTracker::Private::ProgressWidget::pauseResumeClicked() { if (jobRegistered && !suspendedProperty) { tracker->slotSuspend(job); } else if (jobRegistered) { tracker->slotResume(job); } } void KWidgetJobTracker::Private::ProgressWidget::cancelClicked() { if (jobRegistered) { tracker->slotStop(job); } closeNow(); } void KWidgetJobTracker::Private::ProgressWidget::arrowClicked() { if (arrowState == Qt::DownArrow) { //The arrow is in the down position, dialog is collapsed, expand it and change icon. progressLabel->show(); speedLabel->show(); arrowButton->setIcon(QIcon::fromTheme(QStringLiteral("arrow-up"))); arrowButton->setToolTip(QCoreApplication::translate("KWidgetJobTracker", "Click this to collapse the dialog, to hide details")); arrowState = Qt::UpArrow; } else { //Collapse the dialog progressLabel->hide(); speedLabel->hide(); arrowButton->setIcon(QIcon::fromTheme(QStringLiteral("arrow-down"))); arrowButton->setToolTip(QCoreApplication::translate("KWidgetJobTracker", "Click this to expand the dialog, to show details")); arrowState = Qt::DownArrow; } setMaximumHeight(sizeHint().height()); } #include "moc_kwidgetjobtracker.cpp" #include "moc_kwidgetjobtracker_p.cpp" 0707010000001E000081A40000000200000002000000015E1AFA8A00000CA7000000000000000000000000000000000000004700000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/src/kwidgetjobtracker.h/* This file is part of the KDE project Copyright (C) 2000 Matej Koss <koss@miesto.sk> Copyright (C) 2007 Kevin Ottens <ervin@kde.org> Copyright (C) 2009 Shaun Reich <shaun.reich@kdemail.net> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KWIDGETJOBTRACKER_H #define KWIDGETJOBTRACKER_H #include <kjobwidgets_export.h> #include <kabstractwidgetjobtracker.h> /** * @class KWidgetJobTracker kwidgetjobtracker.h KWidgetJobTracker * * This class implements a job tracker with a widget suited for use as a * progress dialog. */ class KJOBWIDGETS_EXPORT KWidgetJobTracker : public KAbstractWidgetJobTracker { Q_OBJECT public: /** * Creates a new KWidgetJobTracker * * @param parent the parent of this object and of the widget displaying the job progresses */ explicit KWidgetJobTracker(QWidget *parent = nullptr); /** * Destroys a KWidgetJobTracker */ ~KWidgetJobTracker() override; /** * The widget associated to this tracker. * * @param job the job that is assigned the widget we want to get * @return the widget displaying the job progresses */ QWidget *widget(KJob *job) override; // KDE5: move this two virtual methods to be placed correctly (ereslibre) public Q_SLOTS: /** * Register a new job in this tracker. * * @param job the job to register */ void registerJob(KJob *job) override; /** * Unregister a job from this tracker. * * @param job the job to unregister */ void unregisterJob(KJob *job) override; public: bool keepOpen(KJob *job) const; protected Q_SLOTS: /** * The following slots are inherited from KJobTrackerInterface. */ void infoMessage(KJob *job, const QString &plain, const QString &rich) override; virtual void description(KJob *job, const QString &title, const QPair<QString, QString> &field1, const QPair<QString, QString> &field2) override; void totalAmount(KJob *job, KJob::Unit unit, qulonglong amount) override; void processedAmount(KJob *job, KJob::Unit unit, qulonglong amount) override; void percent(KJob *job, unsigned long percent) override; void speed(KJob *job, unsigned long value) override; void slotClean(KJob *job) override; void suspended(KJob *job) override; void resumed(KJob *job) override; //TODO: Misses canResume() private: class Private; Private *const d; Q_PRIVATE_SLOT(d, void _k_showProgressWidget()) }; #endif 0707010000001F000081A40000000200000002000000015E1AFA8A000017EE000000000000000000000000000000000000004900000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/src/kwidgetjobtracker_p.h/* This file is part of the KDE project Copyright (C) 2007 Rafael Fernández López <ereslibre@kde.org> Copyright (C) 2007 Kevin Ottens <ervin@kde.org> Copyright (C) 2009 Shaun Reich <shaun.reich@kdemail.net> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KWIDGETJOBTRACKER_P_H #define KWIDGETJOBTRACKER_P_H #include "kabstractwidgetjobtracker_p.h" #include "kwidgetjobtracker.h" #include <QElapsedTimer> #include <QEventLoopLocker> #include <QWidget> #include <QMap> #include <QQueue> #include <QCheckBox> #include <QUrl> #include <QDebug> class QPushButton; class KSqueezedTextLabel; class QLabel; class QProgressBar; class Q_DECL_HIDDEN KWidgetJobTracker::Private : public KAbstractWidgetJobTracker::Private { public: Private(QWidget *parent, KWidgetJobTracker *tracker) : KAbstractWidgetJobTracker::Private(tracker) , parent(parent) , eventLoopLocker(nullptr) { } virtual ~Private() { delete eventLoopLocker; } void setStopOnClose(KJob *job, bool stopOnClose) override; bool stopOnClose(KJob *job) const override; void setAutoDelete(KJob *job, bool autoDelete) override; bool autoDelete(KJob *job) const override; void _k_showProgressWidget(); class ProgressWidget; QWidget *parent; QEventLoopLocker *eventLoopLocker; QMap<KJob *, ProgressWidget *> progressWidget; QQueue<KJob *> progressWidgetsToBeShown; }; class KWidgetJobTracker::Private::ProgressWidget : public QWidget { Q_OBJECT public: ProgressWidget(KJob *job, KWidgetJobTracker *object, QWidget *parent) : QWidget(parent), tracker(object), job(job), totalSize(0), totalFiles(0), totalDirs(0), processedSize(0), processedDirs(0), processedFiles(0), totalSizeKnown(false), stopOnClose(true), jobRegistered(false), cancelClose(nullptr), openFile(nullptr), openLocation(nullptr), keepOpenCheck(nullptr), pauseButton(nullptr), sourceEdit(nullptr), destEdit(nullptr), progressLabel(nullptr), destInvite(nullptr), speedLabel(nullptr), sizeLabel(nullptr), resumeLabel(nullptr), progressBar(nullptr), suspendedProperty(false), refCount(1) { if (!parent) { setWindowFlags(windowFlags() | Qt::Dialog); } init(); } ~ProgressWidget() { delete tracker->d->eventLoopLocker; tracker->d->eventLoopLocker = nullptr; } KWidgetJobTracker *const tracker; KJob *const job; qulonglong totalSize; qulonglong totalFiles; qulonglong totalDirs; qulonglong processedSize; qulonglong processedDirs; qulonglong processedFiles; bool totalSizeKnown; bool stopOnClose; bool jobRegistered; QString caption; QPushButton *cancelClose; QPushButton *openFile; QPushButton *openLocation; QCheckBox *keepOpenCheck; QUrl location; QElapsedTimer startTime; QPushButton *pauseButton; KSqueezedTextLabel *sourceEdit; KSqueezedTextLabel *destEdit; QLabel *progressLabel; QLabel *sourceInvite; QLabel *destInvite; QLabel *speedLabel; QLabel *sizeLabel; QLabel *resumeLabel; QProgressBar *progressBar; QPushButton *arrowButton; Qt::ArrowType arrowState; bool suspendedProperty; int refCount; // will not close the dialog if a modal menu is shown void init(); void showTotals(); void setDestVisible(bool visible); void checkDestination(const QUrl &dest); void ref(); void deref(); void closeNow(); bool eventFilter(QObject *watched, QEvent *event) override; public Q_SLOTS: virtual void infoMessage(const QString &plain, const QString &rich); virtual void description(const QString &title, const QPair<QString, QString> &field1, const QPair<QString, QString> &field2); virtual void totalAmount(KJob::Unit unit, qulonglong amount); virtual void processedAmount(KJob::Unit unit, qulonglong amount); virtual void percent(unsigned long percent); virtual void speed(unsigned long value); virtual void slotClean(); virtual void suspended(); virtual void resumed(); //TODO: Misses canResume() protected: void closeEvent(QCloseEvent *event) override; private Q_SLOTS: void keepOpenToggled(bool); void openFileClicked(); void openLocationClicked(); void pauseResumeClicked(); void cancelClicked(); void arrowClicked(); }; void KWidgetJobTracker::Private::setStopOnClose(KJob *job, bool stopOnClose) { if (!progressWidget.contains(job)) { return; } progressWidget[job]->stopOnClose = stopOnClose; } bool KWidgetJobTracker::Private::stopOnClose(KJob *job) const { if (!progressWidget.contains(job)) { qWarning() << "no widget found for job" << job; return true; } return progressWidget[job]->stopOnClose; } void KWidgetJobTracker::Private::setAutoDelete(KJob *job, bool autoDelete) { if (!progressWidget.contains(job)) { return; } progressWidget[job]->setAttribute(Qt::WA_DeleteOnClose, autoDelete); } bool KWidgetJobTracker::Private::autoDelete(KJob *job) const { if (!progressWidget.contains(job)) { qWarning() << "no widget found for job" << job; return true; } return progressWidget[job]->testAttribute(Qt::WA_DeleteOnClose); } #endif // KWIDGETJOBTRACKER_P_H 07070100000020000081A40000000200000002000000015E1AFA8A0000098A000000000000000000000000000000000000004700000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/src/org.kde.JobView.xml<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> <node> <interface name="org.kde.JobViewV2"> <method name="terminate"> <arg name="errorMessage" type="s" direction="in"/> <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/> </method> <method name="setSuspended"> <arg name="suspended" type="b" direction="in"/> <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/> </method> <method name="setTotalAmount"> <arg name="amount" type="t" direction="in"/> <arg name="unit" type="s" direction="in"/> <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/> </method> <method name="setProcessedAmount"> <arg name="amount" type="t" direction="in"/> <arg name="unit" type="s" direction="in"/> <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/> </method> <method name="setPercent"> <arg name="percent" type="u" direction="in"/> <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/> </method> <method name="setSpeed"> <arg name="bytesPerSecond" type="t" direction="in"/> <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/> </method> <method name="setInfoMessage"> <arg name="message" type="s" direction="in"/> <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/> </method> <method name="setDescriptionField"> <arg name="number" type="u" direction="in"/> <arg name="name" type="s" direction="in"/> <arg name="value" type="s" direction="in"/> <arg name="res" type="b" direction="out"/> </method> <method name="clearDescriptionField"> <arg name="number" type="u" direction="in"/> <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/> </method> <method name="setDestUrl"> <arg name="destUrl" type="v" direction="in"/> <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/> </method> <method name="setError"> <arg name="errorCode" type="u" direction="in"/> <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/> </method> <signal name="suspendRequested"/> <signal name="resumeRequested"/> <signal name="cancelRequested"/> </interface> </node> 07070100000021000081A40000000200000002000000015E1AFA8A000002B8000000000000000000000000000000000000004D00000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/src/org.kde.JobViewServer.xml<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> <node> <interface name="org.kde.JobViewServer"> <method name="requestView"> <arg name="appName" type="s" direction="in"/> <arg name="appIconName" type="s" direction="in"/> <!-- 'capabilities' is used as a bit field: 0x0001 means that the user should be able to cancel the job 0x0002 means that the user should be able to suspend/resume the job --> <arg name="capabilities" type="i" direction="in"/> <arg name="trackerPath" type="o" direction="out"/> </method> </interface> </node> 07070100000022000081A40000000200000002000000015E1AFA8A000008DD000000000000000000000000000000000000004900000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/src/org.kde.JobViewV2.xml<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> <node> <interface name="org.kde.JobViewV2"> <method name="terminate"> <arg name="errorMessage" type="s" direction="in"/> <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/> </method> <method name="setSuspended"> <arg name="suspended" type="b" direction="in"/> <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/> </method> <method name="setTotalAmount"> <arg name="amount" type="t" direction="in"/> <arg name="unit" type="s" direction="in"/> <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/> </method> <method name="setProcessedAmount"> <arg name="amount" type="t" direction="in"/> <arg name="unit" type="s" direction="in"/> <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/> </method> <method name="setPercent"> <arg name="percent" type="u" direction="in"/> <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/> </method> <method name="setSpeed"> <arg name="bytesPerSecond" type="t" direction="in"/> <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/> </method> <method name="setInfoMessage"> <arg name="message" type="s" direction="in"/> <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/> </method> <method name="setDescriptionField"> <arg name="number" type="u" direction="in"/> <arg name="name" type="s" direction="in"/> <arg name="value" type="s" direction="in"/> <arg name="res" type="b" direction="out"/> </method> <method name="clearDescriptionField"> <arg name="number" type="u" direction="in"/> <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/> </method> <method name="setDestUrl"> <arg name="destUrl" type="v" direction="in"/> <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/> </method> <signal name="suspendRequested"/> <signal name="resumeRequested"/> <signal name="cancelRequested"/> </interface> </node> 07070100000023000041ED0000000200000002000000025E1AFA8A00000000000000000000000000000000000000000000003500000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/tests07070100000024000081A40000000200000002000000015E1AFA8A00000188000000000000000000000000000000000000004400000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/tests/CMakeLists.txt include(ECMMarkAsTest) find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Test) macro(kjobwidgets_executable_tests) foreach(_testname ${ARGN}) add_executable(${_testname} ${_testname}.cpp) target_link_libraries(${_testname} Qt5::Test KF5::JobWidgets) ecm_mark_as_test(${_testname}) endforeach(_testname) endmacro() kjobwidgets_executable_tests( kjobtrackerstest ) 07070100000025000081A40000000200000002000000015E1AFA8A00001643000000000000000000000000000000000000004A00000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/tests/kjobtrackerstest.cpp/** * This file is part of the KDE libraries * Copyright (C) 2007 Kevin Ottens <ervin@kde.org> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License version 2 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "kjobtrackerstest.h" #include "kdialogjobuidelegate.h" #include <QApplication> #include <QMainWindow> #include <QStatusBar> #include <QDebug> #include <kwidgetjobtracker.h> #include <kstatusbarjobtracker.h> #include <kuiserverjobtracker.h> #include <kjobwidgets.h> KTestJob::KTestJob(int numberOfDirs) : KJob(), m_numberOfDirs(numberOfDirs), m_currentSpeed(1000), m_state(Stopped) { setCapabilities(KJob::Killable | KJob::Suspendable); } KTestJob::~KTestJob() { } void KTestJob::start() { connect(&m_timer, &QTimer::timeout, this, &KTestJob::nextStep); m_state = StatingDirs; m_timer.start(50); emit description(this, QStringLiteral("Copying"), qMakePair(QStringLiteral("Source"), QStringLiteral("file:/src")), qMakePair(QStringLiteral("Destination"), QStringLiteral("file:/dest"))); } void KTestJob::nextStep() { switch (m_state) { case StatingDirs: emit infoMessage(this, QStringLiteral("Initial listing")); stateNextDir(); break; case CreatingDirs: emit infoMessage(this, QStringLiteral("Folder creation")); createNextDir(); break; case CopyingFiles: emit infoMessage(this, QStringLiteral("Actual file copying")); copyNextFile(); break; case Stopped: qDebug() << "Do nothing, we stopped"; } } void KTestJob::stateNextDir() { if (totalAmount(KJob::Directories) == m_numberOfDirs) { m_state = CreatingDirs; return; } QString directory_name = QStringLiteral("dir") + QString::number(totalAmount(KJob::Directories)); qDebug() << "Stating " << directory_name; setTotalAmount(KJob::Directories, totalAmount(KJob::Directories) + 1); setTotalAmount(KJob::Files, totalAmount(KJob::Directories) * 10); setTotalAmount(KJob::Bytes, totalAmount(KJob::Files) * 1000); emit warning(this, directory_name, directory_name); emit description(this, QStringLiteral("Stating"), qMakePair(QStringLiteral("Stating"), QString(QStringLiteral("file:/src/") + directory_name))); } void KTestJob::createNextDir() { if (processedAmount(KJob::Directories) == totalAmount(KJob::Directories)) { m_state = CopyingFiles; return; } QString directory_name = QStringLiteral("dir") + QString::number(processedAmount(KJob::Directories)); qDebug() << "Creating " << directory_name; setProcessedAmount(KJob::Directories, processedAmount(KJob::Directories) + 1); emit description(this, QStringLiteral("Creating Dir"), qMakePair(QStringLiteral("Creating"), QString(QStringLiteral("file:/dest/") + directory_name))); } void KTestJob::copyNextFile() { if (processedAmount(KJob::Files) == totalAmount(KJob::Files)) { m_state = Stopped; m_timer.stop(); emitResult(); return; } QString file_name = QStringLiteral("dir") + QString::number(processedAmount(KJob::Files) / 10) + QStringLiteral("/file") + QString::number(processedAmount(KJob::Files) % 10); qDebug() << "Copying " << file_name; setProcessedAmount(KJob::Files, processedAmount(KJob::Files) + 1); setProcessedAmount(KJob::Bytes, processedAmount(KJob::Bytes) + 1000); emit description(this, QStringLiteral("Copying"), qMakePair(QStringLiteral("Source"), QString(QStringLiteral("file:/src/") + file_name)), qMakePair(QStringLiteral("Destination"), QString(QStringLiteral("file:/dest/") + file_name))); emitSpeed(m_currentSpeed); } bool KTestJob::doSuspend() { m_timer.stop(); return true; } bool KTestJob::doResume() { m_timer.start(50); return true; } bool KTestJob::doKill() { m_timer.stop(); m_state = Stopped; return true; } int main(int argc, char **argv) { QApplication::setApplicationName(QStringLiteral("kjobtrackerstest")); QApplication app(argc, argv); KTestJob *testJob = new KTestJob(10 /* 100000 bytes to process */); KWidgetJobTracker *tracker1 = new KWidgetJobTracker(); tracker1->registerJob(testJob); QMainWindow *main = new QMainWindow; main->setWindowTitle(QStringLiteral("Mainwindow with statusbar-job-tracker")); main->show(); QStatusBar *statusBar = new QStatusBar(main); KStatusBarJobTracker *tracker2 = new KStatusBarJobTracker(main, true); tracker2->registerJob(testJob); tracker2->setStatusBarMode(KStatusBarJobTracker::ProgressOnly); statusBar->addWidget(tracker2->widget(testJob)); main->setStatusBar(statusBar); KUiServerJobTracker *tracker3 = new KUiServerJobTracker(main); tracker3->registerJob(testJob); KJobWidgets::setWindow(testJob, main); testJob->setUiDelegate(new KDialogJobUiDelegate()); testJob->start(); tracker1->widget(testJob)->show(); tracker2->widget(testJob)->show(); return app.exec(); } 07070100000026000081A40000000200000002000000015E1AFA8A0000060E000000000000000000000000000000000000004800000000kjobwidgets-VERSIONgit.20200112T115258~0fea2a7/tests/kjobtrackerstest.h/** * This file is part of the KDE libraries * Copyright (C) 2007 Kevin Ottens <ervin@kde.org> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License version 2 as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KJOBTRACKERSTEST_H #define KJOBTRACKERSTEST_H #include <kjob.h> #include <QTimer> class KTestJob : public KJob { Q_OBJECT public: enum State { StatingDirs, CreatingDirs, CopyingFiles, Stopped }; // 10 files per directory // 1000 bytes per files KTestJob(int numberOfDirs = 5); ~KTestJob(); void start() override; private Q_SLOTS: void nextStep(); protected: void stateNextDir(); void createNextDir(); void copyNextFile(); void deleteNextFile(); bool doSuspend() override; bool doResume() override; bool doKill() override; private: qulonglong m_numberOfDirs; qulonglong m_currentSpeed; State m_state; QTimer m_timer; }; #endif 07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!284 blocks
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor