pax_global_header00006660000000000000000000000064126150056060014513gustar00rootroot0000000000000052 comment=1d243e51f0e9d653a069247bbb8fd56623d89fda lxqt-powermanagement-0.10.0/000077500000000000000000000000001261500560600157505ustar00rootroot00000000000000lxqt-powermanagement-0.10.0/.gitignore000066400000000000000000000000301261500560600177310ustar00rootroot00000000000000build nbproject *kdev4* lxqt-powermanagement-0.10.0/AUTHORS000066400000000000000000000003031261500560600170140ustar00rootroot00000000000000Upstream Authors: LXQt team: http://lxqt.org Copyright: Copyright (c) 2013-2014 LXQt team License: GPL-2 and LGPL-2.1+ The full text of the licenses can be found in the 'COPYING' file. lxqt-powermanagement-0.10.0/CMakeLists.txt000066400000000000000000000021161261500560600205100ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR) project(lxqt-powermanagement) option(UPDATE_TRANSLATIONS "Update source translation translations/*.ts files" OFF) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) find_package(Qt5Widgets REQUIRED) find_package(Qt5DBus REQUIRED) find_package(Qt5X11Extras REQUIRED) find_package(Qt5Svg REQUIRED) find_package(Qt5LinguistTools REQUIRED QUIET) find_package(lxqt REQUIRED QUIET) find_package(KF5Solid REQUIRED) include(GNUInstallDirs) include(LXQtCompilerSettings NO_POLICY_SCOPE) include(LXQtTranslate) add_subdirectory(config) add_subdirectory(src) # building tarball with CPack ------------------------------------------------- include(InstallRequiredSystemLibraries) set(CPACK_PACKAGE_VERSION_MAJOR ${LXQT_MAJOR_VERSION}) set(CPACK_PACKAGE_VERSION_MINOR ${LXQT_MINOR_VERSION}) set(CPACK_PACKAGE_VERSION_PATCH ${LXQT_PATCH_VERSION}) set(CPACK_GENERATOR TBZ2) set(CPACK_SOURCE_GENERATOR TBZ2) set(CPACK_SOURCE_IGNORE_FILES /build/;.gitignore;.*~;.git;.kdev4;temp) include(CPack) lxqt-powermanagement-0.10.0/LICENSE000066400000000000000000000576361261500560600167760ustar00rootroot00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, 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 lxqt-powermanagement-0.10.0/README.md000066400000000000000000000001141261500560600172230ustar00rootroot00000000000000lxqt-powermanagement ==================== Power management module for LXQt lxqt-powermanagement-0.10.0/config/000077500000000000000000000000001261500560600172155ustar00rootroot00000000000000lxqt-powermanagement-0.10.0/config/CMakeLists.txt000066400000000000000000000027241261500560600217620ustar00rootroot00000000000000project(lxqt-config-powermanagement) set(QTX_LIBRARIES Qt5::Widgets Qt5::DBus Qt5::Svg) set(SOURCES main.cpp mainwindow.cpp lidwatchersettings.cpp batterywatchersettings.cpp idlenesswatchersettings.cpp powermanagementsettings.cpp helpers.cpp ../src/iconproducer.cpp ) set(UI_FILES lidwatchersettings.ui batterywatchersettings.ui idlenesswatchersettings.ui ) set(ICON_FILES icons/laptop-lid.svg ) set(DESKTOP_FILES_IN lxqt-config-powermanagement.desktop.in ) # Translations ********************************** lxqt_translate_ts(QM_FILES UPDATE_TRANSLATIONS ${UPDATE_TRANSLATIONS} SOURCES ${SOURCES} ${UI_FILES} INSTALL_DIR ${LXQT_TRANSLATIONS_DIR}/${PROJECT_NAME} ) lxqt_app_translation_loader(config-powermanagement_QM_LOADER ${PROJECT_NAME}) lxqt_translate_desktop(DESKTOP_FILES SOURCES ${DESKTOP_FILES_IN}) add_executable(${PROJECT_NAME} ${SOURCES} ${DESKTOP_FILES} ${QM_FILES} ${config-powermanagement_QM_LOADER} ) target_link_libraries(lxqt-config-powermanagement lxqt ${QTX_LIBRARIES} KF5::Solid ) install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT Runtime ) install(FILES ${DESKTOP_FILES} DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications" COMPONENT Runtime ) install(FILES ${ICON_FILES} DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/devices" COMPONENT Runtime ) lxqt-powermanagement-0.10.0/config/batterywatchersettings.cpp000066400000000000000000000107531261500560600245400ustar00rootroot00000000000000/* BEGIN_COMMON_COPYRIGHT_HEADER * (c)LGPL2+ * * LXDE-Qt - a lightweight, Qt based, desktop toolset * http://razor-qt.org * * Copyright: 2012 Razor team * Authors: * Christian Surlykke * * This program or library is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General * Public License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA * * END_COMMON_COPYRIGHT_HEADER */ #include #include #include #include #include #include "batterywatchersettings.h" #include "ui_batterywatchersettings.h" #include "powermanagementsettings.h" BatteryWatcherSettings::BatteryWatcherSettings(QWidget *parent) : QWidget(parent), mSettings(), mUi(new Ui::BatteryWatcherSettings), mChargingIconProducer(), mDischargingIconProducer() { mUi->setupUi(this); fillComboBox(mUi->actionComboBox); mUi->chargeLevelSlider->setValue(53); mChargingIconProducer.updateState(Solid::Battery::Charging); mDischargingIconProducer.updateState(Solid::Battery::Discharging); connect(mUi->groupBox, SIGNAL(clicked()), this, SLOT(saveSettings())); connect(mUi->actionComboBox, SIGNAL(activated(int)), this, SLOT(saveSettings())); connect(mUi->warningSpinBox, SIGNAL(editingFinished()), this, SLOT(saveSettings())); connect(mUi->levelSpinBox, SIGNAL(editingFinished()), this, SLOT(saveSettings())); connect(mUi->showIconCheckBox, SIGNAL(clicked(bool)), this, SLOT(saveSettings())); connect(mUi->showIconCheckBox, SIGNAL(clicked(bool)), mUi->previewBox, SLOT(setEnabled(bool))); connect(mUi->useThemeIconsCheckBox, SIGNAL(clicked(bool)), this, SLOT(saveSettings())); connect(mUi->useThemeIconsCheckBox, SIGNAL(clicked(bool)), this, SLOT(updatePreview())); connect(mUi->chargeLevelSlider, SIGNAL(valueChanged(int)), this, SLOT(updatePreview())); connect(&mChargingIconProducer, SIGNAL(iconChanged()), this, SLOT(onChargeIconChanged())); connect(&mDischargingIconProducer, SIGNAL(iconChanged()), this, SLOT(onDischargeIconChanged())); updatePreview(); } BatteryWatcherSettings::~BatteryWatcherSettings() { delete mUi; } void BatteryWatcherSettings::loadSettings() { mUi->groupBox->setChecked(mSettings.isBatteryWatcherEnabled()); setComboBoxToValue(mUi->actionComboBox, mSettings.getPowerLowAction()); mUi->warningSpinBox->setValue(mSettings.getPowerLowWarningTime()); mUi->levelSpinBox->setValue(mSettings.getPowerLowLevel()); mUi->showIconCheckBox->setChecked(mSettings.isShowIcon()); mUi->useThemeIconsCheckBox->setChecked(mSettings.isUseThemeIcons()); } void BatteryWatcherSettings::saveSettings() { mSettings.setBatteryWatcherEnabled(mUi->groupBox->isChecked()); mSettings.setPowerLowAction(currentValue(mUi->actionComboBox)); mSettings.setPowerLowWarningTime(mUi->warningSpinBox->value()); mSettings.setPowerLowLevel(mUi->levelSpinBox->value()); mSettings.setShowIcon(mUi->showIconCheckBox->isChecked()); mSettings.setUseThemeIcons(mUi->useThemeIconsCheckBox->isChecked()); } void BatteryWatcherSettings::updatePreview() { mUi->previewBox->setTitle(tr("Preview") + QString(" (%1)").arg(mSettings.isUseThemeIcons() ? QIcon::themeName() : tr("built in"))); int chargePercent = mUi->chargeLevelSlider->value(); mChargingIconProducer.updateChargePercent(chargePercent); mDischargingIconProducer.updateChargePercent(chargePercent); mUi->chargeLevelLabel->setText(tr("Level: %1%").arg(chargePercent)); } void BatteryWatcherSettings::onChargeIconChanged() { mUi->chargingIcon->setPixmap(mChargingIconProducer.mIcon.pixmap(mUi->chargingIcon->size())); mUi->chargingLabel->setText(mChargingIconProducer.mIconName); } void BatteryWatcherSettings::onDischargeIconChanged() { mUi->dischargingIcon->setPixmap(mDischargingIconProducer.mIcon.pixmap(mUi->dischargingIcon->size())); mUi->dischargingLabel->setText(mDischargingIconProducer.mIconName); } lxqt-powermanagement-0.10.0/config/batterywatchersettings.h000066400000000000000000000034041261500560600242000ustar00rootroot00000000000000/* BEGIN_COMMON_COPYRIGHT_HEADER * (c)LGPL2+ * * LXDE-Qt - a lightweight, Qt based, desktop toolset * http://razor-qt.org * * Copyright: 2012 Razor team * Authors: * Christian Surlykke * * This program or library is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General * Public License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA * * END_COMMON_COPYRIGHT_HEADER */ #ifndef POWERLOWSETTINGS_H #define POWERLOWSETTINGS_H #include #include #include "../config/powermanagementsettings.h" #include "../src/iconproducer.h" #include "helpers.h" namespace Ui { class BatteryWatcherSettings; } class BatteryWatcherSettings : public QWidget { Q_OBJECT public: explicit BatteryWatcherSettings(QWidget *parent = 0); ~BatteryWatcherSettings(); public slots: void loadSettings(); private slots: void saveSettings(); void updatePreview(); void onChargeIconChanged(); void onDischargeIconChanged(); private: PowerManagementSettings mSettings; Ui::BatteryWatcherSettings *mUi; IconProducer mChargingIconProducer; IconProducer mDischargingIconProducer; }; #endif // POWERLOWSETTINGS_H lxqt-powermanagement-0.10.0/config/batterywatchersettings.ui000066400000000000000000000166171261500560600244000ustar00rootroot00000000000000 BatteryWatcherSettings 0 0 428 414 Battery Watcher Settings 0 0 E&nable Battery Watcher true QFormLayout::AllNonFixedFieldsGrow Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter When power is low then: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter Warning: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter seconds 500 Level is low at: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter % Show icon: Use icons from theme: Preview 100 Qt::Horizontal 50 50 Qt::AlignCenter 9 Charging Qt::AlignCenter 50 50 Qt::AlignCenter 9 Discharging Qt::AlignCenter Qt::Vertical QSizePolicy::Fixed 20 15 Qt::Vertical QSizePolicy::Fixed 20 25 lxqt-powermanagement-0.10.0/config/helpers.cpp000066400000000000000000000034751261500560600213740ustar00rootroot00000000000000/* BEGIN_COMMON_COPYRIGHT_HEADER * (c)LGPL2+ * * LXDE-Qt - a lightweight, Qt based, desktop toolset * * Authors: * Christian Surlykke * * This program or library is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General * Public License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA * * END_COMMON_COPYRIGHT_HEADER */ #include #include #include "helpers.h" void fillComboBox(QComboBox* comboBox) { comboBox->clear(); comboBox->addItem(QObject::tr("Nothing"), -1); comboBox->addItem(QObject::tr("Lock screen"), -2); // FIXME comboBox->addItem(QObject::tr("Suspend"), LXQt::Power::PowerSuspend); comboBox->addItem(QObject::tr("Hibernate"), LXQt::Power::PowerHibernate); comboBox->addItem(QObject::tr("Shutdown"), LXQt::Power::PowerShutdown); } void setComboBoxToValue(QComboBox* comboBox, int value) { for (int index = 0; index < comboBox->count(); index++) { if (value == comboBox->itemData(index).toInt()) { comboBox->setCurrentIndex(index); return; } } comboBox->setCurrentIndex(0); } int currentValue(QComboBox *comboBox) { return comboBox->itemData(comboBox->currentIndex()).toInt(); } lxqt-powermanagement-0.10.0/config/helpers.h000066400000000000000000000007631261500560600210360ustar00rootroot00000000000000/* * Copyright (c) 2014 Christian Surlykke * * This file is part of the LXQt project. * It is distributed under the LGPL 2.1 or later license. * Please refer to the LICENSE file for a copy of the license. */ #ifndef POWER_MANAGEMENT_SETTINGS_H #define POWER_MANAGEMENT_SETTINGS_H #include void fillComboBox(QComboBox* comboBox); void setComboBoxToValue(QComboBox* comboBox, int value); int currentValue(QComboBox *comboBox); #endif // POWER_MANAGEMENT_SETTINGS_H lxqt-powermanagement-0.10.0/config/icons/000077500000000000000000000000001261500560600203305ustar00rootroot00000000000000lxqt-powermanagement-0.10.0/config/icons/laptop-lid.svg000066400000000000000000000077601261500560600231300ustar00rootroot00000000000000 image/svg+xml lxqt-powermanagement-0.10.0/config/idlenesswatchersettings.cpp000066400000000000000000000077661261500560600247060ustar00rootroot00000000000000/* BEGIN_COMMON_COPYRIGHT_HEADER * (c)LGPL2+ * * LXDE-Qt - a lightweight, Qt based, desktop toolset * http://razor-qt.org * * Copyright: 2012 Razor team * Authors: * Christian Surlykke * * This program or library is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General * Public License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA * * END_COMMON_COPYRIGHT_HEADER */ #include #include #include "idlenesswatchersettings.h" #include "ui_idlenesswatchersettings.h" #include "helpers.h" #define MINIMUM_SECONDS 30 IdlenessWatcherSettings::IdlenessWatcherSettings(QWidget *parent) : QWidget(parent), mSettings(), mUi(new Ui::IdlenessWatcherSettings) { mUi->setupUi(this); fillComboBox(mUi->idleActionComboBox); connect(mUi->idlenessWatcherGroupBox, SIGNAL(clicked()), SLOT(saveSettings())); connect(mUi->idleActionComboBox, SIGNAL(activated(int)), SLOT(saveSettings())); connect(mUi->idleTimeMinutesSpinBox, SIGNAL(editingFinished()), SLOT(saveSettings())); connect(mUi->idleTimeMinutesSpinBox, SIGNAL(valueChanged(int)), SLOT(minutesChanged(int))); connect(mUi->idleTimeSecondsSpinBox, SIGNAL(valueChanged(int)), SLOT(secondsChanged(int))); connect(mUi->idleTimeSecondsSpinBox, SIGNAL(editingFinished()), SLOT(saveSettings())); } IdlenessWatcherSettings::~IdlenessWatcherSettings() { delete mUi; } void IdlenessWatcherSettings::loadSettings() { mUi->idlenessWatcherGroupBox->setChecked(mSettings.isIdlenessWatcherEnabled()); setComboBoxToValue(mUi->idleActionComboBox, mSettings.getIdlenessAction()); int idlenessTimeSeconds = mSettings.getIdlenessTimeSecs(); // if less than minimum, change to 15 minutes if (idlenessTimeSeconds < MINIMUM_SECONDS) idlenessTimeSeconds = 900; int idlenessTimeMinutes = idlenessTimeSeconds / 60; idlenessTimeSeconds = idlenessTimeSeconds % 60; mUi->idleTimeMinutesSpinBox->setValue(idlenessTimeMinutes); mUi->idleTimeSecondsSpinBox->setValue(idlenessTimeSeconds); } void IdlenessWatcherSettings::minutesChanged(int newVal) { if (newVal < 1 && mUi->idleTimeSecondsSpinBox->value() < MINIMUM_SECONDS) { mUi->idleTimeSecondsSpinBox->setValue(MINIMUM_SECONDS); } } void IdlenessWatcherSettings::secondsChanged(int newVal) { if (newVal > 59) { mUi->idleTimeSecondsSpinBox->setValue(0); mUi->idleTimeMinutesSpinBox->setValue(mUi->idleTimeMinutesSpinBox->value() + 1); } else if (mUi->idleTimeMinutesSpinBox->value() < 1 && newVal < MINIMUM_SECONDS) { mUi->idleTimeMinutesSpinBox->setValue(0); mUi->idleTimeSecondsSpinBox->setValue(MINIMUM_SECONDS); } else if (newVal < 0) { mUi->idleTimeMinutesSpinBox->setValue(mUi->idleTimeMinutesSpinBox->value() - 1); mUi->idleTimeSecondsSpinBox->setValue(59); } } void IdlenessWatcherSettings::saveSettings() { mSettings.setIdlenessWatcherEnabled(mUi->idlenessWatcherGroupBox->isChecked()); mSettings.setIdlenessAction(currentValue(mUi->idleActionComboBox)); int idleTimeSecs = 60 * mUi->idleTimeMinutesSpinBox->value() + mUi->idleTimeSecondsSpinBox->value(); // if less than minimum, change 15 minutes if (idleTimeSecs < MINIMUM_SECONDS) { idleTimeSecs = 900; mUi->idleTimeMinutesSpinBox->setValue(15); mUi->idleTimeSecondsSpinBox->setValue(0); } mSettings.setIdlenessTimeSecs(idleTimeSecs); } lxqt-powermanagement-0.10.0/config/idlenesswatchersettings.h000066400000000000000000000031371261500560600243370ustar00rootroot00000000000000/* BEGIN_COMMON_COPYRIGHT_HEADER * (c)LGPL2+ * * LXDE-Qt - a lightweight, Qt based, desktop toolset * http://razor-qt.org * * Copyright: 2012 Razor team * Authors: * Christian Surlykke * * This program or library is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General * Public License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA * * END_COMMON_COPYRIGHT_HEADER */ #ifndef IDLE_SETTINGS_H #define IDLE_SETTINGS_H #include #include #include "powermanagementsettings.h" namespace Ui { class IdlenessWatcherSettings; } class IdlenessWatcherSettings : public QWidget { Q_OBJECT public: explicit IdlenessWatcherSettings(QWidget *parent = 0); ~IdlenessWatcherSettings(); public slots: void loadSettings(); private slots: void minutesChanged(int newVal); void secondsChanged(int newVal); void saveSettings(); private: PowerManagementSettings mSettings; Ui::IdlenessWatcherSettings *mUi; }; #endif // IDLE_SETTINGS_H lxqt-powermanagement-0.10.0/config/idlenesswatchersettings.ui000066400000000000000000000061721261500560600245270ustar00rootroot00000000000000 IdlenessWatcherSettings 0 0 309 177 Form Enab&le Idleness Watcher true QFormLayout::AllNonFixedFieldsGrow Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter 0 0 When idle then: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter 0 0 Idle time: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter minutes 999 Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter seconds -1 60 lxqt-powermanagement-0.10.0/config/lidwatchersettings.cpp000066400000000000000000000062341261500560600236350ustar00rootroot00000000000000/* BEGIN_COMMON_COPYRIGHT_HEADER * (c)LGPL2+ * * LXDE-Qt - a lightweight, Qt based, desktop toolset * http://razor-qt.org * * Copyright: 2012 Razor team * Authors: * Christian Surlykke * * This program or library is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General * Public License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA * * END_COMMON_COPYRIGHT_HEADER */ #include #include #include "lidwatchersettings.h" #include "ui_lidwatchersettings.h" #include "helpers.h" LidWatcherSettings::LidWatcherSettings(QWidget *parent) : QWidget(parent), mSettings(), mUi(new Ui::LidWatcherSettings) { mUi->setupUi(this); fillComboBox(mUi->onBatteryActionComboBox); fillComboBox(mUi->onAcActionComboBox); fillComboBox(mUi->extMonOnBatteryActionComboBox); fillComboBox(mUi->extMonOnAcActionComboBox); connect(mUi->lidWatcherSettingsGroupBox, SIGNAL(clicked()), this, SLOT(saveSettings())); connect(mUi->onBatteryActionComboBox, SIGNAL(activated(int)), this, SLOT(saveSettings())); connect(mUi->onAcActionComboBox, SIGNAL(activated(int)), this, SLOT(saveSettings())); connect(mUi->extMonOnBatteryActionComboBox, SIGNAL(activated(int)), this, SLOT(saveSettings())); connect(mUi->extMonOnAcActionComboBox, SIGNAL(activated(int)), this, SLOT(saveSettings())); connect(mUi->extMonGroupBox, SIGNAL(clicked()), this, SLOT(saveSettings())); } LidWatcherSettings::~LidWatcherSettings() { delete mUi; } void LidWatcherSettings::loadSettings() { mUi->lidWatcherSettingsGroupBox->setChecked(mSettings.isLidWatcherEnabled()); setComboBoxToValue(mUi->onBatteryActionComboBox, mSettings.getLidClosedAction()); setComboBoxToValue(mUi->onAcActionComboBox, mSettings.getLidClosedAcAction()); mUi->extMonGroupBox->setChecked(mSettings.isEnableExtMonLidClosedActions()); setComboBoxToValue(mUi->extMonOnBatteryActionComboBox, mSettings.getLidClosedExtMonAction()); setComboBoxToValue(mUi->extMonOnAcActionComboBox, mSettings.getLidClosedExtMonAcAction()); } void LidWatcherSettings::saveSettings() { mSettings.setLidWatcherEnabled(mUi->lidWatcherSettingsGroupBox->isChecked()); mSettings.setLidClosedAction(currentValue(mUi->onBatteryActionComboBox)); mSettings.setLidClosedAcAction(currentValue(mUi->onAcActionComboBox)); mSettings.setEnableExtMonLidClosedActions(mUi->extMonGroupBox->isChecked()); mSettings.setLidClosedExtMonAction(currentValue(mUi->extMonOnBatteryActionComboBox)); mSettings.setLidClosedExtMonAcAction(currentValue(mUi->extMonOnAcActionComboBox)); } lxqt-powermanagement-0.10.0/config/lidwatchersettings.h000066400000000000000000000027601261500560600233020ustar00rootroot00000000000000/* BEGIN_COMMON_COPYRIGHT_HEADER * (c)LGPL2+ * * LXDE-Qt - a lightweight, Qt based, desktop toolset * http://razor-qt.org * * Copyright: 2012 Razor team * Authors: * Christian Surlykke * * This program or library is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General * Public License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA * * END_COMMON_COPYRIGHT_HEADER */ #ifndef LIDSETTINGS_H #define LIDSETTINGS_H #include #include #include "powermanagementsettings.h" namespace Ui { class LidWatcherSettings; } class LidWatcherSettings : public QWidget { Q_OBJECT public: explicit LidWatcherSettings(QWidget *parent = 0); ~LidWatcherSettings(); public slots: void loadSettings(); private slots: void saveSettings(); private: PowerManagementSettings mSettings; Ui::LidWatcherSettings *mUi; }; #endif // LIDSETTINGS_H lxqt-powermanagement-0.10.0/config/lidwatchersettings.ui000066400000000000000000000111441261500560600234640ustar00rootroot00000000000000 LidWatcherSettings 0 0 276 289 Form QGroupBox QGroupBox { border: none; padding-top: 30px; } Enable &Lid Watcher true true Action when lid is closed QFormLayout::AllNonFixedFieldsGrow Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter On Battery Nothing Suspend Hibernate Shut down On AC When &using external monitor true QFormLayout::AllNonFixedFieldsGrow Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter 0 0 On Battery On AC 0 0 lxqt-powermanagement-0.10.0/config/lxqt-config-powermanagement.desktop.in000066400000000000000000000005321261500560600266370ustar00rootroot00000000000000[Desktop Entry] Type=Application Name=Power Management GenericName=Power Management Settings Comment=Various settings regarding Power Management like battery or idleness watcher Exec=lxqt-config-powermanagement Icon=preferences-system-power-management Categories=Settings;DesktopSettings;Qt;LXQt; OnlyShowIn=LXQt; #TRANSLATIONS_DIR=translations lxqt-powermanagement-0.10.0/config/main.cpp000066400000000000000000000025071261500560600206510ustar00rootroot00000000000000/* BEGIN_COMMON_COPYRIGHT_HEADER * (c)LGPL2+ * * LXDE-Qt - a lightweight, Qt based, desktop toolset * http://razor-qt.org * * Copyright: 2012 Razor team * Authors: * Christian Surlykke * * This program or library is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General * Public License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA * * END_COMMON_COPYRIGHT_HEADER */ #include #include "mainwindow.h" int main(int argc, char *argv[]) { LXQt::SingleApplication a(argc, argv); MainWindow mainWindow; mainWindow.setWindowIcon(QIcon::fromTheme("preferences-system-power-management")); mainWindow.show(); a.setActivationWindow(&mainWindow); return a.exec(); } lxqt-powermanagement-0.10.0/config/mainwindow.cpp000066400000000000000000000037361261500560600221060ustar00rootroot00000000000000/* BEGIN_COMMON_COPYRIGHT_HEADER * (c)LGPL2+ * * LXDE-Qt - a lightweight, Qt based, desktop toolset * http://razor-qt.org * * Copyright: 2012 Razor team * Authors: * Christian Surlykke * * This program or library is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General * Public License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA * * END_COMMON_COPYRIGHT_HEADER */ #include "mainwindow.h" #include "lidwatchersettings.h" #include "batterywatchersettings.h" #include "idlenesswatchersettings.h" MainWindow::MainWindow(QWidget *parent) : LXQt::ConfigDialog(tr("Power Management Settings"), new PowerManagementSettings(parent)) { BatteryWatcherSettings* batteryWatcherSettings = new BatteryWatcherSettings(this); addPage(batteryWatcherSettings, tr("Battery"), "battery"); connect(this, SIGNAL(reset()), batteryWatcherSettings, SLOT(loadSettings())); LidWatcherSettings *lidwatcherSettings = new LidWatcherSettings(this); addPage(lidwatcherSettings, tr("Lid"), "laptop-lid"); connect(this, SIGNAL(reset()), lidwatcherSettings, SLOT(loadSettings())); IdlenessWatcherSettings* idlenessWatcherSettings = new IdlenessWatcherSettings(this); addPage(idlenessWatcherSettings, tr("Idle"), (QStringList() << "user-idle" << "user-away")); connect(this, SIGNAL(reset()), idlenessWatcherSettings, SLOT(loadSettings())); emit reset(); } lxqt-powermanagement-0.10.0/config/mainwindow.h000066400000000000000000000023001261500560600215350ustar00rootroot00000000000000/* BEGIN_COMMON_COPYRIGHT_HEADER * (c)LGPL2+ * * LXDE-Qt - a lightweight, Qt based, desktop toolset * http://razor-qt.org * * Copyright: 2012 Razor team * Authors: * Christian Surlykke * * This program or library is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General * Public License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA * * END_COMMON_COPYRIGHT_HEADER */ #ifndef MAINWINDOW_H #define MAINWINDOW_H #include class MainWindow : public LXQt::ConfigDialog { Q_OBJECT public: MainWindow(QWidget *parent = 0); }; #endif // MAINWINDOW_H lxqt-powermanagement-0.10.0/config/powermanagementsettings.cpp000066400000000000000000000143711261500560600247010ustar00rootroot00000000000000/* BEGIN_COMMON_COPYRIGHT_HEADER * (c)LGPL2+ * * LXDE-Qt - a lightweight, Qt based, desktop toolset * * Authors: * Christian Surlykke * * This program or library is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General * Public License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA * * END_COMMON_COPYRIGHT_HEADER */ #include #include #include "powermanagementsettings.h" namespace PowerManagementSettingsConstants { const QString RUN_CHECK_LEVEL = "runCheckLevel"; const QString ENABLE_BATTERY_WATCHER_KEY = "enableBatteryWatcher"; const QString ENABLE_LID_WATCHER_KEY = "enableLidWatcher"; const QString ENABLE_IDLENESS_WATCHER_KEY = "enableIdlenessWatcher"; const QString LID_CLOSED_ACTION_KEY = "lidClosedAction"; const QString LID_CLOSED_AC_ACTION_KEY = "lidClosedAcAction"; const QString LID_CLOSED_EXT_MON_ACTION_KEY = "lidClosedExtMonAction"; const QString LID_CLOSED_EXT_MON_AC_ACTION_KEY = "lidClosedExtMonAcAction"; const QString ENABLE_EXT_MON_LIDCLOSED_ACTIONS_KEY = "enableExtMonLidClosedActions"; const QString POWER_LOW_ACTION_KEY = "powerLowAction"; const QString POWER_LOW_WARNING_KEY = "powerLowWarning"; const QString POWER_LOW_LEVEL_KEY = "powerLowLevel"; const QString SHOW_ICON_KEY = "showIcon"; const QString USE_THEME_ICONS_KEY = "useThemeIcons"; const QString IDLENESS_ACTION_KEY = "idlenessAction"; const QString IDLENESS_TIME_SECS_KEY = "idlenessTimeSecs"; } using namespace PowerManagementSettingsConstants; PowerManagementSettings::PowerManagementSettings(QObject* parent) : LXQt::Settings("lxqt-powermanagement") { } PowerManagementSettings::~PowerManagementSettings() { } int PowerManagementSettings::getRunCheckLevel() { return value(RUN_CHECK_LEVEL, 0).toInt(); } void PowerManagementSettings::setRunCheckLevel(int newLevel) { setValue(RUN_CHECK_LEVEL, newLevel); } bool PowerManagementSettings::isBatteryWatcherEnabled() { return value(ENABLE_BATTERY_WATCHER_KEY, true).toBool(); } void PowerManagementSettings::setBatteryWatcherEnabled(bool batteryWatcherEnabled) { setValue(ENABLE_BATTERY_WATCHER_KEY, batteryWatcherEnabled); } int PowerManagementSettings::getPowerLowAction() { return value(POWER_LOW_ACTION_KEY, 0).toInt(); } void PowerManagementSettings::setPowerLowAction(int powerLowAction) { setValue(POWER_LOW_ACTION_KEY, powerLowAction); } int PowerManagementSettings::getPowerLowLevel() { return value(POWER_LOW_LEVEL_KEY, 5).toInt(); } void PowerManagementSettings::setPowerLowLevel(int powerLowLevel) { setValue(POWER_LOW_LEVEL_KEY, powerLowLevel); } int PowerManagementSettings::getPowerLowWarningTime() { return value(POWER_LOW_WARNING_KEY, 30).toInt(); } void PowerManagementSettings::setPowerLowWarningTime(int powerLowWarningTime) { setValue(POWER_LOW_WARNING_KEY, powerLowWarningTime); } bool PowerManagementSettings::isShowIcon() { return value(SHOW_ICON_KEY, true).toBool(); } void PowerManagementSettings::setShowIcon(bool showIcon) { setValue(SHOW_ICON_KEY, showIcon); } bool PowerManagementSettings::isUseThemeIcons() { return value(USE_THEME_ICONS_KEY, false).toBool(); } void PowerManagementSettings::setUseThemeIcons(bool useThemeIcons) { setValue(USE_THEME_ICONS_KEY, useThemeIcons); } bool PowerManagementSettings::isLidWatcherEnabled() { return value(ENABLE_LID_WATCHER_KEY, true).toBool(); } void PowerManagementSettings::setLidWatcherEnabled(bool lidWatcherEnabled) { setValue(ENABLE_LID_WATCHER_KEY, lidWatcherEnabled); } int PowerManagementSettings::getLidClosedAcAction() { return value(LID_CLOSED_AC_ACTION_KEY, 0).toInt(); } void PowerManagementSettings::setLidClosedAcAction(int lidClosedAcAction) { setValue(LID_CLOSED_AC_ACTION_KEY, lidClosedAcAction); } int PowerManagementSettings::getLidClosedAction() { return value(LID_CLOSED_ACTION_KEY, 0).toInt(); } void PowerManagementSettings::setLidClosedAction(int lidClosedAction) { setValue(LID_CLOSED_ACTION_KEY, lidClosedAction); } int PowerManagementSettings::getLidClosedExtMonAcAction() { return value(LID_CLOSED_EXT_MON_AC_ACTION_KEY, 0).toInt(); } void PowerManagementSettings::setLidClosedExtMonAcAction(int lidClosedExtMonAcAction) { setValue(LID_CLOSED_EXT_MON_AC_ACTION_KEY, lidClosedExtMonAcAction); } int PowerManagementSettings::getLidClosedExtMonAction() { return value(LID_CLOSED_EXT_MON_ACTION_KEY, 0).toInt(); } void PowerManagementSettings::setLidClosedExtMonAction(int lidClosedExtMonAction) { setValue(LID_CLOSED_EXT_MON_ACTION_KEY, lidClosedExtMonAction); } bool PowerManagementSettings::isEnableExtMonLidClosedActions() { return value(ENABLE_EXT_MON_LIDCLOSED_ACTIONS_KEY, 0).toBool(); } void PowerManagementSettings::setEnableExtMonLidClosedActions(bool enableExtMonLidClosedActions) { setValue(ENABLE_EXT_MON_LIDCLOSED_ACTIONS_KEY, enableExtMonLidClosedActions); } int PowerManagementSettings::getIdlenessAction() { // default to nothing (-1) return value(IDLENESS_ACTION_KEY, -1).toInt(); } void PowerManagementSettings::setIdlenessAction(int idlenessAction) { setValue(IDLENESS_ACTION_KEY, idlenessAction); } int PowerManagementSettings::getIdlenessTimeSecs() { // default to 15 minutes return value(IDLENESS_TIME_SECS_KEY, 900).toInt(); } void PowerManagementSettings::setIdlenessTimeSecs(int idlenessTimeSecs) { setValue(IDLENESS_TIME_SECS_KEY, idlenessTimeSecs); } bool PowerManagementSettings::isIdlenessWatcherEnabled() { return value(ENABLE_IDLENESS_WATCHER_KEY, false).toBool(); } void PowerManagementSettings::setIdlenessWatcherEnabled(bool idlenessWatcherEnabled) { setValue(ENABLE_IDLENESS_WATCHER_KEY, idlenessWatcherEnabled); } lxqt-powermanagement-0.10.0/config/powermanagementsettings.h000066400000000000000000000052111261500560600243370ustar00rootroot00000000000000/* BEGIN_COMMON_COPYRIGHT_HEADER * (c)LGPL2+ * * LXDE-Qt - a lightweight, Qt based, desktop toolset * http://razor-qt.org * * Copyright: 2012 Razor team * Authors: * Christian Surlykke * * This program or library is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General * Public License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA * * END_COMMON_COPYRIGHT_HEADER */ #ifndef COMMON_H #define COMMON_H #include #include #include class PowerManagementSettings : public LXQt::Settings { Q_OBJECT public: PowerManagementSettings(QObject* parent = 0); ~PowerManagementSettings(); int getRunCheckLevel(); void setRunCheckLevel(int newLevel); bool isBatteryWatcherEnabled(); void setBatteryWatcherEnabled(bool batteryWatcherEnabled); int getPowerLowAction(); void setPowerLowAction(int powerLowAction); int getPowerLowLevel(); void setPowerLowLevel(int powerLowLevel); int getPowerLowWarningTime(); void setPowerLowWarningTime(int powerLowWarningTime); bool isShowIcon(); void setShowIcon(bool showIcon); bool isUseThemeIcons(); void setUseThemeIcons(bool useThemeIcons); bool isLidWatcherEnabled(); void setLidWatcherEnabled(bool lidWatcherEnabled); int getLidClosedAcAction(); void setLidClosedAcAction(int lidClosedAcAction); int getLidClosedAction(); void setLidClosedAction(int lidClosedAction); int getLidClosedExtMonAcAction(); void setLidClosedExtMonAcAction(int lidClosedExtMonAcAction); int getLidClosedExtMonAction(); void setLidClosedExtMonAction(int lidClosedExtMonAction); bool isEnableExtMonLidClosedActions(); void setEnableExtMonLidClosedActions(bool enableExtMonLidClosedActions); int getIdlenessAction(); void setIdlenessAction(int idlenessAction); int getIdlenessTimeSecs(); void setIdlenessTimeSecs(int idlenessTimeSecs); bool isIdlenessWatcherEnabled(); void setIdlenessWatcherEnabled(bool idlenessWatcherEnabled); }; #endif // COMMON_H lxqt-powermanagement-0.10.0/config/translations/000077500000000000000000000000001261500560600217365ustar00rootroot00000000000000lxqt-powermanagement-0.10.0/config/translations/lxqt-config-powermanagement.ts000066400000000000000000000172711261500560600277400ustar00rootroot00000000000000 BatteryWatcherSettings Battery Watcher Settings E&nable Battery Watcher Warning: seconds Level is low at: % Use icons from theme: Preview Charging Discharging When power is low then: Show icon: built in Level: %1% IdlenessWatcherSettings Form Enab&le Idleness Watcher When idle then: Idle time: minutes seconds LidWatcherSettings Form Enable &Lid Watcher Action when lid is closed On Battery Nothing Suspend Hibernate Shut down On AC When &using external monitor MainWindow Power Management Settings Battery Lid Idle QObject Nothing Lock screen Suspend Hibernate Shutdown lxqt-powermanagement-0.10.0/config/translations/lxqt-config-powermanagement_el.desktop000066400000000000000000000004741261500560600314400ustar00rootroot00000000000000Name[el]=Διαχείριση ενέργειας GenericName[el]=Ρυθμίσεις της διαχείρισης ενέργειας Comment[el]=Διάφορες ρυθμίσεις σχετικά με την διαχείριση ενέργειας όπως ο επόπτης μπαταρίας ή αδράνειας lxqt-powermanagement-0.10.0/config/translations/lxqt-config-powermanagement_el.ts000066400000000000000000000212071261500560600304120ustar00rootroot00000000000000 BatteryWatcherSettings Battery Watcher Settings Ρυθμίσεις επόπτη μπαταρίας E&nable Battery Watcher &Ενεργοποίηση του επόπτη της μπαταρίας Warning: Προειδοποίηση: seconds δευτερόλεπτα Level is low at: Το επίπεδο είναι χαμηλό στο: % % Use icons from theme: Χρήση των εικονιδίων από το θέμα: Preview Charging Discharging When power is low then: Όταν η ενέργεια είναι χαμηλά τότε: Show icon: Εμφάνιση εικονιδίου: built in Level: %1% IdlenessWatcherSettings Form Φόρμα Enab&le Idleness Watcher Ενεργοποίηση του επόπτη α&δράνειας When idle then: Όταν είναι αδρανής: Idle time: Χρόνος αδράνειας: minutes λεπτά seconds δευτερόλεπτα LidWatcherSettings Form Φόρμα Enable &Lid Watcher Ενεργοποίηση του επόπτη &καλύμματος Action when lid is closed Ενέργεια κατά το κλείσιμο του καλύμματος On Battery Σε μπαταρία Nothing Τίποτα Suspend Αναστολή Hibernate Νάρκη Shut down Τερματισμός On AC Σε τροφοδοτικό AC When &using external monitor Όταν χρησιμοποιείται εξωτερική ο&θόνη On Ac Σε τροφοδοτικό AC MainWindow LXQt Powermanagement Configuration Διαμόρφωση της διαχείρισης ενέργειας του LXQt Power Management Settings Battery Μπαταρία Lid Κάλυμμα φορητού Idle idle Αδράνεια QObject Nothing Τίποτα Lock screen Κλείδωμα οθόνης Suspend Αναστολή Hibernate Νάρκη Shutdown Τερματισμός lxqt-powermanagement-0.10.0/config/translations/lxqt-config-powermanagement_hu.desktop000066400000000000000000000001331261500560600314440ustar00rootroot00000000000000# Translations GenericName[hu]=LXQt energiakezelés beállítása Name[hu]=Energiakezelés lxqt-powermanagement-0.10.0/config/translations/lxqt-config-powermanagement_hu.ts000066400000000000000000000200151261500560600304220ustar00rootroot00000000000000 BatteryWatcherSettings Battery Watcher Settings Akkumulátor figyelő beállítás E&nable Battery Watcher Akkumulátor figyelő e&ngedélyezése Warning: Figyelmeztetés: seconds másodperc Level is low at: Alacsony energiaszint: % Use icons from theme: Ikonok a témából: Preview Charging Discharging When power is low then: Alacsony energiánál: Show icon: Ikon mutatás: built in Level: %1% IdlenessWatcherSettings Form Űrlap Enab&le Idleness Watcher Tétle&nségi felügyelet When idle then: Tétlenség esetén: Idle time: Tétlenségi idő: minutes perc seconds másodperc LidWatcherSettings Form Űrlap Enable &Lid Watcher Fedélfelügyelet Action when lid is closed Teendő fedélzáráskor On Battery Akkumulátor Nothing Semmi Suspend Készenlét Hibernate Alvás Shut down Kikapcsolás On AC Külső táp When &using external monitor &Külső monitor használatakor On Ac Külső táp MainWindow LXQt Powermanagement Configuration LXQt energiafelügyelet beállítás Power Management Settings Battery Akkumulátor Lid Fedél Idle idle Tétlenség QObject Nothing Semmi Lock screen Képernyőzár Suspend Készenlét Hibernate Alvás Shutdown Kikapcsolás lxqt-powermanagement-0.10.0/config/translations/lxqt-config-powermanagement_it.desktop000066400000000000000000000001171261500560600314460ustar00rootroot00000000000000Name[it]=Gestore energia GenericName[it]=Impostazioni del risparmio energetico lxqt-powermanagement-0.10.0/config/translations/lxqt-config-powermanagement_it.ts000066400000000000000000000200541261500560600304250ustar00rootroot00000000000000 BatteryWatcherSettings Battery Watcher Settings Impostazioni monitor batteria E&nable Battery Watcher &Attiva il monitor della batteria Warning: Tempo di attesa: seconds secondi Level is low at: Livello basso : % Use icons from theme: Usa icone del tema: Preview Charging Discharging When power is low then: Quando il livello è basso: Show icon: Mostra icona: built in Level: %1% IdlenessWatcherSettings Form Enab&le Idleness Watcher &Attiva monitor attività sistema When idle then: Quando inattivo: Idle time: Tempo di inattività: minutes minuti seconds secondi LidWatcherSettings Form Enable &Lid Watcher &Attiva monitor coperchio Action when lid is closed Azione a chiusura On Battery Alimentazione a batteria Nothing Niente Suspend Sospendi Hibernate Iberna Shut down Spegni On AC Alimentazione di rete When &using external monitor Quando è in uso un monitor &esterno On Ac Alimentazione di rete MainWindow LXQt Powermanagement Configuration Configurazione gestione energetica di LXQt Power Management Settings Battery Batteria Lid Coperchio Idle idle Inattività QObject Nothing Nessuna azione Lock screen Blocca schermo Suspend Sospendi Hibernate Iberna Shutdown Spegni lxqt-powermanagement-0.10.0/config/translations/lxqt-config-powermanagement_ja.desktop000066400000000000000000000001531261500560600314240ustar00rootroot00000000000000# Translations GenericName[ja]=電源管理の設定 Name[ja]=電源管理 #TRANSLATIONS_DIR=translations lxqt-powermanagement-0.10.0/config/translations/lxqt-config-powermanagement_ja.ts000066400000000000000000000202371261500560600304060ustar00rootroot00000000000000 BatteryWatcherSettings Battery Watcher Settings バッテリーの監視設定 E&nable Battery Watcher バッテリー監視を有効にする(&N) Warning: 警告: seconds Level is low at: 低いと判断するレベル: % % Use icons from theme: テーマのアイコンを用いる: Preview Charging Discharging When power is low then: 電源が低いときには: Show icon: アイコンを表示: built in Level: %1% IdlenessWatcherSettings Form フォーム Enab&le Idleness Watcher アイドル状態の監視 When idle then: アイドル時には: Idle time: アイドル状態の時間 minutes seconds LidWatcherSettings Form フォーム Enable &Lid Watcher フタの監視を有効にする Action when lid is closed フタが閉じていたときの動作 On Battery バッテリー動作時 Nothing 何もしない Suspend サスペンド Hibernate ハイバネート Shut down シャットダウン On AC AC電源時 When &using external monitor 外部モニター使用時 On Ac AC電源時 MainWindow LXQt Powermanagement Configuration LXQt電源管理の設定 Power Management Settings Battery バッテリー Lid フタ Idle idle アイドル QObject Nothing 何もしない Lock screen スクリーンをロック Suspend サスペンド Hibernate ハイバネート Shutdown シャットダウン lxqt-powermanagement-0.10.0/config/translations/lxqt-config-powermanagement_pl_PL.desktop000066400000000000000000000001301261500560600320330ustar00rootroot00000000000000Name[pl_PL]=Zarządzanie energią GenericName[pl_PL]=Konfiguracja zarządzania energią lxqt-powermanagement-0.10.0/config/translations/lxqt-config-powermanagement_pl_PL.ts000066400000000000000000000200101261500560600310070ustar00rootroot00000000000000 BatteryWatcherSettings Battery Watcher Settings Ustawienia monitorowania baterii E&nable Battery Watcher W&łącz monitorowanie baterii Warning: Ostrzeżenie: seconds sek Level is low at: Poziom niski od: % % Use icons from theme: Użyj ikon z motywu: Preview Charging Discharging When power is low then: Gdy poziom jest niski: Show icon: Pokaż ikonę: built in Level: %1% IdlenessWatcherSettings Form Form Enab&le Idleness Watcher W&łącz monitorowanie bezczynności When idle then: Gdy bezczynny: Idle time: Czas bezczynności: minutes min seconds sek LidWatcherSettings Form Form Enable &Lid Watcher W&łącz monitorowanie pokrywy Action when lid is closed Reakcja na zamknięcie pokrywy On Battery Na baterii Nothing Brak Suspend Wstrzymaj Hibernate Hibernuj Shut down Wyłącz On AC Na zasilaniu When &using external monitor Przy używaniu &zewnętrznego monitora On Ac Na zasilaniu MainWindow LXQt Powermanagement Configuration LXQt Konfiguracja zarządzania energią Power Management Settings Battery Bateria Lid Pokrywa Idle idle Bezczynność QObject Nothing Brak reakcji Lock screen Zablokuj ekran Suspend Wstrzymaj Hibernate Hibernuj Shutdown Wyłącz lxqt-powermanagement-0.10.0/config/translations/lxqt-config-powermanagement_pt.desktop000066400000000000000000000001161261500560600314540ustar00rootroot00000000000000Name[pt]=Gestão de energia GenericName[pt]=Definições do gestor de energia lxqt-powermanagement-0.10.0/config/translations/lxqt-config-powermanagement_pt.ts000066400000000000000000000200731261500560600304350ustar00rootroot00000000000000 BatteryWatcherSettings Battery Watcher Settings Definições do monitorizador de energia E&nable Battery Watcher &Ativar monitorizador de energia Warning: Aviso: seconds segundos Level is low at: O nível está baixo em: % % Use icons from theme: Utilizar ícones do tema: Preview Charging Discharging When power is low then: Se a energia estiver baixa: Show icon: Mostrar ícone: built in Level: %1% IdlenessWatcherSettings Form Formulário Enab&le Idleness Watcher Ativar monitori&zador de inatividade When idle then: Se existir inatividade: Idle time: Tempo para inatividade: minutes minutos seconds segundos LidWatcherSettings Form Formulário Enable &Lid Watcher Ativar monitori&zador da tampa Action when lid is closed Ação ao fechar a tampa On Battery Com bateria Nothing Nada fazer Suspend Suspender Hibernate Hibernar Shut down Desligar On AC Com corrente When &using external monitor Ao &utilizar monitor externo On Ac Com corrente MainWindow LXQt Powermanagement Configuration Configuração do gestor de energia do LXQt Power Management Settings Battery Bateria Lid Tampa Idle idle inatividade QObject Nothing Nada fazer Lock screen Bloquear ecrã Suspend Suspender Hibernate Hibernar Shutdown Desligar lxqt-powermanagement-0.10.0/config/translations/lxqt-config-powermanagement_ru.desktop000066400000000000000000000002561261500560600314640ustar00rootroot00000000000000# Translations GenericName[ru]=Настройки управления энергопотреблением Name[ru]=Управление энергопотреблениемlxqt-powermanagement-0.10.0/config/translations/lxqt-config-powermanagement_ru.ts000066400000000000000000000207611261500560600304440ustar00rootroot00000000000000 BatteryWatcherSettings Battery Watcher Settings Настройки наблюдения за батареей E&nable Battery Watcher &Разрешить наблюдение за батареей Warning: Предупреждение: seconds секунд Level is low at: Низкий уровень при: % % Use icons from theme: Использовать значки из темы: Preview Charging Discharging When power is low then: При низком заряде: Show icon: Показывать значок: built in Level: %1% IdlenessWatcherSettings Form Enab&le Idleness Watcher Включить наблюдение за простоем When idle then: При простое: Idle time: Время простоя: minutes минут seconds секунд LidWatcherSettings Form Enable &Lid Watcher Включить наблюдение за крышкой Action when lid is closed Действие при закрытии крышки On Battery От батареи Nothing Ничего Suspend Ждущий режим Hibernate Спящий режим Shut down Выключить On AC От сети When &using external monitor При использовании внешнего монитора On Ac От сети MainWindow LXQt Powermanagement Configuration Настройка энергопотребления LXQt Power Management Settings Battery Батарея Lid Крышка Idle idle бездействие QObject Nothing Ничего Lock screen Блокирвать экран Suspend Ждущий режим Hibernate Спящий режим Shutdown Выключить компьютер lxqt-powermanagement-0.10.0/config/translations/lxqt-config-powermanagement_ru_RU.desktop000066400000000000000000000002641261500560600320710ustar00rootroot00000000000000# Translations GenericName[ru_RU]=Настройки управления энергопотреблением Name[ru_RU]=Управление энергопотреблениемlxqt-powermanagement-0.10.0/config/translations/lxqt-config-powermanagement_ru_RU.ts000066400000000000000000000207641261500560600310550ustar00rootroot00000000000000 BatteryWatcherSettings Battery Watcher Settings Настройки наблюдения за батареей E&nable Battery Watcher &Разрешить наблюдение за батареей Warning: Предупреждение: seconds секунд Level is low at: Низкий уровень при: % % Use icons from theme: Использовать значки из темы: Preview Charging Discharging When power is low then: При низком заряде: Show icon: Показывать значок: built in Level: %1% IdlenessWatcherSettings Form Enab&le Idleness Watcher Включить наблюдение за простоем When idle then: При простое: Idle time: Время простоя: minutes минут seconds секунд LidWatcherSettings Form Enable &Lid Watcher Включить наблюдение за крышкой Action when lid is closed Действие при закрытии крышки On Battery От батареи Nothing Ничего Suspend Ждущий режим Hibernate Спящий режим Shut down Выключить On AC От сети When &using external monitor При использовании внешнего монитора On Ac От сети MainWindow LXQt Powermanagement Configuration Настройка энергопотребления LXQt Power Management Settings Battery Батарея Lid Крышка Idle idle бездействие QObject Nothing Ничего Lock screen Блокирвать экран Suspend Ждущий режим Hibernate Спящий режим Shutdown Выключить компьютер lxqt-powermanagement-0.10.0/src/000077500000000000000000000000001261500560600165375ustar00rootroot00000000000000lxqt-powermanagement-0.10.0/src/CMakeLists.txt000066400000000000000000000050171261500560600213020ustar00rootroot00000000000000project(lxqt-powermanagement) set(QTX_LIBRARIES Qt5::Widgets Qt5::DBus Qt5::Svg Qt5::X11Extras) set(SOURCES watcher.cpp batteryhelper.cpp batteryinfoframe.cpp batteryinfodialog.cpp batterywatcher.cpp idlenesswatcher.cpp lid.cpp lidwatcher.cpp main.cpp powermanagementd.cpp trayicon.cpp iconproducer.cpp x11helper.cpp ../config/powermanagementsettings.cpp ) set(UI_FILES batteryinfoframe.ui batteryinfodialog.ui ) set(DESKTOP_FILES_IN lxqt-powermanagement.desktop.in ) qt5_add_dbus_adaptor(SOURCES org.freedesktop.ScreenSaver.xml idlenesswatcher.h IdlenessWatcher ) lxqt_translate_ts(QM_FILES UPDATE_TRANSLATIONS ${UPDATE_TRANSLATIONS} SOURCES ${SOURCES} ${UI_FILES} INSTALL_DIR ${LXQT_TRANSLATIONS_DIR}/${PROJECT_NAME} ) lxqt_app_translation_loader(lxqt-powermanagement_QM_LOADER ${PROJECT_NAME}) # XCB stuff (TODO: move into findXCB) find_package(PkgConfig) pkg_check_modules(PKG_XCB xcb) find_path(XCB_INCLUDE_DIR xcb/xcb.h ${PKG_XCB_INCLUDE_DIRS} ) find_library(XCB_LIBRARY NAMES xcb PATHS ${PKG_XCB_LIBRARY_DIRS} ) pkg_check_modules(PKG_X11_XCB x11-xcb) find_path(X11_XCB_INCLUDE_DIR X11/Xlib-xcb.h ${PKG_X11_XCB_INCLUDE_DIRS} ) find_library(X11_XCB_LIBRARY NAMES X11-xcb PATHS ${PKG_X11_XCB_LIBRARY_DIRS} ) pkg_check_modules(PKG_XCB_SCREENSAVER xcb-screensaver) find_path(XCB_SCREENSAVER_INCLUDE_DIR xcb/screensaver.h ${PKG_XCB_SCREENSAVER_INCLUDE_DIRS} ) find_library(XCB_SCREENSAVER_LIBRARY NAMES xcb-screensaver PATHS ${PKG_XCB_SCREENSAVER_LIBRARY_DIRS} ) pkg_check_modules(PKG_XCB_DPMS xcb-dpms) find_path(XCB_DPMS_INCLUDE_DIR xcb/dpms.h ${PKG_XCB_SCREENSAVER_INCLUDE_DIRS} ) find_library(XCB_DPMS_LIBRARY NAMES xcb-dpms PATHS ${PKG_XCB_DPMS_LIBRARY_DIRS} ) include_directories( ${Qt5Gui_PRIVATE_INCLUDE_DIRS} ${XCB_INCLUDE_DIR} ${X11_XCB_INCLUDE_DIR} ${XCB_SCREENSAVER_INCLUDE_DIR} ${XCB_DPMS_INCLUDE_DIR} ) add_executable(lxqt-powermanagement ${SOURCES} ${RSCS} ${QM_FILES} ${lxqt-powermanagement_QM_LOADER} ${DESKTOP_FILES} ) target_link_libraries(lxqt-powermanagement lxqt ${QTX_LIBRARIES} ${XCB_LIBRARY} ${XCB_SCREENSAVER_LIBRARY} ${XCB_DPMS_LIBRARY} ${X11_XCB_LIBRARY} KF5::Solid ) install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT Runtime ) install(FILES ${DESKTOP_FILES} DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications" COMPONENT Runtime ) lxqt-powermanagement-0.10.0/src/batteryhelper.cpp000066400000000000000000000063221261500560600221200ustar00rootroot00000000000000/* BEGIN_COMMON_COPYRIGHT_HEADER * (c)LGPL2+ * * LXDE-Qt - a lightweight, Qt based, desktop toolset * http://razor-qt.org * * Copyright: 2011 Razor team * Authors: * Christian Surlykke * * This program or library is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General * Public License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA * * END_COMMON_COPYRIGHT_HEADER */ #include #include #include #include #include #include "batteryhelper.h" #include "../config/powermanagementsettings.h" QString BatteryHelper::stateToString(Solid::Battery::ChargeState state) { switch (state) { case Solid::Battery::NoCharge: return tr("Empty"); case Solid::Battery::Discharging: return tr("Discharging"); case Solid::Battery::FullyCharged: return tr("Fully charged"); case Solid::Battery::Charging: default: return tr("Charging"); } } QString BatteryHelper::technologyToString(Solid::Battery::Technology tech) { switch (tech) { case Solid::Battery::LithiumIon: return tr("Lithium ion"); case Solid::Battery::LithiumPolymer: return tr("Lithium polymer"); case Solid::Battery::LithiumIronPhosphate: return tr("Lithium iron phosphate"); case Solid::Battery::LeadAcid: return tr("Lead acid"); case Solid::Battery::NickelCadmium: return tr("Nickel cadmium"); case Solid::Battery::NickelMetalHydride: return tr("Nickel metal hydride"); case Solid::Battery::UnknownTechnology: default: return tr("Unknown"); } } QString BatteryHelper::typeToString(Solid::Battery::BatteryType type) { switch (type) { case Solid::Battery::PdaBattery: return tr("Personal Digital Assistant's battery"); case Solid::Battery::UpsBattery: return tr("Uninterruptible Power Supply's battery"); case Solid::Battery::PrimaryBattery: return tr("Primary battery"); case Solid::Battery::MouseBattery: return tr("Mouse battery"); case Solid::Battery::KeyboardBattery: return tr("Keyboard battery"); case Solid::Battery::KeyboardMouseBattery: return tr("Keyboard and mouse's battery"); case Solid::Battery::CameraBattery: return tr("Camera battery"); case Solid::Battery::PhoneBattery: return tr("Phone battery"); case Solid::Battery::MonitorBattery: return tr("Monitor battery"); case Solid::Battery::UnknownBattery: default: return tr("Unknown battery"); } } lxqt-powermanagement-0.10.0/src/batteryhelper.h000066400000000000000000000026301261500560600215630ustar00rootroot00000000000000/* BEGIN_COMMON_COPYRIGHT_HEADER * (c)LGPL2+ * * LXDE-Qt - a lightweight, Qt based, desktop toolset * http://razor-qt.org * * Copyright: 2011 Razor team * Authors: * Christian Surlykke * * This program or library is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General * Public License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA * * END_COMMON_COPYRIGHT_HEADER */ #ifndef BATTERYHELPER_H #define BATTERYHELPER_H #include #include #include #include class BatteryHelper : public QObject { Q_OBJECT public: static QString stateToString(Solid::Battery::ChargeState state); static QString technologyToString(Solid::Battery::Technology tech); static QString typeToString(Solid::Battery::BatteryType type); }; #endif lxqt-powermanagement-0.10.0/src/batteryinfodialog.cpp000066400000000000000000000023611261500560600227530ustar00rootroot00000000000000/* * Copyright (c) 2014 Christian Surlykke * * This file is part of the LXQt project. * It is distributed under the LGPL 2.1 or later license. * Please refer to the LICENSE file for a copy of the license. */ #include "batteryinfodialog.h" #include "ui_batteryinfodialog.h" #include #include #include BatteryInfoDialog::BatteryInfoDialog(QList batteries, QWidget *parent) : QDialog(parent), ui(new Ui::BatteryInfoDialog) { ui->setupUi(this); setWindowTitle(tr("Battery Info")); if (batteries.size() == 1) { BatteryInfoFrame *batteryInfoFrame = new BatteryInfoFrame(batteries[0]); ui->verticalLayout->insertWidget(0, batteryInfoFrame); } else { QTabWidget *tabWidget = new QTabWidget(this); ui->verticalLayout->insertWidget(0, tabWidget); foreach (Solid::Battery *battery, batteries) { BatteryInfoFrame *batteryInfoFrame = new BatteryInfoFrame(battery); tabWidget->addTab(batteryInfoFrame, "BAT"); } } } BatteryInfoDialog::~BatteryInfoDialog() { delete ui; } void BatteryInfoDialog::toggleShow() { qDebug() << "toggleShow"; isVisible() ? hide() : show(); } lxqt-powermanagement-0.10.0/src/batteryinfodialog.h000066400000000000000000000013071261500560600224170ustar00rootroot00000000000000/* * Copyright (c) 2014 Christian Surlykke * * This file is part of the LXQt project. * It is distributed under the LGPL 2.1 or later license. * Please refer to the LICENSE file for a copy of the license. */ #ifndef BATTERYINFODIALOG_H #define BATTERYINFODIALOG_H #include "batteryinfoframe.h" #include #include #include namespace Ui { class BatteryInfoDialog; } class BatteryInfoDialog : public QDialog { Q_OBJECT public: explicit BatteryInfoDialog(QList batteries, QWidget *parent = 0); ~BatteryInfoDialog(); public slots: void toggleShow(); private: Ui::BatteryInfoDialog *ui; }; #endif // BATTERYINFODIALOG_H lxqt-powermanagement-0.10.0/src/batteryinfodialog.ui000066400000000000000000000026151261500560600226100ustar00rootroot00000000000000 BatteryInfoDialog 0 0 334 301 Dialog Qt::Horizontal QDialogButtonBox::Ok buttonBox accepted() BatteryInfoDialog accept() 248 254 157 274 buttonBox rejected() BatteryInfoDialog reject() 316 260 286 274 lxqt-powermanagement-0.10.0/src/batteryinfoframe.cpp000066400000000000000000000052131261500560600226050ustar00rootroot00000000000000/* BEGIN_COMMON_COPYRIGHT_HEADER * (c)LGPL2+ * * LXDE-Qt - a lightweight, Qt based, desktop toolset * http://razor-qt.org * * Copyright: 2012 Razor team * Authors: * Christian Surlykke * * This program or library is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General * Public License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA * * END_COMMON_COPYRIGHT_HEADER */ #include #include #include "batteryinfoframe.h" #include "batteryhelper.h" #include "ui_batteryinfoframe.h" BatteryInfoFrame::BatteryInfoFrame(Solid::Battery *battery) : QFrame(), mBattery(battery), mUi(new Ui::BatteryInfoFrame) { mUi->setupUi(this); mUi->energyFullDesignValue->setText(QString("%1 Wh").arg(mBattery->energyFullDesign(), 0, 'f', 2)); mUi->typeValue->setText(BatteryHelper::typeToString(mBattery->type())); mUi->technologyValue->setText(BatteryHelper::technologyToString(mBattery->technology())); QString vendor = QString("%1 %2").arg(battery->recallVendor()).arg(battery->serial()); if (vendor.trimmed().isEmpty()) vendor = "Unknown"; mUi->vendorValue->setText(vendor); connect(mBattery, SIGNAL(energyChanged(double, const QString)), this, SLOT(onBatteryChanged())); connect(mBattery, SIGNAL(chargeStateChanged(int, const QString)), this, SLOT(onBatteryChanged())); onBatteryChanged(); } BatteryInfoFrame::~BatteryInfoFrame() { delete mUi; } void BatteryInfoFrame::onBatteryChanged() { mUi->stateValue->setText(BatteryHelper::stateToString(mBattery->chargeState())); mUi->energyFullValue->setText(QString("%1 Wh (%2 %)").arg(mBattery->energyFull(), 0, 'f', 2).arg(mBattery->capacity())); mUi->energyValue->setText(QString("%1 Wh (%2 %)").arg(mBattery->energy(), 0, 'f', 2).arg(mBattery->chargePercent())); mUi->energyRateValue->setText(QString("%1 W").arg(mBattery->energyRate(), 0, 'f', 2)); mUi->voltageValue->setText(QString("%1 V").arg(mBattery->voltage(), 0, 'f', 2)); mUi->temperatureValue->setText(QString("%1 ºC").arg(mBattery->temperature())); } lxqt-powermanagement-0.10.0/src/batteryinfoframe.h000066400000000000000000000026451261500560600222600ustar00rootroot00000000000000/* BEGIN_COMMON_COPYRIGHT_HEADER * (c)LGPL2+ * * LXDE-Qt - a lightweight, Qt based, desktop toolset * http://razor-qt.org * * Copyright: 2012 Razor team * Authors: * Christian Surlykke * * This program or library is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General * Public License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA * * END_COMMON_COPYRIGHT_HEADER */ #ifndef BATTERYINFOFRAME_H #define BATTERYINFOFRAME_H #include #include namespace Ui { class BatteryInfoFrame; } class BatteryInfoFrame : public QFrame { Q_OBJECT public: explicit BatteryInfoFrame(Solid::Battery* battery); ~BatteryInfoFrame(); private slots: void onBatteryChanged(); private: Solid::Battery* mBattery; Ui::BatteryInfoFrame *mUi; }; #endif // BATTERYINFOFRAME_H lxqt-powermanagement-0.10.0/src/batteryinfoframe.ui000066400000000000000000000131211261500560600224350ustar00rootroot00000000000000 BatteryInfoFrame 0 0 277 292 Power Management 6 12 12 12 DELL 00 Primary 12.27 ºC Temperature: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter Type: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter State: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter Charging Energy Full Design: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter 73.26 Wh Energy Full: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter 64.58 Wh (88.2 %) Energy Now: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter 63.41 Wh (98.2 %) Energy rate: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter 15.11 W Lithium ion Technology: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter 12.27 V Voltage: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter Vendor: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter lxqt-powermanagement-0.10.0/src/batterywatcher.cpp000066400000000000000000000124371261500560600223020ustar00rootroot00000000000000/* BEGIN_COMMON_COPYRIGHT_HEADER * (c)LGPL2+ * * LXDE-Qt - a lightweight, Qt based, desktop toolset * http://razor-qt.org * * Copyright: 2012 Razor team * Authors: * Christian Surlykke * * This program or library is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General * Public License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA * * END_COMMON_COPYRIGHT_HEADER */ #include #include #include #include #include #include #include #include #include "batterywatcher.h" #include "../config/powermanagementsettings.h" BatteryWatcher::BatteryWatcher(QObject *parent) : Watcher(parent) { QList devices = Solid::Device::listFromType(Solid::DeviceInterface::Battery, QString()); if (devices.isEmpty()) { LXQt::Notification::notify(tr("No battery!"), tr("LXQt could not find data about any battery - monitoring disabled"), "lxqt-powermanagement"); } foreach (Solid::Device device, devices) { Solid::Battery *battery = device.as(); if (battery->type() != Solid::Battery::PrimaryBattery) { continue; } mBatteries << battery; connect(battery, &Solid::Battery::energyChanged, this, &BatteryWatcher::batteryChanged); connect(battery, &Solid::Battery::chargeStateChanged, this, &BatteryWatcher::batteryChanged); } mBatteryInfoDialog = new BatteryInfoDialog(mBatteries); connect(&mSettings, SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); connect(LXQt::Settings::globalSettings(), SIGNAL(iconThemeChanged()), this, SLOT(settingsChanged())); settingsChanged(); batteryChanged(); } BatteryWatcher::~BatteryWatcher() { } void BatteryWatcher::batteryChanged() { static QTime actionTime; static LXQt::Notification *notification = 0; double totalEnergyFull = 0; double totalEnergyNow = 0; bool discharging = true; double chargeLevel; foreach (Solid::Battery *battery, mBatteries) { totalEnergyFull += battery->energyFull(); totalEnergyNow += battery->energy(); discharging &= (battery->chargeState() == Solid::Battery::Discharging); } chargeLevel = 100 * totalEnergyNow / totalEnergyFull; qDebug() << "BatteryChanged" << "discharging:" << discharging << "chargeLevel:" << chargeLevel << "actionTime:" << actionTime; bool powerLowActionRequired = discharging && chargeLevel < mSettings.getPowerLowLevel() && mSettings.getPowerLowAction() > 0; if (powerLowActionRequired) { if (actionTime.isNull()) actionTime = QTime::currentTime().addMSecs(mSettings.getPowerLowWarningTime() * 1000); if (!notification) { notification = new LXQt::Notification(tr("Power low!"), this); notification->setTimeout(2000); } int milliSecondsToAction = QTime::currentTime().msecsTo(actionTime); if (milliSecondsToAction > 0) { int secondsToAction = milliSecondsToAction / 1000; switch (mSettings.getPowerLowAction()) { case LXQt::Power::PowerSuspend: notification->setBody(tr("Suspending in %1 seconds").arg(secondsToAction)); break; case LXQt::Power::PowerHibernate: notification->setBody(tr("Hibernating in %1 seconds").arg(secondsToAction)); break; case LXQt::Power::PowerShutdown: notification->setBody(tr("Shutting down in %1 seconds").arg(secondsToAction)); break; } notification->update(); QTimer::singleShot(200, this, SLOT(batteryChanged())); } else { doAction(mSettings.getPowerLowAction()); } } else { if (!actionTime.isNull()) actionTime = QTime(); if (notification) { delete notification; notification = 0; } } } void BatteryWatcher::settingsChanged() { if (!mSettings.isShowIcon()) { while (!mTrayIcons.isEmpty()) { mTrayIcons.first()->hide(); mTrayIcons.takeFirst()->deleteLater(); } } else if (mTrayIcons.isEmpty()) { foreach (Solid::Battery *battery, mBatteries) { mTrayIcons.append(new TrayIcon(battery, this)); connect(mTrayIcons.last(), SIGNAL(toggleShowInfo()), mBatteryInfoDialog, SLOT(toggleShow())); mTrayIcons.last()->show(); } } } lxqt-powermanagement-0.10.0/src/batterywatcher.h000066400000000000000000000031221261500560600217360ustar00rootroot00000000000000/* BEGIN_COMMON_COPYRIGHT_HEADER * (c)LGPL2+ * * LXDE-Qt - a lightweight, Qt based, desktop toolset * http://razor-qt.org * * Copyright: 2012 Razor team * Authors: * Christian Surlykke * * This program or library is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General * Public License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA * * END_COMMON_COPYRIGHT_HEADER */ #ifndef BATTERYWATCHER_H #define BATTERYWATCHER_H #include "watcher.h" #include "trayicon.h" #include "batteryinfodialog.h" #include "../config/powermanagementsettings.h" #include class BatteryWatcher : public Watcher { Q_OBJECT public: explicit BatteryWatcher(QObject *parent = 0); virtual ~BatteryWatcher(); private slots: void batteryChanged(); void settingsChanged(); private: QList mBatteries; QList mTrayIcons; PowerManagementSettings mSettings; BatteryInfoDialog *mBatteryInfoDialog; }; #endif // BATTERYWATCHER_H lxqt-powermanagement-0.10.0/src/iconproducer.cpp000066400000000000000000000211031261500560600217340ustar00rootroot00000000000000/* * Copyright (c) 2014, 2015 Christian Surlykke, Paulo Lieuthier * * This file is part of the LXQt project. * It is distributed under the LGPL 2.1 or later license. * Please refer to the LICENSE file for a copy of the license. */ #include "iconproducer.h" #include #include #include #include #include #include IconProducer::IconProducer(Solid::Battery *battery, QObject *parent) : QObject(parent) { connect(battery, &Solid::Battery::chargeStateChanged, this, &IconProducer::updateState); connect(battery, &Solid::Battery::chargePercentChanged, this, &IconProducer::updateChargePercent); connect(&mSettings, SIGNAL(settingsChanged()), this, SLOT(update())); mChargePercent = battery->chargePercent(); mState = battery->chargeState(); themeChanged(); } IconProducer::IconProducer(QObject *parent): QObject(parent) { themeChanged(); update(); } void IconProducer::updateChargePercent(int newChargePercent) { mChargePercent = newChargePercent; update(); } void IconProducer::updateState(int newState) { mState = (Solid::Battery::ChargeState) newState; update(); } void IconProducer::update() { QString newIconName; if (mSettings.isUseThemeIcons()) { QMap *levelNameMap = (mState == Solid::Battery::Discharging ? &mLevelNameMapDischarging : &mLevelNameMapCharging); foreach (float level, levelNameMap->keys()) { if (level >= mChargePercent) { newIconName = levelNameMap->value(level); break; } } } if (mSettings.isUseThemeIcons() && newIconName == mIconName) return; mIconName = newIconName; mIcon = mSettings.isUseThemeIcons() ? QIcon::fromTheme(mIconName) : circleIcon(); emit iconChanged(); } void IconProducer::themeChanged() { /* * We maintain specific charge-level-to-icon-name mappings for Oxygen and Awoken and * asume all other themes adhere to the freedesktop standard. * This is certainly not true, and as bug reports come in stating that * this and that theme is not working we will probably have to add new * mappings beside Oxygen and Awoken */ mLevelNameMapDischarging.clear(); mLevelNameMapCharging.clear(); if (QIcon::themeName() == "oxygen") { // Means: // Use 'battery-low' for levels up to 10 // - 'battery-caution' for levels between 10 and 20 // - 'battery-040' for levels between 20 and 40, etc.. mLevelNameMapDischarging[10] = "battery-low"; mLevelNameMapDischarging[20] = "battery-caution"; mLevelNameMapDischarging[40] = "battery-040"; mLevelNameMapDischarging[60] = "battery-060"; mLevelNameMapDischarging[80] = "battery-080"; mLevelNameMapDischarging[101] = "battery-100"; mLevelNameMapCharging[10] = "battery-charging-low"; mLevelNameMapCharging[20] = "battery-charging-caution"; mLevelNameMapCharging[40] = "battery-charging-040"; mLevelNameMapCharging[60] = "battery-charging-060"; mLevelNameMapCharging[80] = "battery-charging-080"; mLevelNameMapCharging[101] = "battery-charging"; } else if (QIcon::themeName().startsWith("AwOken")) // AwOken, AwOkenWhite, AwOkenDark { mLevelNameMapDischarging[5] = "battery-000"; mLevelNameMapDischarging[30] = "battery-020"; mLevelNameMapDischarging[50] = "battery-040"; mLevelNameMapDischarging[70] = "battery-060"; mLevelNameMapDischarging[95] = "battery-080"; mLevelNameMapDischarging[101] = "battery-100"; mLevelNameMapCharging[5] = "battery-000-charging"; mLevelNameMapCharging[30] = "battery-020-charging"; mLevelNameMapCharging[50] = "battery-040-charging"; mLevelNameMapCharging[70] = "battery-060-charging"; mLevelNameMapCharging[95] = "battery-080-charging"; mLevelNameMapCharging[101] = "battery-100-charging"; } else // As default we fall back to the freedesktop scheme. { mLevelNameMapDischarging[3] = "battery-empty"; mLevelNameMapDischarging[10] = "battery-caution"; mLevelNameMapDischarging[50] = "battery-low"; mLevelNameMapDischarging[90] = "battery-good"; mLevelNameMapDischarging[101] = "battery-full"; mLevelNameMapCharging[3] = "battery-empty"; mLevelNameMapCharging[10] = "battery-caution-charging"; mLevelNameMapCharging[50] = "battery-low-charging"; mLevelNameMapCharging[90] = "battery-good-charging"; mLevelNameMapCharging[101] = "battery-full-charging"; } update(); } QIcon& IconProducer::circleIcon() { static QMap > cache; int chargeLevelAsInt = (int) (mChargePercent + 0.49); if (!cache[mState].contains(chargeLevelAsInt)) cache[mState][chargeLevelAsInt] = buildCircleIcon(mState, mChargePercent); return cache[mState][chargeLevelAsInt]; } QIcon IconProducer::buildCircleIcon(Solid::Battery::ChargeState state, int chargeLevel) { static QString svg_template = "\n" "\n" "\n" " \n" " \n" " \n" " \n" "\n" "\n" "\n" "\n" "\n" "\n" " STATE_MARKER\n" "\n" ""; static QString filledCircle = ""; static QString plus = ""; static QString minus = ""; static QString hollowCircle = ""; QString svg = svg_template; if (chargeLevel > 99) chargeLevel = 99; double angle; QString sweepFlag; if (state == Solid::Battery::Discharging) { angle = M_PI_2 + 2 * M_PI * chargeLevel/100; sweepFlag = "0"; } else { angle = M_PI_2 - 2 *M_PI * chargeLevel/100; sweepFlag = "1"; } double circle_endpoint_x = 80.0 * cos(angle) + 100; double circle_endpoint_y = -80.0 * sin(angle) + 100; QString largeArgFlag = chargeLevel > 50 ? "1" : "0"; svg.replace(QString("END_X"), QString::number(circle_endpoint_x)); svg.replace(QString("END_Y"), QString::number(circle_endpoint_y)); svg.replace(QString("LARGE_ARC_FLAG"), largeArgFlag); svg.replace(QString("SWEEP_FLAG"), sweepFlag); switch (state) { case Solid::Battery::FullyCharged: svg.replace("STATE_MARKER", filledCircle); break; case Solid::Battery::Charging: svg.replace("STATE_MARKER", plus); break; case Solid::Battery::Discharging: svg.replace("STATE_MARKER", minus); break; default: svg.replace("STATE_MARKER", hollowCircle); } if (state != Solid::Battery::FullyCharged && state != Solid::Battery::Charging && chargeLevel < mSettings.getPowerLowLevel() + 30) { if (chargeLevel <= mSettings.getPowerLowLevel() + 10) svg.replace("RED_OPACITY", "1"); else svg.replace("RED_OPACITY", QString::number((mSettings.getPowerLowLevel() + 30 - chargeLevel)/20.0)); } else svg.replace("RED_OPACITY", "0"); // qDebug() << svg; // Paint the svg on a pixmap and create an icon from that. QSvgRenderer render(svg.toLatin1()); QPixmap pixmap(render.defaultSize()); pixmap.fill(QColor(0,0,0,0)); QPainter painter(&pixmap); render.render(&painter); return QIcon(pixmap); } lxqt-powermanagement-0.10.0/src/iconproducer.h000066400000000000000000000021601261500560600214030ustar00rootroot00000000000000/* * Copyright (c) 2014 Christian Surlykke * * This file is part of the LXQt project. * It is distributed under the LGPL 2.1 or later license. * Please refer to the LICENSE file for a copy of the license. */ #ifndef ICONPRODUCER_H #define ICONPRODUCER_H #include #include #include #include "../config/powermanagementsettings.h" #include class IconProducer : public QObject { Q_OBJECT public: IconProducer(Solid::Battery* battery, QObject *parent = 0); IconProducer(QObject *parent = 0); QIcon mIcon; QString mIconName; signals: void iconChanged(); public slots: void updateChargePercent(int newChargePercent); void updateState(int newState); void update(); void themeChanged(); private: QIcon &circleIcon(); QIcon buildCircleIcon(Solid::Battery::ChargeState state, int chargeLevel); int mChargePercent; Solid::Battery::ChargeState mState; PowerManagementSettings mSettings; QMap mLevelNameMapCharging; QMap mLevelNameMapDischarging; }; #endif // ICONPRODUCER_H lxqt-powermanagement-0.10.0/src/idlenesswatcher.cpp000066400000000000000000000217761261500560600224440ustar00rootroot00000000000000/* BEGIN_COMMON_COPYRIGHT_HEADER * (c)LGPL2+ * * LXDE-Qt - a lightweight, Qt based, desktop toolset * http://razor-qt.org * * Copyright (C) 2013 Alec Moskvin * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * END_COMMON_COPYRIGHT_HEADER */ #include #include #include #include #include #include #include "screensaveradaptor.h" #include "idlenesswatcher.h" #include "x11helper.h" /* lockers: * * xlock(more) * i3lock -n * slock * alock * xtrlock */ IdlenessWatcher::IdlenessWatcher(QObject* parent): Watcher(parent), mPSettings(), mErrorNotification(tr("LXQt Idleness watcher failed to start")), mDBusWatcher(this), mInhibitorCookie(0), mIsLocked(false) { qDebug() << "Starting idlenesswatcher"; mConn = X11Helper::connection(); xcb_prefetch_extension_data(mConn, &xcb_screensaver_id); xcb_prefetch_extension_data(mConn, &xcb_dpms_id); xcb_screensaver_query_version_cookie_t verCookie = xcb_screensaver_query_version_unchecked(mConn, XCB_SCREENSAVER_MAJOR_VERSION, XCB_SCREENSAVER_MINOR_VERSION); xcb_dpms_get_version_cookie_t dpmsVerCookie = xcb_dpms_get_version_unchecked(mConn, XCB_DPMS_MAJOR_VERSION, XCB_DPMS_MINOR_VERSION); // Note that XCB is asynchronous, so we want to make requests ASAP and get the responses as late as possible. mScreen = screenOfDisplay(mConn, 0); mErrorNotification.setUrgencyHint(LXQt::Notification::UrgencyCritical); mErrorNotification.setIcon("object-unlocked"); mErrorNotification.setTimeout(0); new ScreenSaverAdaptor(this); QDBusConnection sessionBus = QDBusConnection::sessionBus(); if (!sessionBus.registerService("org.freedesktop.ScreenSaver") || !sessionBus.registerObject("/ScreenSaver", this)) { mErrorNotification.setBody(tr("D-Bus interface org.freedesktop.ScreenSaver is already registered")); mErrorNotification.update(); qWarning() << "ERROR: D-Bus interface org.freedesktop.ScreenSaver is already registered"; } mDBusWatcher.setConnection(QDBusConnection::sessionBus()); mDBusWatcher.setWatchMode(QDBusServiceWatcher::WatchForUnregistration); connect(&mTimer, SIGNAL(timeout()), SLOT(idleTimeout())); connect(&mPSettings, SIGNAL(settingsChanged()), SLOT(restartTimer())); connect(this, SIGNAL(done()), this, SLOT(restartTimer())); connect(&mDBusWatcher, SIGNAL(serviceUnregistered(QString)), SLOT(serviceUnregistered(QString))); connect(&mLockProcess, SIGNAL(finished(int,QProcess::ExitStatus)), SLOT(screenUnlocked(int,QProcess::ExitStatus))); connect(&mErrorNotification, SIGNAL(actionActivated(int)), SLOT(notificationAction(int))); // Get XCB responses ... const xcb_query_extension_reply_t* extReply = xcb_get_extension_data(mConn, &xcb_screensaver_id); const xcb_query_extension_reply_t* dpmsExtReply = xcb_get_extension_data(mConn, &xcb_dpms_id); xcb_screensaver_query_version_reply_t* verReply = xcb_screensaver_query_version_reply(mConn, verCookie, NULL); xcb_dpms_get_version_reply_t* dpmsVerReply = xcb_dpms_get_version_reply(mConn, dpmsVerCookie, NULL); if (mScreen && extReply && extReply->present && dpmsExtReply && dpmsExtReply->present && verReply && dpmsVerReply && verReply->server_major_version == XCB_SCREENSAVER_MAJOR_VERSION && verReply->server_minor_version >= XCB_SCREENSAVER_MINOR_VERSION //&& dpmsVerReply->server_major_version == XCB_DPMS_MAJOR_VERSION //&& dpmsVerReply->server_minor_version >= XCB_DPMS_MINOR_VERSION ) { free(verReply); free(dpmsVerReply); } else { mErrorNotification.setBody(tr("The X11 Screensaver extension is not usable")); mErrorNotification.update(); if (verReply) free(verReply); qCritical() << "ERROR: Can't use the X11 Screensaver Extension!"; } mErrorNotification.setActions(QStringList(tr("Configure..."))); qDebug() << "LXQt Screenlocker started."; qDebug() << "timeout:" << getMaxIdleTimeoutMs() << "ms, lock command:" << mLockCommand; restartTimer(); } xcb_screen_t* IdlenessWatcher::screenOfDisplay(xcb_connection_t* conn, int screen) { xcb_screen_iterator_t iter = xcb_setup_roots_iterator(xcb_get_setup(conn)); for (; iter.rem; --screen, xcb_screen_next(&iter)) if (screen == 0) return iter.data; return NULL; } uint IdlenessWatcher::getIdleTimeMs() { xcb_screensaver_query_info_cookie_t infoCookie = xcb_screensaver_query_info_unchecked(mConn, mScreen->root); xcb_screensaver_query_info_reply_t* infoReply = xcb_screensaver_query_info_reply(mConn, infoCookie, NULL); if (!infoReply) { qWarning() << "Bad reply from X11 Screensaver"; return 0; } uint msSinceUserInput = infoReply->ms_since_user_input; free(infoReply); return msSinceUserInput; } uint IdlenessWatcher::getMaxIdleTimeoutMs() { return 1000 * mPSettings.getIdlenessTimeSecs(); } void IdlenessWatcher::idleTimeout() { uint msSinceUserInput = getIdleTimeMs(); if (msSinceUserInput >= getMaxIdleTimeoutMs()) { mTimer.stop(); doAction(mPSettings.getIdlenessAction()); } else mTimer.start(getMaxIdleTimeoutMs() - msSinceUserInput); } void IdlenessWatcher::restartTimer() { qDebug() << ">>> Timer Restarted, waiting: " << getMaxIdleTimeoutMs() << "msecs"; mTimer.start(getMaxIdleTimeoutMs()); } void IdlenessWatcher::screenUnlocked(int exitCode, QProcess::ExitStatus exitStatus) { mIsLocked = false; emit ActiveChanged(false); if (exitCode == 0) { restartTimer(); } else { mErrorNotification.setSummary(tr("ERROR: Screen unlocked")); if (exitStatus == QProcess::NormalExit) mErrorNotification.setBody(tr("Locking program \"%1\" exited with error code %2").arg(mLockCommand).arg(exitCode)); else mErrorNotification.setBody(tr("Locking program \"%1\" crashed with error code %2").arg(mLockCommand).arg(exitCode)); mErrorNotification.update(); mTimer.stop(); connect(&mErrorNotification, SIGNAL(notificationClosed(CloseReason)), SLOT(idleTimeout())); } } void IdlenessWatcher::notificationAction(int num) { switch (num) { case 0: // "Configure" QProcess::startDetached("lxqt-config-screenlocker"); } } void IdlenessWatcher::serviceUnregistered(const QString& service) { for (QMutableMapIterator iter(mInhibitors); iter.hasNext();) { if (iter.next().value() == service) { qDebug() << "Service unregistered:" << iter.value(); mDBusWatcher.removeWatchedService(iter.value()); iter.remove(); } } if (mInhibitors.isEmpty()) restartTimer(); } /* ---------- D-Bus methods ---------- */ void IdlenessWatcher::Lock() { // lockScreen(); } uint IdlenessWatcher::GetSessionIdleTime() { return getIdleTimeMs() / 1000; } uint IdlenessWatcher::GetActiveTime() { if (!mIsLocked) return 0; return mLockTime.secsTo(QDateTime::currentDateTime()); } bool IdlenessWatcher::GetActive() { return mIsLocked; } bool IdlenessWatcher::SetActive(bool activate) { //if (!activate) return false; //return lockScreen(); } void IdlenessWatcher::SimulateUserActivity() { restartTimer(); } uint IdlenessWatcher::Inhibit(const QString& applicationName, const QString& reasonForInhibit) { mInhibitorCookie++; QString service(this->message().service()); qDebug() << "*** Inhibit by" << applicationName << ":" << reasonForInhibit << ". Service:" << service << "->" << mInhibitorCookie; mDBusWatcher.addWatchedService(service); qDebug() << mDBusWatcher.watchedServices(); mInhibitors.insert(mInhibitorCookie, service); mTimer.stop(); return mInhibitorCookie; } void IdlenessWatcher::UnInhibit(uint cookie) { qDebug() << "*** Uninhibit" << cookie; mDBusWatcher.removeWatchedService(mInhibitors.value(cookie)); mInhibitors.remove(cookie); if (mInhibitors.isEmpty()) restartTimer(); } uint IdlenessWatcher::Throttle(const QString& applicationName, const QString& reasonForThrottle) { Q_UNUSED(applicationName); Q_UNUSED(reasonForThrottle); return 0; } void IdlenessWatcher::UnThrottle(uint cookie) { Q_UNUSED(cookie); } lxqt-powermanagement-0.10.0/src/idlenesswatcher.h000066400000000000000000000051641261500560600221020ustar00rootroot00000000000000/* BEGIN_COMMON_COPYRIGHT_HEADER * (c)LGPL2+ * * LXDE-Qt - a lightweight, Qt based, desktop toolset * http://razor-qt.org * * Copyright (C) 2013 Alec Moskvin * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * END_COMMON_COPYRIGHT_HEADER */ #ifndef IDLENESSWATCHER_H #define IDLENESSWATCHER_H #include #include #include #include #include #include #include #include #include #include "../config/powermanagementsettings.h" #include "watcher.h" class IdlenessWatcher : public Watcher, protected QDBusContext { Q_OBJECT public: explicit IdlenessWatcher(QObject* parent = 0); signals: void ActiveChanged(bool in0); public slots: void Lock(); uint GetSessionIdleTime(); uint GetActiveTime(); bool GetActive(); bool SetActive(bool activate); void SimulateUserActivity(); uint Inhibit(const QString& applicationName, const QString& reasonForInhibit); void UnInhibit(uint cookie); uint Throttle(const QString& applicationName, const QString& reasonForThrottle); void UnThrottle(uint cookie); private slots: void idleTimeout(); void screenUnlocked(int exitCode, QProcess::ExitStatus exitStatus); void notificationAction(int num); void serviceUnregistered(const QString& service); void restartTimer(); private: uint getIdleTimeMs(); uint getMaxIdleTimeoutMs(); static xcb_screen_t* screenOfDisplay(xcb_connection_t* mConn, int screen); PowerManagementSettings mPSettings; QTimer mTimer; QProcess mLockProcess; LXQt::Notification mErrorNotification; QString mLockCommand; QDateTime mLockTime; QMap mInhibitors; QDBusServiceWatcher mDBusWatcher; xcb_connection_t* mConn; xcb_screen_t* mScreen; uint mInhibitorCookie; bool mIsLocked; bool mTurnOffDisplay; }; #endif // IDLENESSWATCHER_H lxqt-powermanagement-0.10.0/src/lid.cpp000066400000000000000000000052171261500560600200200ustar00rootroot00000000000000/* BEGIN_COMMON_COPYRIGHT_HEADER * (c)LGPL2+ * * LXDE-Qt - a lightweight, Qt based, desktop toolset * http://razor-qt.org * * Copyright: 2011 Razor team * Authors: * Christian Surlykke * * This program or library is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General * Public License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA * * END_COMMON_COPYRIGHT_HEADER */ #include #include #include #include #include "lid.h" Lid::Lid() { mUPowerInterface = new QDBusInterface("org.freedesktop.UPower", "/org/freedesktop/UPower", "org.freedesktop.UPower", QDBusConnection::systemBus(), this); mUPowerPropertiesInterface = new QDBusInterface("org.freedesktop.UPower", "/org/freedesktop/UPower", "org.freedesktop.DBus.Properties", QDBusConnection::systemBus(), this); if (!QDBusConnection::systemBus().connect("org.freedesktop.UPower", "/org/freedesktop/UPower", "org.freedesktop.DBus.Properties", "PropertiesChanged", this, SLOT(uPowerChange()))) qDebug() << "Could not connect to org.freedesktop.DBus.Properties.PropertiesChanged()"; mIsClosed = mUPowerPropertiesInterface->property("LidIsClosed").toBool(); } bool Lid::haveLid() { return mUPowerInterface->property("LidIsPresent").toBool(); } bool Lid::onBattery() { return mUPowerInterface->property("OnBattery").toBool(); } void Lid::uPowerChange() { bool newIsClosed = mUPowerInterface->property("LidIsClosed").toBool(); if (newIsClosed != mIsClosed) { mIsClosed = newIsClosed; emit changed(mIsClosed); } } lxqt-powermanagement-0.10.0/src/lid.h000066400000000000000000000026261261500560600174660ustar00rootroot00000000000000/* BEGIN_COMMON_COPYRIGHT_HEADER * (c)LGPL2+ * * LXDE-Qt - a lightweight, Qt based, desktop toolset * http://razor-qt.org * * Copyright: 2011 Razor team * Authors: * Christian Surlykke * * This program or library is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General * Public License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA * * END_COMMON_COPYRIGHT_HEADER */ #ifndef LID_H #define LID_H #include class Lid : public QObject { Q_OBJECT signals: void changed(bool closed); public: Lid(); bool haveLid(); bool onBattery(); bool isClosed() { return mIsClosed; } private: bool mIsClosed; QDBusInterface *mUPowerInterface; QDBusInterface *mUPowerPropertiesInterface; private slots: void uPowerChange(); }; #endif // LID_H lxqt-powermanagement-0.10.0/src/lidwatcher.cpp000066400000000000000000000063621261500560600214000ustar00rootroot00000000000000/* BEGIN_COMMON_COPYRIGHT_HEADER * (c)LGPL2+ * * LXDE-Qt - a lightweight, Qt based, desktop toolset * http://razor-qt.org * * Copyright: 2012 Razor team * Authors: * Christian Surlykke * * This program or library is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General * Public License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA * * END_COMMON_COPYRIGHT_HEADER */ #include #include #include #include #include #include #include "lidwatcher.h" #include "../config/powermanagementsettings.h" LidWatcher::LidWatcher(QObject *parent) : Watcher(parent) { inhibitSystemdLogin(); connect(&mLid, SIGNAL(changed(bool)), this, SLOT(lidChanged(bool))); } LidWatcher::~LidWatcher(){ } void LidWatcher::lidChanged(bool closed) { if (closed) { doAction(action()); } } int LidWatcher::action() { if (mSettings.isEnableExtMonLidClosedActions() && externalMonitorPlugged()) { if (mLid.onBattery()) { return mSettings.getLidClosedExtMonAction(); } else { return mSettings.getLidClosedExtMonAcAction(); } } else { if (mLid.onBattery()) { return mSettings.getLidClosedAction(); } else { return mSettings.getLidClosedAcAction(); } } } bool LidWatcher::externalMonitorPlugged() { int monitorCount = 0; QProcess xrandr(this); xrandr.start("xrandr", QIODevice::ReadOnly); xrandr.waitForFinished(1000); if (xrandr.exitCode() != 0) { return false; // Well, what to do? } QTextStream xrandr_stdout(&xrandr); while (!xrandr_stdout.atEnd()) { QString line = xrandr_stdout.readLine(); qDebug() << ">>" << line; if (line.indexOf(" connected", 0) > -1) { monitorCount++; } } qDebug() << "monitorCount: " << monitorCount; return monitorCount >= 2; } void LidWatcher::inhibitSystemdLogin() { QDBusInterface manager("org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.login1.Manager", QDBusConnection::systemBus(), this); QDBusReply reply = manager.call("Inhibit", "handle-lid-switch", "lxqt-powermanagment", "LidWatcher is in da house!", "block"); if (reply.isValid()) { logindLock = reply.value(); qDebug() << "Inhibit got:" << logindLock.fileDescriptor(); } else { qDebug() << "Error from inhibit:" << reply.error(); } } lxqt-powermanagement-0.10.0/src/lidwatcher.h000066400000000000000000000031721261500560600210410ustar00rootroot00000000000000/* BEGIN_COMMON_COPYRIGHT_HEADER * (c)LGPL2+ * * LXDE-Qt - a lightweight, Qt based, desktop toolset * http://razor-qt.org * * Copyright: 2012 Razor team * Authors: * Christian Surlykke * * This program or library is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General * Public License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA * * END_COMMON_COPYRIGHT_HEADER */ #ifndef LIDWATCHER_H #define LIDWATCHER_H #include #include #include #include #include "../config/powermanagementsettings.h" #include "watcher.h" #include "lid.h" class LidWatcher : public Watcher { Q_OBJECT public: explicit LidWatcher(QObject *parent = 0); virtual ~LidWatcher(); private slots: void lidChanged(bool closed); private: int action(); bool externalMonitorPlugged(); void inhibitSystemdLogin(); Lid mLid; LXQt::Power mLXQtPower; PowerManagementSettings mSettings; QDBusUnixFileDescriptor logindLock; }; #endif // LIDWATCHER_H lxqt-powermanagement-0.10.0/src/main.cpp000066400000000000000000000033401261500560600201670ustar00rootroot00000000000000/* BEGIN_COMMON_COPYRIGHT_HEADER * (c)LGPL2+ * * LXDE-Qt - a lightweight, Qt based, desktop toolset * * Authors: * Christian Surlykke * * This program or library is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General * Public License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA * * END_COMMON_COPYRIGHT_HEADER */ #include #include #include #include "powermanagementd.h" int main(int argc, char *argv[]) { LXQt::Application a(argc, argv); a.setQuitOnLastWindowClosed(false); // To ensure only one instance of lxqt-powermanagement is running we register as a DBus service and refuse to run // if not able to do so. // We do not register any object as we don't have any dbus-operations to expose. if (! QDBusConnection::sessionBus().registerService("org.lxqt.lxqt-powermanagement")) { qWarning() << "Unable to register 'org.lxqt.lxqt-powermanagement' service - is another instance of lxqt-powermanagement running?"; return 1; } else { PowerManagementd powerManagementd; return a.exec(); } } lxqt-powermanagement-0.10.0/src/org.freedesktop.ScreenSaver.xml000066400000000000000000000026301261500560600246020ustar00rootroot00000000000000 lxqt-powermanagement-0.10.0/src/powermanagementd.cpp000066400000000000000000000067371261500560600226150ustar00rootroot00000000000000/* BEGIN_COMMON_COPYRIGHT_HEADER * (c)LGPL2+ * * LXDE-Qt - a lightweight, Qt based, desktop toolset * * Authors: * Christian Surlykke * * This program or library is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General * Public License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA * * END_COMMON_COPYRIGHT_HEADER */ #include #include #include "batteryhelper.h" #include "powermanagementd.h" #include "../config/powermanagementsettings.h" #include "idlenesswatcher.h" #include "lidwatcher.h" #include "batterywatcher.h" #define CURRENT_RUNCHECK_LEVEL 1 PowerManagementd::PowerManagementd() : mBatterywatcherd(0), mLidwatcherd(0), mIdlenesswatcherd(0), mSettings() { connect(&mSettings, SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); settingsChanged(); if (mSettings.getRunCheckLevel() < CURRENT_RUNCHECK_LEVEL) { performRunCheck(); mSettings.setRunCheckLevel(CURRENT_RUNCHECK_LEVEL); } } PowerManagementd::~PowerManagementd() { } void PowerManagementd::settingsChanged() { if (mSettings.isBatteryWatcherEnabled() && !mBatterywatcherd) mBatterywatcherd = new BatteryWatcher(this); else if (mBatterywatcherd && ! mSettings.isBatteryWatcherEnabled()) { mBatterywatcherd->deleteLater(); mBatterywatcherd = 0; } if (mSettings.isLidWatcherEnabled() && !mLidwatcherd) { mLidwatcherd = new LidWatcher(this); } else if (mLidwatcherd && ! mSettings.isLidWatcherEnabled()) { mLidwatcherd->deleteLater(); mLidwatcherd = 0; } if (mSettings.isIdlenessWatcherEnabled() && !mIdlenesswatcherd) { mIdlenesswatcherd = new IdlenessWatcher(this); } else if (mIdlenesswatcherd && !mSettings.isIdlenessWatcherEnabled()) { mIdlenesswatcherd->deleteLater(); mIdlenesswatcherd = 0; } } void PowerManagementd::runConfigure() { mNotification.close(); QProcess::startDetached("lxqt-config-powermanagement"); } void PowerManagementd::performRunCheck() { mSettings.setLidWatcherEnabled(Lid().haveLid()); bool hasBattery = false; foreach (Solid::Device device, Solid::Device::listFromType(Solid::DeviceInterface::Battery, QString())) if (device.as()->type() == Solid::Battery::PrimaryBattery) hasBattery = true; mSettings.setBatteryWatcherEnabled(hasBattery); mSettings.setIdlenessWatcherEnabled(true); mSettings.sync(); mNotification.setSummary(tr("Power Management")); mNotification.setBody(tr("You are running LXQt Power Management for the first time.\nYou can configure it from settings... ")); mNotification.setActions(QStringList() << tr("Configure...")); mNotification.setTimeout(10000); connect(&mNotification, SIGNAL(actionActivated(int)), SLOT(runConfigure())); mNotification.update(); } lxqt-powermanagement-0.10.0/src/powermanagementd.h000066400000000000000000000015541261500560600222520ustar00rootroot00000000000000/* * Copyright (c) 2014 Christian Surlykke * * This file is part of the LXQt project. * It is distributed under the LGPL 2.1 or later license. * Please refer to the LICENSE file for a copy of the license. */ #ifndef POWERMANAGEMENTD_H #define POWERMANAGEMENTD_H #include #include "../config/powermanagementsettings.h" class BatteryWatcher; class LidWatcher; class IdlenessWatcher; class PowerManagementd : public QObject { Q_OBJECT public: PowerManagementd(); virtual ~PowerManagementd(); private slots: void settingsChanged(); void runConfigure(); private: void performRunCheck(); BatteryWatcher* mBatterywatcherd; LidWatcher* mLidwatcherd; IdlenessWatcher* mIdlenesswatcherd; PowerManagementSettings mSettings; LXQt::Notification mNotification; }; #endif /* POWERMANAGEMENTD_H */ lxqt-powermanagement-0.10.0/src/translations/000077500000000000000000000000001261500560600212605ustar00rootroot00000000000000lxqt-powermanagement-0.10.0/src/translations/lxqt-powermanagement.ts000066400000000000000000000271301261500560600260120ustar00rootroot00000000000000 BatteryHelper Empty Discharging Fully charged Charging Lithium ion Lithium polymer Lithium iron phosphate Lead acid Nickel cadmium Nickel metal hydride Unknown Personal Digital Assistant's battery Uninterruptible Power Supply's battery Primary battery Mouse battery Keyboard battery Keyboard and mouse's battery Camera battery Phone battery Monitor battery Unknown battery BatteryInfoDialog Dialog Battery Info BatteryInfoFrame Power Management Temperature: Type: State: Energy Full Design: Energy Full: Energy Now: Energy rate: Technology: Voltage: Vendor: BatteryWatcher No battery! LXQt could not find data about any battery - monitoring disabled Power low! Suspending in %1 seconds Hibernating in %1 seconds Shutting down in %1 seconds IdlenessWatcher LXQt Idleness watcher failed to start D-Bus interface org.freedesktop.ScreenSaver is already registered The X11 Screensaver extension is not usable Configure... ERROR: Screen unlocked Locking program "%1" exited with error code %2 Locking program "%1" crashed with error code %2 PowerManagementd Power Management You are running LXQt Power Management for the first time. You can configure it from settings... Configure... TrayIcon Configure About Disable icon <p> <b>LXQt Power Management</b><br/> - Power Management for the LXQt Desktop Environment</p><p> Authors:<br/> &nbsp; Christian Surlykke, Alec Moskvin<br/> &nbsp; - and others from the Razor and LXQt projects</p><p> Copyright &copy; 2012-2014</p> LXQt Power Management info The LXQt Power Management tray icon can be (re)enabled in <i>lxqt-config-powermanagement</i> Configure now lxqt-powermanagement-0.10.0/src/translations/lxqt-powermanagement_el.ts000066400000000000000000000435561261500560600265040ustar00rootroot00000000000000 Battery Charging Φόρτιση Discharging Αποφόρτιση Empty Άδεια Fully charged Γεμάτη Pending charge Φορτίζεται Pending discharge Αποφορτίζεται Unknown Άγνωστο BatteryHelper Empty Άδεια Discharging Αποφόρτιση Fully charged Γεμάτη Charging Φόρτιση Lithium ion Ιόντων λιθίου Lithium polymer Πολυμερούς λιθίου Lithium iron phosphate Λίθιου Φωσφορικού άλατος σιδήρου Lead acid Μολύβδου οξέος Nickel cadmium Νικελίου καδμίου Nickel metal hydride Υβριδική νικελίου μετάλλου Unknown Personal Digital Assistant's battery Uninterruptible Power Supply's battery Primary battery Mouse battery Keyboard battery Keyboard and mouse's battery Camera battery Phone battery Monitor battery Unknown battery BatteryInfo Power Management Διαχείριση ενέργειας Battery info Πληροφορίες της μπαταρίας Energy Now: Η τρέχουσα ενέργεια: Updated: Ενημερωμένη: Technology: Τεχνολογία: Model: Μοντέλο: Energy rate: Ρυθμός ενέργειας: Voltage: Τάση: Energy Full, Design: Πλήρης ενέργεια, σχεδιασμός: Energy Full: Πλήρης ενέργεια: State: Κατάσταση: Lithium ion Ιόντων λιθίου Lithium polymer Πολυμερούς λιθίου Lithium iron phosphate Λίθιου Φωσφορικού άλατος σιδήρου Lead acid Μολύβδου οξέος Nickel cadmium Νικελίου καδμίου Nickel metal hydride Υβριδική νικελίου μετάλλου Unknown Άγνωστη BatteryInfoDialog Dialog Battery Info BatteryInfoFrame Power Management Διαχείριση ενέργειας Temperature: Type: State: Κατάσταση: Energy Full Design: Energy Full: Πλήρης ενέργεια: Energy Now: Η τρέχουσα ενέργεια: Energy rate: Ρυθμός ενέργειας: Technology: Τεχνολογία: Voltage: Τάση: Vendor: BatteryWatcher No battery! Καμιά μπαταρία! LXQt could not find data about any battery - monitoring disabled Το LXQT δεν μπόρεσε να βρει δεδομένα για οποιαδήποτε μπαταρία - η εποπτεία απενεργοποιήθηκε Power low! Η ενέργεια είναι χαμηλή! Suspending in %1 seconds Αναστολή σε %1 δευτερόλεπτα Hibernating in %1 seconds Νάρκωση σε %1 δευτερόλεπτα Shutting down in %1 seconds Τερματισμός σε %1 δευτερόλεπτα IdlenessWatcher LXQt Idleness watcher failed to start Η εκκίνηση του επόπτη αδράνειας του LXQt απέτυχε D-Bus interface org.freedesktop.ScreenSaver is already registered Η διεπαφή του D-Bus org.freedesktop.ScreenSaver έχει καταχωρηθεί ήδη The X11 Screensaver extension is not usable Η επέκταση της προστασίας οθόνης X11 δεν μπορεί να χρησιμοποιηθεί Configure... Διαμόρφωση... ERROR: Screen unlocked ΣΦΑΛΜΑ: Οθόνη ξεκλείδωτη Locking program "%1" exited with error code %2 Το πρόγραμμα κλειδώματος «%1» τερματίστηκε με τον κωδικό σφάλματος %2 Locking program "%1" crashed with error code %2 Το πρόγραμμα κλειδώματος «%1» κατέρρευσε με τον κωδικό σφάλματος %2 PowerManagementd Power Management Διαχείριση ενέργειας You are running LXQt Power Management for the first time. You can configure it from settings... Εκτελείτε την διαχείριση ενέργειας του LXQt για πρώτη φορά. Μπορείτε να την διαμορφώσετε από τις ρυθμίσεις... Configure... Διαμόρφωση... TrayIcon Configure Διαμόρφωση About Σχετικά Disable icon Απενεργοποίηση του εικονιδίου <p> <b>LXQt Power Management</b><br/> - Power Management for the LXQt Desktop Environment</p><p> Authors:<br/> &nbsp; Christian Surlykke, Alec Moskvin<br/> &nbsp; - and others from the Razor and LXQt projects</p><p> Copyright &copy; 2012-2014</p> LXQt Power Management info The LXQt Power Management tray icon can be (re)enabled in <i>lxqt-config-powermanagement</i> Configure now discharging αποφορτίζεται charging φορτίζεται <p> <b>LXQt Powermanagement</b><br/> - Powermanagement for the LXQt Desktop Environment</p><p> Authors:<br/> &nbsp; Christian Surlykke, Alec Moskvin<br/> &nbsp; - and others from the Razor and LXQt projects</p><p> Copyright &copy; 2012-2014</p> <p> <b>Διαχείριση ενέργειας του LXQt</b><br/> - Διαχείριση της ενέργειας για το γραφικό περιβάλλον LXQt</p><p> Συγγραφείς:<br/> &nbsp; Christian Surlykke, Alec Moskvin<br/> &nbsp; - και άλλοι από τα έργα Razor και LXQt</p><p> Πνευματικά δικαιώματα &copy; 2012-2014</p> lxqt-powermanagement-0.10.0/src/translations/lxqt-powermanagement_hu.ts000066400000000000000000000406541261500560600265140ustar00rootroot00000000000000 Battery Charging Töltés Discharging Kisütés Empty Üres Fully charged Teletöltve Pending charge Tölthetőség Pending discharge Kisüthetőség Unknown Ismeretlen BatteryHelper Empty Üres Discharging Kisütés Fully charged Teletöltve Charging Töltés Lithium ion Lítium ion Lithium polymer Lítium polimer Lithium iron phosphate Lítium vasfoszfát Lead acid Savas ólom Nickel cadmium Nikkel kadmium Nickel metal hydride Nikkel fémhidrid Unknown Ismeretlen Personal Digital Assistant's battery Uninterruptible Power Supply's battery Primary battery Mouse battery Keyboard battery Keyboard and mouse's battery Camera battery Phone battery Monitor battery Unknown battery BatteryInfo Power Management Energiakezelés Battery info Akkumulátor információ Energy Now: Állapot: Updated: Frissítve: Technology: Technológia: Model: Modell: Energy rate: Energiaállapot: Voltage: Feszültség: Energy Full, Design: Névleges kapacitás: Energy Full: Teljes kapacitás: State: Állapot: Lithium ion Lítium ion Lithium polymer Lítium polimer Lithium iron phosphate Lítium vasfoszfát Lead acid Savas ólom Nickel cadmium Nikkel kadmium Nickel metal hydride Nikkel fémhidrid Unknown Ismeretlen BatteryInfoDialog Dialog Battery Info BatteryInfoFrame Power Management Energiakezelés Temperature: Type: State: Állapot: Energy Full Design: Energy Full: Teljes kapacitás: Energy Now: Állapot: Energy rate: Energiaállapot: Technology: Technológia: Voltage: Feszültség: Vendor: BatteryWatcher No battery! Nincs akku! LXQt could not find data about any battery - monitoring disabled Az LXQt nem ismert fel akkut - figyelés tiltva Power low! Alacsony feszültség! Suspending in %1 seconds %1 másodperc múlva készülség Hibernating in %1 seconds %1 másodperc múlva mélykészenlét Shutting down in %1 seconds %1 másodperc múlva kikapcsolás IdlenessWatcher LXQt Idleness watcher failed to start Az LXQt tétlenség figyelő indítása sikertelen D-Bus interface org.freedesktop.ScreenSaver is already registered A D-Bus interface org.freedesktop.ScreenSaver imár regisztrálva van. The X11 Screensaver extension is not usable Az X11 képernyővédő bővítmény használhatatlan Configure... Beállítás... ERROR: Screen unlocked HIBA: A képernyő nem zárolt Locking program "%1" exited with error code %2 A"%1" program %2 hibakóddal kilépett Locking program "%1" crashed with error code %2 A"%1" program %2 hibakóddal összeomlott PowerManagementd Power Management Energiakezelés You are running LXQt Power Management for the first time. You can configure it from settings... Az LXQt energiakezelő első alkalommal fut. A beállításokban konfigurálható... Configure... Beállítás... TrayIcon Configure Beállítás About Rólunk Disable icon Ikon tiltása <p> <b>LXQt Power Management</b><br/> - Power Management for the LXQt Desktop Environment</p><p> Authors:<br/> &nbsp; Christian Surlykke, Alec Moskvin<br/> &nbsp; - and others from the Razor and LXQt projects</p><p> Copyright &copy; 2012-2014</p> LXQt Power Management info The LXQt Power Management tray icon can be (re)enabled in <i>lxqt-config-powermanagement</i> Configure now discharging kisütés charging töltés <p> <b>LXQt Powermanagement</b><br/> - Powermanagement for the LXQt Desktop Environment</p><p> Authors:<br/> &nbsp; Christian Surlykke, Alec Moskvin<br/> &nbsp; - and others from the Razor and LXQt projects</p><p> Copyright &copy; 2012-2014</p> <p> <b>LXQt energiakezelő</b><br/> - Energiakezelő az LXQt asztal részére</p><p> Szerzők:<br/> &nbsp; Christian Surlykke, Alec Moskvin<br/> &nbsp; - és még többen a Razor és LXQt fejlesztőiből.</p><p> Copyright &copy; 2012-2014</p> lxqt-powermanagement-0.10.0/src/translations/lxqt-powermanagement_ja.ts000066400000000000000000000413331261500560600264650ustar00rootroot00000000000000 Battery Charging 充電中 Discharging 放電中 Empty Fully charged 満充電 Pending charge 充電中断中 Pending discharge 放電中断中 Unknown 不明 BatteryHelper Empty Discharging 放電中 Fully charged 満充電 Charging 充電中 Lithium ion リチウムイオン Lithium polymer リチウムポリマー Lithium iron phosphate リン酸鉄リチウム Lead acid 鉛蓄電池 Nickel cadmium ニッカド Nickel metal hydride ニッケル水素 Unknown 不明 Personal Digital Assistant's battery Uninterruptible Power Supply's battery Primary battery Mouse battery Keyboard battery Keyboard and mouse's battery Camera battery Phone battery Monitor battery Unknown battery BatteryInfo Power Management 電源管理 Battery info バッテリー情報 Energy Now: 現在の容量: Updated: 更新: Technology: 技術: Model: 型式: Energy rate: エネルギー率: Voltage: 電圧: Energy Full, Design: 満エネルギー、デザイン: Energy Full: 満エネルギー: State: 状態: Lithium ion リチウムイオン Lithium polymer リチウムポリマー Lithium iron phosphate リン酸鉄リチウム Lead acid 鉛蓄電池 Nickel cadmium ニッカド Nickel metal hydride ニッケル水素 Unknown 不明 BatteryInfoDialog Dialog Battery Info BatteryInfoFrame Power Management 電源管理 Temperature: Type: State: 状態: Energy Full Design: Energy Full: 満エネルギー: Energy Now: 現在の容量: Energy rate: エネルギー率: Technology: 技術: Voltage: 電圧: Vendor: BatteryWatcher No battery! バッテリーがありません! LXQt could not find data about any battery - monitoring disabled バッテリーのデーターを見つけられませんので、監視機能は無効です Power low! 電源が少なくなっています! Suspending in %1 seconds %1秒でサスペンドに入ります Hibernating in %1 seconds %1秒でハイバネートに入ります Shutting down in %1 seconds %1秒でシャットダウンします IdlenessWatcher LXQt Idleness watcher failed to start LXQtのアイドル状態監視は始動に失敗しました D-Bus interface org.freedesktop.ScreenSaver is already registered D-Busインターフェース org.freedesktop.ScreenSaver が既に登録されています The X11 Screensaver extension is not usable X11スクリーンセーバー拡張を使えません Configure... 設定する ERROR: Screen unlocked エラー: スクリーンのロックが解除されました Locking program "%1" exited with error code %2 ロック用プログラム "%1" は、エラーコード %2 により終了しました Locking program "%1" crashed with error code %2 ロック用プログラム "%1" は、エラーコード %2 によりクラッシュしました PowerManagementd Power Management 電源管理 You are running LXQt Power Management for the first time. You can configure it from settings... LXQt電源管理は初めて実行されましたので、設定を行ってください Configure... 設定する TrayIcon Configure 設定 About 情報 Disable icon アイコンを無効 <p> <b>LXQt Power Management</b><br/> - Power Management for the LXQt Desktop Environment</p><p> Authors:<br/> &nbsp; Christian Surlykke, Alec Moskvin<br/> &nbsp; - and others from the Razor and LXQt projects</p><p> Copyright &copy; 2012-2014</p> LXQt Power Management info The LXQt Power Management tray icon can be (re)enabled in <i>lxqt-config-powermanagement</i> Configure now discharging 放電中 charging 充電中 <p> <b>LXQt Powermanagement</b><br/> - Powermanagement for the LXQt Desktop Environment</p><p> Authors:<br/> &nbsp; Christian Surlykke, Alec Moskvin<br/> &nbsp; - and others from the Razor and LXQt projects</p><p> Copyright &copy; 2012-2014</p> <p> <b>LXQt Powermanagement</b><br/> - LXQtデスクトップ環境の電源管理</p><p> 作者:<br/> &nbsp; Christian Surlykke, Alec Moskvin<br/> &nbsp; - その他 Razor-qtおよびLXQtプロジェクトのメンバー</p><p> Copyright &copy; 2012-2014</p> lxqt-powermanagement-0.10.0/src/translations/lxqt-powermanagement_pl_PL.ts000066400000000000000000000341111261500560600270750ustar00rootroot00000000000000 Battery Charging Ładowanie Discharging Rozładowywanie Empty Pusta Fully charged W pełni naładowana Unknown Nieznana BatteryHelper Empty Pusta Discharging Rozładowywanie Fully charged W pełni naładowana Charging Ładowanie Lithium ion Lithium polymer Lithium iron phosphate Lead acid Nickel cadmium Nickel metal hydride Unknown Nieznana Personal Digital Assistant's battery Uninterruptible Power Supply's battery Primary battery Mouse battery Keyboard battery Keyboard and mouse's battery Camera battery Phone battery Monitor battery Unknown battery BatteryInfo Battery info Informacje o baterii Technology: Technologia: Model: Model: Unknown Nieznana BatteryInfoDialog Dialog Battery Info BatteryInfoFrame Power Management Zarządzanie zasilaniem Temperature: Type: State: Energy Full Design: Energy Full: Energy Now: Energy rate: Technology: Technologia: Voltage: Vendor: BatteryWatcher No battery! Brak baterii! LXQt could not find data about any battery - monitoring disabled LXQt nie znalazł danych o żadnej baterii - monitorowanie wyłączone Power low! Niski poziom zasilania! Suspending in %1 seconds Wstrzymanie nastąpi w ciągu %1 sekund Hibernating in %1 seconds Hibernacja nastąpi w ciągu %1 sekund Shutting down in %1 seconds Wyłączenie systemu nastąpi w ciągu %1 sekund IdlenessWatcher LXQt Idleness watcher failed to start D-Bus interface org.freedesktop.ScreenSaver is already registered The X11 Screensaver extension is not usable Configure... Konfiguruj... ERROR: Screen unlocked BŁĄD: Ekran odblokowany Locking program "%1" exited with error code %2 Locking program "%1" crashed with error code %2 PowerManagementd Power Management Zarządzanie zasilaniem You are running LXQt Power Management for the first time. You can configure it from settings... Uruchamiasz zarządzanie energią LXQt po raz pierwszy. Możesz skonfiguroweć jego ustawienia... Configure... Konfiguruj... TrayIcon Configure Konfiguruj About Info Disable icon Wyłącz ikonę <p> <b>LXQt Power Management</b><br/> - Power Management for the LXQt Desktop Environment</p><p> Authors:<br/> &nbsp; Christian Surlykke, Alec Moskvin<br/> &nbsp; - and others from the Razor and LXQt projects</p><p> Copyright &copy; 2012-2014</p> LXQt Power Management info The LXQt Power Management tray icon can be (re)enabled in <i>lxqt-config-powermanagement</i> Configure now discharging rozładowywanie charging ładowanie <p> <b>LXQt Powermanagement</b><br/> - Powermanagement for the LXQt Desktop Environment</p><p> Authors:<br/> &nbsp; Christian Surlykke, Alec Moskvin<br/> &nbsp; - and others from the Razor and LXQt projects</p><p> Copyright &copy; 2012-2014</p> <p> <b>LXQt Zarządzanie Energią</b><br/> - Zarządzanie energią dla środowiska LXQt</p><p> Autorzy:<br/> &nbsp; Christian Surlykke, Alec Moskvin<br/> &nbsp; - i inni z projektów Razor oraz LXQt</p><p> Copyright &copy; 2012-2014</p> lxqt-powermanagement-0.10.0/src/translations/lxqt-powermanagement_pt.ts000066400000000000000000000411471261500560600265210ustar00rootroot00000000000000 Battery Charging A carregar Discharging A descarregar Empty Vazia Fully charged Totalmente carregada Pending charge Por carregar Pending discharge Por descarregar Unknown Desconhecido BatteryHelper Empty Vazia Discharging A descarregar Fully charged Totalmente carregada Charging A carregar Lithium ion Ião de lítio Lithium polymer Polímero de lítio Lithium iron phosphate Fosfato de Ferro-Lítio Lead acid Ácido de chumbo Nickel cadmium Níquel-Cádmio Nickel metal hydride Níquel-Hidreto Metálico Unknown Desconhecido Personal Digital Assistant's battery Uninterruptible Power Supply's battery Primary battery Mouse battery Keyboard battery Keyboard and mouse's battery Camera battery Phone battery Monitor battery Unknown battery BatteryInfo Power Management Gestão de energia Battery info Informações da bateria Energy Now: Energia atual: Updated: Atualização: Technology: Tecnologia: Model: Modelo: Energy rate: Taxa de energia: Voltage: Tensão: Energy Full, Design: Energia máxima teórica: Energy Full: Energia máxima: State: Estado: Lithium ion Ião de lítio Lithium polymer Polímero de lítio Lithium iron phosphate Fosfato de Ferro-Lítio Lead acid Ácido de chumbo Nickel cadmium Níquel-Cádmio Nickel metal hydride Níquel-Hidreto Metálico Unknown Desconhecido BatteryInfoDialog Dialog Battery Info BatteryInfoFrame Power Management Gestão de energia Temperature: Type: State: Estado: Energy Full Design: Energy Full: Energia máxima: Energy Now: Energia atual: Energy rate: Taxa de energia: Technology: Tecnologia: Voltage: Tensão: Vendor: BatteryWatcher No battery! Nenhuma bateria! LXQt could not find data about any battery - monitoring disabled O LXQt não consegui encontrar qualquer bateria e a monitorização foi desativada Power low! Energia baixa! Suspending in %1 seconds Suspensão dentro de %1 segundos Hibernating in %1 seconds Hibernação dentro de %1 segundos Shutting down in %1 seconds A desligar dentro de %1 segundos IdlenessWatcher LXQt Idleness watcher failed to start O monitorizador de inatividade não foi iniciado D-Bus interface org.freedesktop.ScreenSaver is already registered A interface D-Bus org.freedesktop.ScreenSaver já está registada The X11 Screensaver extension is not usable A extensão X 11 Screensaver não pode ser utilizada Configure... Configurar... ERROR: Screen unlocked Erro: ecrã não bloqueado Locking program "%1" exited with error code %2 O bloqueio do programa "%1" terminou com o erro "%2" Locking program "%1" crashed with error code %2 O bloqueio do programa "%1" crashou com o erro "%2" PowerManagementd Power Management Gestão de energia You are running LXQt Power Management for the first time. You can configure it from settings... Está a executar a gestão de energia do LXQt pela primeira vez. Pode configurar as opções nas definições... Configure... Configurar... TrayIcon Configure Configurar About Sobre Disable icon Desativar ícone <p> <b>LXQt Power Management</b><br/> - Power Management for the LXQt Desktop Environment</p><p> Authors:<br/> &nbsp; Christian Surlykke, Alec Moskvin<br/> &nbsp; - and others from the Razor and LXQt projects</p><p> Copyright &copy; 2012-2014</p> LXQt Power Management info The LXQt Power Management tray icon can be (re)enabled in <i>lxqt-config-powermanagement</i> Configure now discharging a descarregar charging a carregar <p> <b>LXQt Powermanagement</b><br/> - Powermanagement for the LXQt Desktop Environment</p><p> Authors:<br/> &nbsp; Christian Surlykke, Alec Moskvin<br/> &nbsp; - and others from the Razor and LXQt projects</p><p> Copyright &copy; 2012-2014</p> <p> <b>Gestor de energia do LXQt</b><br/>Gestão de energia para o ambiente de trabalho LXQt</p><p> Autores:<br/> &nbsp; Christian Surlykke, Alec Moskvin<br/> &nbsp; - e outros colaboradores dos projetos Razor e LXQt</p><p> Direitos de autor &copy; 2012-2015</p> lxqt-powermanagement-0.10.0/src/translations/lxqt-powermanagement_ru.ts000066400000000000000000000431751261500560600265270ustar00rootroot00000000000000 Battery Charging Заряжается Discharging Разряжается Empty Пустая Fully charged Полностью заряжена Pending charge Ожидает заряда Pending discharge Ожидает разряда Unknown Неизвестно BatteryHelper Empty Пустая Discharging Разряжается Fully charged Полностью заряжена Charging Заряжается Lithium ion Литий-ионная Lithium polymer Литий-полимерная Lithium iron phosphate Литий-железо-фосфатная Lead acid Свинцово-кислотная Nickel cadmium Никель-кадмиевая Nickel metal hydride Никель-металл-гидридная Unknown Неизвестно Personal Digital Assistant's battery Uninterruptible Power Supply's battery Primary battery Mouse battery Keyboard battery Keyboard and mouse's battery Camera battery Phone battery Monitor battery Unknown battery BatteryInfo Power Management Управление энергопотреблением Battery info Информация о батарее Energy Now: Заряд сейчас: Updated: Обновлено: Technology: Технология: Model: Модель: Energy rate: Мощность тока: Voltage: Напряжение: Energy Full, Design: Максимальный заряд: State: Состояние: Lithium ion Литий-ионная Lithium polymer Литий-полимерная Lithium iron phosphate Литий-железо-фосфатная Lead acid Свинцово-кислотная Nickel cadmium Никель-кадмиевая Nickel metal hydride Никель-металл-гидридная Unknown Неизвестно BatteryInfoDialog Dialog Battery Info BatteryInfoFrame Power Management Управление энергопотреблением Temperature: Type: State: Состояние: Energy Full Design: Energy Full: Energy Now: Заряд сейчас: Energy rate: Мощность тока: Technology: Технология: Voltage: Напряжение: Vendor: BatteryWatcher No battery! Нет батареи! LXQt could not find data about any battery - monitoring disabled LXQt не смог найти информацию о какой-либо батарее - наблюдение отменено Power low! Низкий заряд! Suspending in %1 seconds Ждущий режим через %1 секунд Hibernating in %1 seconds Спящий режим через %1 секунд Shutting down in %1 seconds Выключение компьютера через %1 секунд IdlenessWatcher LXQt Idleness watcher failed to start Не удалось запустить наблюдение за простоем LXQt D-Bus interface org.freedesktop.ScreenSaver is already registered Интерфейс D-Bus org.freedesktop.ScreenSaver уже зарегистрирован The X11 Screensaver extension is not usable Расширение X11 Скринсейвер непригодно для использования Configure... Настроить… ERROR: Screen unlocked ОШИБКА: экран разблокирован Locking program "%1" exited with error code %2 Программа блокировки экрана "%1" вышла с кодом ошибки %2 Locking program "%1" crashed with error code %2 Программа блокировки экрана "%1" упала с кодом ошибки %2 PowerManagementd Power Management Управление энергопотреблением You are running LXQt Power Management for the first time. You can configure it from settings... Вы запускаете управление энергопотреблением LXQt впервые. Вы можете сконфигурировать его в настройках… Configure... Настроить… TrayIcon discharging разряжается charging заряжается About О программе Configure Настроить Disable icon Не показывать значок <p> <b>LXQt Power Management</b><br/> - Power Management for the LXQt Desktop Environment</p><p> Authors:<br/> &nbsp; Christian Surlykke, Alec Moskvin<br/> &nbsp; - and others from the Razor and LXQt projects</p><p> Copyright &copy; 2012-2014</p> LXQt Power Management info The LXQt Power Management tray icon can be (re)enabled in <i>lxqt-config-powermanagement</i> Configure now <p> <b>LXQt Powermanagement</b><br/> - Powermanagement for the LXQt Desktop Environment</p><p> Authors:<br/> &nbsp; Christian Surlykke, Alec Moskvin<br/> &nbsp; - and others from the Razor and LXQt projects</p><p> Copyright &copy; 2012-2014</p> <p> <b>Управление энергопотреблением LXQt</b><br/> - Управление энергопотреблением для окружения рабочего стола LXQt</p><p> Авторы:<br/> &nbsp; Christian Surlykke, Alec Moskvin<br/> &nbsp; - и другие из проектов Razor и LXQt</p><p> Copyright &copy; 2012-2014</p> lxqt-powermanagement-0.10.0/src/translations/lxqt-powermanagement_ru_RU.ts000066400000000000000000000432001261500560600271220ustar00rootroot00000000000000 Battery Charging Заряжается Discharging Разряжается Empty Пустая Fully charged Полностью заряжена Pending charge Ожидает заряда Pending discharge Ожидает разряда Unknown Неизвестно BatteryHelper Empty Пустая Discharging Разряжается Fully charged Полностью заряжена Charging Заряжается Lithium ion Литий-ионная Lithium polymer Литий-полимерная Lithium iron phosphate Литий-железо-фосфатная Lead acid Свинцово-кислотная Nickel cadmium Никель-кадмиевая Nickel metal hydride Никель-металл-гидридная Unknown Неизвестно Personal Digital Assistant's battery Uninterruptible Power Supply's battery Primary battery Mouse battery Keyboard battery Keyboard and mouse's battery Camera battery Phone battery Monitor battery Unknown battery BatteryInfo Power Management Управление энергопотреблением Battery info Информация о батарее Energy Now: Заряд сейчас: Updated: Обновлено: Technology: Технология: Model: Модель: Energy rate: Мощность тока: Voltage: Напряжение: Energy Full, Design: Максимальный заряд: State: Состояние: Lithium ion Литий-ионная Lithium polymer Литий-полимерная Lithium iron phosphate Литий-железо-фосфатная Lead acid Свинцово-кислотная Nickel cadmium Никель-кадмиевая Nickel metal hydride Никель-металл-гидридная Unknown Неизвестно BatteryInfoDialog Dialog Battery Info BatteryInfoFrame Power Management Управление энергопотреблением Temperature: Type: State: Состояние: Energy Full Design: Energy Full: Energy Now: Заряд сейчас: Energy rate: Мощность тока: Technology: Технология: Voltage: Напряжение: Vendor: BatteryWatcher No battery! Нет батареи! LXQt could not find data about any battery - monitoring disabled LXQt не смог найти информацию о какой-либо батарее - наблюдение отменено Power low! Низкий заряд! Suspending in %1 seconds Ждущий режим через %1 секунд Hibernating in %1 seconds Спящий режим через %1 секунд Shutting down in %1 seconds Выключение компьютера через %1 секунд IdlenessWatcher LXQt Idleness watcher failed to start Не удалось запустить наблюдение за простоем LXQt D-Bus interface org.freedesktop.ScreenSaver is already registered Интерфейс D-Bus org.freedesktop.ScreenSaver уже зарегистрирован The X11 Screensaver extension is not usable Расширение X11 Скринсейвер непригодно для использования Configure... Настроить… ERROR: Screen unlocked ОШИБКА: экран разблокирован Locking program "%1" exited with error code %2 Программа блокировки экрана "%1" вышла с кодом ошибки %2 Locking program "%1" crashed with error code %2 Программа блокировки экрана "%1" упала с кодом ошибки %2 PowerManagementd Power Management Управление энергопотреблением You are running LXQt Power Management for the first time. You can configure it from settings... Вы запускаете управление энергопотреблением LXQt впервые. Вы можете сконфигурировать его в настройках… Configure... Настроить… TrayIcon discharging разряжается charging заряжается About О программе Configure Настроить Disable icon Не показывать значок <p> <b>LXQt Power Management</b><br/> - Power Management for the LXQt Desktop Environment</p><p> Authors:<br/> &nbsp; Christian Surlykke, Alec Moskvin<br/> &nbsp; - and others from the Razor and LXQt projects</p><p> Copyright &copy; 2012-2014</p> LXQt Power Management info The LXQt Power Management tray icon can be (re)enabled in <i>lxqt-config-powermanagement</i> Configure now <p> <b>LXQt Powermanagement</b><br/> - Powermanagement for the LXQt Desktop Environment</p><p> Authors:<br/> &nbsp; Christian Surlykke, Alec Moskvin<br/> &nbsp; - and others from the Razor and LXQt projects</p><p> Copyright &copy; 2012-2014</p> <p> <b>Управление энергопотреблением LXQt</b><br/> - Управление энергопотреблением для окружения рабочего стола LXQt</p><p> Авторы:<br/> &nbsp; Christian Surlykke, Alec Moskvin<br/> &nbsp; - и другие из проектов Razor и LXQt</p><p> Copyright &copy; 2012-2014</p> lxqt-powermanagement-0.10.0/src/trayicon.cpp000066400000000000000000000107151261500560600210770ustar00rootroot00000000000000/* BEGIN_COMMON_COPYRIGHT_HEADER * (c)LGPL2+ * * LXDE-Qt - a lightweight, Qt based, desktop toolset * http://razor-qt.org * * Copyright: 2011 Razor team * Authors: * Christian Surlykke * * This program or library is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General * Public License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA * * END_COMMON_COPYRIGHT_HEADER */ #include #include #include #include #include #include #include #include #include #include "trayicon.h" #include "batteryhelper.h" #include "../config/powermanagementsettings.h" #include TrayIcon::TrayIcon(Solid::Battery *battery, QObject *parent) : QSystemTrayIcon(parent), mBattery(battery), mIconProducer(battery), mContextMenu() { connect(mBattery, &Solid::Battery::chargePercentChanged, this, &TrayIcon::updateTooltip); connect(mBattery, &Solid::Battery::chargeStateChanged, this, &TrayIcon::updateTooltip); updateTooltip(); connect(&mIconProducer, SIGNAL(iconChanged()), this, SLOT(iconChanged())); iconChanged(); connect(this, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), SLOT(onActivated(QSystemTrayIcon::ActivationReason))); mContextMenu.addAction(XdgIcon::fromTheme(QStringLiteral("configure")), tr("Configure"), this, SLOT(onConfigureTriggered())); mContextMenu.addAction(XdgIcon::fromTheme(QStringLiteral("help-about")), tr("About"), this, SLOT(onAboutTriggered())); mContextMenu.addAction(XdgIcon::fromTheme(QStringLiteral("edit-delete")), tr("Disable icon"), this, SLOT(onDisableIconTriggered())); setContextMenu(&mContextMenu); } TrayIcon::~TrayIcon() { } void TrayIcon::iconChanged() { setIcon(mIconProducer.mIcon); } void TrayIcon::updateTooltip() { QString tooltip = BatteryHelper::stateToString(mBattery->chargeState()); tooltip += QString(" (%1 %)").arg(mBattery->chargePercent()); setToolTip(tooltip); } void TrayIcon::onConfigureTriggered() { QProcess::startDetached("lxqt-config-powermanagement"); } void TrayIcon::onAboutTriggered() { QMessageBox::about(0, tr("About"), tr( "

