From 6a8950212d23633fbd55e3774e7b1de095bee5c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrew=20Lee=20=28=E6=9D=8E=E5=81=A5=E7=A7=8B=29?= Date: Sun, 16 Aug 2015 18:49:04 +0800 Subject: [PATCH 1/6] Adding upstream version 0.9.0+20150807. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Andrew Lee (李健秋) --- .gitignore | 2 - CMakeLists.txt | 11 +- CMakeLists.txt.user.3.3-pre1 | 239 ---------------- config/CMakeLists.txt | 51 ++-- config/batterywatchersettings.cpp | 12 +- config/batterywatchersettings.h | 2 +- config/helpers.h | 2 +- config/idlenesswatchersettings.cpp | 51 ++-- config/idlenesswatchersettings.h | 2 +- config/idlenesswatchersettings.ui | 2 +- config/lidwatchersettings.cpp | 12 +- config/lidwatchersettings.h | 2 +- config/mainwindow.cpp | 4 +- config/powermanagementsettings.cpp | 7 +- .../lxqt-config-powermanagement.ts | 2 +- .../lxqt-config-powermanagement_hu.desktop | 3 + .../lxqt-config-powermanagement_hu.ts | 195 +++++++++++++ .../lxqt-config-powermanagement_it.desktop | 2 + .../lxqt-config-powermanagement_it.ts | 195 +++++++++++++ .../lxqt-config-powermanagement_ja.ts | 2 +- .../lxqt-config-powermanagement_pl_PL.desktop | 2 + .../lxqt-config-powermanagement_pl_PL.ts | 195 +++++++++++++ .../lxqt-config-powermanagement_pt.ts | 2 +- .../lxqt-config-powermanagement_ru.ts | 2 +- .../lxqt-config-powermanagement_ru_RU.ts | 2 +- src/CMakeLists.txt | 50 ++-- src/battery.cpp | 177 ------------ src/battery.h | 92 ------- src/batteryhelper.cpp | 101 +++++++ src/batteryhelper.h | 44 +++ src/batteryinfodialog.cpp | 6 +- src/batteryinfodialog.h | 4 +- src/batteryinfoframe.cpp | 31 ++- src/batteryinfoframe.h | 8 +- src/batteryinfoframe.ui | 97 ++++--- src/batterywatcher.cpp | 48 ++-- src/batterywatcher.h | 5 +- src/iconproducer.cpp | 120 ++++---- src/iconproducer.h | 17 +- src/idlenesswatcher.cpp | 10 +- src/idlenesswatcher.h | 4 +- src/lid.cpp | 4 +- src/lidwatcher.cpp | 2 +- src/powermanagementd.cpp | 13 +- src/powermanagementd.h | 2 +- src/translations/lxqt-powermanagement_hu.ts | 260 ++++++++++++++++++ .../lxqt-powermanagement_pl_PL.ts | 260 ++++++++++++++++++ src/trayicon.cpp | 46 +++- src/trayicon.h | 7 +- src/watcher.cpp | 18 +- src/watcher.h | 14 +- 51 files changed, 1617 insertions(+), 824 deletions(-) delete mode 100644 .gitignore delete mode 100644 CMakeLists.txt.user.3.3-pre1 create mode 100644 config/translations/lxqt-config-powermanagement_hu.desktop create mode 100644 config/translations/lxqt-config-powermanagement_hu.ts create mode 100644 config/translations/lxqt-config-powermanagement_it.desktop create mode 100644 config/translations/lxqt-config-powermanagement_it.ts create mode 100644 config/translations/lxqt-config-powermanagement_pl_PL.desktop create mode 100644 config/translations/lxqt-config-powermanagement_pl_PL.ts delete mode 100644 src/battery.cpp delete mode 100644 src/battery.h create mode 100644 src/batteryhelper.cpp create mode 100644 src/batteryhelper.h create mode 100644 src/translations/lxqt-powermanagement_hu.ts create mode 100644 src/translations/lxqt-powermanagement_pl_PL.ts diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 384cad1..0000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -build -nbproject diff --git a/CMakeLists.txt b/CMakeLists.txt index eb50fdb..793fbe9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.11) +cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR) project(lxqt-powermanagement) @@ -7,6 +7,7 @@ option(UPDATE_TRANSLATIONS "Update source translation translations/*.ts files" O 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) @@ -14,12 +15,10 @@ find_package(Qt5X11Extras REQUIRED) find_package(Qt5Svg REQUIRED) find_package(Qt5LinguistTools REQUIRED QUIET) find_package(lxqt REQUIRED QUIET) -find_package(Qt5Xdg REQUIRED) -message(STATUS "Building with Qt${Qt5Core_VERSION_STRING}") - -include(${LXQT_USE_FILE}) -include(${QTXDG_USE_FILE}) +find_package(KF5Solid REQUIRED) +include(GNUInstallDirs) +include(LXQtCompilerSettings NO_POLICY_SCOPE) include(LXQtTranslate) add_subdirectory(config) diff --git a/CMakeLists.txt.user.3.3-pre1 b/CMakeLists.txt.user.3.3-pre1 deleted file mode 100644 index 06e993f..0000000 --- a/CMakeLists.txt.user.3.3-pre1 +++ /dev/null @@ -1,239 +0,0 @@ - - - - - - EnvironmentId - {5c6f7c82-f2e7-4d03-9d51-5ba00c7370fd} - - - ProjectExplorer.Project.ActiveTarget - 0 - - - ProjectExplorer.Project.EditorSettings - - true - false - true - - Cpp - - CppGlobal - - - - QmlJS - - QmlJSGlobal - - - 2 - UTF-8 - false - 4 - false - 80 - true - true - 1 - true - false - 0 - true - 0 - 8 - true - 1 - true - true - true - false - - - - ProjectExplorer.Project.PluginSettings - - - - ProjectExplorer.Project.Target.0 - - Desktop - Desktop - {5e382e87-0cbd-448b-81ff-a635a0cc40fe} - 0 - 0 - 0 - - false - /home/christian/projekter/Aktive/lxqt/lxqt-powermanagement/build - - - - - false - true - Make - - CMakeProjectManager.MakeStep - - 1 - Build - - ProjectExplorer.BuildSteps.Build - - - - clean - - true - true - Make - - CMakeProjectManager.MakeStep - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - all - - CMakeProjectManager.CMakeBuildConfiguration - - 1 - - - 0 - Deploy - - ProjectExplorer.BuildSteps.Deploy - - 1 - Deploy locally - - ProjectExplorer.DefaultDeployConfiguration - - 1 - - - - false - false - false - false - true - 0.01 - 10 - true - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - lxqt-config-powermanagement - - false - - 2 - - lxqt-config-powermanagement - - CMakeProjectManager.CMakeRunConfiguration.lxqt-config-powermanagement - 3768 - false - true - false - false - true - - - - false - false - false - false - true - 0.01 - 10 - true - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - lxqt-powermanagement - - false - - 2 - - lxqt-powermanagement - - CMakeProjectManager.CMakeRunConfiguration.lxqt-powermanagement - 3768 - false - true - false - false - true - - 2 - - - - ProjectExplorer.Project.TargetCount - 1 - - - ProjectExplorer.Project.Updater.FileVersion - 16 - - - Version - 16 - - diff --git a/config/CMakeLists.txt b/config/CMakeLists.txt index 3f725eb..6a557ef 100644 --- a/config/CMakeLists.txt +++ b/config/CMakeLists.txt @@ -2,15 +2,7 @@ project(lxqt-config-powermanagement) set(QTX_LIBRARIES Qt5::Widgets Qt5::DBus Qt5::Svg) -set(config-powermanagement_MOCS - mainwindow.h - lidwatchersettings.h - batterywatchersettings.h - idlenesswatchersettings.h - powermanagementsettings.h -) - -set(config-powermanagement_SRCS +set(SOURCES main.cpp mainwindow.cpp lidwatchersettings.cpp @@ -19,19 +11,14 @@ set(config-powermanagement_SRCS powermanagementsettings.cpp helpers.cpp ../src/iconproducer.cpp - ../src/battery.cpp ) -set(config-powermanagement_UIS +set(UI_FILES lidwatchersettings.ui batterywatchersettings.ui idlenesswatchersettings.ui ) -set(config-powermanagement_RSCS - config-powermanagement.qrc -) - set(ICON_FILES icons/laptop-lid.svg ) @@ -45,9 +32,8 @@ set(DESKTOP_FILES_IN lxqt_translate_ts(QM_FILES UPDATE_TRANSLATIONS ${UPDATE_TRANSLATIONS} SOURCES - ${config-powermanagement_SRCS} - ${config-powermanagement_UIS} - ${config-powermanagement_MOCS} + ${SOURCES} + ${UI_FILES} INSTALL_DIR ${LXQT_TRANSLATIONS_DIR}/${PROJECT_NAME} ) @@ -55,24 +41,31 @@ lxqt_translate_ts(QM_FILES lxqt_app_translation_loader(config-powermanagement_QM_LOADER ${PROJECT_NAME}) lxqt_translate_desktop(DESKTOP_FILES SOURCES ${DESKTOP_FILES_IN}) - -qt5_add_resources(RSCS ${config-powermanagement_RSCS}) -qt5_wrap_ui(UIS ${config-powermanagement_UIS}) - add_executable(${PROJECT_NAME} - ${config-powermanagement_SRCS} - ${UIS} + ${SOURCES} ${DESKTOP_FILES} ${QM_FILES} ${config-powermanagement_QM_LOADER} ) target_link_libraries(lxqt-config-powermanagement - ${LXQT_LIBRARIES} - ${QTXDG_LIBRARIES} + lxqt ${QTX_LIBRARIES} + KF5::Solid ) -install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) -install(FILES ${DESKTOP_FILES} DESTINATION share/applications) -install(FILES ${ICON_FILES} DESTINATION share/icons/hicolor/scalable/devices) +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 +) diff --git a/config/batterywatchersettings.cpp b/config/batterywatchersettings.cpp index d680ae4..8bfe4ff 100644 --- a/config/batterywatchersettings.cpp +++ b/config/batterywatchersettings.cpp @@ -29,11 +29,11 @@ #include #include #include +#include #include "batterywatchersettings.h" #include "ui_batterywatchersettings.h" #include "powermanagementsettings.h" -#include "../src/battery.h" BatteryWatcherSettings::BatteryWatcherSettings(QWidget *parent) : QWidget(parent), @@ -46,6 +46,8 @@ BatteryWatcherSettings::BatteryWatcherSettings(QWidget *parent) : 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())); @@ -90,10 +92,10 @@ void BatteryWatcherSettings::updatePreview() { mUi->previewBox->setTitle(tr("Preview") + QString(" (%1)").arg(mSettings.isUseThemeIcons() ? QIcon::themeName() : tr("built in"))); - float chargeLevel = mUi->chargeLevelSlider->value(); - mChargingIconProducer.update(chargeLevel, Battery::Charging); - mDischargingIconProducer.update(chargeLevel, Battery::Discharging); - mUi->chargeLevelLabel->setText(tr("Level: %1%").arg(chargeLevel)); + int chargePercent = mUi->chargeLevelSlider->value(); + mChargingIconProducer.updateChargePercent(chargePercent); + mDischargingIconProducer.updateChargePercent(chargePercent); + mUi->chargeLevelLabel->setText(tr("Level: %1%").arg(chargePercent)); } void BatteryWatcherSettings::onChargeIconChanged() diff --git a/config/batterywatchersettings.h b/config/batterywatchersettings.h index a27ff12..f9b92a5 100644 --- a/config/batterywatchersettings.h +++ b/config/batterywatchersettings.h @@ -42,7 +42,7 @@ class BatteryWatcherSettings; class BatteryWatcherSettings : public QWidget { Q_OBJECT - + public: explicit BatteryWatcherSettings(QWidget *parent = 0); ~BatteryWatcherSettings(); diff --git a/config/helpers.h b/config/helpers.h index 59e2d2c..128a4db 100644 --- a/config/helpers.h +++ b/config/helpers.h @@ -1,4 +1,4 @@ -/* +/* * File: Settings.h * Author: christian * diff --git a/config/idlenesswatchersettings.cpp b/config/idlenesswatchersettings.cpp index 74964cb..9844a29 100644 --- a/config/idlenesswatchersettings.cpp +++ b/config/idlenesswatchersettings.cpp @@ -32,9 +32,11 @@ #include "ui_idlenesswatchersettings.h" #include "helpers.h" +#define MINIMUM_SECONDS 30 + IdlenessWatcherSettings::IdlenessWatcherSettings(QWidget *parent) : - QWidget(parent), - mSettings(), + QWidget(parent), + mSettings(), mUi(new Ui::IdlenessWatcherSettings) { mUi->setupUi(this); @@ -55,13 +57,14 @@ IdlenessWatcherSettings::~IdlenessWatcherSettings() void IdlenessWatcherSettings::loadSettings() { - mUi->idlenessWatcherGroupBox->setChecked(mSettings.isIdlenessWatcherEnabled()); setComboBoxToValue(mUi->idleActionComboBox, mSettings.getIdlenessAction()); - + int idlenessTimeSeconds = mSettings.getIdlenessTimeSecs(); - if (idlenessTimeSeconds < 5) idlenessTimeSeconds = 5; - int idlenessTimeMinutes = idlenessTimeSeconds/60; + // 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); @@ -69,32 +72,28 @@ void IdlenessWatcherSettings::loadSettings() void IdlenessWatcherSettings::minutesChanged(int newVal) { - if (newVal < 1 && mUi->idleTimeSecondsSpinBox->value() < 5) + if (newVal < 1 && mUi->idleTimeSecondsSpinBox->value() < MINIMUM_SECONDS) { - mUi->idleTimeSecondsSpinBox->setValue(5); + mUi->idleTimeSecondsSpinBox->setValue(MINIMUM_SECONDS); } } void IdlenessWatcherSettings::secondsChanged(int newVal) { - if (newVal > 59) + 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) { - if (mUi->idleTimeMinutesSpinBox->value() < 1) - { - mUi->idleTimeMinutesSpinBox->setValue(0); - mUi->idleTimeSecondsSpinBox->setValue(0); - } - else - { - mUi->idleTimeMinutesSpinBox->setValue(mUi->idleTimeMinutesSpinBox->value() - 1); - mUi->idleTimeSecondsSpinBox->setValue(59); - } + mUi->idleTimeMinutesSpinBox->setValue(mUi->idleTimeMinutesSpinBox->value() - 1); + mUi->idleTimeSecondsSpinBox->setValue(59); } } @@ -102,16 +101,16 @@ void IdlenessWatcherSettings::secondsChanged(int newVal) void IdlenessWatcherSettings::saveSettings() { - mSettings.setIdlenessWatcherEnabled(mUi->idlenessWatcherGroupBox->isChecked()); mSettings.setIdlenessAction(currentValue(mUi->idleActionComboBox)); - int idleTimeSecs = 60*mUi->idleTimeMinutesSpinBox->value() + mUi->idleTimeSecondsSpinBox->value(); - if (idleTimeSecs < 5) + int idleTimeSecs = 60 * mUi->idleTimeMinutesSpinBox->value() + mUi->idleTimeSecondsSpinBox->value(); + // if less than minimum, change 15 minutes + if (idleTimeSecs < MINIMUM_SECONDS) { - idleTimeSecs = 5; - mUi->idleTimeMinutesSpinBox->setValue(0); - mUi->idleTimeSecondsSpinBox->setValue(5); + idleTimeSecs = 900; + mUi->idleTimeMinutesSpinBox->setValue(15); + mUi->idleTimeSecondsSpinBox->setValue(0); } mSettings.setIdlenessTimeSecs(idleTimeSecs); diff --git a/config/idlenesswatchersettings.h b/config/idlenesswatchersettings.h index 84af8ca..2219eb4 100644 --- a/config/idlenesswatchersettings.h +++ b/config/idlenesswatchersettings.h @@ -39,7 +39,7 @@ namespace Ui { class IdlenessWatcherSettings : public QWidget { Q_OBJECT - + public: explicit IdlenessWatcherSettings(QWidget *parent = 0); ~IdlenessWatcherSettings(); diff --git a/config/idlenesswatchersettings.ui b/config/idlenesswatchersettings.ui index bc3a225..c00d729 100644 --- a/config/idlenesswatchersettings.ui +++ b/config/idlenesswatchersettings.ui @@ -57,7 +57,7 @@ - IIdle time: + Idle time: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter diff --git a/config/lidwatchersettings.cpp b/config/lidwatchersettings.cpp index e25be49..bfdb88c 100644 --- a/config/lidwatchersettings.cpp +++ b/config/lidwatchersettings.cpp @@ -38,12 +38,12 @@ LidWatcherSettings::LidWatcherSettings(QWidget *parent) : 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())); @@ -60,10 +60,10 @@ LidWatcherSettings::~LidWatcherSettings() 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()); @@ -73,10 +73,10 @@ void LidWatcherSettings::loadSettings() 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)); diff --git a/config/lidwatchersettings.h b/config/lidwatchersettings.h index 47c9212..9c5feb1 100644 --- a/config/lidwatchersettings.h +++ b/config/lidwatchersettings.h @@ -39,7 +39,7 @@ class LidWatcherSettings; class LidWatcherSettings : public QWidget { Q_OBJECT - + public: explicit LidWatcherSettings(QWidget *parent = 0); ~LidWatcherSettings(); diff --git a/config/mainwindow.cpp b/config/mainwindow.cpp index f4ce181..848ba2f 100644 --- a/config/mainwindow.cpp +++ b/config/mainwindow.cpp @@ -31,7 +31,7 @@ #include "idlenesswatchersettings.h" MainWindow::MainWindow(QWidget *parent) : - LxQt::ConfigDialog(tr("LXQt Powermanagement Configuration"), new PowerManagementSettings(parent)) + LxQt::ConfigDialog(tr("Power Management Settings"), new PowerManagementSettings(parent)) { BatteryWatcherSettings* batteryWatcherSettings = new BatteryWatcherSettings(this); addPage(batteryWatcherSettings, tr("Battery"), "battery"); @@ -42,7 +42,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(this, SIGNAL(reset()), lidwatcherSettings, SLOT(loadSettings())); IdlenessWatcherSettings* idlenessWatcherSettings = new IdlenessWatcherSettings(this); - addPage(idlenessWatcherSettings, tr("idle"), (QStringList() << "user-idle" << "user-away")); + addPage(idlenessWatcherSettings, tr("Idle"), (QStringList() << "user-idle" << "user-away")); connect(this, SIGNAL(reset()), idlenessWatcherSettings, SLOT(loadSettings())); emit reset(); diff --git a/config/powermanagementsettings.cpp b/config/powermanagementsettings.cpp index aa34d84..e593bc6 100644 --- a/config/powermanagementsettings.cpp +++ b/config/powermanagementsettings.cpp @@ -46,7 +46,6 @@ namespace PowerManagementSettingsConstants const QString SHOW_ICON_KEY = "showIcon"; const QString USE_THEME_ICONS_KEY = "useThemeIcons"; const QString IDLENESS_ACTION_KEY = "idlenessAction"; - const QString IDLENESS_TIME_MINS_KEY = "idlenessTimeMins"; const QString IDLENESS_TIME_SECS_KEY = "idlenessTimeSecs"; } @@ -192,7 +191,8 @@ void PowerManagementSettings::setEnableExtMonLidClosedActions(bool enableExtMonL int PowerManagementSettings::getIdlenessAction() { - return value(IDLENESS_ACTION_KEY, 0).toInt(); + // default to nothing (-1) + return value(IDLENESS_ACTION_KEY, -1).toInt(); } void PowerManagementSettings::setIdlenessAction(int idlenessAction) @@ -202,7 +202,8 @@ void PowerManagementSettings::setIdlenessAction(int idlenessAction) int PowerManagementSettings::getIdlenessTimeSecs() { - return value(IDLENESS_TIME_SECS_KEY, 5).toInt(); + // default to 15 minutes + return value(IDLENESS_TIME_SECS_KEY, 900).toInt(); } void PowerManagementSettings::setIdlenessTimeSecs(int idlenessTimeSecs) diff --git a/config/translations/lxqt-config-powermanagement.ts b/config/translations/lxqt-config-powermanagement.ts index 52accfe..6c5c01c 100644 --- a/config/translations/lxqt-config-powermanagement.ts +++ b/config/translations/lxqt-config-powermanagement.ts @@ -68,7 +68,7 @@ - IIdle time: + Idle time: diff --git a/config/translations/lxqt-config-powermanagement_hu.desktop b/config/translations/lxqt-config-powermanagement_hu.desktop new file mode 100644 index 0000000..d34e28e --- /dev/null +++ b/config/translations/lxqt-config-powermanagement_hu.desktop @@ -0,0 +1,3 @@ +# Translations +GenericName[hu]=LXQt energiakezelés beállítása +Name[hu]=Energiakezelés diff --git a/config/translations/lxqt-config-powermanagement_hu.ts b/config/translations/lxqt-config-powermanagement_hu.ts new file mode 100644 index 0000000..4bec70b --- /dev/null +++ b/config/translations/lxqt-config-powermanagement_hu.ts @@ -0,0 +1,195 @@ + + + + + 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: + + + + When power is low then: + Alacsony energiánál: + + + + Show icon: + Ikon mutatás: + + + + 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 + + + + Battery + Akkumulátor + + + + Lid + Fedél + + + + idle + Tétlenség + + + + QObject + + + Nothing + Semmi + + + + Lock screen + Képernyőzár + + + + Suspend + Készenlét + + + + Hibernate + Alvás + + + + Shutdown + Kikapcsolás + + + diff --git a/config/translations/lxqt-config-powermanagement_it.desktop b/config/translations/lxqt-config-powermanagement_it.desktop new file mode 100644 index 0000000..c88258a --- /dev/null +++ b/config/translations/lxqt-config-powermanagement_it.desktop @@ -0,0 +1,2 @@ +Name[it]=Gestore energia +GenericName[it]=Impostazioni del risparmio energetico diff --git a/config/translations/lxqt-config-powermanagement_it.ts b/config/translations/lxqt-config-powermanagement_it.ts new file mode 100644 index 0000000..607f01c --- /dev/null +++ b/config/translations/lxqt-config-powermanagement_it.ts @@ -0,0 +1,195 @@ + + + + + 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: + + + + When power is low then: + Quando il livello è basso: + + + + Show icon: + Mostra icona: + + + + 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 + + + + Battery + Batteria + + + + Lid + Coperchio + + + + idle + Inattività + + + + QObject + + + Nothing + Nessuna azione + + + + Lock screen + Blocca schermo + + + + Suspend + Sospendi + + + + Hibernate + Iberna + + + + Shutdown + Spegni + + + diff --git a/config/translations/lxqt-config-powermanagement_ja.ts b/config/translations/lxqt-config-powermanagement_ja.ts index 16810aa..4362a61 100644 --- a/config/translations/lxqt-config-powermanagement_ja.ts +++ b/config/translations/lxqt-config-powermanagement_ja.ts @@ -68,7 +68,7 @@ - IIdle time: + Idle time: アイドル状態の時間 diff --git a/config/translations/lxqt-config-powermanagement_pl_PL.desktop b/config/translations/lxqt-config-powermanagement_pl_PL.desktop new file mode 100644 index 0000000..3f4894b --- /dev/null +++ b/config/translations/lxqt-config-powermanagement_pl_PL.desktop @@ -0,0 +1,2 @@ +Name[pl_PL]=Zarządzanie energią +GenericName[pl_PL]=Konfiguracja zarządzania energią diff --git a/config/translations/lxqt-config-powermanagement_pl_PL.ts b/config/translations/lxqt-config-powermanagement_pl_PL.ts new file mode 100644 index 0000000..85c8642 --- /dev/null +++ b/config/translations/lxqt-config-powermanagement_pl_PL.ts @@ -0,0 +1,195 @@ + + + + + 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: + + + + When power is low then: + Gdy poziom jest niski: + + + + Show icon: + Pokaż ikonę: + + + + 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ą + + + + Battery + Bateria + + + + Lid + Pokrywa + + + + idle + Bezczynność + + + + QObject + + + Nothing + Brak reakcji + + + + Lock screen + Zablokuj ekran + + + + Suspend + Wstrzymaj + + + + Hibernate + Hibernuj + + + + Shutdown + Wyłącz + + + diff --git a/config/translations/lxqt-config-powermanagement_pt.ts b/config/translations/lxqt-config-powermanagement_pt.ts index c825f7b..33e1feb 100644 --- a/config/translations/lxqt-config-powermanagement_pt.ts +++ b/config/translations/lxqt-config-powermanagement_pt.ts @@ -68,7 +68,7 @@ - IIdle time: + Idle time: Tempo para inatividade: diff --git a/config/translations/lxqt-config-powermanagement_ru.ts b/config/translations/lxqt-config-powermanagement_ru.ts index cafcaae..553dd69 100644 --- a/config/translations/lxqt-config-powermanagement_ru.ts +++ b/config/translations/lxqt-config-powermanagement_ru.ts @@ -68,7 +68,7 @@ - IIdle time: + Idle time: Время простоя: diff --git a/config/translations/lxqt-config-powermanagement_ru_RU.ts b/config/translations/lxqt-config-powermanagement_ru_RU.ts index 1ed0b44..77c9b5f 100644 --- a/config/translations/lxqt-config-powermanagement_ru_RU.ts +++ b/config/translations/lxqt-config-powermanagement_ru_RU.ts @@ -68,7 +68,7 @@ - IIdle time: + Idle time: Время простоя: diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 26ace97..4a819f1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,24 +2,9 @@ project(lxqt-powermanagement) set(QTX_LIBRARIES Qt5::Widgets Qt5::DBus Qt5::Svg Qt5::X11Extras) -set(lxqt-powermanagement_MOCS - watcher.h - battery.h - batterywatcher.h - batteryinfoframe.h - batteryinfodialog.h - idlenesswatcher.h - lid.h - lidwatcher.h - powermanagementd.h - trayicon.h - iconproducer.h - ../config/powermanagementsettings.h -) - -set(lxqt-powermanagement_SRCS +set(SOURCES watcher.cpp - battery.cpp + batteryhelper.cpp batteryinfoframe.cpp batteryinfodialog.cpp batterywatcher.cpp @@ -34,7 +19,7 @@ set(lxqt-powermanagement_SRCS ../config/powermanagementsettings.cpp ) -set(lxqt-powermanagement_UIS +set(UI_FILES batteryinfoframe.ui batteryinfodialog.ui ) @@ -43,8 +28,7 @@ set(DESKTOP_FILES_IN lxqt-powermanagement.desktop.in ) -qt5_wrap_ui( UIS ${lxqt-powermanagement_UIS}) -qt5_add_dbus_adaptor(lxqt-powermanagement_SRCS +qt5_add_dbus_adaptor(SOURCES org.freedesktop.ScreenSaver.xml idlenesswatcher.h IdlenessWatcher @@ -53,9 +37,8 @@ qt5_add_dbus_adaptor(lxqt-powermanagement_SRCS lxqt_translate_ts(QM_FILES UPDATE_TRANSLATIONS ${UPDATE_TRANSLATIONS} SOURCES - ${lxqt-powermanagement_SRCS} - ${lxqt-powermanagement_UIS} - ${lxqt-powermanagement_MOCS} + ${SOURCES} + ${UI_FILES} INSTALL_DIR ${LXQT_TRANSLATIONS_DIR}/${PROJECT_NAME} ) @@ -103,18 +86,15 @@ find_library(XCB_DPMS_LIBRARY NAMES xcb-dpms include_directories( - "${CMAKE_CURRENT_BINARY_DIR}" ${Qt5Gui_PRIVATE_INCLUDE_DIRS} ${XCB_INCLUDE_DIR} ${X11_XCB_INCLUDE_DIR} - ${QTXDG_INCLUDE_DIRS} ${XCB_SCREENSAVER_INCLUDE_DIR} ${XCB_DPMS_INCLUDE_DIR} ) add_executable(lxqt-powermanagement - ${lxqt-powermanagement_SRCS} - ${UIS} + ${SOURCES} ${RSCS} ${QM_FILES} ${lxqt-powermanagement_QM_LOADER} @@ -122,14 +102,22 @@ add_executable(lxqt-powermanagement ) target_link_libraries(lxqt-powermanagement - ${LXQT_LIBRARIES} - ${QTXDG_LIBRARY} + lxqt ${QTX_LIBRARIES} ${XCB_LIBRARY} ${XCB_SCREENSAVER_LIBRARY} ${XCB_DPMS_LIBRARY} ${X11_XCB_LIBRARY} + KF5::Solid ) -install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) -install(FILES ${DESKTOP_FILES} DESTINATION share/applications) +install(TARGETS + ${PROJECT_NAME} + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + COMPONENT Runtime +) +install(FILES + ${DESKTOP_FILES} + DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications" + COMPONENT Runtime +) diff --git a/src/battery.cpp b/src/battery.cpp deleted file mode 100644 index 22f8b08..0000000 --- a/src/battery.cpp +++ /dev/null @@ -1,177 +0,0 @@ -/* 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 "battery.h" -#include "../config/powermanagementsettings.h" - -#define UPOWER_SERVICE "org.freedesktop.UPower" -#define UPOWER_PATH "/org/freedesktop/UPower" -#define UPOWER_INTERFACE "org.freedesktop.UPower" -#define DEVICE_INTERFACE "org.freedesktop.UPower.Device" -#define PROPERTIES_INTERFACE "org.freedesktop.DBus.Properties" - -QList Battery::batteries() -{ - QList result; - QDBusInterface uPowerInterface(UPOWER_SERVICE, UPOWER_PATH, UPOWER_SERVICE, QDBusConnection::systemBus()); - - QDBusReply > reply = uPowerInterface.call("EnumerateDevices"); - foreach (QDBusObjectPath objectPath, reply.value()) - { - QDBusInterface *deviceInterface = new QDBusInterface(UPOWER_SERVICE, objectPath.path(), DEVICE_INTERFACE, QDBusConnection::systemBus()); - - if (deviceInterface->property("Type").toUInt() == 2 && - ( deviceInterface->property("PowerSupply").toBool() || // UPower < 0.9.16.3 wrongly reports this false for some laptop batteries - deviceInterface->property("NativePath").toString().contains("power_supply"))) // - hence this line - { - QDBusInterface *propertiesInterface = new QDBusInterface(UPOWER_SERVICE, objectPath.path(), PROPERTIES_INTERFACE, QDBusConnection::systemBus()); - - result << new Battery(deviceInterface, propertiesInterface); - } - else - { - delete deviceInterface; - } - } - - return result; - -} - -Battery::Battery(QDBusInterface *deviceInterface, QDBusInterface *propertiesInterface, QObject* parent) - : QObject(parent), mDeviceInterface(deviceInterface), mPropertiesInterface(propertiesInterface) -{ - if (! connect(mDeviceInterface, SIGNAL(Changed()), this, SLOT(uPowerBatteryChanged())) ) - { - qDebug() << "Could not connect to 'changed' signal, connecting to PropertiesChanged instead and hoping for the best"; - QDBusConnection::systemBus().connect(UPOWER_SERVICE, - mPropertiesInterface->path(), - PROPERTIES_INTERFACE, - "PropertiesChanged", - this, - SLOT(uPowerBatteryChanged())); - - connect(mPropertiesInterface, SIGNAL(PropertiesChanged()), this, SLOT(uPowerBatteryChanged())); - } - - uPowerBatteryChanged(); // To get all properties - - // We assume these do not change during the lifetime of a battery - energyFullDesign = mProperties.value("EnergyFullDesign").toDouble(); - model = mProperties.value("Model").toString(); - technology = technology2String(mProperties.value("Technology, 0").toInt()); -} - -Battery::~Battery() -{ -} - -void Battery::uPowerBatteryChanged() -{ - qDebug() << "uPowerBatteryChanged()"; - - QDBusReply reply = mPropertiesInterface->call("GetAll", "org.freedesktop.UPower.Device"); - mProperties = reply.value(); - - State newState = State(mProperties.value("State").toUInt()); - double newChargeLevel = mProperties.value("Percentage").toDouble(); - - if (newState == state && fabs(newChargeLevel - chargeLevel) < 0.5) - { - // In principle we may miss a change in 'EnergyFull' but we - // assume it's always accompanied by a change in 'Percentage' - return; - } - - chargeLevel = newChargeLevel; - state = newState; - - summary = state2String(state); - if (state == Battery::Charging || state == Battery::Discharging) - { - summary.append(QString(" (%1 %)").arg(chargeLevel, 0, 'f', 0)); - } - - - updated = QDateTime::fromTime_t(mProperties.value("UpdateTime").toULongLong()); - energyFull = mProperties.value("EnergyFull").toDouble(); - capacity = mProperties.value("Capacity").toDouble(); - energyNow = mProperties.value("Energy").toDouble(); - energyRate = mProperties.value("EnergyRate").toDouble(); - voltage = mProperties.value("Voltage").toDouble(); - - qDebug() << "battery now:" - << "summary" << summary - << "updated:" << updated - << "energyFull:" << energyFull - << "energyNow:" << energyNow - << "energyRate:" << energyRate - << "voltage:" << voltage; - - emit chargeStateChange(chargeLevel, state); - emit summaryChanged(summary); -} - - -QString Battery::state2String(State state) -{ - static QMap names; - if (names.isEmpty()) - { - names.insert(Unknown, tr("Unknown")); - names.insert(Charging, tr("Charging")); - names.insert(Discharging, tr("Discharging")); - names.insert(Empty, tr("Empty")); - names.insert(FullyCharged, tr("Fully charged")); - names.insert(PendingCharge, tr("Pending charge")); - names.insert(PendingDischarge, tr("Pending discharge")); - } - - return names.value(state); -} - -QString Battery::technology2String(int tech) -{ - switch (tech) - { - case 1: return tr("Lithium ion"); - case 2: return tr("Lithium polymer"); - case 3: return tr("Lithium iron phosphate"); - case 4: return tr("Lead acid"); - case 5: return tr("Nickel cadmium"); - case 6: return tr("Nickel metal hydride"); - default: return tr("Unknown"); - } -} diff --git a/src/battery.h b/src/battery.h deleted file mode 100644 index 111ad0e..0000000 --- a/src/battery.h +++ /dev/null @@ -1,92 +0,0 @@ -/* 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 BATTERY_H -#define BATTERY_H - -#include -#include -#include -#include - -class Battery : public QObject -{ - Q_OBJECT - -public: - // These must match the UPower api spec - // See http://upower.freedesktop.org/docs/Device.html#Device:State - enum State - { - Unknown = 0, - Charging, - Discharging, - Empty, - FullyCharged, - PendingCharge, - PendingDischarge - }; - - static QList batteries(); - - static QString state2String(State state); - static QString technology2String(int tech); - - - Battery(QDBusInterface *deviceInterface, QDBusInterface *propertiesInterface, QObject* parent = 0); - ~Battery(); - - // This data is all available in mProperties, but we keep it - // here also for easy access (properly converted) - QString summary; - QDateTime updated; - State state; - double energyFullDesign; - double energyFull; - double capacity; - double energyNow; - double energyRate; - QString model; - QString technology; - double voltage; - double chargeLevel; - // -- - - bool haveBattery(); - -signals: - void chargeStateChange(float newChargeLevel, Battery::State newState); - void summaryChanged(QString newSummary); - -private slots: - void uPowerBatteryChanged(); - -private: - QDBusInterface *mDeviceInterface; - QDBusInterface *mPropertiesInterface; - QVariantMap mProperties; -}; -#endif diff --git a/src/batteryhelper.cpp b/src/batteryhelper.cpp new file mode 100644 index 0000000..2e514d8 --- /dev/null +++ b/src/batteryhelper.cpp @@ -0,0 +1,101 @@ +/* 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 Assistent'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("Unkown battery"); + } +} diff --git a/src/batteryhelper.h b/src/batteryhelper.h new file mode 100644 index 0000000..a99adec --- /dev/null +++ b/src/batteryhelper.h @@ -0,0 +1,44 @@ +/* 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 diff --git a/src/batteryinfodialog.cpp b/src/batteryinfodialog.cpp index 3cfff19..3794553 100644 --- a/src/batteryinfodialog.cpp +++ b/src/batteryinfodialog.cpp @@ -5,7 +5,7 @@ #include #include -BatteryInfoDialog::BatteryInfoDialog(QList batteries, QWidget *parent) : +BatteryInfoDialog::BatteryInfoDialog(QList batteries, QWidget *parent) : QDialog(parent), ui(new Ui::BatteryInfoDialog) { @@ -22,13 +22,12 @@ BatteryInfoDialog::BatteryInfoDialog(QList batteries, QWidget *parent) { QTabWidget *tabWidget = new QTabWidget(this); ui->verticalLayout->insertWidget(0, tabWidget); - foreach (Battery *battery, batteries) + foreach (Solid::Battery *battery, batteries) { BatteryInfoFrame *batteryInfoFrame = new BatteryInfoFrame(battery); tabWidget->addTab(batteryInfoFrame, "BAT"); } } - } BatteryInfoDialog::~BatteryInfoDialog() @@ -36,7 +35,6 @@ BatteryInfoDialog::~BatteryInfoDialog() delete ui; } - void BatteryInfoDialog::toggleShow() { qDebug() << "toggleShow"; diff --git a/src/batteryinfodialog.h b/src/batteryinfodialog.h index 168c3fe..eb2afb8 100644 --- a/src/batteryinfodialog.h +++ b/src/batteryinfodialog.h @@ -1,11 +1,11 @@ #ifndef BATTERYINFODIALOG_H #define BATTERYINFODIALOG_H -#include "battery.h" #include "batteryinfoframe.h" #include #include +#include namespace Ui { class BatteryInfoDialog; @@ -16,7 +16,7 @@ class BatteryInfoDialog : public QDialog Q_OBJECT public: - explicit BatteryInfoDialog(QList batteries, QWidget *parent = 0); + explicit BatteryInfoDialog(QList batteries, QWidget *parent = 0); ~BatteryInfoDialog(); public slots: diff --git a/src/batteryinfoframe.cpp b/src/batteryinfoframe.cpp index 339e10e..6e03975 100644 --- a/src/batteryinfoframe.cpp +++ b/src/batteryinfoframe.cpp @@ -28,20 +28,27 @@ #include #include "batteryinfoframe.h" +#include "batteryhelper.h" #include "ui_batteryinfoframe.h" -BatteryInfoFrame::BatteryInfoFrame(Battery *battery) : +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->modelValue->setText(mBattery->model); - mUi->technologyValue->setText(mBattery->technology); + 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())); - connect(mBattery, SIGNAL(chargeStateChange(float,Battery::State)), this, SLOT(onBatteryChanged())); + QString vendor = QString("%1 %2").arg(battery->recallVendor()).arg(battery->serial()); + if (vendor.trimmed().isEmpty()) + vendor = "Unkown"; + 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(); } @@ -52,12 +59,10 @@ BatteryInfoFrame::~BatteryInfoFrame() void BatteryInfoFrame::onBatteryChanged() { - qDebug() << "BatteryInfoFrame.onBatteryChanged" << "updated:" << mBattery->updated; - - mUi->updatedValue->setText(mBattery->updated.toString("hh:mm:ss")); - mUi->stateValue->setText(Battery::state2String(mBattery->state)); - mUi->energyFullValue->setText(QString("%1 Wh (%2 %)").arg(mBattery->energyFull, 0, 'f', 2).arg(mBattery->capacity, 0, 'f', 1)); - mUi->energyValue->setText(QString("%1 Wh (%2 %)").arg(mBattery->energyNow, 0, 'f', 2).arg(mBattery->chargeLevel, 0, 'f', 1)); - 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->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())); } diff --git a/src/batteryinfoframe.h b/src/batteryinfoframe.h index a00bdbc..a4249cf 100644 --- a/src/batteryinfoframe.h +++ b/src/batteryinfoframe.h @@ -29,7 +29,7 @@ #include -#include "battery.h" +#include namespace Ui { class BatteryInfoFrame; @@ -38,16 +38,16 @@ class BatteryInfoFrame; class BatteryInfoFrame : public QFrame { Q_OBJECT - + public: - explicit BatteryInfoFrame(Battery* battery); + explicit BatteryInfoFrame(Solid::Battery* battery); ~BatteryInfoFrame(); private slots: void onBatteryChanged(); private: - Battery* mBattery; + Solid::Battery* mBattery; Ui::BatteryInfoFrame *mUi; }; diff --git a/src/batteryinfoframe.ui b/src/batteryinfoframe.ui index b280712..0465881 100644 --- a/src/batteryinfoframe.ui +++ b/src/batteryinfoframe.ui @@ -2,38 +2,68 @@ BatteryInfoFrame + + + 0 + 0 + 277 + 292 + + Power Management - + + 6 + + 12 - - - - - 11 - + + 12 + + + 12 + + + + + DELL 00 + + + + - Updated: + Primary + + + + + + + 12.27 ºC + + + + + + + Temperature: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - 50 - false - - + + - 21:11:03 + Type: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -57,7 +87,7 @@ - Energy Full, Design: + Energy Full Design: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -122,20 +152,10 @@ - - - - Model: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - + + - DELL 00 + Lithium ion @@ -149,10 +169,10 @@ - - + + - Lithium ion + 12.27 V @@ -166,10 +186,13 @@ - - + + - 12.27 V + Vendor: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter diff --git a/src/batterywatcher.cpp b/src/batterywatcher.cpp index 9c9505d..a09a3ad 100644 --- a/src/batterywatcher.cpp +++ b/src/batterywatcher.cpp @@ -32,23 +32,33 @@ #include #include #include +#include +#include #include "batterywatcher.h" #include "../config/powermanagementsettings.h" BatteryWatcher::BatteryWatcher(QObject *parent) : Watcher(parent) { - mBatteries = Battery::batteries(); - if (mBatteries.isEmpty()) + 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"); + LxQt::Notification::notify(tr("No battery!"), + tr("LXQt could not find data about any battery - monitoring disabled"), + "lxqt-powermanagement"); } - foreach (Battery* battery, mBatteries) + foreach (Solid::Device device, devices) { - connect(battery, SIGNAL(chargeStateChange(float,Battery::State)), this, SLOT(batteryChanged())); + 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); @@ -74,16 +84,14 @@ void BatteryWatcher::batteryChanged() bool discharging = true; double chargeLevel; - - - foreach (Battery *battery, mBatteries) + foreach (Solid::Battery *battery, mBatteries) { - totalEnergyFull += battery->energyFull; - totalEnergyNow += battery->energyNow; - discharging &= (battery->state == Battery::Discharging); // hmm... + totalEnergyFull += battery->energyFull(); + totalEnergyNow += battery->energy(); + discharging &= (battery->chargeState() == Solid::Battery::Discharging); } - chargeLevel = 100*totalEnergyNow/totalEnergyFull; + chargeLevel = 100 * totalEnergyNow / totalEnergyFull; qDebug() << "BatteryChanged" << "discharging:" << discharging @@ -98,11 +106,9 @@ void BatteryWatcher::batteryChanged() if (powerLowActionRequired) { if (actionTime.isNull()) - { - actionTime = QTime::currentTime().addMSecs(mSettings.getPowerLowWarningTime()*1000); - } + actionTime = QTime::currentTime().addMSecs(mSettings.getPowerLowWarningTime() * 1000); - if (notification == 0) + if (!notification) { notification = new LxQt::Notification(tr("Power low!"), this); notification->setTimeout(2000); @@ -112,7 +118,7 @@ void BatteryWatcher::batteryChanged() if (milliSecondsToAction > 0) { - int secondsToAction = milliSecondsToAction/1000; + int secondsToAction = milliSecondsToAction / 1000; switch (mSettings.getPowerLowAction()) { case LxQt::Power::PowerSuspend: @@ -138,9 +144,7 @@ void BatteryWatcher::batteryChanged() else { if (!actionTime.isNull()) - { actionTime = QTime(); - } if (notification) { @@ -162,7 +166,7 @@ void BatteryWatcher::settingsChanged() } else if (mTrayIcons.isEmpty()) { - foreach (Battery *battery, mBatteries) + foreach (Solid::Battery *battery, mBatteries) { mTrayIcons.append(new TrayIcon(battery, this)); connect(mTrayIcons.last(), SIGNAL(toggleShowInfo()), mBatteryInfoDialog, SLOT(toggleShow())); diff --git a/src/batterywatcher.h b/src/batterywatcher.h index e22e39e..4c1075e 100644 --- a/src/batterywatcher.h +++ b/src/batterywatcher.h @@ -28,11 +28,12 @@ #define BATTERYWATCHER_H #include "watcher.h" -#include "battery.h" #include "trayicon.h" #include "batteryinfodialog.h" #include "../config/powermanagementsettings.h" +#include + class BatteryWatcher : public Watcher { Q_OBJECT @@ -45,7 +46,7 @@ private slots: void settingsChanged(); private: - QList mBatteries; + QList mBatteries; QList mTrayIcons; PowerManagementSettings mSettings; diff --git a/src/iconproducer.cpp b/src/iconproducer.cpp index a6873dd..f19dbde 100644 --- a/src/iconproducer.cpp +++ b/src/iconproducer.cpp @@ -6,13 +6,14 @@ #include #include -IconProducer::IconProducer(Battery *battery, QObject *parent) : QObject(parent) +IconProducer::IconProducer(Solid::Battery *battery, QObject *parent) : QObject(parent) { - connect(battery, SIGNAL(chargeStateChange(float,Battery::State)), this, SLOT(update(float,Battery::State))); + connect(battery, &Solid::Battery::chargeStateChanged, this, &IconProducer::updateState); + connect(battery, &Solid::Battery::chargePercentChanged, this, &IconProducer::updateChargePercent); connect(&mSettings, SIGNAL(settingsChanged()), this, SLOT(update())); - mChargeLevel = battery->chargeLevel; - mState = battery->state; + mChargePercent = battery->chargePercent(); + mState = battery->chargeState(); themeChanged(); } @@ -23,10 +24,16 @@ IconProducer::IconProducer(QObject *parent): QObject(parent) } -void IconProducer::update(float newChargeLevel, Battery::State newState) +void IconProducer::updateChargePercent(int newChargePercent) { - mChargeLevel = newChargeLevel; - mState = newState; + mChargePercent = newChargePercent; + + update(); +} + +void IconProducer::updateState(int newState) +{ + mState = (Solid::Battery::ChargeState) newState; update(); } @@ -37,10 +44,10 @@ void IconProducer::update() if (mSettings.isUseThemeIcons()) { - QMap *levelNameMap = (mState == Battery::Discharging ? &mLevelNameMapDischarging : &mLevelNameMapCharging); + QMap *levelNameMap = (mState == Solid::Battery::Discharging ? &mLevelNameMapDischarging : &mLevelNameMapCharging); foreach (float level, levelNameMap->keys()) { - if (level >= mChargeLevel) + if (level >= mChargePercent) { newIconName = levelNameMap->value(level); break; @@ -49,21 +56,10 @@ void IconProducer::update() } if (mSettings.isUseThemeIcons() && newIconName == mIconName) - { return; - } mIconName = newIconName; - - if (mSettings.isUseThemeIcons()) - { - mIcon = QIcon::fromTheme(mIconName); - } - else - { - mIcon = circleIcon(); - } - + mIcon = mSettings.isUseThemeIcons() ? QIcon::fromTheme(mIconName) : circleIcon(); emit iconChanged(); } @@ -80,10 +76,14 @@ void IconProducer::themeChanged() mLevelNameMapCharging.clear(); if (QIcon::themeName() == "oxygen") - { // Means: - mLevelNameMapDischarging[10] = "battery-low"; // Use 'battery-low' for levels up to 10 - mLevelNameMapDischarging[20] = "battery-caution"; // - 'battery-caution' for levels between 10 and 20 - mLevelNameMapDischarging[40] = "battery-040"; // - 'battery-040' for levels between 20 and 40, etc.. + { + // 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"; @@ -126,23 +126,19 @@ void IconProducer::themeChanged() update(); } - - QIcon& IconProducer::circleIcon() { - static QMap > cache; + static QMap > cache; - int chargeLevelAsInt = (int) (mChargeLevel + 0.49); + int chargeLevelAsInt = (int) (mChargePercent + 0.49); - if (! cache[mState].contains(chargeLevelAsInt)) - { - cache[mState][chargeLevelAsInt] = buildCircleIcon(mState, mChargeLevel); - } + if (!cache[mState].contains(chargeLevelAsInt)) + cache[mState][chargeLevelAsInt] = buildCircleIcon(mState, mChargePercent); return cache[mState][chargeLevelAsInt]; } -QIcon IconProducer::buildCircleIcon(Battery::State state, double chargeLevel) +QIcon IconProducer::buildCircleIcon(Solid::Battery::ChargeState state, int chargeLevel) { static QString svg_template = " 99.9) - { - chargeLevel = 99.9; - } - - double angle = M_PI_2 + 2*M_PI*chargeLevel/100; - double circle_endpoint_x = 80.0*cos(angle) + 100; - double circle_endpoint_y = -80.0*sin(angle) + 100; + 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"; - QString sweepFlag = "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 Battery::FullyCharged: svg.replace("STATE_MARKER", filledCircle); break; - case Battery::Charging: svg.replace("STATE_MARKER", plus); break; - case Battery::Discharging: svg.replace("STATE_MARKER", minus); break; - default: svg.replace("STATE_MARKER", hollowCircle); + 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 != Battery::FullyCharged && state != Battery::Charging && chargeLevel < mSettings.getPowerLowLevel() + 30) + 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)); - } + svg.replace("RED_OPACITY", QString::number((mSettings.getPowerLowLevel() + 30 - chargeLevel)/20.0)); } else - { svg.replace("RED_OPACITY", "0"); - } - qDebug() << svg; + // qDebug() << svg; // Paint the svg on a pixmap and create an icon from that. QSvgRenderer render(svg.toLatin1()); @@ -228,6 +232,4 @@ QIcon IconProducer::buildCircleIcon(Battery::State state, double chargeLevel) QPainter painter(&pixmap); render.render(&painter); return QIcon(pixmap); - } - diff --git a/src/iconproducer.h b/src/iconproducer.h index 1e45f18..f80857f 100644 --- a/src/iconproducer.h +++ b/src/iconproducer.h @@ -4,14 +4,14 @@ #include #include #include "../config/powermanagementsettings.h" -#include "battery.h" +#include class IconProducer : public QObject { Q_OBJECT public: - IconProducer(Battery* battery, QObject *parent = 0); + IconProducer(Solid::Battery* battery, QObject *parent = 0); IconProducer(QObject *parent = 0); QIcon mIcon; @@ -21,20 +21,19 @@ signals: void iconChanged(); public slots: - void update(float newChargeLevel, Battery::State newState); - -private slots: - void themeChanged(); + void updateChargePercent(int newChargePercent); + void updateState(int newState); void update(); + void themeChanged(); private: QIcon &circleIcon(); - QIcon buildCircleIcon(Battery::State state, double chargeLevel); + QIcon buildCircleIcon(Solid::Battery::ChargeState state, int chargeLevel); - float mChargeLevel; - Battery::State mState; + int mChargePercent; + Solid::Battery::ChargeState mState; PowerManagementSettings mSettings; diff --git a/src/idlenesswatcher.cpp b/src/idlenesswatcher.cpp index 206c2c2..22bd9d4 100644 --- a/src/idlenesswatcher.cpp +++ b/src/idlenesswatcher.cpp @@ -80,6 +80,7 @@ IdlenessWatcher::IdlenessWatcher(QObject* parent): 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))); @@ -142,22 +143,19 @@ uint IdlenessWatcher::getIdleTimeMs() uint IdlenessWatcher::getMaxIdleTimeoutMs() { - return 1000*mPSettings.getIdlenessTimeSecs(); + return 1000 * mPSettings.getIdlenessTimeSecs(); } void IdlenessWatcher::idleTimeout() { uint msSinceUserInput = getIdleTimeMs(); - qDebug() << " ms since user input:" << msSinceUserInput; if (msSinceUserInput >= getMaxIdleTimeoutMs()) { - doAction(mPSettings.getIdlenessAction()); + mTimer.stop(); + doAction(mPSettings.getIdlenessAction()); } else - { - qDebug() << "--- Locking screen in" << (getMaxIdleTimeoutMs() - msSinceUserInput) << "(maybe)."; mTimer.start(getMaxIdleTimeoutMs() - msSinceUserInput); - } } void IdlenessWatcher::restartTimer() diff --git a/src/idlenesswatcher.h b/src/idlenesswatcher.h index 1b83f3e..c80b011 100644 --- a/src/idlenesswatcher.h +++ b/src/idlenesswatcher.h @@ -66,11 +66,11 @@ private slots: 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; diff --git a/src/lid.cpp b/src/lid.cpp index 7c0b7db..05338eb 100644 --- a/src/lid.cpp +++ b/src/lid.cpp @@ -38,7 +38,7 @@ Lid::Lid() QDBusConnection::systemBus(), this); mUPowerPropertiesInterface = new QDBusInterface("org.freedesktop.UPower", "/org/freedesktop/UPower", "org.freedesktop.DBus.Properties", QDBusConnection::systemBus(), this); - if (! connect(mUPowerInterface, SIGNAL(Changed()), this, SLOT(uPowerChange()))) + if (! connect(mUPowerInterface, SIGNAL(Changed()), this, SLOT(uPowerChange()))) { qDebug() << "Could not connect to org.freedesktop.UPower.changed(), connecting to org.freedesktop.DBus.Properties.PropertiesChanged(..) instead"; QDBusConnection::systemBus().connect("org.freedesktop.UPower", @@ -48,7 +48,7 @@ Lid::Lid() this, SLOT(uPowerChange())); } - + mIsClosed = mUPowerPropertiesInterface->property("LidIsClosed").toBool(); } diff --git a/src/lidwatcher.cpp b/src/lidwatcher.cpp index 26bb5fe..673020d 100644 --- a/src/lidwatcher.cpp +++ b/src/lidwatcher.cpp @@ -73,7 +73,7 @@ int LidWatcher::action() } else { - return mSettings.getLidClosedAcAction(); + return mSettings.getLidClosedAcAction(); } } } diff --git a/src/powermanagementd.cpp b/src/powermanagementd.cpp index 565cc12..c58d398 100644 --- a/src/powermanagementd.cpp +++ b/src/powermanagementd.cpp @@ -26,6 +26,7 @@ #include #include +#include "batteryhelper.h" #include "powermanagementd.h" #include "../config/powermanagementsettings.h" #include "idlenesswatcher.h" @@ -48,7 +49,6 @@ PowerManagementd::PowerManagementd() : performRunCheck(); mSettings.setRunCheckLevel(CURRENT_RUNCHECK_LEVEL); } - } PowerManagementd::~PowerManagementd() @@ -58,9 +58,7 @@ PowerManagementd::~PowerManagementd() void PowerManagementd::settingsChanged() { if (mSettings.isBatteryWatcherEnabled() && !mBatterywatcherd) - { mBatterywatcherd = new BatteryWatcher(this); - } else if (mBatterywatcherd && ! mSettings.isBatteryWatcherEnabled()) { mBatterywatcherd->deleteLater(); @@ -98,9 +96,14 @@ void PowerManagementd::runConfigure() void PowerManagementd::performRunCheck() { mSettings.setLidWatcherEnabled(Lid().haveLid()); - mSettings.setBatteryWatcherEnabled(! Battery::batteries().isEmpty()); - qDebug() << "performRunCheck, lidWatcherEnabled:" << mSettings.isLidWatcherEnabled() << ", batteryWatcherEnabled:" << mSettings.isBatteryWatcherEnabled(); + 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...")); diff --git a/src/powermanagementd.h b/src/powermanagementd.h index 926411f..2209061 100644 --- a/src/powermanagementd.h +++ b/src/powermanagementd.h @@ -1,4 +1,4 @@ -/* +/* * File: powermanagementd.h * Author: Christian Surlykke * diff --git a/src/translations/lxqt-powermanagement_hu.ts b/src/translations/lxqt-powermanagement_hu.ts new file mode 100644 index 0000000..329b4cc --- /dev/null +++ b/src/translations/lxqt-powermanagement_hu.ts @@ -0,0 +1,260 @@ + + + + + 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 + + + + 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 + + + + 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 + + + + 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> + + + diff --git a/src/translations/lxqt-powermanagement_pl_PL.ts b/src/translations/lxqt-powermanagement_pl_PL.ts new file mode 100644 index 0000000..46202ec --- /dev/null +++ b/src/translations/lxqt-powermanagement_pl_PL.ts @@ -0,0 +1,260 @@ + + + + + Battery + + + Charging + Ładowanie + + + + Discharging + Rozładowywanie + + + + Empty + Pusta + + + + Fully charged + W pełni naładowana + + + + Pending charge + + + + + Pending discharge + + + + + Unknown + Nieznana + + + + BatteryInfo + + + Power Management + + + + + Battery info + Informacje o baterii + + + + Energy Now: + + + + + Updated: + + + + + Technology: + Technologia: + + + + Model: + 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 + Nieznana + + + + 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ę + + + + 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> + + + diff --git a/src/trayicon.cpp b/src/trayicon.cpp index 153cb16..3c96049 100644 --- a/src/trayicon.cpp +++ b/src/trayicon.cpp @@ -26,38 +26,58 @@ * END_COMMON_COPYRIGHT_HEADER */ #include -#include #include +#include #include +#include +#include +#include +#include +#include + #include "trayicon.h" +#include "batteryhelper.h" #include "../config/powermanagementsettings.h" -TrayIcon::TrayIcon(Battery *battery, QObject *parent) : QSystemTrayIcon(parent), mIconProducer(battery), mContextMenu() +TrayIcon::TrayIcon(Solid::Battery *battery, QObject *parent) + : QSystemTrayIcon(parent), + mBattery(battery), + mIconProducer(battery), + mContextMenu() { - connect(battery, SIGNAL(summaryChanged(QString)), this, SLOT(updateTooltip(QString))); - updateTooltip(battery->summary); + 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))); + connect(this, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), + SLOT(onActivated(QSystemTrayIcon::ActivationReason))); - mContextMenu.addAction(tr("Configure"), this, SLOT(onConfigureTriggered())); - mContextMenu.addAction(tr("About"), this, SLOT(onAboutTriggered())); - mContextMenu.addAction(tr("Disable icon"), this, SLOT(onDisableIconTriggered())); + 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() {} +TrayIcon::~TrayIcon() +{ +} void TrayIcon::iconChanged() { setIcon(mIconProducer.mIcon); } -void TrayIcon::updateTooltip(QString newTooltip) +void TrayIcon::updateTooltip() { - setToolTip(newTooltip); + QString tooltip = BatteryHelper::stateToString(mBattery->chargeState()); + tooltip += QString(" (%1 %)").arg(mBattery->chargePercent()); + setToolTip(tooltip); } void TrayIcon::onConfigureTriggered() @@ -70,8 +90,8 @@ void TrayIcon::onAboutTriggered() QMessageBox::about(0, tr("About"), tr( "

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

" "

" " Authors:
" diff --git a/src/trayicon.h b/src/trayicon.h index b9050af..f00c70e 100644 --- a/src/trayicon.h +++ b/src/trayicon.h @@ -30,8 +30,8 @@ #include #include +#include -#include "battery.h" #include "iconproducer.h" #include "../config/powermanagementsettings.h" @@ -40,7 +40,7 @@ class TrayIcon : public QSystemTrayIcon Q_OBJECT public: - TrayIcon(Battery *battery, QObject *parent = 0); + TrayIcon(Solid::Battery *battery, QObject *parent = 0); ~TrayIcon(); signals: @@ -48,7 +48,7 @@ signals: public slots: void iconChanged(); - void updateTooltip(QString newTooltip); + void updateTooltip(); private slots: void onConfigureTriggered(); @@ -57,6 +57,7 @@ private slots: void onActivated(QSystemTrayIcon::ActivationReason reason); private: + Solid::Battery *mBattery; IconProducer mIconProducer; QMenu mContextMenu; }; diff --git a/src/watcher.cpp b/src/watcher.cpp index 2bbb240..217399e 100644 --- a/src/watcher.cpp +++ b/src/watcher.cpp @@ -24,13 +24,14 @@ * END_COMMON_COPYRIGHT_HEADER */ #include - #include "../config/powermanagementsettings.h" #include "watcher.h" Watcher::Watcher(QObject *parent) : - QObject(parent) + QObject(parent), + mScreenSaver(this) { + connect(&mScreenSaver, SIGNAL(done()), &mLoop, SLOT(quit())); } Watcher::~Watcher() @@ -39,9 +40,14 @@ Watcher::~Watcher() void Watcher::doAction(int action) { - if (action > -1) - { - mPower.doAction((LxQt::Power::Action) action); + // if (action == -1) { } + if (action == -2) + { + mScreenSaver.lockScreen(); + mLoop.exec(); } -} + else if (action >= 0) + mPower.doAction((LxQt::Power::Action) action); + emit done(); +} diff --git a/src/watcher.h b/src/watcher.h index 2f9f36d..1cb58c0 100644 --- a/src/watcher.h +++ b/src/watcher.h @@ -1,12 +1,13 @@ #ifndef WATCHER_H -#define WATCHER_H +#define WATCHER_H #include +#include #include +#include class Watcher : public QObject { - Q_OBJECT public: @@ -16,10 +17,13 @@ public: protected: void doAction(int action); +signals: + void done(); + private: LxQt::Power mPower; - + LxQt::ScreenSaver mScreenSaver; + QEventLoop mLoop; }; -#endif /* WATCHER_H */ - +#endif // WATCHER_H From fe3d3c1489107c4c5f308806ebb42ffceafb93da Mon Sep 17 00:00:00 2001 From: Alf Gaida Date: Thu, 3 Sep 2015 00:47:45 +0200 Subject: [PATCH 2/6] Adding upstream version 0.9.0+20150831. --- config/helpers.cpp | 6 +- config/lxqt-config-powermanagement.desktop.in | 3 +- config/main.cpp | 2 +- config/mainwindow.cpp | 2 +- config/mainwindow.h | 2 +- config/powermanagementsettings.cpp | 2 +- config/powermanagementsettings.h | 2 +- .../lxqt-config-powermanagement_el.desktop | 3 + .../lxqt-config-powermanagement_el.ts | 195 +++++++++++++ .../lxqt-config-powermanagement_pt.ts | 2 +- src/batterywatcher.cpp | 14 +- src/idlenesswatcher.cpp | 6 +- src/idlenesswatcher.h | 2 +- src/lidwatcher.h | 2 +- src/main.cpp | 2 +- src/powermanagementd.h | 2 +- src/translations/lxqt-powermanagement.ts | 2 +- src/translations/lxqt-powermanagement_el.ts | 261 ++++++++++++++++++ src/translations/lxqt-powermanagement_hu.ts | 2 +- src/translations/lxqt-powermanagement_ja.ts | 2 +- .../lxqt-powermanagement_pl_PL.ts | 2 +- src/translations/lxqt-powermanagement_pt.ts | 8 +- src/translations/lxqt-powermanagement_ru.ts | 4 +- .../lxqt-powermanagement_ru_RU.ts | 4 +- src/watcher.cpp | 2 +- src/watcher.h | 4 +- 26 files changed, 499 insertions(+), 39 deletions(-) create mode 100644 config/translations/lxqt-config-powermanagement_el.desktop create mode 100644 config/translations/lxqt-config-powermanagement_el.ts create mode 100644 src/translations/lxqt-powermanagement_el.ts diff --git a/config/helpers.cpp b/config/helpers.cpp index d8ed276..3181488 100644 --- a/config/helpers.cpp +++ b/config/helpers.cpp @@ -34,9 +34,9 @@ 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); + 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) diff --git a/config/lxqt-config-powermanagement.desktop.in b/config/lxqt-config-powermanagement.desktop.in index 7a3d720..14d77fd 100644 --- a/config/lxqt-config-powermanagement.desktop.in +++ b/config/lxqt-config-powermanagement.desktop.in @@ -1,7 +1,8 @@ [Desktop Entry] Type=Application -Name=Power Management +Name=LXQt 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; diff --git a/config/main.cpp b/config/main.cpp index 8ce09d3..e1eab9e 100644 --- a/config/main.cpp +++ b/config/main.cpp @@ -31,7 +31,7 @@ int main(int argc, char *argv[]) { - LxQt::SingleApplication a(argc, argv); + LXQt::SingleApplication a(argc, argv); MainWindow mainWindow; mainWindow.setWindowIcon(QIcon::fromTheme("preferences-system-power-management")); diff --git a/config/mainwindow.cpp b/config/mainwindow.cpp index 848ba2f..e54fa5c 100644 --- a/config/mainwindow.cpp +++ b/config/mainwindow.cpp @@ -31,7 +31,7 @@ #include "idlenesswatchersettings.h" MainWindow::MainWindow(QWidget *parent) : - LxQt::ConfigDialog(tr("Power Management Settings"), new PowerManagementSettings(parent)) + LXQt::ConfigDialog(tr("Power Management Settings"), new PowerManagementSettings(parent)) { BatteryWatcherSettings* batteryWatcherSettings = new BatteryWatcherSettings(this); addPage(batteryWatcherSettings, tr("Battery"), "battery"); diff --git a/config/mainwindow.h b/config/mainwindow.h index c660df2..51aad10 100644 --- a/config/mainwindow.h +++ b/config/mainwindow.h @@ -29,7 +29,7 @@ #include -class MainWindow : public LxQt::ConfigDialog +class MainWindow : public LXQt::ConfigDialog { Q_OBJECT diff --git a/config/powermanagementsettings.cpp b/config/powermanagementsettings.cpp index e593bc6..996f608 100644 --- a/config/powermanagementsettings.cpp +++ b/config/powermanagementsettings.cpp @@ -51,7 +51,7 @@ namespace PowerManagementSettingsConstants using namespace PowerManagementSettingsConstants; -PowerManagementSettings::PowerManagementSettings(QObject* parent) : LxQt::Settings("lxqt-powermanagement") +PowerManagementSettings::PowerManagementSettings(QObject* parent) : LXQt::Settings("lxqt-powermanagement") { } diff --git a/config/powermanagementsettings.h b/config/powermanagementsettings.h index 73c69d5..f30b93f 100644 --- a/config/powermanagementsettings.h +++ b/config/powermanagementsettings.h @@ -33,7 +33,7 @@ #include -class PowerManagementSettings : public LxQt::Settings +class PowerManagementSettings : public LXQt::Settings { Q_OBJECT diff --git a/config/translations/lxqt-config-powermanagement_el.desktop b/config/translations/lxqt-config-powermanagement_el.desktop new file mode 100644 index 0000000..fba769a --- /dev/null +++ b/config/translations/lxqt-config-powermanagement_el.desktop @@ -0,0 +1,3 @@ +Name[el]=Διαχείριση ενέργειας +GenericName[el]=Ρυθμίσεις της διαχείρισης ενέργειας +Comment[el]=Διάφορες ρυθμίσεις σχετικά με την διαχείριση ενέργειας όπως ο επόπτης μπαταρίας ή αδράνειας diff --git a/config/translations/lxqt-config-powermanagement_el.ts b/config/translations/lxqt-config-powermanagement_el.ts new file mode 100644 index 0000000..d505211 --- /dev/null +++ b/config/translations/lxqt-config-powermanagement_el.ts @@ -0,0 +1,195 @@ + + + + + BatteryWatcherSettings + + + Battery Watcher Settings + Ρυθμίσεις επόπτη μπαταρίας + + + + E&nable Battery Watcher + &Ενεργοποίηση του επόπτη της μπαταρίας + + + + Warning: + Προειδοποίηση: + + + + seconds + δευτερόλεπτα + + + + Level is low at: + Το επίπεδο είναι χαμηλό στο: + + + + % + % + + + + Use icons from theme: + Χρήση των εικονιδίων από το θέμα: + + + + When power is low then: + Όταν η ενέργεια είναι χαμηλά τότε: + + + + Show icon: + Εμφάνιση εικονιδίου: + + + + 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 + + + + Battery + Μπαταρία + + + + Lid + Κάλυμμα φορητού + + + + idle + Αδράνεια + + + + QObject + + + Nothing + Τίποτα + + + + Lock screen + Κλείδωμα οθόνης + + + + Suspend + Αναστολή + + + + Hibernate + Νάρκη + + + + Shutdown + Τερματισμός + + + diff --git a/config/translations/lxqt-config-powermanagement_pt.ts b/config/translations/lxqt-config-powermanagement_pt.ts index 33e1feb..646a7f0 100644 --- a/config/translations/lxqt-config-powermanagement_pt.ts +++ b/config/translations/lxqt-config-powermanagement_pt.ts @@ -146,7 +146,7 @@ LXQt Powermanagement Configuration - Configuração do gestor de energia do LxQt + Configuração do gestor de energia do LXQt diff --git a/src/batterywatcher.cpp b/src/batterywatcher.cpp index a09a3ad..3ed56f3 100644 --- a/src/batterywatcher.cpp +++ b/src/batterywatcher.cpp @@ -44,7 +44,7 @@ BatteryWatcher::BatteryWatcher(QObject *parent) : Watcher(parent) if (devices.isEmpty()) { - LxQt::Notification::notify(tr("No battery!"), + LXQt::Notification::notify(tr("No battery!"), tr("LXQt could not find data about any battery - monitoring disabled"), "lxqt-powermanagement"); } @@ -64,7 +64,7 @@ BatteryWatcher::BatteryWatcher(QObject *parent) : Watcher(parent) mBatteryInfoDialog = new BatteryInfoDialog(mBatteries); connect(&mSettings, SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); - connect(LxQt::Settings::globalSettings(), SIGNAL(iconThemeChanged()), this, SLOT(settingsChanged())); + connect(LXQt::Settings::globalSettings(), SIGNAL(iconThemeChanged()), this, SLOT(settingsChanged())); settingsChanged(); batteryChanged(); @@ -77,7 +77,7 @@ BatteryWatcher::~BatteryWatcher() void BatteryWatcher::batteryChanged() { static QTime actionTime; - static LxQt::Notification *notification = 0; + static LXQt::Notification *notification = 0; double totalEnergyFull = 0; double totalEnergyNow = 0; @@ -110,7 +110,7 @@ void BatteryWatcher::batteryChanged() if (!notification) { - notification = new LxQt::Notification(tr("Power low!"), this); + notification = new LXQt::Notification(tr("Power low!"), this); notification->setTimeout(2000); } @@ -121,13 +121,13 @@ void BatteryWatcher::batteryChanged() int secondsToAction = milliSecondsToAction / 1000; switch (mSettings.getPowerLowAction()) { - case LxQt::Power::PowerSuspend: + case LXQt::Power::PowerSuspend: notification->setBody(tr("Suspending in %1 seconds").arg(secondsToAction)); break; - case LxQt::Power::PowerHibernate: + case LXQt::Power::PowerHibernate: notification->setBody(tr("Hibernating in %1 seconds").arg(secondsToAction)); break; - case LxQt::Power::PowerShutdown: + case LXQt::Power::PowerShutdown: notification->setBody(tr("Shutting down in %1 seconds").arg(secondsToAction)); break; } diff --git a/src/idlenesswatcher.cpp b/src/idlenesswatcher.cpp index 22bd9d4..44b33dc 100644 --- a/src/idlenesswatcher.cpp +++ b/src/idlenesswatcher.cpp @@ -47,7 +47,7 @@ IdlenessWatcher::IdlenessWatcher(QObject* parent): Watcher(parent), mPSettings(), - mErrorNotification(tr("LxQt Idleness watcher failed to start")), + mErrorNotification(tr("LXQt Idleness watcher failed to start")), mDBusWatcher(this), mInhibitorCookie(0), mIsLocked(false) @@ -61,7 +61,7 @@ IdlenessWatcher::IdlenessWatcher(QObject* parent): // 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.setUrgencyHint(LXQt::Notification::UrgencyCritical); mErrorNotification.setIcon("object-unlocked"); mErrorNotification.setTimeout(0); @@ -113,7 +113,7 @@ IdlenessWatcher::IdlenessWatcher(QObject* parent): mErrorNotification.setActions(QStringList(tr("Configure..."))); - qDebug() << "LxQt Screenlocker started."; + qDebug() << "LXQt Screenlocker started."; qDebug() << "timeout:" << getMaxIdleTimeoutMs() << "ms, lock command:" << mLockCommand; restartTimer(); } diff --git a/src/idlenesswatcher.h b/src/idlenesswatcher.h index c80b011..d88b97e 100644 --- a/src/idlenesswatcher.h +++ b/src/idlenesswatcher.h @@ -76,7 +76,7 @@ private: PowerManagementSettings mPSettings; QTimer mTimer; QProcess mLockProcess; - LxQt::Notification mErrorNotification; + LXQt::Notification mErrorNotification; QString mLockCommand; QDateTime mLockTime; QMap mInhibitors; diff --git a/src/lidwatcher.h b/src/lidwatcher.h index e6c21a9..c7fdef3 100644 --- a/src/lidwatcher.h +++ b/src/lidwatcher.h @@ -53,7 +53,7 @@ private: void inhibitSystemdLogin(); Lid mLid; - LxQt::Power mLxQtPower; + LXQt::Power mLXQtPower; PowerManagementSettings mSettings; QDBusUnixFileDescriptor logindLock; }; diff --git a/src/main.cpp b/src/main.cpp index c03669a..bfaf024 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -33,7 +33,7 @@ int main(int argc, char *argv[]) { - LxQt::Application a(argc, 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 diff --git a/src/powermanagementd.h b/src/powermanagementd.h index 2209061..508f71c 100644 --- a/src/powermanagementd.h +++ b/src/powermanagementd.h @@ -36,7 +36,7 @@ private: IdlenessWatcher* mIdlenesswatcherd; PowerManagementSettings mSettings; - LxQt::Notification mNotification; + LXQt::Notification mNotification; }; #endif /* POWERMANAGEMENTD_H */ diff --git a/src/translations/lxqt-powermanagement.ts b/src/translations/lxqt-powermanagement.ts index 2566687..965bfcf 100644 --- a/src/translations/lxqt-powermanagement.ts +++ b/src/translations/lxqt-powermanagement.ts @@ -169,7 +169,7 @@ IdlenessWatcher - LxQt Idleness watcher failed to start + LXQt Idleness watcher failed to start diff --git a/src/translations/lxqt-powermanagement_el.ts b/src/translations/lxqt-powermanagement_el.ts new file mode 100644 index 0000000..40287e5 --- /dev/null +++ b/src/translations/lxqt-powermanagement_el.ts @@ -0,0 +1,261 @@ + + + + + Battery + + + Charging + Φόρτιση + + + + Discharging + Αποφόρτιση + + + + Empty + Άδεια + + + + Fully charged + Γεμάτη + + + + Pending charge + Φορτίζεται + + + + Pending discharge + Αποφορτίζεται + + + + Unknown + Άγνωστο + + + + 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 + Άγνωστη + + + + 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 + Απενεργοποίηση του εικονιδίου + + + + 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> + + + diff --git a/src/translations/lxqt-powermanagement_hu.ts b/src/translations/lxqt-powermanagement_hu.ts index 329b4cc..b8d4f08 100644 --- a/src/translations/lxqt-powermanagement_hu.ts +++ b/src/translations/lxqt-powermanagement_hu.ts @@ -169,7 +169,7 @@ IdlenessWatcher - LxQt Idleness watcher failed to start + LXQt Idleness watcher failed to start Az LXQt tétlenség figyelő indítása sikertelen diff --git a/src/translations/lxqt-powermanagement_ja.ts b/src/translations/lxqt-powermanagement_ja.ts index f845b05..815298d 100644 --- a/src/translations/lxqt-powermanagement_ja.ts +++ b/src/translations/lxqt-powermanagement_ja.ts @@ -169,7 +169,7 @@ IdlenessWatcher - LxQt Idleness watcher failed to start + LXQt Idleness watcher failed to start LXQtのアイドル状態監視は始動に失敗しました diff --git a/src/translations/lxqt-powermanagement_pl_PL.ts b/src/translations/lxqt-powermanagement_pl_PL.ts index 46202ec..d1cce2f 100644 --- a/src/translations/lxqt-powermanagement_pl_PL.ts +++ b/src/translations/lxqt-powermanagement_pl_PL.ts @@ -169,7 +169,7 @@ IdlenessWatcher - LxQt Idleness watcher failed to start + LXQt Idleness watcher failed to start diff --git a/src/translations/lxqt-powermanagement_pt.ts b/src/translations/lxqt-powermanagement_pt.ts index 33e8a49..c0405c1 100644 --- a/src/translations/lxqt-powermanagement_pt.ts +++ b/src/translations/lxqt-powermanagement_pt.ts @@ -142,7 +142,7 @@ LXQt could not find data about any battery - monitoring disabled - O LxQt não consegui encontrar qualquer bateria e a monitorização foi desativada + O LXQt não consegui encontrar qualquer bateria e a monitorização foi desativada @@ -169,7 +169,7 @@ IdlenessWatcher - LxQt Idleness watcher failed to start + LXQt Idleness watcher failed to start O monitorizador de inatividade não foi iniciado @@ -214,7 +214,7 @@ 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. + Está a executar a gestão de energia do LXQt pela primeira vez. Pode configurar as opções nas definições... @@ -254,7 +254,7 @@ Pode configurar as opções nas definições... <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> + <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> diff --git a/src/translations/lxqt-powermanagement_ru.ts b/src/translations/lxqt-powermanagement_ru.ts index 04145a8..87aaa88 100644 --- a/src/translations/lxqt-powermanagement_ru.ts +++ b/src/translations/lxqt-powermanagement_ru.ts @@ -169,8 +169,8 @@ IdlenessWatcher - LxQt Idleness watcher failed to start - Не удалось запустить наблюдение за простоем LxQt + LXQt Idleness watcher failed to start + Не удалось запустить наблюдение за простоем LXQt diff --git a/src/translations/lxqt-powermanagement_ru_RU.ts b/src/translations/lxqt-powermanagement_ru_RU.ts index f151278..4e311e0 100644 --- a/src/translations/lxqt-powermanagement_ru_RU.ts +++ b/src/translations/lxqt-powermanagement_ru_RU.ts @@ -169,8 +169,8 @@ IdlenessWatcher - LxQt Idleness watcher failed to start - Не удалось запустить наблюдение за простоем LxQt + LXQt Idleness watcher failed to start + Не удалось запустить наблюдение за простоем LXQt diff --git a/src/watcher.cpp b/src/watcher.cpp index 217399e..cf9b632 100644 --- a/src/watcher.cpp +++ b/src/watcher.cpp @@ -47,7 +47,7 @@ void Watcher::doAction(int action) mLoop.exec(); } else if (action >= 0) - mPower.doAction((LxQt::Power::Action) action); + mPower.doAction((LXQt::Power::Action) action); emit done(); } diff --git a/src/watcher.h b/src/watcher.h index 1cb58c0..a86f810 100644 --- a/src/watcher.h +++ b/src/watcher.h @@ -21,8 +21,8 @@ signals: void done(); private: - LxQt::Power mPower; - LxQt::ScreenSaver mScreenSaver; + LXQt::Power mPower; + LXQt::ScreenSaver mScreenSaver; QEventLoop mLoop; }; From b27039f629e9c062c26e66b9ccc861004a04d6b0 Mon Sep 17 00:00:00 2001 From: Alf Gaida Date: Fri, 25 Sep 2015 17:56:34 +0200 Subject: [PATCH 3/6] Adding upstream version 0.9.0+20150914. --- config/helpers.h | 11 ++++--- config/lxqt-config-powermanagement.desktop.in | 2 +- src/batteryinfodialog.cpp | 8 +++++ src/batteryinfodialog.h | 8 +++++ src/iconproducer.cpp | 7 ++++ src/iconproducer.h | 8 +++++ src/lid.cpp | 32 ++++++++++--------- src/powermanagementd.h | 11 ++++--- src/watcher.h | 8 +++++ 9 files changed, 69 insertions(+), 26 deletions(-) diff --git a/config/helpers.h b/config/helpers.h index 128a4db..8d54fcb 100644 --- a/config/helpers.h +++ b/config/helpers.h @@ -1,9 +1,10 @@ /* - * File: Settings.h - * Author: christian - * - * Created on 15. februar 2014, 11:44 - */ +* 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 diff --git a/config/lxqt-config-powermanagement.desktop.in b/config/lxqt-config-powermanagement.desktop.in index 14d77fd..7955ace 100644 --- a/config/lxqt-config-powermanagement.desktop.in +++ b/config/lxqt-config-powermanagement.desktop.in @@ -6,6 +6,6 @@ Comment=Various settings regarding Power Management like battery or idleness wat Exec=lxqt-config-powermanagement Icon=preferences-system-power-management Categories=Settings;DesktopSettings;Qt;LXQt; -OnlyShowIn=LXQt;LXDE; +OnlyShowIn=LXQt; #TRANSLATIONS_DIR=translations diff --git a/src/batteryinfodialog.cpp b/src/batteryinfodialog.cpp index 3794553..a6c9a9a 100644 --- a/src/batteryinfodialog.cpp +++ b/src/batteryinfodialog.cpp @@ -1,3 +1,11 @@ +/* +* 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" diff --git a/src/batteryinfodialog.h b/src/batteryinfodialog.h index eb2afb8..c512060 100644 --- a/src/batteryinfodialog.h +++ b/src/batteryinfodialog.h @@ -1,3 +1,11 @@ +/* +* 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 diff --git a/src/iconproducer.cpp b/src/iconproducer.cpp index f19dbde..6fcf751 100644 --- a/src/iconproducer.cpp +++ b/src/iconproducer.cpp @@ -1,3 +1,10 @@ +/* +* 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 diff --git a/src/iconproducer.h b/src/iconproducer.h index f80857f..4e5d166 100644 --- a/src/iconproducer.h +++ b/src/iconproducer.h @@ -1,3 +1,11 @@ +/* +* 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 diff --git a/src/lid.cpp b/src/lid.cpp index 05338eb..35216c4 100644 --- a/src/lid.cpp +++ b/src/lid.cpp @@ -34,22 +34,25 @@ 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", + mUPowerInterface = new QDBusInterface("org.freedesktop.UPower", + "/org/freedesktop/UPower", + "org.freedesktop.UPower", QDBusConnection::systemBus(), this); - if (! connect(mUPowerInterface, SIGNAL(Changed()), this, SLOT(uPowerChange()))) - { - qDebug() << "Could not connect to org.freedesktop.UPower.changed(), connecting to org.freedesktop.DBus.Properties.PropertiesChanged(..) instead"; - QDBusConnection::systemBus().connect("org.freedesktop.UPower", - "/org/freedesktop/UPower", - "org.freedesktop.DBus.Properties", - "PropertiesChanged", - this, - SLOT(uPowerChange())); - } - mIsClosed = mUPowerPropertiesInterface->property("LidIsClosed").toBool(); + 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() @@ -62,7 +65,6 @@ bool Lid::onBattery() return mUPowerInterface->property("OnBattery").toBool(); } - void Lid::uPowerChange() { bool newIsClosed = mUPowerInterface->property("LidIsClosed").toBool(); diff --git a/src/powermanagementd.h b/src/powermanagementd.h index 508f71c..ce1c397 100644 --- a/src/powermanagementd.h +++ b/src/powermanagementd.h @@ -1,9 +1,10 @@ /* - * File: powermanagementd.h - * Author: Christian Surlykke - * - * Created on 9. februar 2014, 16:15 - */ +* 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 diff --git a/src/watcher.h b/src/watcher.h index a86f810..73a6226 100644 --- a/src/watcher.h +++ b/src/watcher.h @@ -1,3 +1,11 @@ +/* +* 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 From c5db783c326dfbad28db5f7793015e16654a1e39 Mon Sep 17 00:00:00 2001 From: Alf Gaida Date: Sat, 3 Oct 2015 12:36:17 +0200 Subject: [PATCH 4/6] Adding upstream version 0.9.0+20150930. --- config/lxqt-config-powermanagement.desktop.in | 2 +- src/batteryhelper.cpp | 2 +- src/batteryinfoframe.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/lxqt-config-powermanagement.desktop.in b/config/lxqt-config-powermanagement.desktop.in index 7955ace..2da97fd 100644 --- a/config/lxqt-config-powermanagement.desktop.in +++ b/config/lxqt-config-powermanagement.desktop.in @@ -1,6 +1,6 @@ [Desktop Entry] Type=Application -Name=LXQt Power Management +Name=Power Management GenericName=Power Management Settings Comment=Various settings regarding Power Management like battery or idleness watcher Exec=lxqt-config-powermanagement diff --git a/src/batteryhelper.cpp b/src/batteryhelper.cpp index 2e514d8..a4bd6b4 100644 --- a/src/batteryhelper.cpp +++ b/src/batteryhelper.cpp @@ -96,6 +96,6 @@ QString BatteryHelper::typeToString(Solid::Battery::BatteryType type) return tr("Monitor battery"); case Solid::Battery::UnknownBattery: default: - return tr("Unkown battery"); + return tr("Unknown battery"); } } diff --git a/src/batteryinfoframe.cpp b/src/batteryinfoframe.cpp index 6e03975..295fb0b 100644 --- a/src/batteryinfoframe.cpp +++ b/src/batteryinfoframe.cpp @@ -44,7 +44,7 @@ BatteryInfoFrame::BatteryInfoFrame(Solid::Battery *battery) : QString vendor = QString("%1 %2").arg(battery->recallVendor()).arg(battery->serial()); if (vendor.trimmed().isEmpty()) - vendor = "Unkown"; + vendor = "Unknown"; mUi->vendorValue->setText(vendor); connect(mBattery, SIGNAL(energyChanged(double, const QString)), this, SLOT(onBatteryChanged())); From dd7709f0fef9c19510b29db168ccae1253791453 Mon Sep 17 00:00:00 2001 From: Alf Gaida Date: Sat, 24 Oct 2015 12:04:11 +0200 Subject: [PATCH 5/6] Adding upstream version 0.9.0+20151024. --- config/lidwatchersettings.ui | 2 +- src/batteryhelper.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/lidwatchersettings.ui b/config/lidwatchersettings.ui index 623ecbe..d5e1647 100644 --- a/config/lidwatchersettings.ui +++ b/config/lidwatchersettings.ui @@ -125,7 +125,7 @@ padding-top: 30px; - On Ac + On AC diff --git a/src/batteryhelper.cpp b/src/batteryhelper.cpp index a4bd6b4..00ae063 100644 --- a/src/batteryhelper.cpp +++ b/src/batteryhelper.cpp @@ -77,7 +77,7 @@ QString BatteryHelper::typeToString(Solid::Battery::BatteryType type) switch (type) { case Solid::Battery::PdaBattery: - return tr("Personal Digital Assistent's battery"); + return tr("Personal Digital Assistant's battery"); case Solid::Battery::UpsBattery: return tr("Uninterruptible Power Supply's battery"); case Solid::Battery::PrimaryBattery: From 23495f619b4a89c95f916f823954813536f41dc7 Mon Sep 17 00:00:00 2001 From: Alf Gaida Date: Fri, 30 Oct 2015 23:20:49 +0100 Subject: [PATCH 6/6] Adding upstream version 0.9.0+20151029. --- src/trayicon.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/trayicon.cpp b/src/trayicon.cpp index 3c96049..8bb5885 100644 --- a/src/trayicon.cpp +++ b/src/trayicon.cpp @@ -38,6 +38,7 @@ #include "trayicon.h" #include "batteryhelper.h" #include "../config/powermanagementsettings.h" +#include TrayIcon::TrayIcon(Solid::Battery *battery, QObject *parent) : QSystemTrayIcon(parent), @@ -107,6 +108,15 @@ void TrayIcon::onAboutTriggered() 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); }