summaryrefslogtreecommitdiffabout
path: root/microkde/kapplication.cpp
Unidiff
Diffstat (limited to 'microkde/kapplication.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kapplication.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/microkde/kapplication.cpp b/microkde/kapplication.cpp
index f05b91b..80a83e0 100644
--- a/microkde/kapplication.cpp
+++ b/microkde/kapplication.cpp
@@ -1,96 +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::testCoords( int* x, int* y, int* wid, int * hei )
50{
51 int dWid = QApplication::desktop()->width() ;
52 int dHei = QApplication::desktop()->height();
53 if ( *x + *wid > dWid ) {
54 *x = 0;
55 if ( *wid > dWid )
56 *wid = dWid;
57 }
58 if ( *y + *hei > dHei ) {
59 *y = 0;
60 if ( *hei > dHei )
61 *hei = dHei;
62 }
63}
49void KApplication::showFile(QString caption, QString fn) 64void KApplication::showFile(QString caption, QString fn)
50{ 65{
51 QString text; 66 QString text;
52 QString fileName; 67 QString fileName;
53#ifndef DESKTOP_VERSION 68#ifndef DESKTOP_VERSION
54 fileName = getenv("QPEDIR"); 69 fileName = getenv("QPEDIR");
55 fileName += "/pics/" + fn ; 70 fileName += "/pics/" + fn ;
56#else 71#else
57 fileName = qApp->applicationDirPath () + "/" + fn; 72 fileName = qApp->applicationDirPath () + "/" + fn;
58#endif 73#endif
59 QFile file( fileName ); 74 QFile file( fileName );
60 if (!file.open( IO_ReadOnly ) ) { 75 if (!file.open( IO_ReadOnly ) ) {
61 return ; 76 return ;
62 } 77 }
63 QTextStream ts( &file ); 78 QTextStream ts( &file );
64 text = ts.read(); 79 text = ts.read();
65 file.close(); 80 file.close();
66 KApplication::showText( caption, text ); 81 KApplication::showText( caption, text );
67 82
68} 83}
69 84
70bool KApplication::convert2latin1(QString fileName) 85bool KApplication::convert2latin1(QString fileName)
71{ 86{
72 QString text; 87 QString text;
73 QFile file( fileName ); 88 QFile file( fileName );
74 if (!file.open( IO_ReadOnly ) ) { 89 if (!file.open( IO_ReadOnly ) ) {
75 return false; 90 return false;
76 91
77 } 92 }
78 QTextStream ts( &file ); 93 QTextStream ts( &file );
79 ts.setEncoding( QTextStream::UnicodeUTF8 ); 94 ts.setEncoding( QTextStream::UnicodeUTF8 );
80 text = ts.read(); 95 text = ts.read();
81 file.close(); 96 file.close();
82 if (!file.open( IO_WriteOnly ) ) { 97 if (!file.open( IO_WriteOnly ) ) {
83 return false; 98 return false;
84 } 99 }
85 QTextStream tsIn( &file ); 100 QTextStream tsIn( &file );
86 tsIn.setEncoding( QTextStream::Latin1 ); 101 tsIn.setEncoding( QTextStream::Latin1 );
87 tsIn << text.latin1(); 102 tsIn << text.latin1();
88 file.close(); 103 file.close();
89 return true; 104 return true;
90 105
91 106
92} 107}
93void KApplication::showText(QString caption, QString text) 108void KApplication::showText(QString caption, QString text)
94{ 109{
95 QDialog dia( 0, "name", true ); ; 110 QDialog dia( 0, "name", true ); ;
96 dia.setCaption( caption ); 111 dia.setCaption( caption );