//  (r)evolution

Microsoft limite son empreinte carbone

Attention, ça arrive rarement, alors profitez-en : je vais dire du bien de Microsoft !

Le géant américain a dévoilé hier ses plans pour conquérir le monde pour afficher une empreinte carbone neutre au 1er juillet 2012.

Pour parvenir à ses fins, Microsoft a notamment créé une taxe carbone interne à l'entreprise qui permet de chiffrer le coût des émissions carboniques de chaque activité. Cette taxe incite ainsi les équipes à réduire leurs émissions. Bien entendu, cette taxe est réinvestie dans de l'énergie renouvelable ou dans des outils permettant à Microsoft de contrôler son impact sur l'environnement.

Ce nouvel effort s'ajoute à plusieurs autres qui ont apparemment déjà porté leurs fruits puisque la U.S. Environmental Protection Agency a désigné Microsoft comme étant le troisième client national en énergies renouvelables, avec une consommation annuelle (pour l'année écoulée) en énergie verte de plus d'1,5 milliard de kilowatt-heures.

Reste à voir ce qu'en dira GreenPeace ;) En attendant, je pense qu'il convient de saluer cette initiative.

  //  actu

Ikea UPPLEVA

Ikea est un fabricant de meubles que j'affectionne particulièrement. La modularité des solutions proposées est exemplaire et permet à chacun de laisser libre court à son imagination.

Le géant suédois devrait frapper fort ces prochaines semaines avec sa nouvelle solution pour le salon : un meuble qui intègre la TV, le lecteur blu-ray et la solution audio.

Personnellement, je ne suis pas fan des solutions tout en un. Mais je retiens une chose : un fabricant grand public s'intéresse enfin à la gestion des câbles. Quel bonheur ! Il reste à espérer qu'Ikea transpose ces idées au reste de leurs gammes et on pourra enfin avoir une installation propre et intelligente.

Sont forts ces Suédois !

  //  _self

2012

Nous voilà déjà à l'heure du traditionnel bilan... 2011 aura finalement été une année spéciale à bien des égards...

Le château de Bernstein

Personnel

2011 aura tout d'abord été l'année durant laquelle j'ai enfin obtenu mon permis de conduire ! J'aurais pas mal de choses à dire à ce sujet d'ailleurs, mais je ne vais retenir que ce qui compte : le papier rose. Le deuxième temps fort de l'année est le petit séjour passé dans le sud de la France, à côté de Narbonne. Cette petite semaine restera un excellent souvenir. Enfin, je suis tonton pour la deuxième fois depuis quelques semaines, et c'est plutôt cool ! Le restant a été bien plus...déconcertant et je termine cette année avec le fort sentiment d'avoir raté un épisode...

D'un point de vue professionnel, la situation a changé : je suis désormais seul à gérer le parc. Malheureusement, c'est aussi la seule chose qui a changé. J'en arrive à un stade où je commence à tout remettre en question, même le fait de poursuivre ma "carrière" dans le domaine de l'informatique. Une chose est sûre : je ne tiendrais plus très longtemps dans ces conditions.

Informatique

L'année 2011 aura finalement été très calme dans le domaine informatique. Les évènements les plus marquants de cette année sont sans doute à chercher dans la rubrique nécrologie avec les décès de Steve Jobs et de Dennis Ritchie, deux légendes de l'informatique.

Le Mur Païen

Projets

Un des points positifs de cette année est que j'ai pas mal avancé sur mes projets. Mon site perso s'est payé une refonte (sur un coup de tête) dont je suis plutôt satisfait. Il reste encore un peu de travail cependant. Mon projet de mediacenter, feu-z3nb0x s'est enfin trouvé un nouveau nom : Helmo. J'ai aussi décidé de réécrire toute la partie UI en QML. Le travail avance donc toujours et mon objectif reste de sortir une première version au cours de l'année 2012. Enfin, j'ai mis un terme à ma "contribution" à ownCloud. Je n'ai pas vraiment apprécié que mon travail soit repris et intégré sans qu'on m'ait posé la moindre question (alors que c'était du WIP !), ni d'ailleurs le ton avec lequel certains membres de l'équipe du projet ont répondu à mes suggestions. Mais gardez un oeil sur ce projet, il reste prometteur !

