-rw-r--r-- | core/apps/textedit/textedit.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 8eaafce..bd0014a 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -1,405 +1,410 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // changes added by L. J. Potter Sun 02-17-2002 21:31:31 | 20 | // changes added by L. J. Potter Sun 02-17-2002 21:31:31 |
21 | 21 | /* | |
22 | useAdvancedfeatures = | ||
23 | 1) do not prompt on cancel, even if text is edited. | ||
24 | 2) prompt user is .desktop file | ||
25 | 3) prompt user for File Permissions on saveAs | ||
26 | */ | ||
22 | #include "textedit.h" | 27 | #include "textedit.h" |
23 | #include "filePermissions.h" | 28 | #include "filePermissions.h" |
24 | #include "fontDialog.h" | 29 | #include "fontDialog.h" |
25 | 30 | ||
26 | #include <opie/ofileselector.h> | 31 | #include <opie/ofileselector.h> |
27 | #include <opie/ofiledialog.h> | 32 | #include <opie/ofiledialog.h> |
28 | 33 | ||
29 | #include <qpe/fontdatabase.h> | 34 | #include <qpe/fontdatabase.h> |
30 | #include <qpe/global.h> | 35 | #include <qpe/global.h> |
31 | #include <qpe/fileselector.h> | 36 | #include <qpe/fileselector.h> |
32 | #include <qpe/applnk.h> | 37 | #include <qpe/applnk.h> |
33 | #include <qpe/resource.h> | 38 | #include <qpe/resource.h> |
34 | #include <qpe/config.h> | 39 | #include <qpe/config.h> |
35 | #include <qpe/qpeapplication.h> | 40 | #include <qpe/qpeapplication.h> |
36 | #include <qpe/qpemenubar.h> | 41 | #include <qpe/qpemenubar.h> |
37 | #include <qpe/qpetoolbar.h> | 42 | #include <qpe/qpetoolbar.h> |
38 | #include <qpe/qcopenvelope_qws.h> | 43 | #include <qpe/qcopenvelope_qws.h> |
39 | 44 | ||
40 | #include <qdatetime.h> | 45 | #include <qdatetime.h> |
41 | #include <qclipboard.h> | 46 | #include <qclipboard.h> |
42 | #include <qstringlist.h> | 47 | #include <qstringlist.h> |
43 | #include <qaction.h> | 48 | #include <qaction.h> |
44 | #include <qcolordialog.h> | 49 | #include <qcolordialog.h> |
45 | #include <qfileinfo.h> | 50 | #include <qfileinfo.h> |
46 | #include <qlineedit.h> | 51 | #include <qlineedit.h> |
47 | #include <qmessagebox.h> | 52 | #include <qmessagebox.h> |
48 | #include <qobjectlist.h> | 53 | #include <qobjectlist.h> |
49 | #include <qpopupmenu.h> | 54 | #include <qpopupmenu.h> |
50 | #include <qspinbox.h> | 55 | #include <qspinbox.h> |
51 | #include <qtoolbutton.h> | 56 | #include <qtoolbutton.h> |
52 | #include <qwidgetstack.h> | 57 | #include <qwidgetstack.h> |
53 | #include <qcheckbox.h> | 58 | #include <qcheckbox.h> |
54 | #include <qcombo.h> | 59 | #include <qcombo.h> |
55 | 60 | ||
56 | #include <unistd.h> | 61 | #include <unistd.h> |
57 | #include <sys/stat.h> | 62 | #include <sys/stat.h> |
58 | #include <stdlib.h> //getenv | 63 | #include <stdlib.h> //getenv |
59 | 64 | ||
60 | 65 | ||
61 | /* XPM */ | 66 | /* XPM */ |
62 | static char * filesave_xpm[] = { | 67 | static char * filesave_xpm[] = { |
63 | "16 16 78 1", | 68 | "16 16 78 1", |
64 | " c None", | 69 | " c None", |
65 | ". c #343434", | 70 | ". c #343434", |
66 | "+ c #A0A0A0", | 71 | "+ c #A0A0A0", |
67 | "@ c #565656", | 72 | "@ c #565656", |
68 | "# c #9E9E9E", | 73 | "# c #9E9E9E", |
69 | "$ c #525252", | 74 | "$ c #525252", |
70 | "% c #929292", | 75 | "% c #929292", |
71 | "& c #676767", | 76 | "& c #676767", |
72 | "* c #848484", | 77 | "* c #848484", |
73 | "= c #666666", | 78 | "= c #666666", |
74 | "- c #D8D8D8", | 79 | "- c #D8D8D8", |
75 | "; c #FFFFFF", | 80 | "; c #FFFFFF", |
76 | "> c #DBDBDB", | 81 | "> c #DBDBDB", |
77 | ", c #636363", | 82 | ", c #636363", |
78 | "' c #989898", | 83 | "' c #989898", |
79 | ") c #2D2D2D", | 84 | ") c #2D2D2D", |
80 | "! c #909090", | 85 | "! c #909090", |
81 | "~ c #AEAEAE", | 86 | "~ c #AEAEAE", |
82 | "{ c #EAEAEA", | 87 | "{ c #EAEAEA", |
83 | "] c #575757", | 88 | "] c #575757", |
84 | "^ c #585858", | 89 | "^ c #585858", |
85 | "/ c #8A8A8A", | 90 | "/ c #8A8A8A", |
86 | "( c #828282", | 91 | "( c #828282", |
87 | "_ c #6F6F6F", | 92 | "_ c #6F6F6F", |
88 | ": c #C9C9C9", | 93 | ": c #C9C9C9", |
89 | "< c #050505", | 94 | "< c #050505", |
90 | "[ c #292929", | 95 | "[ c #292929", |
91 | "} c #777777", | 96 | "} c #777777", |
92 | "| c #616161", | 97 | "| c #616161", |
93 | "1 c #3A3A3A", | 98 | "1 c #3A3A3A", |
94 | "2 c #BEBEBE", | 99 | "2 c #BEBEBE", |
95 | "3 c #2C2C2C", | 100 | "3 c #2C2C2C", |
96 | "4 c #7C7C7C", | 101 | "4 c #7C7C7C", |
97 | "5 c #F6F6F6", | 102 | "5 c #F6F6F6", |
98 | "6 c #FCFCFC", | 103 | "6 c #FCFCFC", |
99 | "7 c #6B6B6B", | 104 | "7 c #6B6B6B", |
100 | "8 c #959595", | 105 | "8 c #959595", |
101 | "9 c #4F4F4F", | 106 | "9 c #4F4F4F", |
102 | "0 c #808080", | 107 | "0 c #808080", |
103 | "a c #767676", | 108 | "a c #767676", |
104 | "b c #818181", | 109 | "b c #818181", |
105 | "c c #B8B8B8", | 110 | "c c #B8B8B8", |
106 | "d c #FBFBFB", | 111 | "d c #FBFBFB", |
107 | "e c #F9F9F9", | 112 | "e c #F9F9F9", |
108 | "f c #CCCCCC", | 113 | "f c #CCCCCC", |
109 | "g c #030303", | 114 | "g c #030303", |
110 | "h c #737373", | 115 | "h c #737373", |
111 | "i c #7A7A7A", | 116 | "i c #7A7A7A", |
112 | "j c #7E7E7E", | 117 | "j c #7E7E7E", |
113 | "k c #6A6A6A", | 118 | "k c #6A6A6A", |
114 | "l c #FAFAFA", | 119 | "l c #FAFAFA", |
115 | "m c #505050", | 120 | "m c #505050", |
116 | "n c #9D9D9D", | 121 | "n c #9D9D9D", |
117 | "o c #333333", | 122 | "o c #333333", |
118 | "p c #7B7B7B", | 123 | "p c #7B7B7B", |
119 | "q c #787878", | 124 | "q c #787878", |
120 | "r c #696969", | 125 | "r c #696969", |
121 | "s c #494949", | 126 | "s c #494949", |
122 | "t c #555555", | 127 | "t c #555555", |
123 | "u c #949494", | 128 | "u c #949494", |
124 | "v c #E6E6E6", | 129 | "v c #E6E6E6", |
125 | "w c #424242", | 130 | "w c #424242", |
126 | "x c #515151", | 131 | "x c #515151", |
127 | "y c #535353", | 132 | "y c #535353", |
128 | "z c #3E3E3E", | 133 | "z c #3E3E3E", |
129 | "A c #D4D4D4", | 134 | "A c #D4D4D4", |
130 | "B c #0C0C0C", | 135 | "B c #0C0C0C", |
131 | "C c #353535", | 136 | "C c #353535", |
132 | "D c #474747", | 137 | "D c #474747", |
133 | "E c #ECECEC", | 138 | "E c #ECECEC", |
134 | "F c #919191", | 139 | "F c #919191", |
135 | "G c #7D7D7D", | 140 | "G c #7D7D7D", |
136 | "H c #000000", | 141 | "H c #000000", |
137 | "I c #404040", | 142 | "I c #404040", |
138 | "J c #858585", | 143 | "J c #858585", |
139 | "K c #323232", | 144 | "K c #323232", |
140 | "L c #D0D0D0", | 145 | "L c #D0D0D0", |
141 | "M c #1C1C1C", | 146 | "M c #1C1C1C", |
142 | " ...+ ", | 147 | " ...+ ", |
143 | " @#$%&..+ ", | 148 | " @#$%&..+ ", |
144 | " .*=-;;>,..+ ", | 149 | " .*=-;;>,..+ ", |
145 | " ')!~;;;;;;{]..", | 150 | " ')!~;;;;;;{]..", |
146 | " ^/(-;;;;;;;_:<", | 151 | " ^/(-;;;;;;;_:<", |
147 | " [}|;;;;;;;{12$", | 152 | " [}|;;;;;;;{12$", |
148 | " #34-55;;;;678$+", | 153 | " #34-55;;;;678$+", |
149 | " 90ab=c;dd;e1fg ", | 154 | " 90ab=c;dd;e1fg ", |
150 | " [ahij((kbl0mn$ ", | 155 | " [ahij((kbl0mn$ ", |
151 | " op^q^^7r&]s/$+ ", | 156 | " op^q^^7r&]s/$+ ", |
152 | "@btu;vbwxy]zAB ", | 157 | "@btu;vbwxy]zAB ", |
153 | "CzDEvEv;;DssF$ ", | 158 | "CzDEvEv;;DssF$ ", |
154 | "G.H{E{E{IxsJ$+ ", | 159 | "G.H{E{E{IxsJ$+ ", |
155 | " +...vEKxzLM ", | 160 | " +...vEKxzLM ", |
156 | " +...z]n$ ", | 161 | " +...z]n$ ", |
157 | " +... "}; | 162 | " +... "}; |
158 | 163 | ||
159 | 164 | ||
160 | #if QT_VERSION < 300 | 165 | #if QT_VERSION < 300 |
161 | 166 | ||
162 | class QpeEditor : public QMultiLineEdit | 167 | class QpeEditor : public QMultiLineEdit |
163 | { | 168 | { |
164 | // Q_OBJECT | 169 | // Q_OBJECT |
165 | public: | 170 | public: |
166 | QpeEditor( QWidget *parent, const char * name = 0 ) | 171 | QpeEditor( QWidget *parent, const char * name = 0 ) |
167 | : QMultiLineEdit( parent, name ) | 172 | : QMultiLineEdit( parent, name ) |
168 | { | 173 | { |
169 | clearTableFlags(); | 174 | clearTableFlags(); |
170 | setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); | 175 | setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); |
171 | } | 176 | } |
172 | 177 | ||
173 | void find( const QString &txt, bool caseSensitive, | 178 | void find( const QString &txt, bool caseSensitive, |
174 | bool backwards ); | 179 | bool backwards ); |
175 | //public slots: | 180 | //public slots: |
176 | /* | 181 | /* |
177 | signals: | 182 | signals: |
178 | void notFound(); | 183 | void notFound(); |
179 | void searchWrapped(); | 184 | void searchWrapped(); |
180 | */ | 185 | */ |
181 | 186 | ||
182 | private: | 187 | private: |
183 | 188 | ||
184 | }; | 189 | }; |
185 | 190 | ||
186 | 191 | ||
187 | void QpeEditor::find ( const QString &txt, bool caseSensitive, | 192 | void QpeEditor::find ( const QString &txt, bool caseSensitive, |
188 | bool backwards ) | 193 | bool backwards ) |
189 | { | 194 | { |
190 | static bool wrap = FALSE; | 195 | static bool wrap = FALSE; |
191 | int line, col; | 196 | int line, col; |
192 | if ( wrap ) { | 197 | if ( wrap ) { |
193 | if ( !backwards ) | 198 | if ( !backwards ) |
194 | line = col = 0; | 199 | line = col = 0; |
195 | wrap = FALSE; | 200 | wrap = FALSE; |
196 | // emit searchWrapped(); | 201 | // emit searchWrapped(); |
197 | } else { | 202 | } else { |
198 | getCursorPosition( &line, &col ); | 203 | getCursorPosition( &line, &col ); |
199 | } | 204 | } |
200 | //ignore backwards for now.... | 205 | //ignore backwards for now.... |
201 | if ( !backwards ) { | 206 | if ( !backwards ) { |
202 | for ( ; ; ) { | 207 | for ( ; ; ) { |
203 | if ( line >= numLines() ) { | 208 | if ( line >= numLines() ) { |
204 | wrap = TRUE; | 209 | wrap = TRUE; |
205 | //emit notFound(); | 210 | //emit notFound(); |
206 | break; | 211 | break; |
207 | } | 212 | } |
208 | int findCol = getString( line )->find( txt, col, caseSensitive ); | 213 | int findCol = getString( line )->find( txt, col, caseSensitive ); |
209 | if ( findCol >= 0 ) { | 214 | if ( findCol >= 0 ) { |
210 | setCursorPosition( line, findCol, FALSE ); | 215 | setCursorPosition( line, findCol, FALSE ); |
211 | col = findCol + txt.length(); | 216 | col = findCol + txt.length(); |
212 | setCursorPosition( line, col, TRUE ); | 217 | setCursorPosition( line, col, TRUE ); |
213 | 218 | ||
214 | //found = TRUE; | 219 | //found = TRUE; |
215 | break; | 220 | break; |
216 | } | 221 | } |
217 | line++; | 222 | line++; |
218 | col = 0; | 223 | col = 0; |
219 | } | 224 | } |
220 | 225 | ||
221 | } | 226 | } |
222 | 227 | ||
223 | } | 228 | } |
224 | 229 | ||
225 | 230 | ||
226 | #else | 231 | #else |
227 | 232 | ||
228 | #error "Must make a QpeEditor that inherits QTextEdit" | 233 | #error "Must make a QpeEditor that inherits QTextEdit" |
229 | 234 | ||
230 | #endif | 235 | #endif |
231 | 236 | ||
232 | 237 | ||
233 | static const int nfontsizes = 6; | 238 | static const int nfontsizes = 6; |
234 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; | 239 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; |
235 | 240 | ||
236 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | 241 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) |
237 | : QMainWindow( parent, name, f ), bFromDocView( FALSE ) | 242 | : QMainWindow( parent, name, f ), bFromDocView( FALSE ) |
238 | { | 243 | { |
239 | doc = 0; | 244 | doc = 0; |
240 | edited=FALSE; | 245 | edited=FALSE; |
241 | edited1=FALSE; | 246 | edited1=FALSE; |
242 | setToolBarsMovable( FALSE ); | 247 | setToolBarsMovable( FALSE ); |
243 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 248 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
244 | 249 | ||
245 | channel = new QCopChannel( "QPE/Application/textedit", this ); | 250 | channel = new QCopChannel( "QPE/Application/textedit", this ); |
246 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 251 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
247 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 252 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
248 | 253 | ||
249 | setIcon( Resource::loadPixmap( "TextEditor" ) ); | 254 | setIcon( Resource::loadPixmap( "TextEditor" ) ); |
250 | 255 | ||
251 | QPEToolBar *bar = new QPEToolBar( this ); | 256 | QPEToolBar *bar = new QPEToolBar( this ); |
252 | bar->setHorizontalStretchable( TRUE ); | 257 | bar->setHorizontalStretchable( TRUE ); |
253 | menu = bar; | 258 | menu = bar; |
254 | 259 | ||
255 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 260 | QPEMenuBar *mb = new QPEMenuBar( bar ); |
256 | QPopupMenu *file = new QPopupMenu( this ); | 261 | QPopupMenu *file = new QPopupMenu( this ); |
257 | QPopupMenu *edit = new QPopupMenu( this ); | 262 | QPopupMenu *edit = new QPopupMenu( this ); |
258 | font = new QPopupMenu( this ); | 263 | font = new QPopupMenu( this ); |
259 | 264 | ||
260 | bar = new QPEToolBar( this ); | 265 | bar = new QPEToolBar( this ); |
261 | editBar = bar; | 266 | editBar = bar; |
262 | 267 | ||
263 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); | 268 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
264 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 269 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
265 | a->addTo( bar ); | 270 | a->addTo( bar ); |
266 | a->addTo( file ); | 271 | a->addTo( file ); |
267 | 272 | ||
268 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); | 273 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); |
269 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); | 274 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); |
270 | a->addTo( bar ); | 275 | a->addTo( bar ); |
271 | a->addTo( file ); | 276 | a->addTo( file ); |
272 | 277 | ||
273 | a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); | 278 | a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); |
274 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); | 279 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); |
275 | file->insertSeparator(); | 280 | file->insertSeparator(); |
276 | a->addTo( file ); | 281 | a->addTo( file ); |
277 | 282 | ||
278 | a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); | 283 | a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); |
279 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); | 284 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); |
280 | a->addTo( file ); | 285 | a->addTo( file ); |
281 | 286 | ||
282 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); | 287 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); |
283 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); | 288 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); |
284 | a->addTo( editBar ); | 289 | a->addTo( editBar ); |
285 | a->addTo( edit ); | 290 | a->addTo( edit ); |
286 | 291 | ||
287 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 ); | 292 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 ); |
288 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); | 293 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); |
289 | a->addTo( editBar ); | 294 | a->addTo( editBar ); |
290 | a->addTo( edit ); | 295 | a->addTo( edit ); |
291 | 296 | ||
292 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 297 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); |
293 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); | 298 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); |
294 | a->addTo( editBar ); | 299 | a->addTo( editBar ); |
295 | a->addTo( edit ); | 300 | a->addTo( edit ); |
296 | 301 | ||
297 | 302 | ||
298 | #ifndef QT_NO_CLIPBOARD | 303 | #ifndef QT_NO_CLIPBOARD |
299 | a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 304 | a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); |
300 | connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); | 305 | connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); |
301 | a->addTo( edit ); | 306 | a->addTo( edit ); |
302 | #endif | 307 | #endif |
303 | 308 | ||
304 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 309 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); |
305 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); | 310 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); |
306 | edit->insertSeparator(); | 311 | edit->insertSeparator(); |
307 | a->addTo( bar ); | 312 | a->addTo( bar ); |
308 | a->addTo( edit ); | 313 | a->addTo( edit ); |
309 | 314 | ||
310 | int defsize; | 315 | int defsize; |
311 | bool defb, defi, wrap; | 316 | bool defb, defi, wrap; |
312 | 317 | ||
313 | Config cfg("TextEdit"); | 318 | Config cfg("TextEdit"); |
314 | cfg.setGroup("View"); | 319 | cfg.setGroup("View"); |
315 | defsize = cfg.readNumEntry("FontSize",10); | 320 | defsize = cfg.readNumEntry("FontSize",10); |
316 | defb = cfg.readBoolEntry("Bold",FALSE); | 321 | defb = cfg.readBoolEntry("Bold",FALSE); |
317 | defi = cfg.readBoolEntry("Italic",FALSE); | 322 | defi = cfg.readBoolEntry("Italic",FALSE); |
318 | wrap = cfg.readBoolEntry("Wrap",TRUE); | 323 | wrap = cfg.readBoolEntry("Wrap",TRUE); |
319 | 324 | ||
320 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); | 325 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); |
321 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); | 326 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); |
322 | zin->addTo( font ); | 327 | zin->addTo( font ); |
323 | 328 | ||
324 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); | 329 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); |
325 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); | 330 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); |
326 | zout->addTo( font ); | 331 | zout->addTo( font ); |
327 | 332 | ||
328 | font->insertSeparator(); | 333 | font->insertSeparator(); |
329 | 334 | ||
330 | #if 0 | 335 | #if 0 |
331 | QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 ); | 336 | QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 ); |
332 | connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) ); | 337 | connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) ); |
333 | ba->setToggleAction(TRUE); | 338 | ba->setToggleAction(TRUE); |
334 | ba->addTo( font ); | 339 | ba->addTo( font ); |
335 | 340 | ||
336 | QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 ); | 341 | QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 ); |
337 | connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) ); | 342 | connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) ); |
338 | ia->setToggleAction(TRUE); | 343 | ia->setToggleAction(TRUE); |
339 | ia->addTo( font ); | 344 | ia->addTo( font ); |
340 | 345 | ||
341 | ba->setOn(defb); | 346 | ba->setOn(defb); |
342 | ia->setOn(defi); | 347 | ia->setOn(defi); |
343 | 348 | ||
344 | font->insertSeparator(); | 349 | font->insertSeparator(); |
345 | #endif | 350 | #endif |
346 | 351 | ||
347 | QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); | 352 | QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); |
348 | connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); | 353 | connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); |
349 | wa->setToggleAction(TRUE); | 354 | wa->setToggleAction(TRUE); |
350 | wa->addTo( font ); | 355 | wa->addTo( font ); |
351 | 356 | ||
352 | font->insertSeparator(); | 357 | font->insertSeparator(); |
353 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); | 358 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); |
354 | 359 | ||
355 | font->insertSeparator(); | 360 | font->insertSeparator(); |
356 | 361 | ||
357 | nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); | 362 | nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); |
358 | connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); | 363 | connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); |
359 | nStart->setToggleAction(TRUE); | 364 | nStart->setToggleAction(TRUE); |
360 | nStart->addTo( font ); | 365 | nStart->addTo( font ); |
361 | 366 | ||
362 | nAdvanced = new QAction( tr("Advanced features"), QString::null, 0, this, 0 ); | 367 | nAdvanced = new QAction( tr("Advanced features"), QString::null, 0, this, 0 ); |
363 | connect( nAdvanced, SIGNAL( toggled(bool) ), this, SLOT( doAdvanced(bool) ) ); | 368 | connect( nAdvanced, SIGNAL( toggled(bool) ), this, SLOT( doAdvanced(bool) ) ); |
364 | nAdvanced->setToggleAction(TRUE); | 369 | nAdvanced->setToggleAction(TRUE); |
365 | nAdvanced->addTo( font ); | 370 | nAdvanced->addTo( font ); |
366 | 371 | ||
367 | if(cfg.readBoolEntry("AdvancedFeatures")) { | 372 | if(cfg.readBoolEntry("AdvancedFeatures")) { |
368 | qDebug("using advanced features"); | 373 | qDebug("using advanced features"); |
369 | useAdvancedFeatures = true; | 374 | useAdvancedFeatures = true; |
370 | nAdvanced->setOn(TRUE); | 375 | nAdvanced->setOn(TRUE); |
371 | } else | 376 | } else |
372 | useAdvancedFeatures = false; | 377 | useAdvancedFeatures = false; |
373 | 378 | ||
374 | font->insertSeparator(); | 379 | font->insertSeparator(); |
375 | 380 | ||
376 | font->insertItem(tr("About"), this, SLOT( doAbout()) ); | 381 | font->insertItem(tr("About"), this, SLOT( doAbout()) ); |
377 | 382 | ||
378 | mb->insertItem( tr( "File" ), file ); | 383 | mb->insertItem( tr( "File" ), file ); |
379 | mb->insertItem( tr( "Edit" ), edit ); | 384 | mb->insertItem( tr( "Edit" ), edit ); |
380 | mb->insertItem( tr( "View" ), font ); | 385 | mb->insertItem( tr( "View" ), font ); |
381 | 386 | ||
382 | searchBar = new QPEToolBar(this); | 387 | searchBar = new QPEToolBar(this); |
383 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); | 388 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); |
384 | 389 | ||
385 | searchBar->setHorizontalStretchable( TRUE ); | 390 | searchBar->setHorizontalStretchable( TRUE ); |
386 | 391 | ||
387 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 392 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
388 | searchBar->setStretchableWidget( searchEdit ); | 393 | searchBar->setStretchableWidget( searchEdit ); |
389 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 394 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
390 | this, SLOT( search() ) ); | 395 | this, SLOT( search() ) ); |
391 | 396 | ||
392 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); | 397 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); |
393 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); | 398 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); |
394 | a->addTo( searchBar ); | 399 | a->addTo( searchBar ); |
395 | a->addTo( edit ); | 400 | a->addTo( edit ); |
396 | 401 | ||
397 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 402 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
398 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 403 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
399 | a->addTo( searchBar ); | 404 | a->addTo( searchBar ); |
400 | 405 | ||
401 | edit->insertSeparator(); | 406 | edit->insertSeparator(); |
402 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 407 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
403 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); | 408 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); |
404 | a->addTo( edit ); | 409 | a->addTo( edit ); |
405 | 410 | ||