File: qservercount.cpp

package info (click to toggle)
libindicate-qt 0.2.5.91-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 388 kB
  • ctags: 262
  • sloc: cpp: 1,655; makefile: 6
file content (63 lines) | stat: -rw-r--r-- 1,379 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
 * Example of an application which only defines a server count
 *
 * Copyright 2009 Canonical Ltd.
 *
 * Authors:
 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
 *
 * License: LGPL v2.1 or LGPL v3
 */
#include "qservercount.h"

#include <QDebug>
#include <QTimer>

Controller::Controller(QIndicate::Server* server)
: mServer(server)
, mCount(0)
{
    connect(mServer, SIGNAL(serverDisplay()), SLOT(slotServerDisplay()));

    QTimer* timer = new QTimer(this);
    timer->setInterval(2000);
    connect(timer, SIGNAL(timeout()), SLOT(increaseCount()));
    timer->start();
}

void Controller::slotServerDisplay()
{
    qDebug() << "A listener wants us to display the server";
    mCount = 0;
    mServer->setCount(mCount);
}

void Controller::increaseCount()
{
    mCount++;
    mServer->setCount(mCount);
}

int main (int argc, char ** argv)
{
    QApplication app(argc, argv);

    if (argc != 3) {
        qCritical("Syntax: %s <desktop/file> <serverType>", argv[0]);
        return 1;
    }

    QString desktopFile = QString::fromLocal8Bit(argv[1]);
    QString serverType = QString::fromLocal8Bit(argv[2]);

    QIndicate::Server* server = QIndicate::Server::defaultInstance();
    server->setType(serverType);
    server->setDesktopFile(desktopFile);
    server->show();

    Controller controller(server);

    return app.exec();
}

#include "qservercount.moc"