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