summaryrefslogtreecommitdiffabout
path: root/microkde/kapplication.cpp
blob: f0de71e216aa69c42e9133cbb86d64e42f78686f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <stdlib.h>
#include <stdio.h>

#include "kapplication.h"
#include <qapplication.h>
#include <qstring.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qdialog.h>
#include <qlayout.h>
#include <qtextbrowser.h>

int KApplication::random()
{
  return rand();
}

//US
QString KApplication::randomString(int length)
{
   if (length <=0 ) return QString::null;

   QString str;
   while (length--)
   {
      int r=random() % 62;
      r+=48;
      if (r>57) r+=7;
      if (r>90) r+=6;
      str += char(r);
      // so what if I work backwards?
   }
   return str;
}
int KApplication::execDialog( QDialog* d )
{
    if (QApplication::desktop()->width() <= 640 )    
        d->showMaximized();
    return d->exec();
}
void KApplication::showLicence()
{
   QString fileName ;
   QString text;
#ifndef DESKTOP_VERSION
   fileName = getenv("QPEDIR");
   fileName += "/pics/kdepim/LICENCE.TXT" ;
#else
   fileName  = qApp->applicationDirPath () + "/kdepim/LICENCE.TXT";
#endif 
   QFile file( fileName );
   qDebug("Licence file name %s ",fileName.latin1() );
   if (!file.open( IO_ReadOnly ) ) {
       return ;
   } 
   QTextStream ts( &file );
   text = ts.read();
   file.close();
   
   QDialog dia( 0, "name", true ); ;
   dia.setCaption( "KDE-Pim/Pi licence" );
   QVBoxLayout* lay = new QVBoxLayout( &dia );
   lay->setSpacing( 3 );
   lay->setMargin( 3 );
   QTextBrowser tb ( &dia );
   lay->addWidget( &tb ); 
   tb.setText( text );
#ifdef DESKTOP_VERSION
   dia.resize( 640, 480);
#else
   dia.showMaximized();
#endif
   dia.exec();
   
}