author | mickeyl <mickeyl> | 2005-01-29 14:18:51 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-01-29 14:18:51 (UTC) |
commit | 555b999359a5aad999eaaf48632ce85f25125b85 (patch) (unidiff) | |
tree | 7414362241e49e06f49486e93a8f504113961b1c /examples/opiecore/odebugdemo | |
parent | 7b06e36fe27adc6a4fde2004eac13aaf8c0f0f02 (diff) | |
download | opie-555b999359a5aad999eaaf48632ce85f25125b85.zip opie-555b999359a5aad999eaaf48632ce85f25125b85.tar.gz opie-555b999359a5aad999eaaf48632ce85f25125b85.tar.bz2 |
examples appear here
-rw-r--r-- | examples/opiecore/odebugdemo/.cvsignore | 8 | ||||
-rw-r--r-- | examples/opiecore/odebugdemo/odebugdemo.cpp | 142 | ||||
-rw-r--r-- | examples/opiecore/odebugdemo/odebugdemo.pro | 17 |
3 files changed, 167 insertions, 0 deletions
diff --git a/examples/opiecore/odebugdemo/.cvsignore b/examples/opiecore/odebugdemo/.cvsignore new file mode 100644 index 0000000..731667d --- a/dev/null +++ b/examples/opiecore/odebugdemo/.cvsignore | |||
@@ -0,0 +1,8 @@ | |||
1 | odebugdemo | ||
2 | Makefile* | ||
3 | obj | ||
4 | moc* | ||
5 | *moc | ||
6 | *.o | ||
7 | ~* | ||
8 | |||
diff --git a/examples/opiecore/odebugdemo/odebugdemo.cpp b/examples/opiecore/odebugdemo/odebugdemo.cpp new file mode 100644 index 0000000..b046d28 --- a/dev/null +++ b/examples/opiecore/odebugdemo/odebugdemo.cpp | |||
@@ -0,0 +1,142 @@ | |||
1 | /* QT */ | ||
2 | |||
3 | #include <qvbox.h> | ||
4 | #include <qhbox.h> | ||
5 | #include <qvbuttongroup.h> | ||
6 | #include <qhbuttongroup.h> | ||
7 | #include <qlineedit.h> | ||
8 | #include <qradiobutton.h> | ||
9 | #include <qpushbutton.h> | ||
10 | |||
11 | /* OPIE */ | ||
12 | |||
13 | #include <qpe/config.h> | ||
14 | |||
15 | #include <opie2/odebug.h> | ||
16 | #include <opie2/oapplication.h> | ||
17 | #include <opie2/oglobal.h> | ||
18 | #include <opie2/oglobalsettings.h> | ||
19 | |||
20 | using namespace Opie::Core; | ||
21 | |||
22 | class DemoApp : public OApplication | ||
23 | { | ||
24 | Q_OBJECT | ||
25 | public: | ||
26 | DemoApp( int argc, char** argv ) : OApplication( argc, argv, "libopie2 debug demo" ) | ||
27 | { | ||
28 | // you have access to your OApplication object via oApp | ||
29 | odebug << "Process-wide OApplication object @ " << oApp << "" << oendl; | ||
30 | |||
31 | // you have access to global settings via OGlobalSettings | ||
32 | int mode = OGlobalSettings::debugMode(); | ||
33 | |||
34 | QVBox* vbox = new QVBox(); | ||
35 | setMainWidget( vbox ); | ||
36 | |||
37 | g = new QVButtonGroup( "Output Strategy", vbox ); | ||
38 | QRadioButton* r0 = new QRadioButton( "file", g ); | ||
39 | QRadioButton* r1 = new QRadioButton( "messagebox", g ); | ||
40 | QRadioButton* r2 = new QRadioButton( "stderr", g ); | ||
41 | QRadioButton* r3 = new QRadioButton( "syslog", g ); | ||
42 | QRadioButton* r4 = new QRadioButton( "socket", g ); | ||
43 | g->insert( r0, 0 ); | ||
44 | g->insert( r1, 1 ); | ||
45 | g->insert( r2, 2 ); | ||
46 | g->insert( r3, 3 ); | ||
47 | g->insert( r4, 4 ); | ||
48 | g->setRadioButtonExclusive( true ); | ||
49 | connect( g, SIGNAL( clicked(int) ), this, SLOT( chooseMethod(int) ) ); | ||
50 | |||
51 | if ( mode != -1 ) g->setButton( mode ); | ||
52 | |||
53 | QHButtonGroup* hbox = new QHButtonGroup( "Extra Output Information", vbox ); | ||
54 | e = new QLineEdit( hbox ); | ||
55 | QPushButton* pb = new QPushButton( hbox ); | ||
56 | |||
57 | connect( e, SIGNAL( returnPressed() ), this, SLOT( updateDebugOutput() ) ); | ||
58 | connect( pb, SIGNAL( clicked() ), this, SLOT( updateDebugOutput() ) ); | ||
59 | |||
60 | // show the additional debug mode dependent output information | ||
61 | e->setText( OGlobalSettings::debugOutput() ); | ||
62 | |||
63 | // buttos | ||
64 | QPushButton* info = new QPushButton( "Emit Debug(Info) Output!", vbox ); | ||
65 | connect( info, SIGNAL( clicked() ), this, SLOT( emitInfoOutput() ) ); | ||
66 | QPushButton* warn = new QPushButton( "Emit a Warning Output!", vbox ); | ||
67 | connect( warn, SIGNAL( clicked() ), this, SLOT( emitWarningOutput() ) ); | ||
68 | QPushButton* error = new QPushButton( "Emit an Error Output!", vbox ); | ||
69 | connect( error, SIGNAL( clicked() ), this, SLOT( emitErrorOutput() ) ); | ||
70 | QPushButton* fatal = new QPushButton( "Emit a Fatal Output!", vbox ); | ||
71 | connect( fatal, SIGNAL( clicked() ), this, SLOT( emitFatalOutput() ) ); | ||
72 | |||
73 | QPushButton* tb = new QPushButton( "Emit a Fatal Backtrace!", vbox ); | ||
74 | connect( tb, SIGNAL( clicked() ), this, SLOT( emitTBOutput() ) ); | ||
75 | |||
76 | info->show(); | ||
77 | warn->show(); | ||
78 | error->show(); | ||
79 | fatal->show(); | ||
80 | tb->show(); | ||
81 | g->show(); | ||
82 | hbox->show(); | ||
83 | e->show(); | ||
84 | vbox->show(); | ||
85 | showMainWidget( vbox ); | ||
86 | } | ||
87 | |||
88 | public slots: | ||
89 | void chooseMethod(int method) | ||
90 | { | ||
91 | m = method; | ||
92 | odebug << "choosing method: " << method << "" << oendl; | ||
93 | OConfig* g = OGlobal::config(); | ||
94 | g->setGroup( "General" ); | ||
95 | g->writeEntry( "debugMode", m ); | ||
96 | e->setText( OGlobalSettings::debugOutput() ); | ||
97 | g->write(); | ||
98 | } | ||
99 | void updateDebugOutput() | ||
100 | { | ||
101 | OConfig* g = OGlobal::config(); | ||
102 | g->setGroup( "General" ); | ||
103 | g->writeEntry( "debugOutput"+QString::number(OGlobalSettings::debugMode()), e->text() ); | ||
104 | g->write(); | ||
105 | } | ||
106 | void emitInfoOutput() | ||
107 | { | ||
108 | odebug << "This is a debug message" << oendl; | ||
109 | } | ||
110 | void emitWarningOutput() | ||
111 | { | ||
112 | owarn << "This is a warning message" << oendl; | ||
113 | } | ||
114 | void emitErrorOutput() | ||
115 | { | ||
116 | oerr << "This is an errror message" << oendl; | ||
117 | } | ||
118 | void emitFatalOutput() | ||
119 | { | ||
120 | ofatal << "This is a fatal message" << oendl; | ||
121 | } | ||
122 | void emitTBOutput() | ||
123 | { | ||
124 | ofatal << "This is a fatal message + backtrace\n" + odBacktrace(); // odBacktrace includes \n | ||
125 | } | ||
126 | |||
127 | private: | ||
128 | QButtonGroup* g; | ||
129 | int m; | ||
130 | QLineEdit* e; | ||
131 | }; | ||
132 | |||
133 | int main( int argc, char** argv ) | ||
134 | { | ||
135 | DemoApp* app = new DemoApp( argc, argv ); | ||
136 | app->exec(); | ||
137 | |||
138 | return 0; | ||
139 | |||
140 | } | ||
141 | |||
142 | #include "odebugdemo.moc" | ||
diff --git a/examples/opiecore/odebugdemo/odebugdemo.pro b/examples/opiecore/odebugdemo/odebugdemo.pro new file mode 100644 index 0000000..e06053c --- a/dev/null +++ b/examples/opiecore/odebugdemo/odebugdemo.pro | |||
@@ -0,0 +1,17 @@ | |||
1 | TEMPLATE = app | ||
2 | CONFIG = qt warn_on | ||
3 | HEADERS = | ||
4 | SOURCES = odebugdemo.cpp | ||
5 | INCLUDEPATH += $(OPIEDIR)/include | ||
6 | DEPENDPATH += $(OPIEDIR)/include | ||
7 | LIBS += -lopiecore2 | ||
8 | TARGET = odebugdemo | ||
9 | |||
10 | !contains( platform, x11 ) { | ||
11 | include( $(OPIEDIR)/include.pro ) | ||
12 | } | ||
13 | |||
14 | contains( platform, x11 ) { | ||
15 | LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib | ||
16 | } | ||
17 | |||