~ubuntu-branches/ubuntu/utopic/psi/utopic

« back to all changes in this revision

Viewing changes to src/tools/growlnotifier/growltest.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2010-02-19 09:37:12 UTC
  • mfrom: (6.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100219093712-e225xvm1wjcf1cgi
Tags: 0.14-2
* comment out only function which uses va_list to work around build
  problems on armel
* Set Standards-Version to 3.8.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * growltest.cpp: A test program for the GrowlNotifier class
3
 
 * Copyright (C) 2005  Remko Troncon
4
 
 *
5
 
 * This program is free software; you can redistribute it and/or
6
 
 * modify it under the terms of the GNU General Public License
7
 
 * as published by the Free Software Foundation; either version 2
8
 
 * of the License, or (at your option) any later version.
9
 
 *
10
 
 * You can also redistribute and/or modify this program under the
11
 
 * terms of the Psi License, specified in the accompanied COPYING
12
 
 * file, as published by the Psi Project; either dated January 1st,
13
 
 * 2005, or (at your option) any later version.
14
 
 *
15
 
 * This program is distributed in the hope that it will be useful,
16
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 
 * GNU General Public License for more details.
19
 
 *
20
 
 * You should have received a copy of the GNU General Public License
21
 
 * along with this library; if not, write to the Free Software
22
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
 
 *
24
 
 */
25
 
 
26
 
#include "growlnotifier.h"
27
 
 
28
 
#include <QStringList>
29
 
#include <QApplication>
30
 
#include <QMessageBox>
31
 
#include <QPushButton>
32
 
#include <QLayout>
33
 
#include <QVBoxLayout>
34
 
#include <QLineEdit>
35
 
#include <QCheckBox>
36
 
#include <QLabel>
37
 
#include <QPixmap>
38
 
#include <QGridLayout>
39
 
 
40
 
class GrowlTestWidget : public QWidget
41
 
{
42
 
        Q_OBJECT
43
 
 
44
 
public:
45
 
    GrowlTestWidget(QWidget *parent=0);
46
 
 
47
 
public slots:
48
 
        void do_notification1();
49
 
        void do_notification2();
50
 
        void notification_clicked();
51
 
 
52
 
private:
53
 
        QLineEdit *text, *title;
54
 
        QCheckBox* sticky;
55
 
        GrowlNotifier* growlNotifier;
56
 
};
57
 
 
58
 
 
59
 
GrowlTestWidget::GrowlTestWidget(QWidget *parent) : QWidget(parent)
60
 
{
61
 
        // Initialize widgets
62
 
        QGridLayout *layout = new QGridLayout(this);
63
 
 
64
 
        layout->addWidget(new QLabel("Title",this),0,0);
65
 
        title = new QLineEdit(this);
66
 
        title->setText("My Text");
67
 
        layout->addWidget(title,0,1);
68
 
 
69
 
        layout->addWidget(new QLabel("Text",this),1,0);
70
 
        text = new QLineEdit(this);
71
 
        text->setText("My Description");
72
 
        layout->addWidget(text,1,1);
73
 
 
74
 
        //layout->addWidget(new QLabel("Sticky",this),2,0);
75
 
        //sticky = new QCheckBox(this);
76
 
        //sticky->setTristate();
77
 
        //layout->addWidget(sticky,2,1);
78
 
        
79
 
    QPushButton *notification1 = new QPushButton( "Notification 1", this );
80
 
        connect(notification1, SIGNAL(clicked()), SLOT(do_notification1()));
81
 
        layout->addWidget(notification1,3,0);
82
 
 
83
 
        QPushButton *notification2 = new QPushButton( "Notification 2", this );
84
 
        connect(notification2, SIGNAL(clicked()), SLOT(do_notification2()));
85
 
        layout->addWidget(notification2,3,1);
86
 
        
87
 
        // Initialize GrowlNotifier
88
 
        QStringList nots, defaults;
89
 
        nots << "Notification 1" << "Notification 2";
90
 
        defaults << "Notification 1";
91
 
        growlNotifier = new GrowlNotifier(nots, defaults, "GrowlNotifierTest");
92
 
}
93
 
 
94
 
int main( int argc, char **argv )
95
 
{
96
 
    QApplication a( argc, argv );
97
 
    GrowlTestWidget w;
98
 
    w.show();
99
 
    return a.exec();
100
 
}
101
 
        
102
 
void GrowlTestWidget::do_notification1()
103
 
{
104
 
        //if (sticky->state() != QButton::NoChange) {
105
 
        //      growlNotifier->notify("Notification 1", title->text(), text->text(), QPixmap(), sticky->isChecked(), this, SLOT(notification_clicked()));
106
 
        //}
107
 
        //else {
108
 
        //      growlNotifier->notify("Notification 1", title->text(), text->text(), QPixmap());
109
 
        //}
110
 
        growlNotifier->notify("Notification 1", title->text(), text->text(), QPixmap(), false, this, SLOT(notification_clicked()));
111
 
}
112
 
 
113
 
void GrowlTestWidget::do_notification2()
114
 
{
115
 
        //if (sticky->state() != QButton::NoChange) {
116
 
        //      growlNotifier->notify("Notification 2", title->text(), text->text(), QPixmap(), sticky->isChecked(), this, SLOT(notification_clicked()));
117
 
        //}
118
 
        //else {
119
 
        //      growlNotifier->notify("Notification 2", title->text(), text->text(), QPixmap());
120
 
        //}
121
 
                growlNotifier->notify("Notification 2", title->text(), text->text(), QPixmap(), false, this, SLOT(notification_clicked()));
122
 
}
123
 
 
124
 
void GrowlTestWidget::notification_clicked()
125
 
{
126
 
        QMessageBox::information(0, "Information", "Notification was clicked\n");
127
 
}
128
 
 
129
 
#include "growltest.moc"