" " LXQt Power Management
" " - Power Management for the LXQt Desktop Environment" "

" "

" " Authors:
" "   Christian Surlykke, Alec Moskvin
" "   - and others from the Razor and LXQt projects" "

" "

" " Copyright © 2012-2014" "

" )); } void TrayIcon::onDisableIconTriggered() { auto notification = new LXQt::Notification{tr("LXQt Power Management info"), nullptr}; notification->setBody(tr("The LXQt Power Management tray icon can be (re)enabled in lxqt-config-powermanagement")); notification->setIcon("preferences-system-power-management"); notification->setActions({tr("Configure now")}); notification->setUrgencyHint(LXQt::Notification::UrgencyLow); connect(notification, &LXQt::Notification::actionActivated, [notification] { notification->close(); QProcess::startDetached("lxqt-config-powermanagement"); }); connect(notification, &LXQt::Notification::notificationClosed, notification, &QObject::deleteLater); notification->update(); PowerManagementSettings().setShowIcon(false); } void TrayIcon::onActivated(QSystemTrayIcon::ActivationReason reason) { qDebug() << "onActivated" << reason; if (Trigger == reason) emit toggleShowInfo(); } lxqt-powermanagement-0.10.0/src/trayicon.h000066400000000000000000000033071261500560600205430ustar00rootroot00000000000000/* BEGIN_COMMON_COPYRIGHT_HEADER * (c)LGPL2+ * * LXDE-Qt - a lightweight, Qt based, desktop toolset * http://razor-qt.org * * Copyright: 2011 Razor team * Authors: * Christian Surlykke * * This program or library is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General * Public License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA * * END_COMMON_COPYRIGHT_HEADER */ #ifndef TRAYICON_H #define TRAYICON_H #include #include #include #include "iconproducer.h" #include "../config/powermanagementsettings.h" class TrayIcon : public QSystemTrayIcon { Q_OBJECT public: TrayIcon(Solid::Battery *battery, QObject *parent = 0); ~TrayIcon(); signals: void toggleShowInfo(); public slots: void iconChanged(); void updateTooltip(); private slots: void onConfigureTriggered(); void onAboutTriggered(); void onDisableIconTriggered(); void onActivated(QSystemTrayIcon::ActivationReason reason); private: Solid::Battery *mBattery; IconProducer mIconProducer; QMenu mContextMenu; }; #endif // TRAYICON_H lxqt-powermanagement-0.10.0/src/watcher.cpp000066400000000000000000000027071261500560600207060ustar00rootroot00000000000000/* BEGIN_COMMON_COPYRIGHT_HEADER * (c)LGPL2+ * * LXDE-Qt - a lightweight, Qt based, desktop toolset * * Authors: * Christian Surlykke * * This program or library is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General * Public License along with this library; if not, write to the * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA * * END_COMMON_COPYRIGHT_HEADER */ #include #include "../config/powermanagementsettings.h" #include "watcher.h" Watcher::Watcher(QObject *parent) : QObject(parent), mScreenSaver(this) { connect(&mScreenSaver, SIGNAL(done()), &mLoop, SLOT(quit())); } Watcher::~Watcher() { } void Watcher::doAction(int action) { // if (action == -1) { } if (action == -2) { mScreenSaver.lockScreen(); mLoop.exec(); } else if (action >= 0) mPower.doAction((LXQt::Power::Action) action); emit done(); } lxqt-powermanagement-0.10.0/src/watcher.h000066400000000000000000000012451261500560600203470ustar00rootroot00000000000000/* * Copyright (c) 2014,2015 Christian Surlykke, Paulo Lieuthier * * This file is part of the LXQt project. * It is distributed under the LGPL 2.1 or later license. * Please refer to the LICENSE file for a copy of the license. */ #ifndef WATCHER_H #define WATCHER_H #include #include #include #include class Watcher : public QObject { Q_OBJECT public: Watcher(QObject *parent = 0); virtual ~Watcher(); protected: void doAction(int action); signals: void done(); private: LXQt::Power mPower; LXQt::ScreenSaver mScreenSaver; QEventLoop mLoop; }; #endif // WATCHER_H lxqt-powermanagement-0.10.0/src/x11helper.cpp000066400000000000000000000027741261500560600210660ustar00rootroot00000000000000/* BEGIN_COMMON_COPYRIGHT_HEADER * (c)LGPL2+ * * LXDE-Qt - a lightweight, Qt based, desktop toolset * http://razor-qt.org * * Copyright (C) 2012 Alec Moskvin * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * END_COMMON_COPYRIGHT_HEADER */ #include "x11helper.h" #include #include Display* X11Helper::display() { QPlatformNativeInterface *native = qApp->platformNativeInterface(); void* display = native->nativeResourceForWindow("display", 0); return reinterpret_cast(display); } xcb_connection_t* X11Helper::connection() { QPlatformNativeInterface *native = qApp->platformNativeInterface(); void* connection = native->nativeResourceForWindow("connection", 0); return reinterpret_cast(connection); } lxqt-powermanagement-0.10.0/src/x11helper.h000066400000000000000000000030461261500560600205240ustar00rootroot00000000000000/* BEGIN_COMMON_COPYRIGHT_HEADER * (c)LGPL2+ * * LXDE-Qt - a lightweight, Qt based, desktop toolset * http://razor-qt.org * * Copyright (C) 2013 Alec Moskvin * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * END_COMMON_COPYRIGHT_HEADER */ #ifndef X11HELPER_H #define X11HELPER_H #include // Avoid polluting everything with X11/Xlib.h: typedef struct _XDisplay Display; /** * @brief The X11Helper class is class to get the X11 Display or XCB connection * * It's intended to be used as a wrapper/replacement for QX11Info, which is removed in Qt5. */ class X11Helper { public: /** * @brief display Returns the X11 display * @return */ static Display* display(); /** * @brief connection Returns the XCB connection * @return */ static xcb_connection_t* connection(); }; #endif // X11HELPER_H