author | zautrix <zautrix> | 2004-10-30 17:07:04 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-30 17:07:04 (UTC) |
commit | 28df10a0eb5ff343191755a06391bc6ce2fd84b0 (patch) (unidiff) | |
tree | 930882e7400006887d68fd434939e3a376b8631b /microkde/kapplication.cpp | |
parent | c8662dc632987a317386b923e24acb9507859528 (diff) | |
download | kdepimpi-28df10a0eb5ff343191755a06391bc6ce2fd84b0.zip kdepimpi-28df10a0eb5ff343191755a06391bc6ce2fd84b0.tar.gz kdepimpi-28df10a0eb5ff343191755a06391bc6ce2fd84b0.tar.bz2 |
ompi fixes
-rw-r--r-- | microkde/kapplication.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/microkde/kapplication.cpp b/microkde/kapplication.cpp index 56c01af..d6f556d 100644 --- a/microkde/kapplication.cpp +++ b/microkde/kapplication.cpp | |||
@@ -1,106 +1,108 @@ | |||
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 | else | ||
40 | ;//d->resize( 800, 600 ); | ||
39 | return d->exec(); | 41 | return d->exec(); |
40 | } | 42 | } |
41 | void KApplication::showLicence() | 43 | void KApplication::showLicence() |
42 | { | 44 | { |
43 | KApplication::showFile( "KDE-Pim/Pi licence", "kdepim/LICENCE.TXT" ); | 45 | KApplication::showFile( "KDE-Pim/Pi licence", "kdepim/licence.txt" ); |
44 | } | 46 | } |
45 | 47 | ||
46 | void KApplication::showFile(QString caption, QString fn) | 48 | void KApplication::showFile(QString caption, QString fn) |
47 | { | 49 | { |
48 | QString text; | 50 | QString text; |
49 | QString fileName; | 51 | QString fileName; |
50 | #ifndef DESKTOP_VERSION | 52 | #ifndef DESKTOP_VERSION |
51 | fileName = getenv("QPEDIR"); | 53 | fileName = getenv("QPEDIR"); |
52 | fileName += "/pics/" + fn ; | 54 | fileName += "/pics/" + fn ; |
53 | #else | 55 | #else |
54 | fileName = qApp->applicationDirPath () + "/" + fn; | 56 | fileName = qApp->applicationDirPath () + "/" + fn; |
55 | #endif | 57 | #endif |
56 | QFile file( fileName ); | 58 | QFile file( fileName ); |
57 | if (!file.open( IO_ReadOnly ) ) { | 59 | if (!file.open( IO_ReadOnly ) ) { |
58 | return ; | 60 | return ; |
59 | } | 61 | } |
60 | QTextStream ts( &file ); | 62 | QTextStream ts( &file ); |
61 | text = ts.read(); | 63 | text = ts.read(); |
62 | file.close(); | 64 | file.close(); |
63 | KApplication::showText( caption, text ); | 65 | KApplication::showText( caption, text ); |
64 | 66 | ||
65 | } | 67 | } |
66 | 68 | ||
67 | bool KApplication::convert2latin1(QString fileName) | 69 | bool KApplication::convert2latin1(QString fileName) |
68 | { | 70 | { |
69 | QString text; | 71 | QString text; |
70 | QFile file( fileName ); | 72 | QFile file( fileName ); |
71 | if (!file.open( IO_ReadOnly ) ) { | 73 | if (!file.open( IO_ReadOnly ) ) { |
72 | return false; | 74 | return false; |
73 | 75 | ||
74 | } | 76 | } |
75 | QTextStream ts( &file ); | 77 | QTextStream ts( &file ); |
76 | ts.setEncoding( QTextStream::UnicodeUTF8 ); | 78 | ts.setEncoding( QTextStream::UnicodeUTF8 ); |
77 | text = ts.read(); | 79 | text = ts.read(); |
78 | file.close(); | 80 | file.close(); |
79 | if (!file.open( IO_WriteOnly ) ) { | 81 | if (!file.open( IO_WriteOnly ) ) { |
80 | return false; | 82 | return false; |
81 | } | 83 | } |
82 | QTextStream tsIn( &file ); | 84 | QTextStream tsIn( &file ); |
83 | tsIn.setEncoding( QTextStream::Latin1 ); | 85 | tsIn.setEncoding( QTextStream::Latin1 ); |
84 | tsIn << text.latin1(); | 86 | tsIn << text.latin1(); |
85 | file.close(); | 87 | file.close(); |
86 | 88 | ||
87 | 89 | ||
88 | } | 90 | } |
89 | void KApplication::showText(QString caption, QString text) | 91 | void KApplication::showText(QString caption, QString text) |
90 | { | 92 | { |
91 | QDialog dia( 0, "name", true ); ; | 93 | QDialog dia( 0, "name", true ); ; |
92 | dia.setCaption( caption ); | 94 | dia.setCaption( caption ); |
93 | QVBoxLayout* lay = new QVBoxLayout( &dia ); | 95 | QVBoxLayout* lay = new QVBoxLayout( &dia ); |
94 | lay->setSpacing( 3 ); | 96 | lay->setSpacing( 3 ); |
95 | lay->setMargin( 3 ); | 97 | lay->setMargin( 3 ); |
96 | QTextBrowser tb ( &dia ); | 98 | QTextBrowser tb ( &dia ); |
97 | lay->addWidget( &tb ); | 99 | lay->addWidget( &tb ); |
98 | tb.setText( text ); | 100 | tb.setText( text ); |
99 | #ifdef DESKTOP_VERSION | 101 | #ifdef DESKTOP_VERSION |
100 | dia.resize( 640, 480); | 102 | dia.resize( 640, 480); |
101 | #else | 103 | #else |
102 | dia.showMaximized(); | 104 | dia.showMaximized(); |
103 | #endif | 105 | #endif |
104 | dia.exec(); | 106 | dia.exec(); |
105 | 107 | ||
106 | } | 108 | } |