Merging upstream version 0.9.0+20150807.

ubuntu/cosmic
Andrew Lee (李健秋) 9 years ago
parent 920c2cbf92
commit 6588e53d28

@ -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)

@ -1,239 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.2.2, 2014-12-12T20:37:00. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{5c6f7c82-f2e7-4d03-9d51-5ba00c7370fd}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="int">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap"/>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5e382e87-0cbd-448b-81ff-a635a0cc40fe}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="bool" key="CMakeProjectManager.CMakeBuildConfiguration.UseNinja">false</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/christian/projekter/Aktive/lxqt/lxqt-powermanagement/build</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments"></value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="CMakeProjectManager.MakeStep.Clean">false</value>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments">clean</value>
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="CMakeProjectManager.MakeStep.Clean">true</value>
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">all</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
<value type="int">0</value>
<value type="int">1</value>
<value type="int">2</value>
<value type="int">3</value>
<value type="int">4</value>
<value type="int">5</value>
<value type="int">6</value>
<value type="int">7</value>
<value type="int">8</value>
<value type="int">9</value>
<value type="int">10</value>
<value type="int">11</value>
<value type="int">12</value>
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguation.Title">lxqt-config-powermanagement</value>
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.Arguments"></value>
<value type="bool" key="CMakeProjectManager.CMakeRunConfiguration.UseTerminal">false</value>
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory"></value>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">lxqt-config-powermanagement</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.lxqt-config-powermanagement</value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.1">
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
<value type="int">0</value>
<value type="int">1</value>
<value type="int">2</value>
<value type="int">3</value>
<value type="int">4</value>
<value type="int">5</value>
<value type="int">6</value>
<value type="int">7</value>
<value type="int">8</value>
<value type="int">9</value>
<value type="int">10</value>
<value type="int">11</value>
<value type="int">12</value>
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguation.Title">lxqt-powermanagement</value>
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.Arguments"></value>
<value type="bool" key="CMakeProjectManager.CMakeRunConfiguration.UseTerminal">false</value>
<value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory"></value>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">lxqt-powermanagement</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.lxqt-powermanagement</value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">2</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="int">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">16</value>
</data>
<data>
<variable>Version</variable>
<value type="int">16</value>
</data>
</qtcreator>

@ -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
)

@ -29,11 +29,11 @@
#include <QDebug>
#include <QLabel>
#include <QGroupBox>
#include <Solid/Battery>
#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()

