Diffstat (limited to 'examples/opiecore/onotifytest/main.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | examples/opiecore/onotifytest/main.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/examples/opiecore/onotifytest/main.cpp b/examples/opiecore/onotifytest/main.cpp new file mode 100644 index 0000000..467ebc9 --- a/dev/null +++ b/examples/opiecore/onotifytest/main.cpp | |||
@@ -0,0 +1,59 @@ | |||
1 | // (C) Michael 'Mickey' Lauer <mickey@Vanille.de> | ||
2 | // LICENSE = "GPLv2" | ||
3 | |||
4 | /* OPIE */ | ||
5 | #include <opie2/odebug.h> | ||
6 | #include <opie2/oapplication.h> | ||
7 | #include <opie2/ofilenotify.h> | ||
8 | using namespace Opie::Core; | ||
9 | |||
10 | /* QT */ | ||
11 | #include <qpushbutton.h> | ||
12 | #include <qtextstream.h> | ||
13 | |||
14 | class App : public OApplication | ||
15 | { | ||
16 | |||
17 | public: | ||
18 | OFile* tmpfoo; | ||
19 | |||
20 | App( int argc, char** argv ) : OApplication( argc, argv, "libopie2 notify test" ) | ||
21 | { | ||
22 | odebug << "App()" << oendl; | ||
23 | |||
24 | tmpfoo = new OFile( "/tmp/foo" ); | ||
25 | if ( tmpfoo->open( IO_ReadWrite ) ) | ||
26 | { | ||
27 | QTextStream stream( tmpfoo ); | ||
28 | stream << "This is my content"; | ||
29 | } | ||
30 | |||
31 | QObject::connect( tmpfoo, SIGNAL(accessed(const QString&)), this, SLOT(quit()) ); | ||
32 | QObject::connect( tmpfoo, SIGNAL(closed(const QString&,bool)), this, SLOT(quit()) ); | ||
33 | } | ||
34 | |||
35 | ~App() | ||
36 | { | ||
37 | odebug << "~App()" << oendl; | ||
38 | |||
39 | delete tmpfoo; | ||
40 | } | ||
41 | |||
42 | }; | ||
43 | |||
44 | int main( int argc, char** argv ) | ||
45 | { | ||
46 | App* app = new App( argc, argv ); | ||
47 | QPushButton* b = new QPushButton( "Click me to close", 0 ); | ||
48 | QObject::connect( b, SIGNAL(clicked()), app, SLOT(quit()) ); | ||
49 | b->resize( 200, 200 ); | ||
50 | b->move( 150, 150 ); | ||
51 | b->show(); | ||
52 | app->setMainWidget( b ); | ||
53 | app->exec(); | ||
54 | delete app; | ||
55 | |||
56 | return 0; | ||
57 | |||
58 | } | ||
59 | |||