Vue depuis le château de Queribus

Objectifs

Voyons où j'en suis. L'an dernier je m'étais fixé ces objectifs :

  • Passer mon permis : Fait !
  • Trouver un nouveau job : Pas fait du tout
  • Devenir (enfin !) membre de l'April : Pas fait du tout
  • Aller plus régulièrement au sport, même si c'est pas toujours très motivant : Pas fait du tout
  • Investir un peu de temps dans ownCloud : Fait...
  • Avancer le plus possible sur z3nb0x (et lui trouver un nouveau nom) : Fait !
  • Apporter quelques améliorations supplémentaires à mon site perso : Fait !

Le bilan est somme toute assez mitigé :/ En voici quelques uns pour cette année :

  • Trouver un nouveau job,
  • Devenir (enfin !) membre de l'April,
  • Reprendre une activité sportive régulière,
  • Sortir une première version d'Helmo.

2012 risque d'être une année passionnante avec les élections présidentielles, la crise financière, Anonymous, la loi SOPA, le mouvement des 99% qui prend de l'ampleur, l'Iran, la Syrie, ... Rendez-vous l'an prochain !

  //  parse error

QtQuick : Helmo's rewrite - part 3

Today we're going to play a bit with a ListView. A ListView is a simple but powerful widget that shows items in a list. In Helmo, the main menu I'm working on is a customized ListView.

Let's see how to start. We are going to start a new QML file. Let's call it MyList.qml :

import QtQuick 1.0

ListView {
    id: myList

    anchors.bottom: parent.bottom
    height: parent.height*0.25
    width: parent.width
    boundsBehavior: Flickable.DragOverBounds
    cacheBuffer: width
    focus: true
    highlightMoveDuration: 300
    orientation: ListView.Horizontal
    snapMode: ListView.SnapToItem
    spacing: 20
}

As you can see, we've built a simple horizontal list view (orientation property). The view will stick to its parent bottom (anchors.bottom property). We've also set a height and width. I strongly recommend you to RTFM if you want to know more about others properties :P

We still miss two important things : the data and how the data is displayed. Well, the list view is able to get the data from a model (you know MVC, right ?), thanks to the model property. Here, we're going to use a simple ListModel, but keep in mind that you can build your own model if you need to. Let's have a look at this model, stored in the MyListModel.qml file :

import QtQuick 1.0

ListModel {
    ListElement {
         name: "Plugin 1"
    }
    ListElement {
         name: "Plugin 2"
    }
    ListElement {
         name: "Plugin 3"
    }
    ListElement {
         name: "Plugin 4"
    }
    ListElement {
         name: "Plugin 5"
    }
    ListElement {
         name: "Plugin 6"
    }
}

Pretty easy to understand, isn't it ?

Now that the list view knows what to display, we still have to tell it how to display the data. Once again, the list view is very smart. It provides a delegate property to do that. A delegate is a simple template defining each item instanciated by the list view. And guess what, a delegate is a Component. So we're almost free to do whatever we want.

For this example, I chose a simple 256x75 text button as delegate. The source code is as follow :

Rectangle {
    color: "transparent"
    height: 75
    width: 256
    Text {
        anchors.bottom: parent.bottom
        anchors.horizontalCenter: parent.horizontalCenter
        color: "#FFFFFF"
        font.pointSize: 32
        horizontalAlignment: Text.AlignHCenter
        text: name
    }

    MouseArea {
        anchors.fill: parent
        onClicked: {
            console.log(name)
        }
    }
}

Now that everything is ready, let's stick all the pieces together. MyList.qml source code becomes :

import QtQuick 1.0