@ -42,7 +42,7 @@ class BatteryWatcherSettings;
class BatteryWatcherSettings : public QWidget
{
Q_OBJECT
public:
explicit BatteryWatcherSettings(QWidget *parent = 0);
~BatteryWatcherSettings();

@ -1,4 +1,4 @@
/*
/*
* File: Settings.h
* Author: christian
*

@ -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);

@ -39,7 +39,7 @@ namespace Ui {
class IdlenessWatcherSettings : public QWidget
{
Q_OBJECT
public:
explicit IdlenessWatcherSettings(QWidget *parent = 0);
~IdlenessWatcherSettings();

@ -57,7 +57,7 @@
</sizepolicy>
</property>
<property name="text">
<string>IIdle time:</string>
<string>Idle time:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>

@ -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));

@ -39,7 +39,7 @@ class LidWatcherSettings;
class LidWatcherSettings : public QWidget
{
Q_OBJECT
public:
explicit LidWatcherSettings(QWidget *parent = 0);
~LidWatcherSettings();

@ -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();

@ -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)

@ -68,7 +68,7 @@
</message>
<message>
<location filename="../idlenesswatchersettings.ui" line="66"/>
<source>IIdle time:</source>
<source>Idle time:</source>
<translation type="unfinished"></translation>
</message>
<message>

@ -0,0 +1,3 @@
# Translations
GenericName[hu]=LXQt energiakezelés beállítása
Name[hu]=Energiakezelés

@ -0,0 +1,195 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="hu_HU">
<context>
<name>BatteryWatcherSettings</name>
<message>
<location filename="../batterywatchersettings.ui" line="14"/>
<source>Battery Watcher Settings</source>
<translation>Akkumulátor figyelő beállítás</translation>
</message>
<message>
<location filename="../batterywatchersettings.ui" line="37"/>
<source>E&amp;nable Battery Watcher</source>
<translation>Akkumulátor figyelő e&amp;ngedélyezése</translation>
</message>
<message>
<location filename="../batterywatchersettings.ui" line="55"/>
<source>Warning:</source>
<translation>Figyelmeztetés:</translation>
</message>
<message>
<location filename="../batterywatchersettings.ui" line="68"/>
<source> seconds</source>
<translation> másodperc</translation>
</message>
<message>
<location filename="../batterywatchersettings.ui" line="78"/>
<source>Level is low at:</source>
<translation>Alacsony energiaszint:</translation>
</message>
<message>
<location filename="../batterywatchersettings.ui" line="91"/>
<source> %</source>
<translation></translation>
</message>
<message>
<location filename="../batterywatchersettings.ui" line="98"/>
<source>Use icons from theme:</source>
<translation>Ikonok a témából:</translation>
</message>
<message>
<location filename="../batterywatchersettings.ui" line="112"/>
<source>When power is low then:</source>
<translation>Alacsony energiánál:</translation>
</message>
<message>
<location filename="../batterywatchersettings.ui" line="129"/>
<source>Show icon:</source>
<translation>Ikon mutatás:</translation>
</message>
</context>
<context>
<name>IdlenessWatcherSettings</name>
<message>
<location filename="../idlenesswatchersettings.ui" line="14"/>
<source>Form</source>
<translation>Űrlap</translation>
</message>
<message>
<location filename="../idlenesswatchersettings.ui" line="26"/>
<source>Enab&amp;le Idleness Watcher</source>
<translation>Tétle&amp;nségi felügyelet</translation>
</message>
<message>
<location filename="../idlenesswatchersettings.ui" line="47"/>
<source>When idle then:</source>
<translation>Tétlenség esetén:</translation>
</message>
<message>
<location filename="../idlenesswatchersettings.ui" line="66"/>
<source>Idle time:</source>
<translation>Tétlenségi idő:</translation>
</message>
<message>
<location filename="../idlenesswatchersettings.ui" line="79"/>
<source> minutes</source>
<translation> perc</translation>
</message>
<message>
<location filename="../idlenesswatchersettings.ui" line="92"/>
<source> seconds</source>
<translation> másodperc</translation>
</message>
</context>
<context>
<name>LidWatcherSettings</name>
<message>
<location filename="../lidwatchersettings.ui" line="14"/>
<source>Form</source>
<translation>Űrlap</translation>
</message>
<message>
<location filename="../lidwatchersettings.ui" line="26"/>
<source>Enable &amp;Lid Watcher</source>
<translation>Fedélfelügyelet</translation>
</message>
<message>
<location filename="../lidwatchersettings.ui" line="45"/>
<source>Action when lid is closed</source>
<translation>Teendő fedélzáráskor</translation>
</message>
<message>
<location filename="../lidwatchersettings.ui" line="57"/>
<location filename="../lidwatchersettings.ui" line="160"/>
<source>On Battery</source>
<translation>Akkumulátor</translation>
</message>
<message>
<location filename="../lidwatchersettings.ui" line="77"/>
<source>Nothing</source>
<translation>Semmi</translation>
</message>
<message>
<location filename="../lidwatchersettings.ui" line="82"/>
<source>Suspend</source>
<translation>Készenlét</translation>
</message>
<message>
<location filename="../lidwatchersettings.ui" line="87"/>
<source>Hibernate</source>
<translation>Alvás</translation>
</message>
<message>
<location filename="../lidwatchersettings.ui" line="92"/>
<source>Shut down</source>
<translation>Kikapcsolás</translation>
</message>
<message>
<location filename="../lidwatchersettings.ui" line="100"/>
<source>On AC</source>
<translation>Külső táp</translation>
</message>
<message>
<location filename="../lidwatchersettings.ui" line="139"/>
<source>When &amp;using external monitor</source>
<translation>&amp;Külső monitor használatakor</translation>
</message>
<message>
<location filename="../lidwatchersettings.ui" line="177"/>
<source>On Ac</source>
<translation>Külső táp</translation>
</message>
</context>
<context>
<name>MainWindow</name>
<message>
<location filename="../mainwindow.cpp" line="34"/>
<source>LXQt Powermanagement Configuration</source>
<translation>LXQt energiafelügyelet beállítás</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="37"/>
<source>Battery</source>
<translation>Akkumulátor</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="41"/>
<source>Lid</source>
<translation>Fedél</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="45"/>
<source>idle</source>
<translation>Tétlenség</translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
<location filename="../helpers.cpp" line="35"/>
<source>Nothing</source>
<translation>Semmi</translation>
</message>
<message>
<location filename="../helpers.cpp" line="36"/>
<source>Lock screen</source>
<translation>Képernyőzár</translation>
</message>
<message>
<location filename="../helpers.cpp" line="37"/>
<source>Suspend</source>
<translation>Készenlét</translation>
</message>
<message>
<location filename="../helpers.cpp" line="38"/>
<source>Hibernate</source>
<translation>Alvás</translation>
</message>
<message>
<location filename="../helpers.cpp" line="39"/>
<source>Shutdown</source>
<translation>Kikapcsolás</translation>
</message>
</context>
</TS>

@ -0,0 +1,2 @@
Name[it]=Gestore energia
GenericName[it]=Impostazioni del risparmio energetico

@ -0,0 +1,195 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="it" sourcelanguage="it">
<context>
<name>BatteryWatcherSettings</name>
<message>
<location filename="../batterywatchersettings.ui" line="14"/>
<source>Battery Watcher Settings</source>
<translation>Impostazioni monitor batteria</translation>
</message>
<message>
<location filename="../batterywatchersettings.ui" line="37"/>
<source>E&amp;nable Battery Watcher</source>
<translation>&amp;Attiva il monitor della batteria</translation>
</message>
<message>
<location filename="../batterywatchersettings.ui" line="55"/>
<source>Warning:</source>
<translation>Tempo di attesa:</translation>
</message>
<message>
<location filename="../batterywatchersettings.ui" line="68"/>
<source> seconds</source>
<translation> secondi</translation>
</message>
<message>
<location filename="../batterywatchersettings.ui" line="78"/>
<source>Level is low at:</source>
<translation>Livello basso :</translation>
</message>
<message>
<location filename="../batterywatchersettings.ui" line="91"/>
<source> %</source>
<translation></translation>
</message>
<message>
<location filename="../batterywatchersettings.ui" line="98"/>
<source>Use icons from theme:</source>
<translation>Usa icone del tema:</translation>
</message>
<message>
<location filename="../batterywatchersettings.ui" line="112"/>
<source>When power is low then:</source>
<translation>Quando il livello è basso:</translation>
</message>
<message>
<location filename="../batterywatchersettings.ui" line="129"/>
<source>Show icon:</source>
<translation>Mostra icona:</translation>
</message>
</context>
<context>
<name>IdlenessWatcherSettings</name>
<message>
<location filename="../idlenesswatchersettings.ui" line="14"/>
<source>Form</source>
<translation></translation>
</message>
<message>
<location filename="../idlenesswatchersettings.ui" line="26"/>
<source>Enab&amp;le Idleness Watcher</source>
<translation>&amp;Attiva monitor attività sistema</translation>
</message>
<message>
<location filename="../idlenesswatchersettings.ui" line="47"/>
<source>When idle then:</source>
<translation>Quando inattivo:</translation>
</message>
<message>
<location filename="../idlenesswatchersettings.ui" line="66"/>
<source>Idle time:</source>
<translation>Tempo di inattività:</translation>
</message>
<message>
<location filename="../idlenesswatchersettings.ui" line="79"/>
<source> minutes</source>
<translation> minuti</translation>
</message>
<message>
<location filename="../idlenesswatchersettings.ui" line="92"/>
<source> seconds</source>
<translation> secondi</translation>
</message>
</context>
<context>
<name>LidWatcherSettings</name>
<message>
<location filename="../lidwatchersettings.ui" line="14"/>
<source>Form</source>
<translation></translation>
</message>
<message>
<location filename="../lidwatchersettings.ui" line="26"/>
<source>Enable &amp;Lid Watcher</source>
<translation>&amp;Attiva monitor coperchio</translation>
</message>
<message>
<location filename="../lidwatchersettings.ui" line="45"/>
<source>Action when lid is closed</source>
<translation>Azione a chiusura</translation>
</message>
<message>
<location filename="../lidwatchersettings.ui" line="57"/>
<location filename="../lidwatchersettings.ui" line="160"/>
<source>On Battery</source>
<translation>Alimentazione a batteria</translation>
</message>
<message>
<location filename="../lidwatchersettings.ui" line="77"/>
<source>Nothing</source>
<translation>Niente</translation>
</message>
<message>
<location filename="../lidwatchersettings.ui" line="82"/>
<source>Suspend</source>
<translation>Sospendi</translation>
</message>
<message>
<location filename="../lidwatchersettings.ui" line="87"/>
<source>Hibernate</source>
<translation>Iberna</translation>
</message>
<message>
<location filename="../lidwatchersettings.ui" line="92"/>
<source>Shut down</source>
<translation>Spegni</translation>
</message>
<message>
<location filename="../lidwatchersettings.ui" line="100"/>
<source>On AC</source>
<translation>Alimentazione di rete</translation>
</message>
<message>
<location filename="../lidwatchersettings.ui" line="139"/>
<source>When &amp;using external monitor</source>
<translation>Quando è in uso un monitor &amp;esterno</translation>
</message>
<message>
<location filename="../lidwatchersettings.ui" line="177"/>
<source>On Ac</source>
<translation>Alimentazione di rete</translation>
</message>
</context>
<context>
<name>MainWindow</name>
<message>
<location filename="../mainwindow.cpp" line="34"/>
<source>LXQt Powermanagement Configuration</source>
<translation>Configurazione gestione energetica di LXQt</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="37"/>
<source>Battery</source>
<translation>Batteria</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="41"/>
<source>Lid</source>
<translation>Coperchio</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="45"/>
<source>idle</source>
<translation>Inattività</translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
<location filename="../helpers.cpp" line="35"/>
<source>Nothing</source>
<translation>Nessuna azione</translation>
</message>
<message>
<location filename="../helpers.cpp" line="36"/>
<source>Lock screen</source>
<translation>Blocca schermo</translation>
</message>
<message>
<location filename="../helpers.cpp" line="37"/>
<source>Suspend</source>
<translation>Sospendi</translation>
</message>
<message>
<location filename="../helpers.cpp" line="38"/>
<source>Hibernate</source>
<translation>Iberna</translation>
</message>
<message>
<location filename="../helpers.cpp" line="39"/>
<source>Shutdown</source>
<translation>Spegni</translation>
</message>
</context>
</TS>

@ -68,7 +68,7 @@
</message>
<message>
<location filename="../idlenesswatchersettings.ui" line="66"/>
<source>IIdle time:</source>
<source>Idle time:</source>
<translation></translation>
</message>
<message>

@ -0,0 +1,2 @@
Name[pl_PL]=Zarządzanie energią
GenericName[pl_PL]=Konfiguracja zarządzania energią

@ -0,0 +1,195 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="pl_PL">
<context>
<name>BatteryWatcherSettings</name>
<message>
<location filename="../batterywatchersettings.ui" line="14"/>
<source>Battery Watcher Settings</source>
<translation>Ustawienia monitorowania baterii</translation>
</message>
<message>
<location filename="../batterywatchersettings.ui" line="37"/>
<source>E&amp;nable Battery Watcher</source>
<translation>W&amp;łącz monitorowanie baterii</translation>
</message>
<message>
<location filename="../batterywatchersettings.ui" line="55"/>
<source>Warning:</source>
<translation>Ostrzeżenie:</translation>
</message>
<message>
<location filename="../batterywatchersettings.ui" line="68"/>
<source> seconds</source>
<translation> sek</translation>
</message>
<message>
<location filename="../batterywatchersettings.ui" line="78"/>
<source>Level is low at:</source>
<translation>Poziom niski od:</translation>
</message>
<message>
<location filename="../batterywatchersettings.ui" line="91"/>
<source> %</source>
<translation> %</translation>
</message>
<message>
<location filename="../batterywatchersettings.ui" line="98"/>
<source>Use icons from theme:</source>
<translation>Użyj ikon z motywu:</translation>
</message>
<message>
<location filename="../batterywatchersettings.ui" line="112"/>
<source>When power is low then:</source>
<translation>Gdy poziom jest niski:</translation>
</message>
<message>
<location filename="../batterywatchersettings.ui" line="129"/>
<source>Show icon:</source>
<translation>Pokaż ikonę:</translation>
</message>
</context>
<context>
<name>IdlenessWatcherSettings</name>
<message>
<location filename="../idlenesswatchersettings.ui" line="14"/>
<source>Form</source>
<translation>Form</translation>
</message>
<message>
<location filename="../idlenesswatchersettings.ui" line="26"/>
<source>Enab&amp;le Idleness Watcher</source>
<translation>W&amp;łącz monitorowanie bezczynności</translation>
</message>
<message>
<location filename="../idlenesswatchersettings.ui" line="47"/>
<source>When idle then:</source>
<translation>Gdy bezczynny:</translation>
</message>
<message>
<location filename="../idlenesswatchersettings.ui" line="66"/>
<source>Idle time:</source>
<translation>Czas bezczynności:</translation>
</message>
<message>
<location filename="../idlenesswatchersettings.ui" line="79"/>
<source> minutes</source>
<translation>min</translation>
</message>
<message>
<location filename="../idlenesswatchersettings.ui" line="92"/>
<source> seconds</source>
<translation>sek</translation>
</message>
</context>
<context>
<name>LidWatcherSettings</name>
<message>
<location filename="../lidwatchersettings.ui" line="14"/>
<source>Form</source>
<translation>Form</translation>
</message>
<message>
<location filename="../lidwatchersettings.ui" line="26"/>
<source>Enable &amp;Lid Watcher</source>
<translation>W&amp;łącz monitorowanie pokrywy</translation>
</message>
<message>
<location filename="../lidwatchersettings.ui" line="45"/>
<source>Action when lid is closed</source>
<translation>Reakcja na zamknięcie pokrywy</translation>
</message>
<message>
<location filename="../lidwatchersettings.ui" line="57"/>
<location filename="../lidwatchersettings.ui" line="160"/>
<source>On Battery</source>
<translation>Na baterii</translation>
</message>
<message>
<location filename="../lidwatchersettings.ui" line="77"/>
<source>Nothing</source>
<translation>Brak</translation>
</message>
<message>
<location filename="../lidwatchersettings.ui" line="82"/>
<source>Suspend</source>
<translation>Wstrzymaj</translation>
</message>
<message>
<location filename="../lidwatchersettings.ui" line="87"/>
<source>Hibernate</source>
<translation>Hibernuj</translation>
</message>
<message>
<location filename="../lidwatchersettings.ui" line="92"/>
<source>Shut down</source>
<translation>Wyłącz</translation>
</message>
<message>
<location filename="../lidwatchersettings.ui" line="100"/>
<source>On AC</source>
<translation>Na zasilaniu</translation>
</message>
<message>
<location filename="../lidwatchersettings.ui" line="139"/>
<source>When &amp;using external monitor</source>
<translation>Przy używaniu &amp;zewnętrznego monitora</translation>
</message>
<message>
<location filename="../lidwatchersettings.ui" line="177"/>
<source>On Ac</source>
<translation>Na zasilaniu</translation>
</message>
</context>
<context>
<name>MainWindow</name>
<message>
<location filename="../mainwindow.cpp" line="34"/>
<source>LXQt Powermanagement Configuration</source>
<translation>LXQt Konfiguracja zarządzania energią</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="37"/>
<source>Battery</source>
<translation>Bateria</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="41"/>
<source>Lid</source>
<translation>Pokrywa</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="45"/>
<source>idle</source>
<translation>Bezczynność</translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
<location filename="../helpers.cpp" line="35"/>
<source>Nothing</source>
<translation>Brak reakcji</translation>
</message>
<message>
<location filename="../helpers.cpp" line="36"/>
<source>Lock screen</source>
<translation>Zablokuj ekran</translation>
</message>
<message>
<location filename="../helpers.cpp" line="37"/>
<source>Suspend</source>
<translation>Wstrzymaj</translation>
</message>
<message>
<location filename="../helpers.cpp" line="38"/>
<source>Hibernate</source>
<translation>Hibernuj</translation>
</message>
<message>
<location filename="../helpers.cpp" line="39"/>
<source>Shutdown</source>
<translation>Wyłącz</translation>
</message>
</context>
</TS>

@ -68,7 +68,7 @@
</message>
<message>
<location filename="../idlenesswatchersettings.ui" line="66"/>
<source>IIdle time:</source>
<source>Idle time:</source>
<translation>Tempo para inatividade:</translation>
</message>
<message>

@ -68,7 +68,7 @@
</message>
<message>
<location filename="../idlenesswatchersettings.ui" line="66"/>
<source>IIdle time:</source>
<source>Idle time:</source>
<translation>Время простоя:</translation>
</message>
<message>

@ -68,7 +68,7 @@
</message>
<message>
<location filename="../idlenesswatchersettings.ui" line="66"/>
<source>IIdle time:</source>
<source>Idle time:</source>
<translation>Время простоя:</translation>
</message>
<message>

@ -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
)

@ -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 <christian@surlykke.dk>
*
* 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 <QDBusConnection>
#include <QDBusReply>
#include <QList>
#include <QDBusObjectPath>
#include <QDebug>
#include <QMap>
#include <QDateTime>
#include <math.h>
#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*> Battery::batteries()
{
QList<Battery*> result;
QDBusInterface uPowerInterface(UPOWER_SERVICE, UPOWER_PATH, UPOWER_SERVICE, QDBusConnection::systemBus());
QDBusReply<QList<QDBusObjectPath> > 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<QVariantMap> 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<State, QString> 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");
}
}

@ -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 <christian@surlykke.dk>
*
* 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 <QObject>
#include <QDBusInterface>
#include <QVariantMap>
#include <QDateTime>
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<Battery*> 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

@ -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 <christian@surlykke.dk>
*
* 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 <QList>
#include <QDebug>
#include <QMap>
#include <QDateTime>
#include <cmath>
#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");
}
}

@ -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 <christian@surlykke.dk>
*
* 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 <QVariantMap>
#include <QDateTime>
#include <Solid/Battery>
#include <Solid/Device>
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

@ -5,7 +5,7 @@
#include <QTabWidget>
#include <QDebug>
BatteryInfoDialog::BatteryInfoDialog(QList<Battery*> batteries, QWidget *parent) :
BatteryInfoDialog::BatteryInfoDialog(QList<Solid::Battery*> batteries, QWidget *parent) :
QDialog(parent),
ui(new Ui::BatteryInfoDialog)
{
@ -22,13 +22,12 @@ BatteryInfoDialog::BatteryInfoDialog(QList<Battery*> 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";

@ -1,11 +1,11 @@
#ifndef BATTERYINFODIALOG_H
#define BATTERYINFODIALOG_H
#include "battery.h"
#include "batteryinfoframe.h"
#include <QDialog>
#include <QList>
#include <Solid/Battery>
namespace Ui {
class BatteryInfoDialog;
@ -16,7 +16,7 @@ class BatteryInfoDialog : public QDialog
Q_OBJECT
public:
explicit BatteryInfoDialog(QList<Battery*> batteries, QWidget *parent = 0);
explicit BatteryInfoDialog(QList<Solid::Battery*> batteries, QWidget *parent = 0);
~BatteryInfoDialog();
public slots:

@ -28,20 +28,27 @@
#include <QDebug>
#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()));
}

@ -29,7 +29,7 @@
#include <QFrame>
#include "battery.h"
#include <Solid/Battery>
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;
};

@ -2,38 +2,68 @@
<ui version="4.0">
<class>BatteryInfoFrame</class>
<widget class="QFrame" name="BatteryInfoFrame">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>277</width>
<height>292</height>
</rect>
</property>
<property name="windowTitle">
<string>Power Management</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="horizontalSpacing">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>12</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="updatedCaption">
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
<property name="bottomMargin">
<number>12</number>
</property>
<property name="spacing">
<number>12</number>
</property>
<item row="10" column="1">
<widget class="QLabel" name="vendorValue">
<property name="text">
<string notr="true">DELL 00</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="typeValue">
<property name="text">
<string>Updated:</string>
<string notr="true">Primary</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QLabel" name="temperatureValue">
<property name="text">
<string notr="true">12.27 ºC</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="temperatureCaption">
<property name="text">
<string>Temperature:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="updatedValue">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<item row="0" column="0">
<widget class="QLabel" name="typeCaption">
<property name="text">
<string notr="true">21:11:03</string>
<string>Type:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
@ -57,7 +87,7 @@
<item row="2" column="0">
<widget class="QLabel" name="energyFullDesignCaption">
<property name="text">
<string>Energy Full, Design:</string>
<string>Energy Full Design:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@ -122,20 +152,10 @@
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="modelCaption">
<property name="text">
<string>Model:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLabel" name="modelValue">
<item row="7" column="1">
<widget class="QLabel" name="technologyValue">
<property name="text">
<string notr="true">DELL 00</string>
<string notr="true">Lithium ion</string>
</property>
</widget>
</item>
@ -149,10 +169,10 @@
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLabel" name="technologyValue">
<item row="8" column="1">
<widget class="QLabel" name="voltageValue">
<property name="text">
<string notr="true">Lithium ion</string>
<string notr="true">12.27 V</string>
</property>
</widget>
</item>
@ -166,10 +186,13 @@
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLabel" name="voltageValue">
<item row="10" column="0">
<widget class="QLabel" name="vendorCaption">
<property name="text">
<string notr="true">12.27 V</string>
<string>Vendor:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>

@ -32,23 +32,33 @@
#include <LXQt/Notification>
#include <LXQt/AutostartEntry>
#include <LXQt/Power>
#include <Solid/Device>
#include <Solid/Battery>
#include "batterywatcher.h"
#include "../config/powermanagementsettings.h"
BatteryWatcher::BatteryWatcher(QObject *parent) : Watcher(parent)
{
mBatteries = Battery::batteries();
if (mBatteries.isEmpty())
QList<Solid::Device> 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<Solid::Battery>();
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()));

@ -28,11 +28,12 @@
#define BATTERYWATCHER_H
#include "watcher.h"
#include "battery.h"
#include "trayicon.h"
#include "batteryinfodialog.h"
#include "../config/powermanagementsettings.h"
#include <Solid/Battery>
class BatteryWatcher : public Watcher
{
Q_OBJECT
@ -45,7 +46,7 @@ private slots:
void settingsChanged();
private:
QList<Battery*> mBatteries;
QList<Solid::Battery*> mBatteries;
QList<TrayIcon*> mTrayIcons;
PowerManagementSettings mSettings;

@ -6,13 +6,14 @@
#include <QPainter>
#include <math.h>
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<float, QString> *levelNameMap = (mState == Battery::Discharging ? &mLevelNameMapDischarging : &mLevelNameMapCharging);
QMap<float, QString> *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<Battery::State, QMap<int, QIcon> > cache;
static QMap<Solid::Battery::ChargeState, QMap<int, QIcon> > 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 =
"<svg\n"
@ -177,49 +173,57 @@ QIcon IconProducer::buildCircleIcon(Battery::State state, double chargeLevel)
QString svg = svg_template;
if (chargeLevel > 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);
}

@ -4,14 +4,14 @@
#include <QMap>
#include <QObject>
#include "../config/powermanagementsettings.h"
#include "battery.h"
#include <Solid/Battery>
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;

@ -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()

@ -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;

@ -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();
}

@ -73,7 +73,7 @@ int LidWatcher::action()
}
else
{
return mSettings.getLidClosedAcAction();
return mSettings.getLidClosedAcAction();
}
}
}

@ -26,6 +26,7 @@
#include <QDebug>
#include <QStringList>
#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<Solid::Battery>()->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..."));

@ -1,4 +1,4 @@
/*
/*
* File: powermanagementd.h
* Author: Christian Surlykke
*

@ -0,0 +1,260 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="hu_HU">
<context>
<name>Battery</name>
<message>
<location filename="../battery.cpp" line="136"/>
<source>Charging</source>
<translation>Töltés</translation>
</message>
<message>
<location filename="../battery.cpp" line="137"/>
<source>Discharging</source>
<translation>Kisütés</translation>
</message>
<message>
<location filename="../battery.cpp" line="138"/>
<source>Empty</source>
<translation>Üres</translation>
</message>
<message>
<location filename="../battery.cpp" line="139"/>
<source>Fully charged</source>
<translation>Teletöltve</translation>
</message>
<message>
<location filename="../battery.cpp" line="140"/>
<source>Pending charge</source>
<translation>Tölthetőség</translation>
</message>
<message>
<location filename="../battery.cpp" line="141"/>
<source>Pending discharge</source>
<translation>Kisüthetőség</translation>
</message>
<message>
<location filename="../battery.cpp" line="142"/>
<source>Unknown</source>
<translation>Ismeretlen</translation>
</message>
</context>
<context>
<name>BatteryInfo</name>
<message>
<location filename="../batteryinfo.ui" line="14"/>
<source>Power Management</source>
<translation>Energiakezelés</translation>
</message>
<message>
<location filename="../batteryinfo.ui" line="25"/>
<source>Battery info</source>
<translation>Akkumulátor információ</translation>
</message>
<message>
<location filename="../batteryinfo.ui" line="40"/>
<source>Energy Now:</source>
<translation>Állapot:</translation>
</message>
<message>
<location filename="../batteryinfo.ui" line="62"/>
<source>Updated:</source>
<translation>Frissítve:</translation>
</message>
<message>
<location filename="../batteryinfo.ui" line="72"/>
<source>Technology:</source>
<translation>Technológia:</translation>
</message>
<message>
<location filename="../batteryinfo.ui" line="82"/>
<source>Model:</source>
<translation>Modell:</translation>
</message>
<message>
<location filename="../batteryinfo.ui" line="92"/>
<source>Energy rate:</source>
<translation>Energiaállapot:</translation>
</message>
<message>
<location filename="../batteryinfo.ui" line="102"/>
<source>Voltage:</source>
<translation>Feszültség:</translation>
</message>
<message>
<location filename="../batteryinfo.ui" line="112"/>
<source>Energy Full, Design:</source>
<translation>Névleges kapacitás: </translation>
</message>
<message>
<location filename="../batteryinfo.ui" line="129"/>
<source>Energy Full:</source>
<translation>Teljes kapacitás:</translation>
</message>
<message>
<location filename="../batteryinfo.ui" line="181"/>
<source>State:</source>
<translation>Állapot:</translation>
</message>
<message>
<location filename="../batteryinfo.cpp" line="74"/>
<source>Lithium ion</source>
<translation>Lítium ion</translation>
</message>
<message>
<location filename="../batteryinfo.cpp" line="75"/>
<source>Lithium polymer</source>
<translation>Lítium polimer</translation>
</message>
<message>
<location filename="../batteryinfo.cpp" line="76"/>
<source>Lithium iron phosphate</source>
<translation>Lítium vasfoszfát</translation>
</message>
<message>
<location filename="../batteryinfo.cpp" line="77"/>
<source>Lead acid</source>
<translation>Savas ólom</translation>
</message>
<message>
<location filename="../batteryinfo.cpp" line="78"/>
<source>Nickel cadmium</source>
<translation>Nikkel kadmium</translation>
</message>
<message>
<location filename="../batteryinfo.cpp" line="79"/>
<source>Nickel metal hydride</source>
<translation>Nikkel fémhidrid</translation>
</message>
<message>
<location filename="../batteryinfo.cpp" line="80"/>
<source>Unknown</source>
<translation>Ismeretlen</translation>
</message>
</context>
<context>
<name>BatteryWatcher</name>
<message>
<location filename="../batterywatcher.cpp" line="49"/>
<source>No battery!</source>
<translation>Nincs akku!</translation>
</message>
<message>
<location filename="../batterywatcher.cpp" line="50"/>
<source>LXQt could not find data about any battery - monitoring disabled</source>
<translation>Az LXQt nem ismert fel akkut - figyelés tiltva</translation>
</message>
<message>
<location filename="../batterywatcher.cpp" line="91"/>
<source>Power low!</source>
<translation>Alacsony feszültség!</translation>
</message>
<message>
<location filename="../batterywatcher.cpp" line="103"/>
<source>Suspending in %1 seconds</source>
<translation>%1 másodperc múlva készülség</translation>
</message>
<message>
<location filename="../batterywatcher.cpp" line="106"/>
<source>Hibernating in %1 seconds</source>
<translation>%1 másodperc múlva mélykészenlét</translation>
</message>
<message>
<location filename="../batterywatcher.cpp" line="109"/>
<source>Shutting down in %1 seconds</source>
<translation>%1 másodperc múlva kikapcsolás</translation>
</message>
</context>
<context>
<name>IdlenessWatcher</name>
<message>
<location filename="../idlenesswatcher.cpp" line="50"/>
<source>LxQt Idleness watcher failed to start</source>
<translation>Az LXQt tétlenség figyelő indítása sikertelen</translation>
</message>
<message>
<location filename="../idlenesswatcher.cpp" line="73"/>
<source>D-Bus interface org.freedesktop.ScreenSaver is already registered</source>
<translation>A D-Bus interface org.freedesktop.ScreenSaver imár regisztrálva van.</translation>
</message>
<message>
<location filename="../idlenesswatcher.cpp" line="106"/>
<source>The X11 Screensaver extension is not usable</source>
<translation>Az X11 képernyővédő bővítmény használhatatlan</translation>
</message>
<message>
<location filename="../idlenesswatcher.cpp" line="113"/>
<source>Configure...</source>
<translation>Beállítás...</translation>
</message>
<message>
<location filename="../idlenesswatcher.cpp" line="181"/>
<source>ERROR: Screen unlocked</source>
<translation>HIBA: A képernyő nem zárolt</translation>
</message>
<message>
<location filename="../idlenesswatcher.cpp" line="183"/>
<source>Locking program &quot;%1&quot; exited with error code %2</source>
<translation>A&quot;%1&quot; program %2 hibakóddal kilépett</translation>
</message>
<message>
<location filename="../idlenesswatcher.cpp" line="185"/>
<source>Locking program &quot;%1&quot; crashed with error code %2</source>
<translation>A&quot;%1&quot; program %2 hibakóddal összeomlott</translation>
</message>
</context>
<context>
<name>PowerManagementd</name>
<message>
<location filename="../powermanagementd.cpp" line="104"/>
<source>Power Management</source>
<translation>Energiakezelés</translation>
</message>
<message>
<location filename="../powermanagementd.cpp" line="105"/>
<source>You are running LXQt Power Management for the first time.
You can configure it from settings... </source>
<translation>Az LXQt energiakezelő első alkalommal fut.
A beállításokban konfigurálható...</translation>
</message>
<message>
<location filename="../powermanagementd.cpp" line="106"/>
<source>Configure...</source>
<translation>Beállítás...</translation>
</message>
</context>
<context>
<name>TrayIcon</name>
<message>
<location filename="../trayicon.cpp" line="132"/>
<source>Configure</source>
<translation>Beállítás</translation>
</message>
<message>
<location filename="../trayicon.cpp" line="133"/>
<location filename="../trayicon.cpp" line="167"/>
<source>About</source>
<translation>Rólunk</translation>
</message>
<message>
<location filename="../trayicon.cpp" line="134"/>
<source>Disable icon</source>
<translation>Ikon tiltása</translation>
</message>
<message>
<location filename="../trayicon.cpp" line="154"/>
<source>discharging</source>
<translation>kisütés</translation>
</message>
<message>
<location filename="../trayicon.cpp" line="154"/>
<source>charging</source>
<translation>töltés</translation>
</message>
<message>
<location filename="../trayicon.cpp" line="168"/>
<source>&lt;p&gt; &lt;b&gt;LXQt Powermanagement&lt;/b&gt;&lt;br/&gt; - Powermanagement for the LXQt Desktop Environment&lt;/p&gt;&lt;p&gt; Authors:&lt;br/&gt; &amp;nbsp; Christian Surlykke, Alec Moskvin&lt;br/&gt; &amp;nbsp; - and others from the Razor and LXQt projects&lt;/p&gt;&lt;p&gt; Copyright &amp;copy; 2012-2014&lt;/p&gt;</source>
<translation>&lt;p&gt; &lt;b&gt;LXQt energiakezelő&lt;/b&gt;&lt;br/&gt; - Energiakezelő az LXQt asztal részére&lt;/p&gt;&lt;p&gt; Szerzők:&lt;br/&gt; &amp;nbsp; Christian Surlykke, Alec Moskvin&lt;br/&gt; &amp;nbsp; - és még többen a Razor és LXQt fejlesztőiből.&lt;/p&gt;&lt;p&gt; Copyright &amp;copy; 2012-2014&lt;/p&gt;</translation>
</message>
</context>
</TS>

@ -0,0 +1,260 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="pl_PL">
<context>
<name>Battery</name>
<message>
<location filename="../battery.cpp" line="136"/>
<source>Charging</source>
<translation>Ładowanie</translation>
</message>
<message>
<location filename="../battery.cpp" line="137"/>
<source>Discharging</source>
<translation>Rozładowywanie</translation>
</message>
<message>
<location filename="../battery.cpp" line="138"/>
<source>Empty</source>
<translation>Pusta</translation>
</message>
<message>
<location filename="../battery.cpp" line="139"/>
<source>Fully charged</source>
<translation>W pełni naładowana</translation>
</message>
<message>
<location filename="../battery.cpp" line="140"/>
<source>Pending charge</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../battery.cpp" line="141"/>
<source>Pending discharge</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../battery.cpp" line="142"/>
<source>Unknown</source>
<translation>Nieznana</translation>
</message>
</context>
<context>
<name>BatteryInfo</name>
<message>
<location filename="../batteryinfo.ui" line="14"/>
<source>Power Management</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../batteryinfo.ui" line="25"/>
<source>Battery info</source>
<translation>Informacje o baterii</translation>
</message>
<message>
<location filename="../batteryinfo.ui" line="40"/>
<source>Energy Now:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../batteryinfo.ui" line="62"/>
<source>Updated:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../batteryinfo.ui" line="72"/>
<source>Technology:</source>
<translation>Technologia:</translation>
</message>
<message>
<location filename="../batteryinfo.ui" line="82"/>
<source>Model:</source>
<translation>Model:</translation>
</message>
<message>
<location filename="../batteryinfo.ui" line="92"/>
<source>Energy rate:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../batteryinfo.ui" line="102"/>
<source>Voltage:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../batteryinfo.ui" line="112"/>
<source>Energy Full, Design:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../batteryinfo.ui" line="129"/>
<source>Energy Full:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../batteryinfo.ui" line="181"/>
<source>State:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../batteryinfo.cpp" line="74"/>
<source>Lithium ion</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../batteryinfo.cpp" line="75"/>
<source>Lithium polymer</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../batteryinfo.cpp" line="76"/>
<source>Lithium iron phosphate</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../batteryinfo.cpp" line="77"/>
<source>Lead acid</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../batteryinfo.cpp" line="78"/>
<source>Nickel cadmium</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../batteryinfo.cpp" line="79"/>
<source>Nickel metal hydride</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../batteryinfo.cpp" line="80"/>
<source>Unknown</source>
<translation>Nieznana</translation>
</message>
</context>
<context>
<name>BatteryWatcher</name>
<message>
<location filename="../batterywatcher.cpp" line="49"/>
<source>No battery!</source>
<translation>Brak baterii!</translation>
</message>
<message>
<location filename="../batterywatcher.cpp" line="50"/>
<source>LXQt could not find data about any battery - monitoring disabled</source>
<translation>LXQt nie znalazł danych o żadnej baterii - monitorowanie wyłączone</translation>
</message>
<message>
<location filename="../batterywatcher.cpp" line="91"/>
<source>Power low!</source>
<translation>Niski poziom zasilania!</translation>
</message>
<message>
<location filename="../batterywatcher.cpp" line="103"/>
<source>Suspending in %1 seconds</source>
<translation>Wstrzymanie nastąpi w ciągu %1 sekund</translation>
</message>
<message>
<location filename="../batterywatcher.cpp" line="106"/>
<source>Hibernating in %1 seconds</source>
<translation>Hibernacja nastąpi w ciągu %1 sekund</translation>
</message>
<message>
<location filename="../batterywatcher.cpp" line="109"/>
<source>Shutting down in %1 seconds</source>
<translation>Wyłączenie systemu nastąpi w ciągu %1 sekund</translation>
</message>
</context>
<context>
<name>IdlenessWatcher</name>
<message>
<location filename="../idlenesswatcher.cpp" line="50"/>
<source>LxQt Idleness watcher failed to start</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../idlenesswatcher.cpp" line="73"/>
<source>D-Bus interface org.freedesktop.ScreenSaver is already registered</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../idlenesswatcher.cpp" line="106"/>
<source>The X11 Screensaver extension is not usable</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../idlenesswatcher.cpp" line="113"/>
<source>Configure...</source>
<translation>Konfiguruj...</translation>
</message>
<message>
<location filename="../idlenesswatcher.cpp" line="181"/>
<source>ERROR: Screen unlocked</source>
<translation>BŁĄD: Ekran odblokowany</translation>
</message>
<message>
<location filename="../idlenesswatcher.cpp" line="183"/>
<source>Locking program &quot;%1&quot; exited with error code %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../idlenesswatcher.cpp" line="185"/>
<source>Locking program &quot;%1&quot; crashed with error code %2</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PowerManagementd</name>
<message>
<location filename="../powermanagementd.cpp" line="104"/>
<source>Power Management</source>
<translation>Zarządzanie zasilaniem</translation>
</message>
<message>
<location filename="../powermanagementd.cpp" line="105"/>
<source>You are running LXQt Power Management for the first time.
You can configure it from settings... </source>
<translation>Uruchamiasz zarządzanie energią LXQt po raz pierwszy.
Możesz skonfiguroweć jego ustawienia...</translation>
</message>
<message>
<location filename="../powermanagementd.cpp" line="106"/>
<source>Configure...</source>
<translation>Konfiguruj...</translation>
</message>
</context>
<context>
<name>TrayIcon</name>
<message>
<location filename="../trayicon.cpp" line="132"/>
<source>Configure</source>
<translation>Konfiguruj</translation>
</message>
<message>
<location filename="../trayicon.cpp" line="133"/>
<location filename="../trayicon.cpp" line="167"/>
<source>About</source>
<translation>Info</translation>
</message>
<message>
<location filename="../trayicon.cpp" line="134"/>
<source>Disable icon</source>
<translation>Wyłącz ikonę</translation>
</message>
<message>
<location filename="../trayicon.cpp" line="154"/>
<source>discharging</source>
<translation>rozładowywanie</translation>
</message>
<message>
<location filename="../trayicon.cpp" line="154"/>
<source>charging</source>
<translation>ładowanie</translation>
</message>
<message>
<location filename="../trayicon.cpp" line="168"/>
<source>&lt;p&gt; &lt;b&gt;LXQt Powermanagement&lt;/b&gt;&lt;br/&gt; - Powermanagement for the LXQt Desktop Environment&lt;/p&gt;&lt;p&gt; Authors:&lt;br/&gt; &amp;nbsp; Christian Surlykke, Alec Moskvin&lt;br/&gt; &amp;nbsp; - and others from the Razor and LXQt projects&lt;/p&gt;&lt;p&gt; Copyright &amp;copy; 2012-2014&lt;/p&gt;</source>
<translation>&lt;p&gt; &lt;b&gt;LXQt Zarządzanie Energią&lt;/b&gt;&lt;br/&gt; - Zarządzanie energią dla środowiska LXQt&lt;/p&gt;&lt;p&gt; Autorzy:&lt;br/&gt; &amp;nbsp; Christian Surlykke, Alec Moskvin&lt;br/&gt; &amp;nbsp; - i inni z projektów Razor oraz LXQt&lt;/p&gt;&lt;p&gt; Copyright &amp;copy; 2012-2014&lt;/p&gt;</translation>
</message>
</context>
</TS>

@ -26,38 +26,58 @@
* END_COMMON_COPYRIGHT_HEADER */
#include <QDebug>
#include <QProcess>
#include <QApplication>
#include <QProcess>
#include <QMessageBox>
#include <QToolTip>
#include <QHelpEvent>
#include <Solid/Battery>
#include <Solid/Device>
#include <XdgIcon>
#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( "<p>"
" <b>LXQt Powermanagement</b><br/>"
" - Powermanagement for the LXQt Desktop Environment"
" <b>LXQt Power Management</b><br/>"
" - Power Management for the LXQt Desktop Environment"
"</p>"
"<p>"
" Authors:<br/>"

@ -30,8 +30,8 @@
#include <QSystemTrayIcon>
#include <QMenu>
#include <Solid/Battery>
#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;
};

@ -24,13 +24,14 @@
* END_COMMON_COPYRIGHT_HEADER */
#include <QDebug>
#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();
}

@ -1,12 +1,13 @@
#ifndef WATCHER_H
#define WATCHER_H
#define WATCHER_H
#include <QObject>
#include <QEventLoop>
#include <LXQt/Power>
#include <LXQt/ScreenSaver>
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

Loading…
Cancel
Save