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