summaryrefslogtreecommitdiffabout
path: root/microkde
Unidiff
Diffstat (limited to 'microkde') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kapplication.cpp52
-rw-r--r--microkde/kapplication.h1
2 files changed, 29 insertions, 24 deletions
diff --git a/microkde/kapplication.cpp b/microkde/kapplication.cpp
index f0de71e..ad0b78e 100644
--- a/microkde/kapplication.cpp
+++ b/microkde/kapplication.cpp
@@ -1,75 +1,79 @@
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
13int KApplication::random() 13int KApplication::random()
14{ 14{
15 return rand(); 15 return rand();
16} 16}
17 17
18//US 18//US
19QString KApplication::randomString(int length) 19QString 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}
35int KApplication::execDialog( QDialog* d ) 35int 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}
41void KApplication::showLicence() 41void KApplication::showLicence()
42{ 42{
43 QString fileName ; 43 KApplication::showFile( "KDE-Pim/Pi licence", "kdepim/LICENCE.TXT" );
44 QString text; 44}
45
46void KApplication::showFile(QString caption, QString fn)
47{
48 QString text;
49 QString fileName;
45#ifndef DESKTOP_VERSION 50#ifndef DESKTOP_VERSION
46 fileName = getenv("QPEDIR"); 51 fileName = getenv("QPEDIR");
47 fileName += "/pics/kdepim/LICENCE.TXT" ; 52 fileName += "/pics/" + fn ;
48#else 53#else
49 fileName = qApp->applicationDirPath () + "/kdepim/LICENCE.TXT"; 54 fileName = qApp->applicationDirPath () + "/" + fn;
50#endif 55#endif
51 QFile file( fileName ); 56 QFile file( fileName );
52 qDebug("Licence file name %s ",fileName.latin1() ); 57 if (!file.open( IO_ReadOnly ) ) {
53 if (!file.open( IO_ReadOnly ) ) { 58 return ;
54 return ; 59 }
55 } 60 QTextStream ts( &file );
56 QTextStream ts( &file ); 61 text = ts.read();
57 text = ts.read(); 62 file.close();
58 file.close(); 63
59 64 QDialog dia( 0, "name", true ); ;
60 QDialog dia( 0, "name", true ); ; 65 dia.setCaption( caption );
61 dia.setCaption( "KDE-Pim/Pi licence" ); 66 QVBoxLayout* lay = new QVBoxLayout( &dia );
62 QVBoxLayout* lay = new QVBoxLayout( &dia ); 67 lay->setSpacing( 3 );
63 lay->setSpacing( 3 ); 68 lay->setMargin( 3 );
64 lay->setMargin( 3 ); 69 QTextBrowser tb ( &dia );
65 QTextBrowser tb ( &dia ); 70 lay->addWidget( &tb );
66 lay->addWidget( &tb ); 71 tb.setText( text );
67 tb.setText( text );
68#ifdef DESKTOP_VERSION 72#ifdef DESKTOP_VERSION
69 dia.resize( 640, 480); 73 dia.resize( 640, 480);
70#else 74#else
71 dia.showMaximized(); 75 dia.showMaximized();
72#endif 76#endif
73 dia.exec(); 77 dia.exec();
74 78
75} 79}
diff --git a/microkde/kapplication.h b/microkde/kapplication.h
index 9515c60..5ae5c00 100644
--- a/microkde/kapplication.h
+++ b/microkde/kapplication.h
@@ -1,24 +1,25 @@
1#ifndef MINIKDE_KAPPLICATION_H 1#ifndef MINIKDE_KAPPLICATION_H
2#define MINIKDE_KAPPLICATION_H 2#define MINIKDE_KAPPLICATION_H
3 3
4#include "qstring.h" 4#include "qstring.h"
5#include <qdialog.h> 5#include <qdialog.h>
6 6
7class KApplication 7class KApplication
8{ 8{
9 public: 9 public:
10 static int random(); 10 static int random();
11 11
12//US 12//US
13 /** 13 /**
14 * Generates a random string. It operates in the range [A-Za-z0-9] 14 * Generates a random string. It operates in the range [A-Za-z0-9]
15 * @param length Generate a string of this length. 15 * @param length Generate a string of this length.
16 * @return the random string 16 * @return the random string
17 */ 17 */
18 static QString randomString(int length); 18 static QString randomString(int length);
19 static int execDialog( QDialog* ); 19 static int execDialog( QDialog* );
20 static void showLicence(); 20 static void showLicence();
21 static void showFile(QString caption, QString file);
21}; 22};
22 23
23 24
24#endif 25#endif