-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 d6f556d..21aa0a4 100644 --- a/microkde/kapplication.cpp +++ b/microkde/kapplication.cpp | |||
@@ -1,108 +1,110 @@ | |||
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 "ktextedit.h" | ||
5 | #include <qapplication.h> | 6 | #include <qapplication.h> |
6 | #include <qstring.h> | 7 | #include <qstring.h> |
7 | #include <qfile.h> | 8 | #include <qfile.h> |
8 | #include <qtextstream.h> | 9 | #include <qtextstream.h> |
9 | #include <qdialog.h> | 10 | #include <qdialog.h> |
10 | #include <qlayout.h> | 11 | #include <qlayout.h> |
11 | #include <qtextbrowser.h> | 12 | #include <qtextbrowser.h> |
12 | 13 | ||
13 | int KApplication::random() | 14 | int KApplication::random() |
14 | { | 15 | { |
15 | return rand(); | 16 | return rand(); |
16 | } | 17 | } |
17 | 18 | ||
18 | //US | 19 | //US |
19 | QString KApplication::randomString(int length) | 20 | QString KApplication::randomString(int length) |
20 | { | 21 | { |
21 | if (length <=0 ) return QString::null; | 22 | if (length <=0 ) return QString::null; |
22 | 23 | ||
23 | QString str; | 24 | QString str; |
24 | while (length--) | 25 | while (length--) |
25 | { | 26 | { |
26 | int r=random() % 62; | 27 | int r=random() % 62; |
27 | r+=48; | 28 | r+=48; |
28 | if (r>57) r+=7; | 29 | if (r>57) r+=7; |
29 | if (r>90) r+=6; | 30 | if (r>90) r+=6; |
30 | str += char(r); | 31 | str += char(r); |
31 | // so what if I work backwards? | 32 | // so what if I work backwards? |
32 | } | 33 | } |
33 | return str; | 34 | return str; |
34 | } | 35 | } |
35 | int KApplication::execDialog( QDialog* d ) | 36 | int KApplication::execDialog( QDialog* d ) |
36 | { | 37 | { |
37 | if (QApplication::desktop()->width() <= 640 ) | 38 | if (QApplication::desktop()->width() <= 640 ) |
38 | d->showMaximized(); | 39 | d->showMaximized(); |
39 | else | 40 | else |
40 | ;//d->resize( 800, 600 ); | 41 | ;//d->resize( 800, 600 ); |
41 | return d->exec(); | 42 | return d->exec(); |
42 | } | 43 | } |
43 | void KApplication::showLicence() | 44 | void KApplication::showLicence() |
44 | { | 45 | { |
45 | KApplication::showFile( "KDE-Pim/Pi licence", "kdepim/licence.txt" ); | 46 | KApplication::showFile( "KDE-Pim/Pi licence", "kdepim/licence.txt" ); |
46 | } | 47 | } |
47 | 48 | ||
48 | void KApplication::showFile(QString caption, QString fn) | 49 | void KApplication::showFile(QString caption, QString fn) |
49 | { | 50 | { |
50 | QString text; | 51 | QString text; |
51 | QString fileName; | 52 | QString fileName; |
52 | #ifndef DESKTOP_VERSION | 53 | #ifndef DESKTOP_VERSION |
53 | fileName = getenv("QPEDIR"); | 54 | fileName = getenv("QPEDIR"); |
54 | fileName += "/pics/" + fn ; | 55 | fileName += "/pics/" + fn ; |
55 | #else | 56 | #else |
56 | fileName = qApp->applicationDirPath () + "/" + fn; | 57 | fileName = qApp->applicationDirPath () + "/" + fn; |
57 | #endif | 58 | #endif |
58 | QFile file( fileName ); | 59 | QFile file( fileName ); |
59 | if (!file.open( IO_ReadOnly ) ) { | 60 | if (!file.open( IO_ReadOnly ) ) { |
60 | return ; | 61 | return ; |
61 | } | 62 | } |
62 | QTextStream ts( &file ); | 63 | QTextStream ts( &file ); |
63 | text = ts.read(); | 64 | text = ts.read(); |
64 | file.close(); | 65 | file.close(); |
65 | KApplication::showText( caption, text ); | 66 | KApplication::showText( caption, text ); |
66 | 67 | ||
67 | } | 68 | } |
68 | 69 | ||
69 | bool KApplication::convert2latin1(QString fileName) | 70 | bool KApplication::convert2latin1(QString fileName) |
70 | { | 71 | { |
71 | QString text; | 72 | QString text; |
72 | QFile file( fileName ); | 73 | QFile file( fileName ); |
73 | if (!file.open( IO_ReadOnly ) ) { | 74 | if (!file.open( IO_ReadOnly ) ) { |
74 | return false; | 75 | return false; |
75 | 76 | ||
76 | } | 77 | } |
77 | QTextStream ts( &file ); | 78 | QTextStream ts( &file ); |
78 | ts.setEncoding( QTextStream::UnicodeUTF8 ); | 79 | ts.setEncoding( QTextStream::UnicodeUTF8 ); |
79 | text = ts.read(); | 80 | text = ts.read(); |
80 | file.close(); | 81 | file.close(); |
81 | if (!file.open( IO_WriteOnly ) ) { | 82 | if (!file.open( IO_WriteOnly ) ) { |
82 | return false; | 83 | return false; |
83 | } | 84 | } |
84 | QTextStream tsIn( &file ); | 85 | QTextStream tsIn( &file ); |
85 | tsIn.setEncoding( QTextStream::Latin1 ); | 86 | tsIn.setEncoding( QTextStream::Latin1 ); |
86 | tsIn << text.latin1(); | 87 | tsIn << text.latin1(); |
87 | file.close(); | 88 | file.close(); |
88 | 89 | ||
89 | 90 | ||
90 | } | 91 | } |
91 | void KApplication::showText(QString caption, QString text) | 92 | void KApplication::showText(QString caption, QString text) |
92 | { | 93 | { |
93 | QDialog dia( 0, "name", true ); ; | 94 | QDialog dia( 0, "name", true ); ; |
94 | dia.setCaption( caption ); | 95 | dia.setCaption( caption ); |
95 | QVBoxLayout* lay = new QVBoxLayout( &dia ); | 96 | QVBoxLayout* lay = new QVBoxLayout( &dia ); |
96 | lay->setSpacing( 3 ); | 97 | lay->setSpacing( 3 ); |
97 | lay->setMargin( 3 ); | 98 | lay->setMargin( 3 ); |
98 | QTextBrowser tb ( &dia ); | 99 | KTextEdit tb ( &dia ); |
100 | tb.setWordWrap( QMultiLineEdit::WidgetWidth ); | ||
99 | lay->addWidget( &tb ); | 101 | lay->addWidget( &tb ); |
100 | tb.setText( text ); | 102 | tb.setText( text ); |
101 | #ifdef DESKTOP_VERSION | 103 | #ifdef DESKTOP_VERSION |
102 | dia.resize( 640, 480); | 104 | dia.resize( 640, 480); |
103 | #else | 105 | #else |
104 | dia.showMaximized(); | 106 | dia.showMaximized(); |
105 | #endif | 107 | #endif |
106 | dia.exec(); | 108 | dia.exec(); |
107 | 109 | ||
108 | } | 110 | } |