From 0c4649c61723bd0f53842781736ae138a07842ea Mon Sep 17 00:00:00 2001 From: Mohammad Abu-Garbeyyeh Date: Mon, 28 May 2012 23:26:27 +0300 Subject: [PATCH] Initial commit --- .gitignore | 1 + brightnesscontroller.cpp | 51 +++++++++++++++ brightnesscontroller.cpp.autosave | 51 +++++++++++++++ brightnesscontroller.h | 35 +++++++++++ brightnessplugin.cpp | 36 +++++++++++ brightnessplugin.h | 40 ++++++++++++ debian/changelog | 5 ++ debian/compat | 1 + debian/control | 14 +++++ debian/copyright | 36 +++++++++++ debian/manifest.aegis | 69 ++++++++++++++++++++ debian/postinst | 8 +++ debian/postrm | 6 ++ debian/rules | 87 ++++++++++++++++++++++++++ statusindicatormenu-brightness.desktop | 7 +++ system-ui-brightness-control.pro | 28 +++++++++ 16 files changed, 475 insertions(+) create mode 100644 .gitignore create mode 100644 brightnesscontroller.cpp create mode 100644 brightnesscontroller.cpp.autosave create mode 100644 brightnesscontroller.h create mode 100644 brightnessplugin.cpp create mode 100644 brightnessplugin.h create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/manifest.aegis create mode 100644 debian/postinst create mode 100644 debian/postrm create mode 100755 debian/rules create mode 100644 statusindicatormenu-brightness.desktop create mode 100644 system-ui-brightness-control.pro diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bbe89aa --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +system-ui-brightness-control.pro.user system-ui-brightness-control.pro.user.2.3pre1 diff --git a/brightnesscontroller.cpp b/brightnesscontroller.cpp new file mode 100644 index 0000000..a8ffabb --- /dev/null +++ b/brightnesscontroller.cpp @@ -0,0 +1,51 @@ +#include "brightnesscontroller.h" +#include +#include + +BrightnessController::BrightnessController(BrightnessPlugin *brightnessPlugin, QGraphicsItem *parent) : + MWidget(parent), + m_brightnessSlider(new MSlider(this)), + m_brightnessPlugin(brightnessPlugin) +{ + QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Horizontal, this); + //setTitle(tr("Brightness")); + setObjectName("StatusIndicatorMenuExtensionContentItem"); + + MImageWidget *lowBrightnessImage = new MImageWidget("icon-s-camera-low-brightness", this); + layout->addItem(lowBrightnessImage); + + m_brightnessSlider->setRange(1, GConfItem("/system/osso/dsm/display/max_display_brightness_levels", this).value().toInt()); + layout->addItem(m_brightnessSlider); + + MImageWidget *highBrightnessImage = new MImageWidget("icon-s-camera-high-brightness", this); + layout->addItem(highBrightnessImage); + + layout->setContentsMargins(30, 15, 15, 15); + + m_brightnessGConfItem = new GConfItem("/system/osso/dsm/display/display_brightness"); + m_brightnessSlider->setValue(m_brightnessGConfItem->value().toInt()); + connect(m_brightnessGConfItem, SIGNAL(valueChanged()), this, SLOT(onValueChanged())); + connect(m_brightnessSlider, SIGNAL(valueChanged(int)), this, SLOT(onSliderValueChanged(int))); +} + +BrightnessController::~BrightnessController() +{ + +} + +void BrightnessController::onValueChanged() +{ + // Avoid infinite loops :) + disconnect(m_brightnessSlider, SIGNAL(valueChanged(int)), this, SLOT(onSliderValueChanged(int))); + + m_brightnessSlider->setValue(m_brightnessGConfItem->value().toInt()); + + connect(m_brightnessSlider, SIGNAL(valueChanged(int)), this, SLOT(onSliderValueChanged(int))); +} + +void BrightnessController::onSliderValueChanged(int newValue) +{ + m_brightnessGConfItem->blockSignals(true); + m_brightnessGConfItem->set(newValue); + m_brightnessGConfItem->blockSignals(false); +} diff --git a/brightnesscontroller.cpp.autosave b/brightnesscontroller.cpp.autosave new file mode 100644 index 0000000..a8ffabb --- /dev/null +++ b/brightnesscontroller.cpp.autosave @@ -0,0 +1,51 @@ +#include "brightnesscontroller.h" +#include +#include + +BrightnessController::BrightnessController(BrightnessPlugin *brightnessPlugin, QGraphicsItem *parent) : + MWidget(parent), + m_brightnessSlider(new MSlider(this)), + m_brightnessPlugin(brightnessPlugin) +{ + QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Horizontal, this); + //setTitle(tr("Brightness")); + setObjectName("StatusIndicatorMenuExtensionContentItem"); + + MImageWidget *lowBrightnessImage = new MImageWidget("icon-s-camera-low-brightness", this); + layout->addItem(lowBrightnessImage); + + m_brightnessSlider->setRange(1, GConfItem("/system/osso/dsm/display/max_display_brightness_levels", this).value().toInt()); + layout->addItem(m_brightnessSlider); + + MImageWidget *highBrightnessImage = new MImageWidget("icon-s-camera-high-brightness", this); + layout->addItem(highBrightnessImage); + + layout->setContentsMargins(30, 15, 15, 15); + + m_brightnessGConfItem = new GConfItem("/system/osso/dsm/display/display_brightness"); + m_brightnessSlider->setValue(m_brightnessGConfItem->value().toInt()); + connect(m_brightnessGConfItem, SIGNAL(valueChanged()), this, SLOT(onValueChanged())); + connect(m_brightnessSlider, SIGNAL(valueChanged(int)), this, SLOT(onSliderValueChanged(int))); +} + +BrightnessController::~BrightnessController() +{ + +} + +void BrightnessController::onValueChanged() +{ + // Avoid infinite loops :) + disconnect(m_brightnessSlider, SIGNAL(valueChanged(int)), this, SLOT(onSliderValueChanged(int))); + + m_brightnessSlider->setValue(m_brightnessGConfItem->value().toInt()); + + connect(m_brightnessSlider, SIGNAL(valueChanged(int)), this, SLOT(onSliderValueChanged(int))); +} + +void BrightnessController::onSliderValueChanged(int newValue) +{ + m_brightnessGConfItem->blockSignals(true); + m_brightnessGConfItem->set(newValue); + m_brightnessGConfItem->blockSignals(false); +} diff --git a/brightnesscontroller.h b/brightnesscontroller.h new file mode 100644 index 0000000..c447de4 --- /dev/null +++ b/brightnesscontroller.h @@ -0,0 +1,35 @@ +#ifndef BRIGHTNESSCONTROLLER_H +#define BRIGHTNESSCONTROLLER_H + +#include +#include +#include +#include "brightnessplugin.h" +#include + +class MStatusIndicatorMenuInterface; +class ProfilePlugin; + +class BrightnessController : public MWidget +{ + Q_OBJECT +public: + explicit BrightnessController(BrightnessPlugin *brightnessPlugin, QGraphicsItem *parent = NULL); + virtual ~BrightnessController(); + +signals: + +public slots: + +private: + MSlider *m_brightnessSlider; + BrightnessPlugin *m_brightnessPlugin; + + GConfItem *m_brightnessGConfItem; + +private slots: + void onSliderValueChanged(int); + void onValueChanged(); +}; + +#endif // BRIGHTNESSCONTROLLER_H diff --git a/brightnessplugin.cpp b/brightnessplugin.cpp new file mode 100644 index 0000000..1c65d51 --- /dev/null +++ b/brightnessplugin.cpp @@ -0,0 +1,36 @@ +#include "brightnessplugin.h" +#include "brightnesscontroller.h" + +Q_EXPORT_PLUGIN2(profile, BrightnessPlugin) + +BrightnessPlugin::BrightnessPlugin(QObject *parent) : + statusIndicatorMenu(0), + m_brightnessController(0) +{ + Q_UNUSED(parent) +} + +void BrightnessPlugin::setStatusIndicatorMenuInterface(MStatusIndicatorMenuInterface &menuInterface) +{ + statusIndicatorMenu = &menuInterface; +} + +MStatusIndicatorMenuInterface *BrightnessPlugin::statusIndicatorMenuInterface() const +{ + return statusIndicatorMenu; +} + +// Methods derived from MApplicationExtensionInterface +bool BrightnessPlugin::initialize(const QString &) +{ + m_brightnessController = new BrightnessController(this); + + return true; +} + +QGraphicsWidget *BrightnessPlugin::widget() +{ + return m_brightnessController; +} + +M_LIBRARY diff --git a/brightnessplugin.h b/brightnessplugin.h new file mode 100644 index 0000000..abc1f5d --- /dev/null +++ b/brightnessplugin.h @@ -0,0 +1,40 @@ +#ifndef BRIGHTNESSPLUGIN_H +#define BRIGHTNESSPLUGIN_H + +#include +#include +#include +#include +#include +#include + +class BrightnessController; + +class BrightnessPlugin : public QObject, public MStatusIndicatorMenuExtensionInterface +{ + Q_OBJECT + Q_INTERFACES(MStatusIndicatorMenuExtensionInterface MApplicationExtensionInterface) + +public: + explicit BrightnessPlugin(QObject *parent = 0); + + // Getter for the status indicator menu interface + MStatusIndicatorMenuInterface *statusIndicatorMenuInterface() const; + + // Methods derived from MStatusIndicatorMenuPlugin + virtual void setStatusIndicatorMenuInterface(MStatusIndicatorMenuInterface &menuInterface); + + // Methods derived from MApplicationExtensionInterface + virtual bool initialize(const QString &interface); + virtual QGraphicsWidget *widget(); + +signals: + +public slots: + +private: + MStatusIndicatorMenuInterface *statusIndicatorMenu; + BrightnessController *m_brightnessController; +}; + +#endif // BRIGHTNESSPLUGIN_H diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..fd5ab1e --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +system-ui-brightness-control (0.1) unstable; urgency=low + + * Initial Release. + + -- Mohammad Abu-Garbeyyeh Mon, 28 May 2012 22:31:39 +0300 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7f8f011 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +7 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..8f41c48 --- /dev/null +++ b/debian/control @@ -0,0 +1,14 @@ +Source: system-ui-brightness-control +Section: user/other +Priority: optional +Maintainer: Mohammad Abu-Garbeyyeh +Build-Depends: debhelper (>= 5), libqt4-dev, libmeegotouch-dev +Standards-Version: 3.7.3 + +Package: system-ui-brightness-control +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, unrestricted-system-ui +Description: Brightness plugin in status menu + A status menu plugin that can be used to change + the brightness of the display. +XSBC-Maemo-Display-Name: Brightness control status menu applet diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..4d1eb5f --- /dev/null +++ b/debian/copyright @@ -0,0 +1,36 @@ +This package was debianized by Mohammad Abu-Garbeyyeh + on Sat, 02 Jul 2011 01:38:53 +0300. + +Upstream Author(s): + + Mohammad Abu-Garbeyyeh + +Copyright: + + Copyright (C) 2012 Mohammad Abu-Garbeyyeh + +License: + + This package 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 package 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 package; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +On Debian systems, the complete text of the GNU General +Public License can be found in `/usr/share/common-licenses/GPL'. + +The Debian packaging is (C) 2012, Mohammad Abu-Garbeyyeh and +is licensed under the GPL, see above. + + +# Please also look if there are files or directories which have a +# different copyright/license attached and list them here. diff --git a/debian/manifest.aegis b/debian/manifest.aegis new file mode 100644 index 0000000..507e50f --- /dev/null +++ b/debian/manifest.aegis @@ -0,0 +1,69 @@ +AutoGenerateAegisFile + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 0000000..ce16bae --- /dev/null +++ b/debian/postinst @@ -0,0 +1,8 @@ +#!/bin/sh + +echo "Restarting status menu" +/sbin/stop xsession/sysuid +sleep 1 +/sbin/start xsession/sysuid + +exit 0 diff --git a/debian/postrm b/debian/postrm new file mode 100644 index 0000000..84b90c5 --- /dev/null +++ b/debian/postrm @@ -0,0 +1,6 @@ +#!/bin/sh + +/sbin/stop xsession/sysuid +sleep 1 +/sbin/start xsession/sysuid +exit 0 diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..8e2d014 --- /dev/null +++ b/debian/rules @@ -0,0 +1,87 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +configure: configure-stamp +configure-stamp: + dh_testdir + qmake # Uncomment this line for use without Qt Creator + + touch configure-stamp + + +build: build-stamp + +build-stamp: configure-stamp + dh_testdir + + # Add here commands to compile the package. + $(MAKE) # Uncomment this line for use without Qt Creator + #docbook-to-man debian/system-ui-brightness-control.sgml > system-ui-brightness-control.1 + + touch $@ + +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + + # Add here commands to clean up after the build process. + $(MAKE) clean + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/system-ui-brightness-control. + $(MAKE) INSTALL_ROOT="$(CURDIR)"/debian/system-ui-brightness-control install + + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_installexamples +# dh_install +# dh_installmenu +# dh_installdebconf +# dh_installlogrotate +# dh_installemacsen +# dh_installpam +# dh_installmime +# dh_python +# dh_installinit +# dh_installcron +# dh_installinfo + dh_installman + dh_link + dh_strip + dh_compress + dh_fixperms +# dh_perl +# dh_makeshlibs + dh_installdeb + dh_shlibdeps # Uncomment this line for use without Qt Creator + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/statusindicatormenu-brightness.desktop b/statusindicatormenu-brightness.desktop new file mode 100644 index 0000000..61937d8 --- /dev/null +++ b/statusindicatormenu-brightness.desktop @@ -0,0 +1,7 @@ +[Desktop Entry] +Type=X-MeeGoApplicationExtension +Name=Status Indicator Menu Brightness Extension + +[X-MeeGoApplicationExtension] +Interface=com.meego.core.MStatusIndicatorMenuExtensionInterface/1.0 +Extension=libstatusindicatormenu-brightness.so diff --git a/system-ui-brightness-control.pro b/system-ui-brightness-control.pro new file mode 100644 index 0000000..27cfc9b --- /dev/null +++ b/system-ui-brightness-control.pro @@ -0,0 +1,28 @@ +TEMPLATE = lib +CONFIG += plugin gui meegotouch system-ui + +TARGET = statusindicatormenu-brightness + +CONFIG += link_pkgconfig +PKGCONFIG += gq-gconf + +INCLUDEPATH += /usr/include/meegotouch +INCLUDEPATH += /usr/include/system-ui + +HEADERS += \ + brightnessplugin.h \ + brightnesscontroller.h + +SOURCES += \ + brightnessplugin.cpp \ + brightnesscontroller.cpp + +OTHER_FILES += \ + statusindicatormenu-brightness.desktop + +target.path = /usr/lib/meegotouch/applicationextensions + +desktop.files = statusindicatormenu-brightness.desktop +desktop.path = /usr/share/meegotouch/applicationextensions + +INSTALLS += target desktop