| 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.h>
|
|---|
| 29 | #include <qapplication.h>
|
|---|
| 30 | #include <qmessagebox.h>
|
|---|
| 31 | #include <qpushbutton.h>
|
|---|
| 32 | #include <qlayout.h>
|
|---|
| 33 | #include <qvbox.h>
|
|---|
| 34 | #include <qlineedit.h>
|
|---|
| 35 | #include <qcheckbox.h>
|
|---|
| 36 | #include <qlabel.h>
|
|---|
| 37 |
|
|---|
| 38 | class GrowlTestWidget : public QWidget
|
|---|
| 39 | {
|
|---|
| 40 | Q_OBJECT
|
|---|
| 41 |
|
|---|
| 42 | public:
|
|---|
| 43 | GrowlTestWidget( QWidget *parent=0, const char *name=0 );
|
|---|
| 44 |
|
|---|
| 45 | public slots:
|
|---|
| 46 | void do_notification1();
|
|---|
| 47 | void do_notification2();
|
|---|
| 48 | void notification_clicked();
|
|---|
| 49 |
|
|---|
| 50 | private:
|
|---|
| 51 | QLineEdit *text, *title;
|
|---|
| 52 | QCheckBox* sticky;
|
|---|
| 53 | GrowlNotifier* growlNotifier;
|
|---|
| 54 | };
|
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 | GrowlTestWidget::GrowlTestWidget( QWidget *parent, const char *name ) : QWidget(parent, name)
|
|---|
| 58 | {
|
|---|
| 59 | // Initialize widgets
|
|---|
| 60 | QGridLayout *layout = new QGridLayout(this,4,2);
|
|---|
| 61 |
|
|---|
| 62 | layout->addWidget(new QLabel("Title",this),0,0);
|
|---|
| 63 | title = new QLineEdit(this);
|
|---|
| 64 | title->setText("My Text");
|
|---|
| 65 | layout->addWidget(title,0,1);
|
|---|
| 66 |
|
|---|
| 67 | layout->addWidget(new QLabel("Text",this),1,0);
|
|---|
| 68 | text = new QLineEdit(this);
|
|---|
| 69 | text->setText("My Description");
|
|---|
| 70 | layout->addWidget(text,1,1);
|
|---|
| 71 |
|
|---|
| 72 | //layout->addWidget(new QLabel("Sticky",this),2,0);
|
|---|
| 73 | //sticky = new QCheckBox(this);
|
|---|
| 74 | //sticky->setTristate();
|
|---|
| 75 | //layout->addWidget(sticky,2,1);
|
|---|
| 76 |
|
|---|
| 77 | QPushButton *notification1 = new QPushButton( "Notification 1", this );
|
|---|
| 78 | connect(notification1, SIGNAL(clicked()), SLOT(do_notification1()));
|
|---|
| 79 | layout->addWidget(notification1,3,0);
|
|---|
| 80 |
|
|---|
| 81 | QPushButton *notification2 = new QPushButton( "Notification 2", this );
|
|---|
| 82 | connect(notification2, SIGNAL(clicked()), SLOT(do_notification2()));
|
|---|
| 83 | layout->addWidget(notification2,3,1);
|
|---|
| 84 |
|
|---|
| 85 | // Initialize GrowlNotifier
|
|---|
| 86 | QStringList nots, defaults;
|
|---|
| 87 | nots << "Notification 1" << "Notification 2";
|
|---|
| 88 | defaults << "Notification 1";
|
|---|
| 89 | growlNotifier = new GrowlNotifier(nots, defaults, "GrowlNotifierTest");
|
|---|
| 90 | }
|
|---|
| 91 |
|
|---|
| 92 | int main( int argc, char **argv )
|
|---|
| 93 | {
|
|---|
| 94 | QApplication a( argc, argv );
|
|---|
| 95 | GrowlTestWidget w;
|
|---|
| 96 | a.setMainWidget( &w );
|
|---|
| 97 | w.show();
|
|---|
| 98 | return a.exec();
|
|---|
| 99 | }
|
|---|
| 100 |
|
|---|
| 101 | void GrowlTestWidget::do_notification1()
|
|---|
| 102 | {
|
|---|
| 103 | //if (sticky->state() != QButton::NoChange) {
|
|---|
| 104 | growlNotifier->notify("Notification 1", title->text(), text->text(), QPixmap(), sticky->isChecked(), this, SLOT(notification_clicked()));
|
|---|
| 105 | //}
|
|---|
| 106 | //else {
|
|---|
| 107 | // growlNotifier->notify("Notification 1", title->text(), text->text(), QPixmap());
|
|---|
| 108 | //}
|
|---|
| 109 | }
|
|---|
| 110 |
|
|---|
| 111 | void GrowlTestWidget::do_notification2()
|
|---|
| 112 | {
|
|---|
| 113 | //if (sticky->state() != QButton::NoChange) {
|
|---|
| 114 | growlNotifier->notify("Notification 2", title->text(), text->text(), QPixmap(), sticky->isChecked(), this, SLOT(notification_clicked()));
|
|---|
| 115 | //}
|
|---|
| 116 | //else {
|
|---|
| 117 | // growlNotifier->notify("Notification 2", title->text(), text->text(), QPixmap());
|
|---|
| 118 | //}
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 | void GrowlTestWidget::notification_clicked()
|
|---|
| 122 | {
|
|---|
| 123 | QMessageBox::information(0, "Information", "Notification was clicked\n");
|
|---|
| 124 | }
|
|---|
| 125 |
|
|---|
| 126 | #include "growltest.moc"
|
|---|