-rw-r--r-- | microkde/kapplication.cpp | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/microkde/kapplication.cpp b/microkde/kapplication.cpp index d7c12bb..b058d54 100644 --- a/microkde/kapplication.cpp +++ b/microkde/kapplication.cpp | |||
@@ -1,29 +1,32 @@ | |||
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 <q3textstream.h> |
10 | #include <qdialog.h> | 10 | #include <qdialog.h> |
11 | #include <qlayout.h> | 11 | #include <qlayout.h> |
12 | #include <qtextbrowser.h> | 12 | #include <q3textbrowser.h> |
13 | #include <qregexp.h> | 13 | #include <qregexp.h> |
14 | #include <QDesktopWidget> | ||
15 | //Added by qt3to4: | ||
16 | #include <Q3VBoxLayout> | ||
14 | 17 | ||
15 | int KApplication::random() | 18 | int KApplication::random() |
16 | { | 19 | { |
17 | return rand(); | 20 | return rand(); |
18 | } | 21 | } |
19 | 22 | ||
20 | //US | 23 | //US |
21 | QString KApplication::randomString(int length) | 24 | QString KApplication::randomString(int length) |
22 | { | 25 | { |
23 | if (length <=0 ) return QString::null; | 26 | if (length <=0 ) return QString::null; |
24 | 27 | ||
25 | QString str; | 28 | QString str; |
26 | while (length--) | 29 | while (length--) |
27 | { | 30 | { |
28 | int r=random() % 62; | 31 | int r=random() % 62; |
29 | r+=48; | 32 | r+=48; |
@@ -62,107 +65,107 @@ void KApplication::testCoords( int* x, int* y, int* wid, int * hei ) | |||
62 | *y = 20; | 65 | *y = 20; |
63 | if ( *hei > dHei ) | 66 | if ( *hei > dHei ) |
64 | *hei = dHei; | 67 | *hei = dHei; |
65 | } | 68 | } |
66 | } | 69 | } |
67 | void KApplication::showFile(QString caption, QString fn) | 70 | void KApplication::showFile(QString caption, QString fn) |
68 | { | 71 | { |
69 | QString text; | 72 | QString text; |
70 | QString fileName; | 73 | QString fileName; |
71 | #ifndef DESKTOP_VERSION | 74 | #ifndef DESKTOP_VERSION |
72 | fileName = getenv("QPEDIR"); | 75 | fileName = getenv("QPEDIR"); |
73 | fileName += "/pics/" + fn ; | 76 | fileName += "/pics/" + fn ; |
74 | #else | 77 | #else |
75 | fileName = qApp->applicationDirPath () + "/" + fn; | 78 | fileName = qApp->applicationDirPath () + "/" + fn; |
76 | #endif | 79 | #endif |
77 | QFile file( fileName ); | 80 | QFile file( fileName ); |
78 | if (!file.open( IO_ReadOnly ) ) { | 81 | if (!file.open( QIODevice::ReadOnly ) ) { |
79 | return ; | 82 | return ; |
80 | } | 83 | } |
81 | QTextStream ts( &file ); | 84 | Q3TextStream ts( &file ); |
82 | text = ts.read(); | 85 | text = ts.read(); |
83 | file.close(); | 86 | file.close(); |
84 | KApplication::showText( caption, text ); | 87 | KApplication::showText( caption, text ); |
85 | 88 | ||
86 | } | 89 | } |
87 | 90 | ||
88 | bool KApplication::convert2latin1(QString fileName) | 91 | bool KApplication::convert2latin1(QString fileName) |
89 | { | 92 | { |
90 | QString text; | 93 | QString text; |
91 | QFile file( fileName ); | 94 | QFile file( fileName ); |
92 | if (!file.open( IO_ReadOnly ) ) { | 95 | if (!file.open( QIODevice::ReadOnly ) ) { |
93 | return false; | 96 | return false; |
94 | 97 | ||
95 | } | 98 | } |
96 | QTextStream ts( &file ); | 99 | Q3TextStream ts( &file ); |
97 | ts.setEncoding( QTextStream::UnicodeUTF8 ); | 100 | ts.setEncoding( Q3TextStream::UnicodeUTF8 ); |
98 | text = ts.read(); | 101 | text = ts.read(); |
99 | file.close(); | 102 | file.close(); |
100 | if (!file.open( IO_WriteOnly ) ) { | 103 | if (!file.open( QIODevice::WriteOnly ) ) { |
101 | return false; | 104 | return false; |
102 | } | 105 | } |
103 | QTextStream tsIn( &file ); | 106 | Q3TextStream tsIn( &file ); |
104 | tsIn.setEncoding( QTextStream::Latin1 ); | 107 | tsIn.setEncoding( Q3TextStream::Latin1 ); |
105 | tsIn << text.latin1(); | 108 | tsIn << text.latin1(); |
106 | file.close(); | 109 | file.close(); |
107 | return true; | 110 | return true; |
108 | 111 | ||
109 | 112 | ||
110 | } | 113 | } |
111 | void KApplication::showText(QString caption, QString text) | 114 | void KApplication::showText(QString caption, QString text) |
112 | { | 115 | { |
113 | QDialog dia( 0, "name", true ); ; | 116 | QDialog dia( 0, "name", true ); ; |
114 | dia.setCaption( caption ); | 117 | dia.setCaption( caption ); |
115 | QVBoxLayout* lay = new QVBoxLayout( &dia ); | 118 | Q3VBoxLayout* lay = new Q3VBoxLayout( &dia ); |
116 | lay->setSpacing( 3 ); | 119 | lay->setSpacing( 3 ); |
117 | lay->setMargin( 3 ); | 120 | lay->setMargin( 3 ); |
118 | KTextEdit tb ( &dia ); | 121 | KTextEdit tb ( &dia ); |
119 | tb.setWordWrap( QMultiLineEdit::WidgetWidth ); | 122 | tb.setWordWrap( Q3MultiLineEdit::WidgetWidth ); |
120 | lay->addWidget( &tb ); | 123 | lay->addWidget( &tb ); |
121 | tb.setText( text ); | 124 | tb.setText( text ); |
122 | #ifdef DESKTOP_VERSION | 125 | #ifdef DESKTOP_VERSION |
123 | dia.resize( 640, 480); | 126 | dia.resize( 640, 480); |
124 | #else | 127 | #else |
125 | dia.showMaximized(); | 128 | dia.showMaximized(); |
126 | #endif | 129 | #endif |
127 | dia.exec(); | 130 | dia.exec(); |
128 | 131 | ||
129 | } | 132 | } |
130 | 133 | ||
131 | #include <qlabel.h> | 134 | #include <qlabel.h> |
132 | #include <qpushbutton.h> | 135 | #include <qpushbutton.h> |
133 | #include <qlayout.h> | 136 | #include <qlayout.h> |
134 | #include <qdir.h> | 137 | #include <qdir.h> |
135 | #include <qradiobutton.h> | 138 | #include <qradiobutton.h> |
136 | #include <qbuttongroup.h> | 139 | #include <q3buttongroup.h> |
137 | #include "kglobal.h" | 140 | #include "kglobal.h" |
138 | #include "klocale.h" | 141 | #include "klocale.h" |
139 | 142 | ||
140 | class KBackupPrefs : public QDialog | 143 | class KBackupPrefs : public QDialog |
141 | { | 144 | { |
142 | public: | 145 | public: |
143 | KBackupPrefs( QString message , QWidget *parent=0, const char *name=0 ) : | 146 | KBackupPrefs( QString message , QWidget *parent=0, const char *name=0 ) : |
144 | QDialog( parent, name, true ) | 147 | QDialog( parent, name, true ) |
145 | { | 148 | { |
146 | setCaption( i18n("Backup Failed!") ); | 149 | setCaption( i18n("Backup Failed!") ); |
147 | QVBoxLayout* lay = new QVBoxLayout( this ); | 150 | Q3VBoxLayout* lay = new Q3VBoxLayout( this ); |
148 | lay->setSpacing( 3 ); | 151 | lay->setSpacing( 3 ); |
149 | lay->setMargin( 3 ); | 152 | lay->setMargin( 3 ); |
150 | QLabel * lab = new QLabel( message, this ); | 153 | QLabel * lab = new QLabel( message, this ); |
151 | lay->addWidget( lab ); | 154 | lay->addWidget( lab ); |
152 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Choose action"), this ); | 155 | Q3ButtonGroup* format = new Q3ButtonGroup( 1, Qt::Horizontal, i18n("Choose action"), this ); |
153 | lay->addWidget( format ); | 156 | lay->addWidget( format ); |
154 | format->setExclusive ( true ) ; | 157 | format->setExclusive ( true ) ; |
155 | vcal = new QRadioButton(i18n("Try again now"), format ); | 158 | vcal = new QRadioButton(i18n("Try again now"), format ); |
156 | tcal = new QRadioButton(i18n("Try again later"), format ); | 159 | tcal = new QRadioButton(i18n("Try again later"), format ); |
157 | ical = new QRadioButton(i18n("Try again tomorrow"), format ); | 160 | ical = new QRadioButton(i18n("Try again tomorrow"), format ); |
158 | ocal = new QRadioButton(i18n("Disable backup"), format ); | 161 | ocal = new QRadioButton(i18n("Disable backup"), format ); |
159 | vcal->setChecked( true ); | 162 | vcal->setChecked( true ); |
160 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 163 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
161 | lay->addWidget(ok ); | 164 | lay->addWidget(ok ); |
162 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 165 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
163 | } | 166 | } |
164 | 167 | ||
165 | bool again() { return vcal->isChecked(); } | 168 | bool again() { return vcal->isChecked(); } |
166 | bool later() { return tcal->isChecked(); } | 169 | bool later() { return tcal->isChecked(); } |
167 | bool againTomorrow() { return ical->isChecked(); } | 170 | bool againTomorrow() { return ical->isChecked(); } |
168 | private: | 171 | private: |