~ubuntu-branches/ubuntu/natty/unity-2d/natty-updates

« back to all changes in this revision

Viewing changes to libunity-2d-private/tests/mouseareademo.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Oliver Grawert
  • Date: 2011-02-24 13:45:27 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20110224134527-d2lk3qu3sxe9a8z0
Tags: 3.6.0-0ubuntu1
New Upstream version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of unity-2d
 
3
 *
 
4
 * Copyright 2011 Canonical Ltd.
 
5
 *
 
6
 * Authors:
 
7
 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
 
8
 *
 
9
 * This program is free software; you can redistribute it and/or modify
 
10
 * it under the terms of the GNU General Public License as published
 
11
 * by the Free Software Foundation; version 3.
 
12
 *
 
13
 * This program is distributed in the hope that it will be useful,
 
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
 * GNU General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU General Public License
 
19
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
20
 */
 
21
 
 
22
// Local
 
23
#include <mousearea.h>
 
24
#include <unity2dapplication.h>
 
25
 
 
26
// Qt
 
27
#include <QLabel>
 
28
#include <QVBoxLayout>
 
29
 
 
30
int main(int argc, char** argv)
 
31
{
 
32
    Unity2dApplication app(argc, argv);
 
33
    QWidget window;
 
34
    QLabel* enteredLabel = new QLabel("Entered");
 
35
    QVBoxLayout* layout = new QVBoxLayout(&window);
 
36
    layout->addWidget(enteredLabel);
 
37
 
 
38
    MouseArea* area = new MouseArea(&window);
 
39
    area->setGeometry(QRect(10, 10, 200, 100));
 
40
    QObject::connect(area, SIGNAL(entered()), enteredLabel, SLOT(show()));
 
41
    QObject::connect(area, SIGNAL(exited()), enteredLabel, SLOT(hide()));
 
42
 
 
43
    enteredLabel->setVisible(area->containsMouse());
 
44
 
 
45
    window.show();
 
46
    return app.exec();
 
47
}