2
* growltest.cpp: A test program for the GrowlNotifier class
3
* Copyright (C) 2005 Remko Troncon
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.
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.
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.
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
26
#include "growlnotifier.h"
28
#include <QStringList>
29
#include <QApplication>
30
#include <QMessageBox>
31
#include <QPushButton>
33
#include <QVBoxLayout>
38
#include <QGridLayout>
40
class GrowlTestWidget : public QWidget
45
GrowlTestWidget(QWidget *parent=0);
48
void do_notification1();
49
void do_notification2();
50
void notification_clicked();
53
QLineEdit *text, *title;
55
GrowlNotifier* growlNotifier;
59
GrowlTestWidget::GrowlTestWidget(QWidget *parent) : QWidget(parent)
62
QGridLayout *layout = new QGridLayout(this);
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);
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);
74
//layout->addWidget(new QLabel("Sticky",this),2,0);
75
//sticky = new QCheckBox(this);
76
//sticky->setTristate();
77
//layout->addWidget(sticky,2,1);
79
QPushButton *notification1 = new QPushButton( "Notification 1", this );
80
connect(notification1, SIGNAL(clicked()), SLOT(do_notification1()));
81
layout->addWidget(notification1,3,0);
83
QPushButton *notification2 = new QPushButton( "Notification 2", this );
84
connect(notification2, SIGNAL(clicked()), SLOT(do_notification2()));
85
layout->addWidget(notification2,3,1);
87
// Initialize GrowlNotifier
88
QStringList nots, defaults;
89
nots << "Notification 1" << "Notification 2";
90
defaults << "Notification 1";
91
growlNotifier = new GrowlNotifier(nots, defaults, "GrowlNotifierTest");
94
int main( int argc, char **argv )
96
QApplication a( argc, argv );
102
void GrowlTestWidget::do_notification1()
104
//if (sticky->state() != QButton::NoChange) {
105
// growlNotifier->notify("Notification 1", title->text(), text->text(), QPixmap(), sticky->isChecked(), this, SLOT(notification_clicked()));
108
// growlNotifier->notify("Notification 1", title->text(), text->text(), QPixmap());
110
growlNotifier->notify("Notification 1", title->text(), text->text(), QPixmap(), false, this, SLOT(notification_clicked()));
113
void GrowlTestWidget::do_notification2()
115
//if (sticky->state() != QButton::NoChange) {
116
// growlNotifier->notify("Notification 2", title->text(), text->text(), QPixmap(), sticky->isChecked(), this, SLOT(notification_clicked()));
119
// growlNotifier->notify("Notification 2", title->text(), text->text(), QPixmap());
121
growlNotifier->notify("Notification 2", title->text(), text->text(), QPixmap(), false, this, SLOT(notification_clicked()));
124
void GrowlTestWidget::notification_clicked()
126
QMessageBox::information(0, "Information", "Notification was clicked\n");
129
#include "growltest.moc"