-rw-r--r-- | microkde/kapplication.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/microkde/kapplication.cpp b/microkde/kapplication.cpp index ad0b78e..98ef2f2 100644 --- a/microkde/kapplication.cpp +++ b/microkde/kapplication.cpp | |||
@@ -1,79 +1,84 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <stdio.h> | 2 | #include <stdio.h> |
3 | 3 | ||
4 | #include "kapplication.h" | 4 | #include "kapplication.h" |
5 | #include <qapplication.h> | 5 | #include <qapplication.h> |
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | #include <qfile.h> | 7 | #include <qfile.h> |
8 | #include <qtextstream.h> | 8 | #include <qtextstream.h> |
9 | #include <qdialog.h> | 9 | #include <qdialog.h> |
10 | #include <qlayout.h> | 10 | #include <qlayout.h> |
11 | #include <qtextbrowser.h> | 11 | #include <qtextbrowser.h> |
12 | 12 | ||
13 | int KApplication::random() | 13 | int KApplication::random() |
14 | { | 14 | { |
15 | return rand(); | 15 | return rand(); |
16 | } | 16 | } |
17 | 17 | ||
18 | //US | 18 | //US |
19 | QString KApplication::randomString(int length) | 19 | QString KApplication::randomString(int length) |
20 | { | 20 | { |
21 | if (length <=0 ) return QString::null; | 21 | if (length <=0 ) return QString::null; |
22 | 22 | ||
23 | QString str; | 23 | QString str; |
24 | while (length--) | 24 | while (length--) |
25 | { | 25 | { |
26 | int r=random() % 62; | 26 | int r=random() % 62; |
27 | r+=48; | 27 | r+=48; |
28 | if (r>57) r+=7; | 28 | if (r>57) r+=7; |
29 | if (r>90) r+=6; | 29 | if (r>90) r+=6; |
30 | str += char(r); | 30 | str += char(r); |
31 | // so what if I work backwards? | 31 | // so what if I work backwards? |
32 | } | 32 | } |
33 | return str; | 33 | return str; |
34 | } | 34 | } |
35 | int KApplication::execDialog( QDialog* d ) | 35 | int KApplication::execDialog( QDialog* d ) |
36 | { | 36 | { |
37 | if (QApplication::desktop()->width() <= 640 ) | 37 | if (QApplication::desktop()->width() <= 640 ) |
38 | d->showMaximized(); | 38 | d->showMaximized(); |
39 | return d->exec(); | 39 | return d->exec(); |
40 | } | 40 | } |
41 | void KApplication::showLicence() | 41 | void KApplication::showLicence() |
42 | { | 42 | { |
43 | KApplication::showFile( "KDE-Pim/Pi licence", "kdepim/LICENCE.TXT" ); | 43 | KApplication::showFile( "KDE-Pim/Pi licence", "kdepim/LICENCE.TXT" ); |
44 | } | 44 | } |
45 | 45 | ||
46 | void KApplication::showFile(QString caption, QString fn) | 46 | void KApplication::showFile(QString caption, QString fn) |
47 | { | 47 | { |
48 | QString text; | 48 | QString text; |
49 | QString fileName; | 49 | QString fileName; |
50 | #ifndef DESKTOP_VERSION | 50 | #ifndef DESKTOP_VERSION |
51 | fileName = getenv("QPEDIR"); | 51 | fileName = getenv("QPEDIR"); |
52 | fileName += "/pics/" + fn ; | 52 | fileName += "/pics/" + fn ; |
53 | #else | 53 | #else |
54 | fileName = qApp->applicationDirPath () + "/" + fn; | 54 | fileName = qApp->applicationDirPath () + "/" + fn; |
55 | #endif | 55 | #endif |
56 | QFile file( fileName ); | 56 | QFile file( fileName ); |
57 | if (!file.open( IO_ReadOnly ) ) { | 57 | if (!file.open( IO_ReadOnly ) ) { |
58 | return ; | 58 | return ; |
59 | } | 59 | } |
60 | QTextStream ts( &file ); | 60 | QTextStream ts( &file ); |
61 | text = ts.read(); | 61 | text = ts.read(); |
62 | file.close(); | 62 | file.close(); |
63 | 63 | KApplication::showText( caption, text ); | |
64 | |||
65 | } | ||
66 | |||
67 | void KApplication::showText(QString caption, QString text) | ||
68 | { | ||
64 | QDialog dia( 0, "name", true ); ; | 69 | QDialog dia( 0, "name", true ); ; |
65 | dia.setCaption( caption ); | 70 | dia.setCaption( caption ); |
66 | QVBoxLayout* lay = new QVBoxLayout( &dia ); | 71 | QVBoxLayout* lay = new QVBoxLayout( &dia ); |
67 | lay->setSpacing( 3 ); | 72 | lay->setSpacing( 3 ); |
68 | lay->setMargin( 3 ); | 73 | lay->setMargin( 3 ); |
69 | QTextBrowser tb ( &dia ); | 74 | QTextBrowser tb ( &dia ); |
70 | lay->addWidget( &tb ); | 75 | lay->addWidget( &tb ); |
71 | tb.setText( text ); | 76 | tb.setText( text ); |
72 | #ifdef DESKTOP_VERSION | 77 | #ifdef DESKTOP_VERSION |
73 | dia.resize( 640, 480); | 78 | dia.resize( 640, 480); |
74 | #else | 79 | #else |
75 | dia.showMaximized(); | 80 | dia.showMaximized(); |
76 | #endif | 81 | #endif |
77 | dia.exec(); | 82 | dia.exec(); |
78 | 83 | ||
79 | } | 84 | } |