Skip to content

Commit

Permalink
Back light control added.
Browse files Browse the repository at this point in the history
  • Loading branch information
selairi authored and agaida committed Apr 29, 2018
1 parent 37e3c93 commit 4a2766e
Show file tree
Hide file tree
Showing 12 changed files with 915 additions and 0 deletions.
20 changes: 20 additions & 0 deletions CMakeLists.txt
Expand Up @@ -25,6 +25,8 @@ set(LXQT_VERSION ${LXQT_MAJOR_VERSION}.${LXQT_MINOR_VERSION}.${LXQT_PATCH_VERSIO
include(CMakePackageConfigHelpers)
include(GNUInstallDirs) # Standard directories for installation

add_subdirectory(lxqtbacklight/linux_backend/driver)

#-----------------------------------------------------------------------------
# Release is the default build type
#-----------------------------------------------------------------------------
Expand Down Expand Up @@ -55,6 +57,9 @@ set(PUB_HDRS
lxqtgridlayout.h
lxqtrotatedwidget.h
lxqtglobals.h
lxqtbacklight.h
#lxqtbacklight/virtual_backend.h
#lxqtbacklight/linux_backend/linuxbackend.h
)

set(PUBLIC_CLASSES
Expand All @@ -78,6 +83,7 @@ set(PUBLIC_CLASSES
GridLayout
RotatedWidget
Globals
Backlight
)

set(SRCS
Expand All @@ -101,6 +107,9 @@ set(SRCS
lxqtnotification.cpp
lxqtgridlayout.cpp
lxqtrotatedwidget.cpp
lxqtbacklight.cpp
lxqtbacklight/virtual_backend.cpp
lxqtbacklight/linux_backend/linuxbackend.cpp
)

set(MOCS
Expand All @@ -109,6 +118,7 @@ set(MOCS
lxqtsettings.h
lxqtscreensaver.h
lxqtapplication.h
lxqtbacklight.h

configdialog/lxqtconfigdialog.h
configdialog/lxqtconfigdialog_p.h
Expand All @@ -120,12 +130,22 @@ set(MOCS
lxqtpower/lxqtpowerproviders.h
lxqtgridlayout.h
lxqtrotatedwidget.h
lxqtbacklight/virtual_backend.h
lxqtbacklight/linux_backend/linuxbackend.h
)

set(FORMS
configdialog/lxqtconfigdialog.ui
)

set(POLKIT_FILES
${CMAKE_BINARY_DIR}/org.lxqt.backlight.pkexec.policy
)

# Build Polkit file
configure_file ( polkit/org.lxqt.backlight.pkexec.policy.in org.lxqt.backlight.pkexec.policy )
install(FILES ${POLKIT_FILES} DESTINATION /usr/share/polkit-1/actions/)

file(GLOB LXQT_CONFIG_FILES resources/*.conf)

option(UPDATE_TRANSLATIONS "Update source translation translations/*.ts files" OFF)
Expand Down
61 changes: 61 additions & 0 deletions lxqtbacklight.cpp
@@ -0,0 +1,61 @@
/*
* Copyright (C) 2016 P.L. Lucas
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#include "lxqtbacklight.h"
#include "lxqtbacklight/virtual_backend.h"
#include "lxqtbacklight/linux_backend/linuxbackend.h"

namespace LXQt {

Backlight::Backlight(QObject *parent):QObject(parent)
{
_backend = (VirtualBackEnd *) new LinuxBackend(this);
connect(_backend, SIGNAL(backlightChanged(int)), this, SLOT(backlightChangedSlot(int)));
}

Backlight::~Backlight()
{
delete _backend;
}

int Backlight::getBacklight()
{
return _backend->getBacklight();
}

int Backlight::getMaxBacklight()
{
return _backend->getMaxBacklight();
}

bool Backlight::isBacklightAvailable()
{
return _backend->isBacklightAvailable();
}

void Backlight::setBacklight(int value)
{
_backend->setBacklight(value);
}

void Backlight::backlightChangedSlot(int value)
{
emit backlightChanged(value);
}

} // namespace LXQt
53 changes: 53 additions & 0 deletions lxqtbacklight.h
@@ -0,0 +1,53 @@
/*
* Copyright (C) 2016 P.L. Lucas
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __Backlight_H__
#define __Backlight_H__

#include <QObject>
#include "lxqtglobals.h"

namespace LXQt
{
class VirtualBackEnd;

class LXQT_API Backlight : public QObject
{
Q_OBJECT

public:
Backlight(QObject *parent = 0);
~Backlight();

bool isBacklightAvailable();
void setBacklight(int value);
int getBacklight();
int getMaxBacklight();

signals:
void backlightChanged(int value);

private slots:
void backlightChangedSlot(int value);

private:
VirtualBackEnd *_backend;
};

} // namespace LXQt

#endif // __Backlight_H__
21 changes: 21 additions & 0 deletions lxqtbacklight/linux_backend/driver/CMakeLists.txt
@@ -0,0 +1,21 @@

project(lxqt-backlight_backend)

set(C_FILES
lxqtbacklight_backend.c
)

include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)

if(NOT CMAKE_BUILD_TYPE)
set( CMAKE_BUILD_TYPE Release )
endif (NOT CMAKE_BUILD_TYPE)

add_executable(${PROJECT_NAME}
${C_FILES}
)

install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)

0 comments on commit 4a2766e

Please sign in to comment.