ListView {
    id: myList

    anchors.bottom: parent.bottom
    height: parent.height*0.25
    width: parent.width
    boundsBehavior: Flickable.DragOverBounds
    cacheBuffer: width
    focus: true
    highlightMoveDuration: 300
    orientation: ListView.Horizontal
    snapMode: ListView.SnapToItem
    spacing: 20

    model: MyListModel {}

    delegate : Component {
        Rectangle {
            color: "transparent"
            height: 75
            width: 256
            Text {
                anchors.bottom: parent.bottom
                anchors.horizontalCenter: parent.horizontalCenter
                color: "#FFFFFF"
                font.pointSize: 32
                horizontalAlignment: Text.AlignHCenter
                text: name
            }

            MouseArea {
                anchors.fill: parent
                onClicked: {
                    console.log(name)
                }
            }
        }
    }
}

Notice that I could have put the delegate in a seperate file (and I strongly encourage you to do so).

And do not forget to update your HelloWorld.qml file to add the list view :

import QtQuick 1.0

Rectangle {
    id: appWindow

    color: "#111"
    width: 1360
    height: 768
    Text {
        anchors.centerIn: parent
        font.pointSize: 32
        color: "white"
        text: hello.foo
    }

    MyList {}
}

Now just launch the Python file and see the magic happen. Isn't it great to build such a thing in minutes ?

  //  parse error

QtQuick : Helmo's rewrite - part 2

In the first chapter, we've seen how to make a very very basic application written in Python and QtQuick. In this second part, we'll go one step further and see how to share data between the application and the GUI.

We are going to add a _foo attribute to our HelloWorld class. To keep things simple, this attribute will be a simple unicode string.

The great thing with QML is that the internal engine can be automatically notified when the value of an attribute changes. To see the magic happen, we will need to create a specific Signal and make QML aware of it. To do so, we will declare foo as a Qt Property and thus, write a getter and a setter. The code for our HelloWorld class becomes :

from PyQt4.QtCore import pyqtSignal, pyqtProperty

class HelloWorld(QObject):

    fooModified = pyqtSignal()

    def __init__(self):
        QObject.__init__(self)
        self._foo = u'Hello'

    def getFoo(self):
        return self._foo

    def setFoo(self, newValue):
        if self._foo != newValue:
            self._foo = s
            self.fooModified.emit()

    foo = pyqtProperty(unicode, fget=getFoo, fset=setFoo, notify=fooModified)

See ? We tell QML that foo is a property with a getter (getFoo) and setter (setFoo). And also that the fooModified signal will be emitted whenever the value of _foo changes. The cool thing is that the view will be updated automatically with the new value ! Well, we still need to tell QML that the HelloWorld class exists. This is done via Contexts. Qt provides a QDeclarativeContext class to do so. Our Python file now looks like this :

# -*- coding: utf-8 -*-

import sys

from PyQt4.QtCore import QObject, QUrl, pyqtSignal, pyqtProperty
from PyQt4.QtGui import QApplication
from PyQt4.QtDeclarative import QDeclarativeView


class HelloWorld(QObject):

    fooModified = pyqtSignal()

    def __init__(self):
        QObject.__init__(self)
        self._foo = u"Hello"

    def getFoo(self):
        return self._foo

    def setFoo(self, newValue):
        if self._foo != newValue:
            self._foo = s
            self.fooModified.emit()

    foo = pyqtProperty(unicode, fget=getFoo, fset=setFoo, notify=fooModified)


app = QApplication(sys.argv)
h = HelloWorld()
v = QDeclarativeView()

context = v.rootContext()
context.setContextProperty('hello', h)

v.setSource(QUrl(__file__.replace('.py', '.qml')))
v.setResizeMode(QDeclarativeView.SizeRootObjectToView)
v.show()

app.exec_()

Okay, it's time to add some stuff to our QML file. We'll add a simple Text element to show the value of _foo. This value is available through the hello property (defined with context.setContextProperty('hello', h) :

import QtQuick 1.0

Rectangle {
    id: appWindow

    color: "#111"
    width: 1360
    height: 768
    Text {
        anchors.centerIn: parent
        font.pointSize: 32
        color: "white"
        text: hello.foo
    }
}

If everything's ok, you should see a darkgrey rectangle with a white centered label stating "Hello". That's it !

In the next part, we'll play a bit with a ListView, stay tuned !

← Billets plus vieux - 1/10

Les amères leçons du passé doivent être réapprises sans cesse. - Albert Einstein.