Diffstat (limited to 'noncore/apps/opie-reader/QTReaderApp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/QTReaderApp.cpp | 9188 |
1 files changed, 4966 insertions, 4222 deletions
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp index f18cb59..63d1fb0 100644 --- a/noncore/apps/opie-reader/QTReaderApp.cpp +++ b/noncore/apps/opie-reader/QTReaderApp.cpp | |||
@@ -1,4222 +1,4966 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. Allrights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. Allrights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop 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 | 20 | #include "useqpe.h" | |
21 | #include "useqpe.h" | 21 | #include <qregexp.h> |
22 | #include "QTReader.h" | 22 | #include <qclipboard.h> |
23 | #include "GraphicWin.h" | 23 | #include <qwidgetstack.h> |
24 | #include "Bkmks.h" | 24 | #ifdef USEQPE |
25 | #include "cbkmkselector.h" | 25 | #include <qpe/qpemenubar.h> |
26 | #include "infowin.h" | 26 | #include <qpe/qpetoolbar.h> |
27 | #include "ToolbarPrefs.h" | 27 | #endif |
28 | #include "Prefs.h" | 28 | #include <qmenubar.h> |
29 | #include "CAnnoEdit.h" | 29 | #include <qtoolbar.h> |
30 | #include "QFloatBar.h" | 30 | #ifdef USEQPE |
31 | #include "FixedFont.h" | 31 | #include <qpe/menubutton.h> |
32 | #include "URLDialog.h" | 32 | #endif |
33 | #include "QTReaderApp.h" | 33 | #include <qcombobox.h> |
34 | #include "CDrawBuffer.h" | 34 | #include <qpopupmenu.h> |
35 | #include "Filedata.h" | 35 | #include <qaction.h> |
36 | #include "opie.h" | 36 | #include <qapplication.h> |
37 | #include "names.h" | 37 | #include <qlineedit.h> |
38 | #include "CEncoding_tables.h" | 38 | #include <qtoolbutton.h> |
39 | #include "CloseDialog.h" | 39 | #include <qspinbox.h> |
40 | 40 | #include <qobjectlist.h> | |
41 | /* OPIE */ | 41 | #include <qstatusbar.h> |
42 | #include <opie2/odebug.h> | 42 | #ifdef USEQPE |
43 | #ifdef USEQPE | 43 | #include <qpe/global.h> |
44 | #include <qpe/menubutton.h> | 44 | #include <qpe/applnk.h> |
45 | #include <qpe/fontdatabase.h> | 45 | #endif |
46 | #include <qpe/global.h> | 46 | #include <qfileinfo.h> |
47 | #include <qpe/applnk.h> | 47 | #include <stdlib.h> //getenv |
48 | #include <qpe/config.h> | 48 | #include <qprogressbar.h> |
49 | #include <qpe/qcopenvelope_qws.h> | 49 | #ifdef USEQPE |
50 | #endif | 50 | #include <qpe/config.h> |
51 | 51 | #endif | |
52 | /* QT */ | 52 | #include <qbuttongroup.h> |
53 | #ifdef USEQPE | 53 | #include <qradiobutton.h> |
54 | #include <qmenubar.h> | 54 | #ifdef USEQPE |
55 | #include <qtoolbar.h> | 55 | #include <qpe/qcopenvelope_qws.h> |
56 | #endif | 56 | #endif |
57 | #include <qregexp.h> | 57 | #include "QTReader.h" |
58 | #include <qclipboard.h> | 58 | #include "GraphicWin.h" |
59 | #include <qwidgetstack.h> | 59 | #include "Bkmks.h" |
60 | #include <qmenubar.h> | 60 | #include "cbkmkselector.h" |
61 | #include <qtoolbar.h> | 61 | #include "infowin.h" |
62 | #include <qcombobox.h> | 62 | #include "ToolbarPrefs.h" |
63 | #include <qpopupmenu.h> | 63 | #include "Prefs.h" |
64 | #include <qaction.h> | 64 | #include "CAnnoEdit.h" |
65 | #include <qapplication.h> | 65 | #include "QFloatBar.h" |
66 | #include <qlineedit.h> | 66 | #include "FixedFont.h" |
67 | #include <qtoolbutton.h> | 67 | #include "URLDialog.h" |
68 | #include <qspinbox.h> | 68 | #include "util.h" |
69 | #include <qobjectlist.h> | 69 | #include <qfontdatabase.h> |
70 | #include <qfileinfo.h> | 70 | #include "opie.h" |
71 | #include <qprogressbar.h> | 71 | #ifdef USEQPE |
72 | #include <qbuttongroup.h> | 72 | #include <qpe/resource.h> |
73 | #include <qradiobutton.h> | 73 | #ifdef OPIE |
74 | 74 | //#include <qpe/applnk.h> | |
75 | /* STD */ | 75 | #include <opie2/ofiledialog.h> |
76 | #include <stdlib.h> //getenv | 76 | using namespace Opie::Ui; |
77 | 77 | #else | |
78 | 78 | #include "fileBrowser.h" | |
79 | #ifdef USEQPE | 79 | #endif |
80 | #include <qpe/resource.h> | 80 | #else |
81 | #include <qpe/qpeapplication.h> | 81 | #include "qfiledialog.h" |
82 | #include "fileBrowser.h" | 82 | #endif |
83 | #else | 83 | |
84 | #include "qfiledialog.h" | 84 | #include "QTReaderApp.h" |
85 | #endif | 85 | #include "CDrawBuffer.h" |
86 | 86 | #include "Filedata.h" | |
87 | bool CheckVersion(int&, int&, char&); | 87 | #include "useqpe.h" |
88 | 88 | #include "names.h" | |
89 | #ifdef _WINDOWS | 89 | #include "CEncoding_tables.h" |
90 | #define PICDIR "c:\\uqtreader\\pics\\" | 90 | #include "CloseDialog.h" |
91 | #else | 91 | |
92 | #ifdef USEQPE | 92 | #include "ButtonPrefs.h" |
93 | #define PICDIR "opie-reader/" | 93 | |
94 | #else | 94 | bool CheckVersion(int&, int&, char&); |
95 | #define PICDIR "/home/tim/uqtreader/pics/" | 95 | |
96 | #endif | 96 | #ifdef _WINDOWS |
97 | #endif | 97 | #define PICDIR "c:\\uqtreader\\pics\\" |
98 | 98 | #else | |
99 | unsigned long QTReaderApp::m_uid = 0; | 99 | #ifdef USEQPE |
100 | 100 | #define USEMSGS | |
101 | void QTReaderApp::setScrollState(bool _b) { m_scrollButton->setOn(_b); } | 101 | #define PICDIR "opie-reader/" |
102 | 102 | #else | |
103 | #ifdef USEQPE | 103 | //#define PICDIR "/home/tim/uqtreader/pics/" |
104 | #define geticon(iconname) Resource::loadPixmap( iconname ) | 104 | QString picdir() |
105 | #define getmyicon(iconname) Resource::loadPixmap( PICDIR iconname ) | 105 | { |
106 | #else | 106 | QString hd(getenv("READERDIR")); |
107 | #define geticon(iconname) QPixmap(PICDIR iconname ".png") | 107 | return hd + "/pics"; |
108 | #define getmyicon(iconname) geticon(iconname) | 108 | } |
109 | //#define geticon(iconname) QIconSet( QPixmap(PICDIR iconname) ) | 109 | #define PICDIR picdir() |
110 | #endif | 110 | #endif |
111 | 111 | #endif | |
112 | #ifndef _WINDOWS | 112 | |
113 | #include <unistd.h> | 113 | unsigned long QTReaderApp::m_uid = 0; |
114 | #endif | 114 | |
115 | #include <stddef.h> | 115 | void QTReaderApp::setScrollState(bool _b) { m_scrollButton->setOn(_b); } |
116 | #ifndef _WINDOWS | 116 | |
117 | #include <dirent.h> | 117 | #ifdef USEQPE |
118 | #endif | 118 | #define geticon(iconname) Resource::loadPixmap( iconname ) |
119 | 119 | #define getmyicon(iconname) Resource::loadPixmap( PICDIR iconname ) | |
120 | void QTReaderApp::listBkmkFiles() | 120 | #else |
121 | { | 121 | //#define geticon(iconname) QPixmap(PICDIR iconname ".png") |
122 | bkmkselector->clear(); | 122 | #define geticon(iconname) QPixmap(PICDIR +"/"+iconname+".png") |
123 | bkmkselector->setText("Cancel"); | 123 | #define getmyicon(iconname) geticon(iconname) |
124 | #ifndef USEQPE | 124 | //#define geticon(iconname) QIconSet( QPixmap(PICDIR iconname) ) |
125 | int cnt = 0; | 125 | #endif |
126 | 126 | ||
127 | QDir d = QDir::home(); // "/" | 127 | #ifndef _WINDOWS |
128 | if ( !d.cd(APPDIR) ) { // "/tmp" | 128 | #include <unistd.h> |
129 | owarn << "Cannot find the \"~/" APPDIR "\" directory" << oendl; | 129 | #endif |
130 | d = QDir::home(); | 130 | #include <stddef.h> |
131 | d.mkdir(APPDIR); | 131 | #ifndef _WINDOWS |
132 | d.cd(APPDIR); | 132 | #include <dirent.h> |
133 | } | 133 | #endif |
134 | 134 | ||
135 | 135 | void QTReaderApp::listBkmkFiles() | |
136 | 136 | { | |
137 | 137 | bkmkselector->clear(); | |
138 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | 138 | bkmkselector->setText("Cancel"); |
139 | // d.setSorting( QDir::Size | QDir::Reversed ); | 139 | #ifndef USEQPE |
140 | 140 | int cnt = 0; | |
141 | const QFileInfoList *list = d.entryInfoList(); | 141 | |
142 | QFileInfoListIterator it( *list ); // create list iterator | 142 | QDir d = QDir::home(); // "/" |
143 | QFileInfo *fi; // pointer for traversing | 143 | if ( !d.cd(APPDIR) ) { // "/tmp" |
144 | 144 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | |
145 | while ( (fi=it.current()) ) { // for each file... | 145 | d = QDir::home(); |
146 | 146 | d.mkdir(APPDIR); | |
147 | bkmkselector->insertItem(fi->fileName()); | 147 | d.cd(APPDIR); |
148 | cnt++; | 148 | } |
149 | 149 | ||
150 | //odebug << "" << fi->size() << " " << fi->fileName().data() << "" << oendl; | 150 | |
151 | ++it; // goto next list element | 151 | |
152 | } | 152 | |
153 | 153 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | |
154 | #else /* USEQPE */ | 154 | // d.setSorting( QDir::Size | QDir::Reversed ); |
155 | int cnt = 0; | 155 | |
156 | DIR *d; | 156 | const QFileInfoList *list = d.entryInfoList(); |
157 | d = opendir((const char *)Global::applicationFileName(APPDIR,"")); | 157 | QFileInfoListIterator it( *list ); // create list iterator |
158 | 158 | QFileInfo *fi; // pointer for traversing | |
159 | while(1) | 159 | |
160 | { | 160 | while ( (fi=it.current()) ) { // for each file... |
161 | struct dirent* de; | 161 | |
162 | struct stat buf; | 162 | bkmkselector->insertItem(fi->fileName()); |
163 | de = readdir(d); | 163 | cnt++; |
164 | if (de == NULL) break; | 164 | |
165 | 165 | //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); | |
166 | if (lstat((const char *)Global::applicationFileName(APPDIR,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) | 166 | ++it; // goto next list element |
167 | { | 167 | } |
168 | bkmkselector->insertItem(de->d_name); | 168 | |
169 | cnt++; | 169 | #else /* USEQPE */ |
170 | } | 170 | int cnt = 0; |
171 | } | 171 | DIR *d; |
172 | 172 | d = opendir((const char *)Global::applicationFileName(APPDIR,"")); | |
173 | closedir(d); | 173 | |
174 | #endif | 174 | while(1) |
175 | if (cnt > 0) | 175 | { |
176 | { | 176 | struct dirent* de; |
177 | //tjw menu->hide(); | 177 | struct stat buf; |
178 | editorStack->raiseWidget( bkmkselector ); | 178 | de = readdir(d); |
179 | hidetoolbars(); | 179 | if (de == NULL) break; |
180 | m_nBkmkAction = cRmBkmkFile; | 180 | |
181 | } | 181 | if (lstat((const char *)Global::applicationFileName(APPDIR,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) |
182 | else | 182 | { |
183 | QMessageBox::information(this, PROGNAME, "No bookmark files"); | 183 | bkmkselector->insertItem(de->d_name); |
184 | } | 184 | cnt++; |
185 | 185 | } | |
186 | void QTReaderApp::hidetoolbars() | 186 | } |
187 | { | 187 | |
188 | menubar->hide(); | 188 | closedir(d); |
189 | if (fileBar != NULL) fileBar->hide(); | 189 | #endif |
190 | if (viewBar != NULL) viewBar->hide(); | 190 | if (cnt > 0) |
191 | if (navBar != NULL) navBar->hide(); | 191 | { |
192 | if (markBar != NULL) markBar->hide(); | 192 | //tjw menu->hide(); |
193 | if (m_fontVisible) m_fontBar->hide(); | 193 | |
194 | if (regVisible) | 194 | |
195 | { | 195 | editorStack->raiseWidget( bkmkselector ); |
196 | #ifdef USEQPE | 196 | hidetoolbars(); |
197 | Global::hideInputMethod(); | 197 | m_nBkmkAction = cRmBkmkFile; |
198 | #endif | 198 | } |
199 | regBar->hide(); | 199 | else |
200 | } | 200 | QMessageBox::information(this, PROGNAME, "No bookmark files"); |
201 | if (searchVisible) | 201 | } |
202 | { | 202 | |
203 | #ifdef USEQPE | 203 | void QTReaderApp::hidetoolbars() |
204 | Global::hideInputMethod(); | 204 | { |
205 | #endif | 205 | if (m_scrollbar != NULL) m_scrollbar->hide(); |
206 | searchBar->hide(); | 206 | if (m_prog != NULL) m_prog->hide(); |
207 | } | 207 | |
208 | } | 208 | #ifdef USEQPE |
209 | 209 | menubar->hide(); | |
210 | QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | 210 | #endif |
211 | : QMainWindow( parent, name, f ), bFromDocView( FALSE ), m_dontSave(false), | 211 | |
212 | fileBar(NULL), navBar(NULL), viewBar(NULL), markBar(NULL) | 212 | if (m_scrollbar != NULL) m_scrollbar->hide(); |
213 | { | 213 | |
214 | m_url_clipboard = false; | 214 | if (fileBar != NULL) fileBar->hide(); |
215 | m_url_localfile = false; | 215 | if (viewBar != NULL) viewBar->hide(); |
216 | m_url_globalfile = false; | 216 | if (navBar != NULL) navBar->hide(); |
217 | ftime(&m_lastkeytime); | 217 | if (markBar != NULL) markBar->hide(); |
218 | //// odebug << "Application directory = " << (const tchar *)QPEApplication::documentDir() << "" << oendl; | 218 | if (m_fontVisible) m_fontBar->hide(); |
219 | //// odebug << "Application directory = " << (const tchar *)Global::applicationFileName("uqtreader" << "" << oendl; | 219 | if (regVisible) |
220 | 220 | { | |
221 | m_bcloseDisabled = true; | 221 | #ifdef USEQPE |
222 | m_disableesckey = false; | 222 | Global::hideInputMethod(); |
223 | pBkmklist = NULL; | 223 | #endif |
224 | pOpenlist = NULL; | 224 | regBar->hide(); |
225 | // doc = 0; | 225 | } |
226 | 226 | if (searchVisible) | |
227 | m_fBkmksChanged = false; | 227 | { |
228 | 228 | #ifdef USEQPE | |
229 | QString lang = getenv( "LANG" ); | 229 | Global::hideInputMethod(); |
230 | QString rot = getenv( "QWS_DISPLAY" ); | 230 | #endif |
231 | 231 | searchBar->hide(); | |
232 | /* | 232 | } |
233 | int m_rot = 0; | 233 | } |
234 | if (rot.contains("Rot90")) | 234 | |
235 | { | 235 | QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) |
236 | m_rot = 90; | 236 | : QMainWindow( parent, name, f ), m_dontSave(false), |
237 | } | 237 | fileBar(NULL), navBar(NULL), viewBar(NULL), markBar(NULL), m_scrollbar(NULL), m_localscroll(2), m_hidebars(false), m_kmapchanged(false) |
238 | else if (rot.contains("Rot180")) | 238 | { |
239 | { | 239 | { |
240 | m_rot = 180; | 240 | setKeyCompression ( true ); |
241 | } | 241 | #ifndef USEQPE |
242 | else if (rot.contains("Rot270")) | 242 | QDir d = QDir::home(); // "/" |
243 | { | 243 | d.cd(APPDIR); |
244 | m_rot = 270; | 244 | QFileInfo fi(d, ".keymap"); |
245 | } | 245 | FILE* f = fopen((const char *)fi.absFilePath(), "r"); |
246 | 246 | #else /* USEQPE */ | |
247 | // odebug << "Initial Rotation(" << m_rot << "):" << rot << "" << oendl; | 247 | FILE* f = fopen((const char *)Global::applicationFileName(APPDIR,".keymap"), "r"); |
248 | */ | 248 | #endif /* USEQPE */ |
249 | m_autogenstr = "^ *[A-Z].*[a-z] *$"; | 249 | if (f != NULL) |
250 | 250 | { | |
251 | #ifdef USEQPE | 251 | uint cnt; |
252 | setIcon( Resource::loadPixmap( PICDIR "uqtreader") ); | 252 | if ((fread(&cnt, sizeof(cnt), 1, f) != 0) && (cnt == KEYMAPVERSION)) |
253 | #else | 253 | { |
254 | setIcon( QPixmap (PICDIR "uqtreader.png") ); | 254 | if (fread(&cnt, sizeof(cnt), 1, f) == 0) cnt = 0; |
255 | #endif /* USEQPE */ | 255 | for (uint i = 0; i != cnt; i++) |
256 | 256 | { | |
257 | // QToolBar *bar = new QToolBar( this ); | 257 | orKey key; |
258 | // menubar = new QToolBar( this ); | 258 | int data; |
259 | #ifdef USEQPE | 259 | fread(&key, sizeof(key), 1, f); |
260 | Config config( APPDIR ); | 260 | fread(&data, sizeof(data), 1, f); |
261 | #else | 261 | kmap[key] = data; |
262 | QDir d = QDir::home(); // "/" | 262 | } |
263 | if ( !d.cd(APPDIR) ) { // "/tmp" | 263 | } |
264 | owarn << "Cannot find the \"~/" APPDIR "\" directory" << oendl; | 264 | fclose(f); |
265 | d = QDir::home(); | 265 | } |
266 | d.mkdir(APPDIR); | 266 | } |
267 | d.cd(APPDIR); | 267 | |
268 | } | 268 | m_url_clipboard = false; |
269 | QFileInfo fi(d, INIFILE); | 269 | m_url_localfile = false; |
270 | // odebug << "Path:" << fi.absFilePath() << "" << oendl; | 270 | m_url_globalfile = false; |
271 | Config config(fi.absFilePath()); | 271 | ftime(&m_lastkeytime); |
272 | #endif | 272 | //// qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir()); |
273 | config.setGroup("Toolbar"); | 273 | //// qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml")); |
274 | m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false); | 274 | |
275 | m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1); | 275 | m_bcloseDisabled = true; |
276 | m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2); | 276 | m_disableesckey = false; |
277 | menubar = new QToolBar("Menus", this, m_tbposition); | 277 | pBkmklist = NULL; |
278 | 278 | pOpenlist = NULL; | |
279 | // fileBar = new QToolBar("File", this); | 279 | // doc = 0; |
280 | // QToolBar* viewBar = new QToolBar("File", this); | 280 | |
281 | // QToolBar* navBar = new QToolBar("File", this); | 281 | m_fBkmksChanged = false; |
282 | // QToolBar* markBar = new QToolBar("File", this); | 282 | |
283 | 283 | QString lang = getenv( "LANG" ); | |
284 | #ifdef USEQPE | 284 | QString rot = getenv( "QWS_DISPLAY" ); |
285 | mb = new QMenuBar( menubar ); | 285 | |
286 | #else | 286 | /* |
287 | mb = new QMenuBar( menubar ); | 287 | int m_rot = 0; |
288 | #endif | 288 | if (rot.contains("Rot90")) |
289 | 289 | { | |
290 | //#ifdef USEQPE | 290 | m_rot = 90; |
291 | QPopupMenu* tmp = new QPopupMenu(mb); | 291 | } |
292 | mb->insertItem( geticon( "AppsIcon" ), tmp ); | 292 | else if (rot.contains("Rot180")) |
293 | //#else | 293 | { |
294 | // QMenuBar* tmp = mb; | 294 | m_rot = 180; |
295 | //#endif | 295 | } |
296 | 296 | else if (rot.contains("Rot270")) | |
297 | QPopupMenu *file = new QPopupMenu( mb ); | 297 | { |
298 | tmp->insertItem( tr( "File" ), file ); | 298 | m_rot = 270; |
299 | 299 | } | |
300 | QPopupMenu *navigation = new QPopupMenu(mb); | 300 | |
301 | tmp->insertItem( tr( "Navigation" ), navigation ); | 301 | // qDebug("Initial Rotation(%d):%s", m_rot, (const char*)rot); |
302 | 302 | */ | |
303 | QPopupMenu *view = new QPopupMenu( mb ); | 303 | m_autogenstr = "^ *[A-Z].*[a-z] *$"; |
304 | tmp->insertItem( tr( "View" ), view ); | 304 | |
305 | 305 | #ifdef USEQPE | |
306 | QPopupMenu *marks = new QPopupMenu( this ); | 306 | setIcon( Resource::loadPixmap( PICDIR "uqtreader") ); |
307 | tmp->insertItem( tr( "Marks" ), marks ); | 307 | #else |
308 | 308 | setIcon( QPixmap (PICDIR + "/uqtreader.png") ); | |
309 | QPopupMenu *settings = new QPopupMenu( this ); | 309 | #endif /* USEQPE */ |
310 | tmp->insertItem( tr( "Settings" ), settings ); | 310 | |
311 | 311 | // QPEToolBar *bar = new QPEToolBar( this ); | |
312 | // addToolBar(menubar, "Menus",QMainWindow::Top); | 312 | // menubar = new QPEToolBar( this ); |
313 | // addToolBar(fileBar, "Toolbar",QMainWindow::Top); | 313 | #ifdef USEQPE |
314 | 314 | Config config( APPDIR ); | |
315 | // QPopupMenu *edit = new QPopupMenu( this ); | 315 | #else |
316 | 316 | QDir d = QDir::home(); // "/" | |
317 | /* | 317 | if ( !d.cd(APPDIR) ) { // "/tmp" |
318 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); | 318 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); |
319 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 319 | d = QDir::home(); |
320 | a->addTo( bar ); | 320 | d.mkdir(APPDIR); |
321 | a->addTo( file ); | 321 | d.cd(APPDIR); |
322 | */ | 322 | } |
323 | 323 | QFileInfo fi(d, INIFILE); | |
324 | editorStack = new QWidgetStack( this ); | 324 | // qDebug("Path:%s", (const char*)fi.absFilePath()); |
325 | setCentralWidget( editorStack ); | 325 | Config config(fi.absFilePath()); |
326 | 326 | #endif | |
327 | searchVisible = FALSE; | 327 | config.setGroup("Toolbar"); |
328 | regVisible = FALSE; | 328 | m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false); |
329 | m_fontVisible = false; | 329 | m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1); |
330 | 330 | m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2); | |
331 | m_annoWin = new CAnnoEdit(editorStack); | 331 | m_qtscroll = config.readNumEntry("QTScrollBar", false); |
332 | editorStack->addWidget(m_annoWin, get_unique_id()); | 332 | m_localscroll = config.readNumEntry("LocalScrollBar", false); |
333 | connect( m_annoWin, SIGNAL( finished(const QString&,const QString&) ), this, SLOT( addAnno(const QString&,const QString&) ) ); | 333 | |
334 | connect( m_annoWin, SIGNAL( cancelled() ), this, SLOT( infoClose() ) ); | 334 | // fileBar = new QToolBar("File", this); |
335 | 335 | // QToolBar* viewBar = new QToolBar("File", this); | |
336 | m_infoWin = new infowin(editorStack); | 336 | // QToolBar* navBar = new QToolBar("File", this); |
337 | editorStack->addWidget(m_infoWin, get_unique_id()); | 337 | // QToolBar* markBar = new QToolBar("File", this); |
338 | connect( m_infoWin, SIGNAL( Close() ), this, SLOT( infoClose() ) ); | 338 | |
339 | 339 | #ifdef USEQPE | |
340 | m_graphicwin = new GraphicWin(editorStack); | 340 | menubar = new QToolBar("Menus", this, m_tbposition); |
341 | editorStack->addWidget(m_graphicwin, get_unique_id()); | 341 | mb = new QPEMenuBar( menubar ); |
342 | connect( m_graphicwin, SIGNAL( Closed() ), this, SLOT( infoClose() ) ); | 342 | #else |
343 | 343 | mb = new QMenuBar( this ); | |
344 | // bkmkselector = new QListBox(editorStack, "Bookmarks"); | 344 | #endif |
345 | bkmkselector = new CBkmkSelector(editorStack, "Bookmarks"); | 345 | |
346 | // connect(bkmkselector, SIGNAL( selected(const QString&) ), this, SLOT( gotobkmk(const QString&) ) ); | 346 | #ifdef USEQPE |
347 | connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( gotobkmk(int) ) ); | 347 | QPopupMenu* tmp = new QPopupMenu(mb); |
348 | connect(bkmkselector, SIGNAL( cancelled() ), this, SLOT( cancelbkmk() ) ); | 348 | mb->insertItem( geticon( "AppsIcon" ), tmp ); |
349 | editorStack->addWidget( bkmkselector, get_unique_id() ); | 349 | #else |
350 | 350 | QMenuBar* tmp = mb; | |
351 | /* | 351 | #endif |
352 | importSelector = new FileSelector( "*", editorStack, "importselector", false ); | 352 | |
353 | connect( importSelector, SIGNAL( fileSelected(const DocLnk&) ), this, SLOT( importFile(const DocLnk&) ) ); | 353 | QPopupMenu *file = new QPopupMenu( mb ); |
354 | 354 | tmp->insertItem( tr( "File" ), file ); | |
355 | editorStack->addWidget( importSelector, get_unique_id() ); | 355 | |
356 | 356 | QPopupMenu *navigation = new QPopupMenu(mb); | |
357 | // don't need the close visible, it is redundant... | 357 | tmp->insertItem( tr( "Navigation" ), navigation ); |
358 | importSelector->setCloseVisible( FALSE ); | 358 | |
359 | */ | 359 | QPopupMenu *view = new QPopupMenu( mb ); |
360 | // odebug << "Reading file list" << oendl; | 360 | tmp->insertItem( tr( "View" ), view ); |
361 | readfilelist(); | 361 | |
362 | 362 | QPopupMenu *marks = new QPopupMenu( this ); | |
363 | reader = new QTReader( editorStack ); | 363 | tmp->insertItem( tr( "Marks" ), marks ); |
364 | 364 | ||
365 | reader->bDoUpdates = false; | 365 | QPopupMenu *settings = new QPopupMenu( this ); |
366 | 366 | tmp->insertItem( tr( "Settings" ), settings ); | |
367 | #ifdef USEQPE | 367 | |
368 | ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold); | 368 | // addToolBar(menubar, "Menus",QMainWindow::Top); |
369 | #endif | 369 | // addToolBar(fileBar, "Toolbar",QMainWindow::Top); |
370 | 370 | ||
371 | // odebug << "Reading config" << oendl; | 371 | // QPopupMenu *edit = new QPopupMenu( this ); |
372 | // Config config( APPDIR ); | 372 | |
373 | config.setGroup( "View" ); | 373 | /* |
374 | m_debounce = config.readNumEntry("Debounce", 0); | 374 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
375 | #ifdef USEQPE | 375 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
376 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false); | 376 | a->addTo( bar ); |
377 | #else | 377 | a->addTo( file ); |
378 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", true); | 378 | */ |
379 | #endif | 379 | QWidget* widge = new QWidget(this); |
380 | reader->bstripcr = config.readBoolEntry( "StripCr", true ); | 380 | setCentralWidget( widge ); |
381 | reader->bfulljust = config.readBoolEntry( "FullJust", false ); | 381 | QVBoxLayout* vlayout = new QVBoxLayout(widge); |
382 | reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 )); | 382 | m_layout = new QBoxLayout(QBoxLayout::LeftToRight); |
383 | reader->setlead(config.readNumEntry( "ExtraLead", 0 )); | 383 | m_prog = new QLabel(widge); |
384 | reader->btextfmt = config.readBoolEntry( "TextFmt", false ); | 384 | vlayout->addLayout(m_layout, 1); |
385 | reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); | 385 | vlayout->addWidget(m_prog); |
386 | reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); | 386 | |
387 | reader->bpeanut = config.readBoolEntry( "Peanut", false ); | 387 | editorStack = new QWidgetStack( widge ); |
388 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); | 388 | // setCentralWidget( editorStack ); |
389 | reader->bdepluck = config.readBoolEntry( "Depluck", false ); | 389 | |
390 | reader->bdejpluck = config.readBoolEntry( "Dejpluck", false ); | 390 | searchVisible = FALSE; |
391 | reader->bonespace = config.readBoolEntry( "OneSpace", false ); | 391 | regVisible = FALSE; |
392 | reader->bunindent = config.readBoolEntry( "Unindent", false ); | 392 | m_fontVisible = false; |
393 | reader->brepara = config.readBoolEntry( "Repara", false ); | 393 | |
394 | reader->bdblspce = config.readBoolEntry( "DoubleSpace", false ); | 394 | m_buttonprefs = new CButtonPrefs(&kmap, this); |
395 | reader->bindenter = config.readNumEntry( "Indent", 0 ); | 395 | editorStack->addWidget(m_buttonprefs, get_unique_id()); |
396 | reader->m_textsize = config.readNumEntry( "FontSize", 12 ); | 396 | connect( m_buttonprefs, SIGNAL( Closed() ), this, SLOT( infoClose() ) ); |
397 | reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); | 397 | |
398 | reader->m_lastfile = config.readEntry( "LastFile", QString::null ); | 398 | |
399 | reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); | 399 | m_annoWin = new CAnnoEdit(editorStack); |
400 | reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); | 400 | editorStack->addWidget(m_annoWin, get_unique_id()); |
401 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); | 401 | connect( m_annoWin, SIGNAL( finished(const QString&, const QString&) ), this, SLOT( addAnno(const QString&, const QString&) ) ); |
402 | reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false); | 402 | connect( m_annoWin, SIGNAL( cancelled() ), this, SLOT( infoClose() ) ); |
403 | reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); | 403 | |
404 | reader->m_encd = config.readNumEntry( "Encoding", 0 ); | 404 | m_infoWin = new infowin(editorStack); |
405 | reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); | 405 | editorStack->addWidget(m_infoWin, get_unique_id()); |
406 | reader->m_overlap = config.readNumEntry( "Overlap", 0 ); | 406 | connect( m_infoWin, SIGNAL( Close() ), this, SLOT( infoClose() ) ); |
407 | reader->m_border = config.readNumEntry( "Margin", 6 ); | 407 | |
408 | #ifdef REPALM | 408 | m_graphicwin = new GraphicWin(editorStack); |
409 | reader->brepalm = config.readBoolEntry( "Repalm", true ); | 409 | editorStack->addWidget(m_graphicwin, get_unique_id()); |
410 | #endif | 410 | connect( m_graphicwin, SIGNAL( Closed() ), this, SLOT( infoClose() ) ); |
411 | reader->bremap = config.readBoolEntry( "Remap", true ); | 411 | |
412 | reader->bmakebold = config.readBoolEntry( "MakeBold", false ); | 412 | // bkmkselector = new QListBox(editorStack, "Bookmarks"); |
413 | reader->setContinuous(config.readBoolEntry( "Continuous", true )); | 413 | bkmkselector = new CBkmkSelector(editorStack, "Bookmarks"); |
414 | m_targetapp = config.readEntry( "TargetApp", QString::null ); | 414 | // connect(bkmkselector, SIGNAL( selected(const QString&) ), this, SLOT( gotobkmk(const QString&) ) ); |
415 | m_targetmsg = config.readEntry( "TargetMsg", QString::null ); | 415 | connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( gotobkmk(int) ) ); |
416 | #ifdef _SCROLLPIPE | 416 | connect(bkmkselector, SIGNAL( cancelled() ), this, SLOT( cancelbkmk() ) ); |
417 | reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null ); | 417 | editorStack->addWidget( bkmkselector, get_unique_id() ); |
418 | reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true ); | 418 | |
419 | #endif | 419 | /* |
420 | m_twoTouch = config.readBoolEntry( "TwoTouch", false); | 420 | importSelector = new FileSelector( "*", editorStack, "importselector", false ); |
421 | m_doAnnotation = config.readBoolEntry( "Annotation", false); | 421 | connect( importSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( importFile( const DocLnk & ) ) ); |
422 | m_doDictionary = config.readBoolEntry( "Dictionary", false); | 422 | |
423 | m_doClipboard = config.readBoolEntry( "Clipboard", false); | 423 | editorStack->addWidget( importSelector, get_unique_id() ); |
424 | m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll); | 424 | |
425 | m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone); | 425 | // don't need the close visible, it is redundant... |
426 | m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen); | 426 | importSelector->setCloseVisible( FALSE ); |
427 | m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut); | 427 | */ |
428 | m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn); | 428 | // qDebug("Reading file list"); |
429 | m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp); | 429 | readfilelist(); |
430 | m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown); | 430 | |
431 | 431 | reader = new QTReader( editorStack ); | |
432 | m_leftScroll = config.readBoolEntry("LeftScroll", false); | 432 | |
433 | m_rightScroll = config.readBoolEntry("RightScroll", false); | 433 | reader->setDoUpdates(false); |
434 | m_upScroll = config.readBoolEntry("UpScroll", true); | 434 | |
435 | m_downScroll = config.readBoolEntry("DownScroll", true); | 435 | #ifdef USEQPE |
436 | 436 | ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold); | |
437 | m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false); | 437 | #endif |
438 | reader->setBaseSize(config.readNumEntry( "Basesize", 10 )); | 438 | |
439 | 439 | // qDebug("Reading config"); | |
440 | #ifndef USEQPE | 440 | // Config config( APPDIR ); |
441 | config.setGroup( "Geometry" ); | 441 | config.setGroup( "View" ); |
442 | setGeometry(0,0, | 442 | m_debounce = config.readNumEntry("Debounce", 0); |
443 | config.readNumEntry( "width", QApplication::desktop()->width()/2 ), | 443 | m_buttonprefs->Debounce(m_debounce); |
444 | config.readNumEntry( "height", QApplication::desktop()->height()/2 )); | 444 | #ifdef USEQPE |
445 | move( | 445 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false); |
446 | config.readNumEntry( "x", 20 ), | 446 | #else |
447 | config.readNumEntry( "y", 20 )); | 447 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", true); |
448 | #endif | 448 | #endif |
449 | 449 | reader->setStripCR(config.readBoolEntry( "StripCr", true )); | |
450 | 450 | reader->bfulljust = config.readBoolEntry( "FullJust", false ); | |
451 | 451 | /* | |
452 | setTwoTouch(m_twoTouch); | 452 | bool btmp = config.readBoolEntry("Negative", false); |
453 | 453 | if (btmp) reader->setNegative(); | |
454 | connect( reader, SIGNAL( OnShowPicture(QImage&) ), this, SLOT( showgraphic(QImage&) ) ); | 454 | */ |
455 | 455 | reader->bInverse = config.readBoolEntry("Inverse", false); | |
456 | connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) ); | 456 | reader->m_fontControl.FixGraphics(config.readBoolEntry( "FixGraphics", false )); |
457 | connect( reader, SIGNAL( OnWordSelected(const QString&,size_t,const QString&) ), this, SLOT( OnWordSelected(const QString&,size_t,const QString&) ) ); | 457 | reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 )); |
458 | connect( reader, SIGNAL( OnURLSelected(const QString&) ), this, SLOT( OnURLSelected(const QString&) ) ); | 458 | reader->setlead(config.readNumEntry( "ExtraLead", 0 )); |
459 | editorStack->addWidget( reader, get_unique_id() ); | 459 | reader->btextfmt = config.readBoolEntry( "TextFmt", false ); |
460 | 460 | reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); | |
461 | m_preferences_action = new QAction( tr( "Configuration" ), geticon( "SettingsIcon" ), QString::null, 0, this, NULL); | 461 | reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); |
462 | connect( m_preferences_action, SIGNAL( activated() ), this, SLOT( showprefs() ) ); | 462 | reader->bpeanut = config.readBoolEntry( "Peanut", false ); |
463 | m_preferences_action->addTo( settings ); | 463 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); |
464 | 464 | reader->bdepluck = config.readBoolEntry( "Depluck", false ); | |
465 | m_saveconfig_action = new QAction( tr( "Save Config" ), QString::null, 0, this, NULL); | 465 | reader->bdejpluck = config.readBoolEntry( "Dejpluck", false ); |
466 | connect( m_saveconfig_action, SIGNAL( activated() ), this, SLOT( SaveConfig() ) ); | 466 | reader->bonespace = config.readBoolEntry( "OneSpace", false ); |
467 | m_saveconfig_action->addTo( settings ); | 467 | reader->bunindent = config.readBoolEntry( "Unindent", false ); |
468 | 468 | reader->brepara = config.readBoolEntry( "Repara", false ); | |
469 | m_loadconfig_action = new QAction( tr( "Load Config" ), QString::null, 0, this, NULL); | 469 | reader->m_reparastring = config.readEntry( "ReparaString", "\\n{[\\n \\t]}"); |
470 | connect( m_loadconfig_action, SIGNAL( activated() ), this, SLOT( LoadConfig() ) ); | 470 | m_bgtype = (bground)config.readNumEntry( "BackgroundType" , 0 ); |
471 | m_loadconfig_action->addTo( settings ); | 471 | m_themename = config.readEntry("Theme", QString::null ); |
472 | 472 | reader->bdblspce = config.readBoolEntry( "DoubleSpace", false ); | |
473 | m_tidyconfig_action = new QAction( tr( "Delete Config" ), QString::null, 0, this, NULL); | 473 | reader->bindenter = config.readNumEntry( "Indent", 0 ); |
474 | connect( m_tidyconfig_action, SIGNAL( activated() ), this, SLOT( TidyConfig() ) ); | 474 | reader->m_textsize = config.readNumEntry( "FontSize", 12 ); |
475 | m_tidyconfig_action->addTo( settings ); | 475 | reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); |
476 | 476 | reader->m_scrollstep = config.readNumEntry( "ScrollStep", 1); | |
477 | settings->insertSeparator(); | 477 | |
478 | m_toolbarprefs_action = new QAction( tr( "Toolbars" ), QString::null, 0, this, NULL); | 478 | reader->m_lastfile = config.readEntry( "LastFile", QString::null ); |
479 | connect( m_toolbarprefs_action, SIGNAL( activated() ), this, SLOT( showtoolbarprefs() ) ); | 479 | reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); |
480 | m_toolbarprefs_action->addTo( settings ); | 480 | reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); |
481 | 481 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); | |
482 | m_open_action = new QAction( tr( "Open" ), geticon( "fileopen" ), QString::null, 0, this, 0 ); | 482 | reader->m_rotated = config.readBoolEntry( "IsRotated", false ); |
483 | connect( m_open_action, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); | 483 | reader->m_scrolltype = config.readNumEntry( "ScrollType", 0 ); |
484 | m_open_action->addTo( file ); | 484 | m_statusstring = config.readEntry("StatusContent", "%P%% Doc:%d/%D %p%% %z%%"); |
485 | 485 | m_statusishidden = config.readBoolEntry("StatusHidden", false); | |
486 | m_close_action = new QAction( tr( "Close" ), geticon( "close" ), QString::null, 0, this, 0 ); | 486 | m_background = config.readNumEntry( "Background", 0 ); |
487 | connect( m_close_action, SIGNAL( activated() ), this, SLOT( fileClose() ) ); | 487 | reader->setBackground(getcolour(m_background)); |
488 | m_close_action->addTo( file ); | 488 | m_foreground = config.readNumEntry( "Foreground", 1 ); |
489 | 489 | reader->setForeground(getcolour(m_foreground)); | |
490 | #ifdef _SCRIPT | 490 | m_scrollcolor = config.readNumEntry( "ScrollColour", 5 ); |
491 | a = new QAction( tr( "Run Script" ), QString::null, 0, this, NULL); | 491 | setscrollcolour(); |
492 | connect( a, SIGNAL( activated() ), this, SLOT( RunScript() ) ); | 492 | m_scrollbarcolor = config.readNumEntry( "ScrollBarColour", 5 ); |
493 | a->addTo( file ); | 493 | setscrollbarcolour(); |
494 | #endif | 494 | reader->hyphenate = config.readBoolEntry( "Hyphenate", false ); |
495 | /* | 495 | reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false); |
496 | a = new QAction( tr( "Revert" ), geticon( "close" ), QString::null, 0, this, 0 ); | 496 | reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); |
497 | connect( a, SIGNAL( activated() ), this, SLOT( fileRevert() ) ); | 497 | reader->m_encd = config.readNumEntry( "Encoding", 0 ); |
498 | a->addTo( file ); | 498 | reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); |
499 | 499 | reader->m_overlap = config.readNumEntry( "Overlap", 0 ); | |
500 | a = new QAction( tr( "Cut" ), geticon( "cut" ), QString::null, 0, this, 0 ); | 500 | reader->m_abstopmargin = config.readNumEntry( "Top Margin", 100 ); |
501 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); | 501 | reader->m_absbottommargin = config.readNumEntry( "Bottom Margin", 100 ); |
502 | a->addTo( filebar() ); | 502 | reader->m_absleft_border = config.readNumEntry( "Left Margin", 100 ); |
503 | a->addTo( edit ); | 503 | reader->m_absright_border = config.readNumEntry( "Right Margin", 100 ); |
504 | */ | 504 | |
505 | 505 | m_scrollishidden = config.readBoolEntry( "HideScrollBar", false ); | |
506 | m_info_action = new QAction( tr( "Info" ), geticon( "UtilsIcon" ), QString::null, 0, this, NULL); | 506 | |
507 | connect( m_info_action, SIGNAL( activated() ), this, SLOT( showinfo() ) ); | 507 | reader->brepalm = config.readBoolEntry( "Repalm", false ); |
508 | m_info_action->addTo( file ); | 508 | reader->bkern = config.readBoolEntry( "Kern", false ); |
509 | 509 | reader->bremap = config.readBoolEntry( "Remap", true ); | |
510 | m_touch_action = new QAction( tr( "Two/One Touch" ), geticon( "1to1" ), QString::null, 0, this, NULL, true ); | 510 | reader->bmakebold = config.readBoolEntry( "MakeBold", false ); |
511 | connect( m_touch_action, SIGNAL( toggled(bool) ), this, SLOT( setTwoTouch(bool) ) ); | 511 | reader->setContinuous(config.readBoolEntry( "Continuous", true )); |
512 | m_touch_action->setOn(m_twoTouch); | 512 | m_targetapp = config.readEntry( "TargetApp", QString::null ); |
513 | m_touch_action->addTo( file ); | 513 | m_targetmsg = config.readEntry( "TargetMsg", QString::null ); |
514 | 514 | #ifdef _SCROLLPIPE | |
515 | m_find_action = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, NULL); | 515 | reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null ); |
516 | connect( m_find_action, SIGNAL( activated() ), this, SLOT( editFind() ) ); | 516 | reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true ); |
517 | file->insertSeparator(); | 517 | #endif |
518 | // a->addTo( bar ); | 518 | m_twoTouch = config.readBoolEntry( "TwoTouch", false); |
519 | m_find_action->addTo( file ); | 519 | m_doAnnotation = config.readBoolEntry( "Annotation", false); |
520 | 520 | m_doDictionary = config.readBoolEntry( "Dictionary", false); | |
521 | m_exportlinks_action = new QAction( tr( "Export Links" ), QString::null, 0, this, NULL); | 521 | m_doClipboard = config.readBoolEntry( "Clipboard", false); |
522 | connect( m_exportlinks_action, SIGNAL( activated() ), this, SLOT( ExportLinks() ) ); | 522 | /* |
523 | m_exportlinks_action->addTo( file ); | 523 | m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll); |
524 | 524 | m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone); | |
525 | m_scrollButton = new QAction( tr( "Scroll" ), getmyicon( "panel-arrow-down" ), QString::null, 0, this, 0, true ); | 525 | m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen); |
526 | connect( m_scrollButton, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) ); | 526 | m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut); |
527 | m_scrollButton->addTo(navigation); | 527 | m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn); |
528 | m_scrollButton->setOn(false); | 528 | m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp); |
529 | 529 | m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown); | |
530 | m_start_action = new QAction( tr( "Goto Start" ), geticon( "start" ), QString::null, 0, this, NULL); | 530 | |
531 | connect( m_start_action, SIGNAL( activated() ), this, SLOT( gotoStart() ) ); | 531 | m_leftScroll = config.readBoolEntry("LeftScroll", false); |
532 | m_start_action->addTo(navigation); | 532 | m_rightScroll = config.readBoolEntry("RightScroll", false); |
533 | 533 | m_upScroll = config.readBoolEntry("UpScroll", true); | |
534 | m_end_action = new QAction( tr( "Goto End" ), geticon( "finish" ), QString::null, 0, this, NULL); | 534 | m_downScroll = config.readBoolEntry("DownScroll", true); |
535 | connect( m_end_action, SIGNAL( activated() ), this, SLOT( gotoEnd() ) ); | 535 | */ |
536 | m_end_action->addTo(navigation); | 536 | m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false); |
537 | 537 | reader->setBaseSize(config.readNumEntry( "Basesize", 10 )); | |
538 | m_jump_action = new QAction( tr( "Jump" ), geticon( "rotate" ), QString::null, 0, this, NULL); | 538 | reader->setHyphenThreshold(config.readNumEntry( "HyphenThreshold", 50 )); |
539 | connect( m_jump_action, SIGNAL( activated() ), this, SLOT( jump() ) ); | 539 | // reader->buffdoc.setCustomHyphen(config.readBoolEntry( "CustomHyphen", false )); |
540 | m_jump_action->addTo(navigation); | 540 | #ifndef USEQPE |
541 | 541 | config.setGroup( "Geometry" ); | |
542 | m_pageline_action = new QAction( tr( "Page/Line Scroll" ), geticon( "pass" ), QString::null, 0, this, NULL, true ); | 542 | setGeometry(0,0, |
543 | connect( m_pageline_action, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) ); | 543 | config.readNumEntry( "width", QApplication::desktop()->width()/2 ), |
544 | m_pageline_action->addTo(navigation); | 544 | config.readNumEntry( "height", QApplication::desktop()->height()/2 )); |
545 | m_pageline_action->setOn(reader->m_bpagemode); | 545 | move( |
546 | 546 | config.readNumEntry( "x", 20 ), | |
547 | m_pageup_action = new QAction( tr( "Up" ), geticon( "up" ), QString::null, 0, this, 0 ); | 547 | config.readNumEntry( "y", 20 )); |
548 | connect( m_pageup_action, SIGNAL( activated() ), this, SLOT( pageup() ) ); | 548 | #else |
549 | m_pageup_action->addTo( navigation ); | 549 | m_grabkeyboard = config.readBoolEntry( "GrabKeyboard", false); |
550 | 550 | #endif | |
551 | m_pagedn_action = new QAction( tr( "Down" ), geticon( "down" ), QString::null, 0, this, 0 ); | 551 | |
552 | connect( m_pagedn_action, SIGNAL( activated() ), this, SLOT( pagedn() ) ); | 552 | |
553 | m_pagedn_action->addTo( navigation ); | 553 | |
554 | 554 | setTwoTouch(m_twoTouch); | |
555 | m_back_action = new QAction( tr( "Back" ), geticon( "back" ), QString::null, 0, this, 0 ); | 555 | |
556 | connect( m_back_action, SIGNAL( activated() ), reader, SLOT( goBack() ) ); | 556 | connect( reader, SIGNAL( OnShowPicture(QImage&) ), this, SLOT( showgraphic(QImage&) ) ); |
557 | m_back_action->addTo( navigation ); | 557 | |
558 | 558 | connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) ); | |
559 | m_home_action = new QAction( tr( "Home" ), geticon( "home" ), QString::null, 0, this, 0 ); | 559 | connect( reader, SIGNAL( OnWordSelected(const QString&, size_t, size_t, const QString&) ), this, SLOT( OnWordSelected(const QString&, size_t, size_t, const QString&) ) ); |
560 | connect( m_home_action, SIGNAL( activated() ), reader, SLOT( goHome() ) ); | 560 | connect( reader, SIGNAL( OnURLSelected(const QString&, const size_t) ), this, SLOT( OnURLSelected(const QString&, const size_t) ) ); |
561 | m_home_action->addTo( navigation ); | 561 | connect( reader, SIGNAL( NewFileRequest(const QString&) ), this, SLOT( forceopen(const QString&) ) ); |
562 | 562 | connect( reader, SIGNAL( HandleKeyRequest(QKeyEvent*) ), this, SLOT( handlekey(QKeyEvent*) ) ); | |
563 | m_forward_action = new QAction( tr( "Forward" ), geticon( "forward" ), QString::null, 0, this, 0 ); | 563 | connect( reader, SIGNAL( SetScrollState(bool) ), this, SLOT( setScrollState(bool) ) ); |
564 | connect( m_forward_action, SIGNAL( activated() ), reader, SLOT( goForward() ) ); | 564 | connect( reader, SIGNAL(RefreshBitmap()), this, SLOT(setBackgroundBitmap())); |
565 | m_forward_action->addTo( navigation ); | 565 | editorStack->addWidget( reader, get_unique_id() ); |
566 | 566 | ||
567 | /* | 567 | m_preferences_action = new QAction( tr( "Configuration" ), geticon( "SettingsIcon" ), QString::null, 0, this, NULL); |
568 | a = new QAction( tr( "Find" ), QString::null, 0, this, NULL, true ); | 568 | connect( m_preferences_action, SIGNAL( activated() ), this, SLOT( showprefs() ) ); |
569 | // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); | 569 | m_preferences_action->addTo( settings ); |
570 | a->addTo( file ); | 570 | |
571 | 571 | m_saveconfig_action = new QAction( tr( "Save Config" ), QString::null, 0, this, NULL); | |
572 | a = new QAction( tr( "Find Again" ), QString::null, 0, this, NULL, true ); | 572 | connect( m_saveconfig_action, SIGNAL( activated() ), this, SLOT( SaveConfig() ) ); |
573 | // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); | 573 | m_saveconfig_action->addTo( settings ); |
574 | a->addTo( file ); | 574 | |
575 | */ | 575 | m_loadconfig_action = new QAction( tr( "Load Config" ), QString::null, 0, this, NULL); |
576 | 576 | connect( m_loadconfig_action, SIGNAL( activated() ), this, SLOT( LoadConfig() ) ); | |
577 | // file->insertSeparator(); | 577 | m_loadconfig_action->addTo( settings ); |
578 | 578 | ||
579 | #ifdef _SCROLLPIPE | 579 | m_tidyconfig_action = new QAction( tr( "Delete Config" ), QString::null, 0, this, NULL); |
580 | 580 | connect( m_tidyconfig_action, SIGNAL( activated() ), this, SLOT( TidyConfig() ) ); | |
581 | QActionGroup* ag = new QActionGroup(this); | 581 | m_tidyconfig_action->addTo( settings ); |
582 | ag->setExclusive(false); | 582 | |
583 | spacemenu = new QPopupMenu(this); | 583 | settings->insertSeparator(); |
584 | file->insertItem( tr( "Scrolling" ), spacemenu ); | 584 | m_toolbarprefs_action = new QAction( tr( "Toolbars" ), QString::null, 0, this, NULL); |
585 | 585 | connect( m_toolbarprefs_action, SIGNAL( activated() ), this, SLOT( showtoolbarprefs() ) ); | |
586 | a = new QAction( tr( "Set Target" ), QString::null, 0, ag, NULL); | 586 | m_toolbarprefs_action->addTo( settings ); |
587 | connect( a, SIGNAL( activated() ), this, SLOT( setpipetarget() ) ); | 587 | |
588 | 588 | m_buttonprefs_action = new QAction( tr( "Buttons" ), QString::null, 0, this, NULL); | |
589 | a = new QAction( tr( "Pause Paras" ), QString::null, 0, ag, NULL, true ); | 589 | connect( m_buttonprefs_action, SIGNAL( activated() ), this, SLOT( showbuttonprefs() ) ); |
590 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( setpause(bool) ) ); | 590 | m_buttonprefs_action->addTo( settings ); |
591 | a->setOn(reader->m_pauseAfterEachPara); | 591 | |
592 | 592 | m_loadtheme_action = new QAction( tr( "Load Theme" ), QString::null, 0, this, NULL); | |
593 | ag->addTo(spacemenu); | 593 | connect( m_loadtheme_action, SIGNAL( activated() ), this, SLOT( LoadTheme() ) ); |
594 | // file->insertSeparator(); | 594 | m_loadtheme_action->addTo( settings ); |
595 | 595 | ||
596 | #endif | 596 | m_repara_action = new QAction( tr( "EOP Marker" ), QString::null, 0, this, NULL); |
597 | 597 | connect( m_repara_action, SIGNAL( activated() ), this, SLOT( reparastring() ) ); | |
598 | /* | 598 | m_repara_action->addTo(settings); |
599 | a = new QAction( tr( "Import" ), QString::null, 0, this, NULL ); | 599 | |
600 | connect( a, SIGNAL( activated() ), this, SLOT( importFiles() ) ); | 600 | #ifdef USEQPE |
601 | a->addTo( file ); | 601 | m_grab_action = new QAction( tr( "Grab Buttons" ), QString::null, 0, this, NULL, true ); |
602 | */ | 602 | connect( m_grab_action, SIGNAL( toggled(bool) ), this, SLOT( setgrab(bool) ) ); |
603 | 603 | m_grab_action->setOn(m_grabkeyboard); | |
604 | /* | 604 | m_grab_action->addTo( settings ); |
605 | a = new QAction( tr( "Paste" ), geticon( "paste" ), QString::null, 0, this, 0 ); | 605 | #endif |
606 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); | 606 | |
607 | a->addTo( fileBar ); | 607 | m_open_action = new QAction( tr( "Open" ), geticon( "fileopen" ), QString::null, 0, this, 0 ); |
608 | a->addTo( edit ); | 608 | connect( m_open_action, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); |
609 | */ | 609 | m_open_action->addTo( file ); |
610 | 610 | ||
611 | // a = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, 0 ); | 611 | m_close_action = new QAction( tr( "Close" ), geticon( "close" ), QString::null, 0, this, 0 ); |
612 | 612 | connect( m_close_action, SIGNAL( activated() ), this, SLOT( fileClose() ) ); | |
613 | m_fullscreen = false; | 613 | m_close_action->addTo( file ); |
614 | m_actFullscreen = new QAction( tr( "Fullscreen" ), geticon( "fullscreen" ), QString::null, 0, this, NULL, true ); | 614 | |
615 | connect( m_actFullscreen, SIGNAL( toggled(bool) ), this, SLOT( setfullscreen(bool) ) ); | 615 | #ifdef _SCRIPT |
616 | m_actFullscreen->setOn(m_fullscreen); | 616 | a = new QAction( tr( "Run Script" ), QString::null, 0, this, NULL); |
617 | m_actFullscreen->addTo( view ); | 617 | connect( a, SIGNAL( activated() ), this, SLOT( RunScript() ) ); |
618 | 618 | a->addTo( file ); | |
619 | view->insertSeparator(); | 619 | #endif |
620 | 620 | /* | |
621 | m_zoomin_action = new QAction( tr( "Zoom In" ), geticon( "zoom" ), QString::null, 0, this); | 621 | a = new QAction( tr( "Revert" ), geticon( "close" ), QString::null, 0, this, 0 ); |
622 | connect( m_zoomin_action, SIGNAL( activated() ), this, SLOT( zoomin() ) ); | 622 | connect( a, SIGNAL( activated() ), this, SLOT( fileRevert() ) ); |
623 | m_zoomin_action->addTo( view ); | 623 | a->addTo( file ); |
624 | 624 | ||
625 | m_zoomout_action = new QAction( tr( "Zoom Out" ), geticon( "mag" ), QString::null, 0, this); | 625 | a = new QAction( tr( "Cut" ), geticon( "cut" ), QString::null, 0, this, 0 ); |
626 | connect( m_zoomout_action, SIGNAL( activated() ), this, SLOT( zoomout() ) ); | 626 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); |
627 | m_zoomout_action->addTo( view ); | 627 | a->addTo( filebar() ); |
628 | 628 | a->addTo( edit ); | |
629 | view->insertSeparator(); | 629 | */ |
630 | m_setfont_action = new QAction( tr( "Set Font" ), getmyicon( "font" ), QString::null, 0, this); | 630 | |
631 | connect( m_setfont_action, SIGNAL( activated() ), this, SLOT( setfont() ) ); | 631 | m_info_action = new QAction( tr( "Info" ), geticon( "UtilsIcon" ), QString::null, 0, this, NULL); |
632 | m_setfont_action->addTo( view ); | 632 | connect( m_info_action, SIGNAL( activated() ), this, SLOT( showinfo() ) ); |
633 | 633 | m_info_action->addTo( file ); | |
634 | view->insertSeparator(); | 634 | |
635 | m_setenc_action = new QAction( tr( "Set Encoding" ), getmyicon( "charset" ), QString::null, 0, this); | 635 | m_touch_action = new QAction( tr( "Two/One Touch" ), geticon( "1to1" ), QString::null, 0, this, NULL, true ); |
636 | connect( m_setenc_action, SIGNAL( activated() ), this, SLOT( chooseencoding() ) ); | 636 | connect( m_touch_action, SIGNAL( toggled(bool) ), this, SLOT( setTwoTouch(bool) ) ); |
637 | m_setenc_action->addTo( view ); | 637 | m_touch_action->setOn(m_twoTouch); |
638 | 638 | m_touch_action->addTo( file ); | |
639 | m_setmono_action = new QAction( tr( "Ideogram" ), getmyicon( "ideogram" ), QString::null, 0, this, NULL, true); | 639 | |
640 | connect( m_setmono_action, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); | 640 | m_find_action = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, NULL); |
641 | m_setmono_action->addTo( view ); | 641 | connect( m_find_action, SIGNAL( activated() ), this, SLOT( editFind() ) ); |
642 | m_setmono_action->setOn(reader->m_bMonoSpaced); | 642 | file->insertSeparator(); |
643 | 643 | // a->addTo( bar ); | |
644 | 644 | m_find_action->addTo( file ); | |
645 | // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true ); | 645 | |
646 | // a = new QAction( tr( "Zoom" ), geticon( "mag" ), QString::null, 0, this, 0 ); | 646 | m_exportlinks_action = new QAction( tr( "Export Links" ), QString::null, 0, this, NULL); |
647 | 647 | connect( m_exportlinks_action, SIGNAL( activated() ), this, SLOT( ExportLinks() ) ); | |
648 | 648 | m_exportlinks_action->addTo( file ); | |
649 | 649 | ||
650 | // a->addTo( filebar() ); | 650 | m_scrollButton = new QAction( tr( "Scroll" ), getmyicon( "panel-arrow-down" ), QString::null, 0, this, 0, true ); |
651 | // view->insertSeparator(); | 651 | connect( m_scrollButton, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) ); |
652 | 652 | m_scrollButton->addTo(navigation); | |
653 | /* | 653 | m_scrollButton->setOn(false); |
654 | a = new QAction( tr( "Ideogram/Word" ), QString::null, 0, this, NULL, true ); | 654 | |
655 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); | 655 | m_start_action = new QAction( tr( "Goto Start" ), geticon( "start" ), QString::null, 0, this, NULL); |
656 | a->setOn(reader->m_bMonoSpaced); | 656 | connect( m_start_action, SIGNAL( activated() ), this, SLOT( gotoStart() ) ); |
657 | a->addTo( view ); | 657 | m_start_action->addTo(navigation); |
658 | */ | 658 | |
659 | /* | 659 | m_end_action = new QAction( tr( "Goto End" ), geticon( "finish" ), QString::null, 0, this, NULL); |
660 | a = new QAction( tr( "Set Width" ), QString::null, 0, this, NULL); | 660 | connect( m_end_action, SIGNAL( activated() ), this, SLOT( gotoEnd() ) ); |
661 | connect( a, SIGNAL( activated() ), this, SLOT( setspacing() ) ); | 661 | m_end_action->addTo(navigation); |
662 | a->addTo( view ); | 662 | |
663 | */ | 663 | m_jump_action = new QAction( tr( "Jump" ), geticon( "rotate" ), QString::null, 0, this, NULL); |
664 | 664 | connect( m_jump_action, SIGNAL( activated() ), this, SLOT( jump() ) ); | |
665 | m_mark_action = new QAction( tr( "Bookmark" ), getmyicon( "bookmark" ), QString::null, 0, this, NULL); | 665 | m_jump_action->addTo(navigation); |
666 | connect( m_mark_action, SIGNAL( activated() ), this, SLOT( addbkmk() ) ); | 666 | |
667 | m_mark_action->addTo( marks ); | 667 | m_pageline_action = new QAction( tr( "Page/Line Scroll" ), geticon( "pass" ), QString::null, 0, this, NULL, true ); |
668 | 668 | connect( m_pageline_action, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) ); | |
669 | m_annotate_action = new QAction( tr( "Annotate" ), getmyicon( "annotate" ), QString::null, 0, this, NULL); | 669 | m_pageline_action->addTo(navigation); |
670 | connect( m_annotate_action, SIGNAL( activated() ), this, SLOT( addanno() ) ); | 670 | m_pageline_action->setOn(reader->m_bpagemode); |
671 | m_annotate_action->addTo( marks ); | 671 | |
672 | 672 | m_pageup_action = new QAction( tr( "Up" ), geticon( "up" ), QString::null, 0, this, 0 ); | |
673 | m_goto_action = new QAction( tr( "Goto" ), getmyicon( "bookmark_goto" ), QString::null, 0, this, NULL, false ); | 673 | connect( m_pageup_action, SIGNAL( activated() ), this, SLOT( pageup() ) ); |
674 | connect( m_goto_action, SIGNAL( activated() ), this, SLOT( do_gotomark() ) ); | 674 | m_pageup_action->addTo( navigation ); |
675 | m_goto_action->addTo( marks ); | 675 | |
676 | 676 | m_pagedn_action = new QAction( tr( "Down" ), geticon( "down" ), QString::null, 0, this, 0 ); | |
677 | m_delete_action = new QAction( tr( "Delete" ), getmyicon( "bookmark_delete" ), QString::null, 0, this, NULL); | 677 | connect( m_pagedn_action, SIGNAL( activated() ), this, SLOT( pagedn() ) ); |
678 | connect( m_delete_action, SIGNAL( activated() ), this, SLOT( do_delmark() ) ); | 678 | m_pagedn_action->addTo( navigation ); |
679 | m_delete_action->addTo( marks ); | 679 | |
680 | 680 | m_back_action = new QAction( tr( "Back" ), geticon( "back" ), QString::null, 0, this, 0 ); | |
681 | m_autogen_action = new QAction( tr( "Autogen" ), geticon( "exec" ), QString::null, 0, this, NULL, false ); | 681 | connect( m_back_action, SIGNAL( activated() ), reader, SLOT( goBack() ) ); |
682 | connect( m_autogen_action, SIGNAL( activated() ), this, SLOT( do_autogen() ) ); | 682 | m_back_action->addTo( navigation ); |
683 | marks->insertSeparator(); | 683 | |
684 | m_autogen_action->addTo( marks ); | 684 | m_home_action = new QAction( tr( "Home" ), geticon( "home" ), QString::null, 0, this, 0 ); |
685 | 685 | connect( m_home_action, SIGNAL( activated() ), reader, SLOT( goHome() ) ); | |
686 | m_clear_action = new QAction( tr( "Clear" ), getmyicon( "bookmark_clear" ), QString::null, 0, this, NULL); | 686 | m_home_action->addTo( navigation ); |
687 | connect( m_clear_action, SIGNAL( activated() ), this, SLOT( clearBkmkList() ) ); | 687 | |
688 | m_clear_action->addTo( marks ); | 688 | m_forward_action = new QAction( tr( "Forward" ), geticon( "forward" ), QString::null, 0, this, 0 ); |
689 | 689 | connect( m_forward_action, SIGNAL( activated() ), reader, SLOT( goForward() ) ); | |
690 | m_save_action = new QAction( tr( "Save" ), getmyicon( "bookmark_save" ), QString::null, 0, this, NULL ); | 690 | m_forward_action->addTo( navigation ); |
691 | connect( m_save_action, SIGNAL( activated() ), this, SLOT( savebkmks() ) ); | 691 | |
692 | m_save_action->addTo( marks ); | 692 | /* |
693 | 693 | a = new QAction( tr( "Find" ), QString::null, 0, this, NULL, true ); | |
694 | m_tidy_action = new QAction( tr( "Tidy" ), getmyicon( "bookmark_tidy" ), QString::null, 0, this, NULL); | 694 | // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); |
695 | connect( m_tidy_action, SIGNAL( activated() ), this, SLOT( listBkmkFiles() ) ); | 695 | a->addTo( file ); |
696 | marks->insertSeparator(); | 696 | |
697 | m_tidy_action->addTo( marks ); | 697 | a = new QAction( tr( "Find Again" ), QString::null, 0, this, NULL, true ); |
698 | 698 | // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); | |
699 | m_startBlock_action = new QAction( tr( "Start Block" ), geticon( "new" ), QString::null, 0, this, NULL); | 699 | a->addTo( file ); |
700 | connect( m_startBlock_action, SIGNAL( activated() ), this, SLOT( editMark() ) ); | 700 | */ |
701 | marks->insertSeparator(); | 701 | |
702 | m_startBlock_action->addTo( marks ); | 702 | // file->insertSeparator(); |
703 | 703 | ||
704 | m_endBlock_action = new QAction( tr( "Copy Block" ), geticon( "copy" ), QString::null, 0, this, NULL); | 704 | #ifdef _SCROLLPIPE |
705 | connect( m_endBlock_action, SIGNAL( activated() ), this, SLOT( editCopy() ) ); | 705 | |
706 | m_endBlock_action->addTo( marks ); | 706 | QActionGroup* ag = new QActionGroup(this); |
707 | 707 | ag->setExclusive(false); | |
708 | m_bkmkAvail = NULL; | 708 | spacemenu = new QPopupMenu(this); |
709 | 709 | file->insertItem( tr( "Scrolling" ), spacemenu ); | |
710 | 710 | ||
711 | setToolBarsMovable(m_tbmove); | 711 | a = new QAction( tr( "Set Target" ), QString::null, 0, ag, NULL); |
712 | addtoolbars(&config); | 712 | connect( a, SIGNAL( activated() ), this, SLOT( setpipetarget() ) ); |
713 | 713 | ||
714 | pbar = new QProgressBar(this); | 714 | a = new QAction( tr( "Pause Paras" ), QString::null, 0, ag, NULL, true ); |
715 | pbar->hide(); | 715 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( setpause(bool) ) ); |
716 | 716 | a->setOn(reader->m_pauseAfterEachPara); | |
717 | searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE ); | 717 | |
718 | 718 | ag->addTo(spacemenu); | |
719 | searchBar->setHorizontalStretchable( TRUE ); | 719 | // file->insertSeparator(); |
720 | 720 | ||
721 | connect(searchBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); | 721 | #endif |
722 | 722 | ||
723 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 723 | /* |
724 | // QFont f("unifont", 16 /*, QFont::Bold*/); | 724 | a = new QAction( tr( "Import" ), QString::null, 0, this, NULL ); |
725 | // searchEdit->setFont( f ); | 725 | connect( a, SIGNAL( activated() ), this, SLOT( importFiles() ) ); |
726 | searchBar->setStretchableWidget( searchEdit ); | 726 | a->addTo( file ); |
727 | 727 | */ | |
728 | 728 | ||
729 | #ifdef __ISEARCH | 729 | /* |
730 | connect( searchEdit, SIGNAL( textChanged(const QString&) ), | 730 | a = new QAction( tr( "Paste" ), geticon( "paste" ), QString::null, 0, this, 0 ); |
731 | this, SLOT( search(const QString&) ) ); | 731 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); |
732 | #else | 732 | a->addTo( fileBar ); |
733 | connect( searchEdit, SIGNAL( returnPressed() ), | 733 | a->addTo( edit ); |
734 | this, SLOT( search() ) ); | 734 | */ |
735 | #endif | 735 | |
736 | QAction*a = new QAction( tr( "Find Next" ), geticon( "next" ), QString::null, 0, this, 0 ); | 736 | // a = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, 0 ); |
737 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); | 737 | |
738 | a->addTo( searchBar ); | 738 | m_fullscreen = false; |
739 | 739 | m_actFullscreen = new QAction( tr( "Fullscreen" ), geticon( "fullscreen" ), QString::null, 0, this, NULL, true ); | |
740 | a = new QAction( tr( "Close Find" ), geticon( "close" ), QString::null, 0, this, 0 ); | 740 | connect( m_actFullscreen, SIGNAL( toggled(bool) ), this, SLOT( setfullscreen(bool) ) ); |
741 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 741 | m_actFullscreen->setOn(m_fullscreen); |
742 | a->addTo( searchBar ); | 742 | m_actFullscreen->addTo( view ); |
743 | 743 | ||
744 | searchBar->hide(); | 744 | m_rotate_action = new QAction( tr( "Rotate" ), geticon( "repeat" ), QString::null, 0, this, NULL, true ); |
745 | 745 | connect( m_rotate_action, SIGNAL( toggled(bool) ), this, SLOT( setrotated(bool) ) ); | |
746 | regBar = new QFloatBar( "Autogen", this, QMainWindow::Top, TRUE ); | 746 | m_rotate_action->setOn(reader->m_rotated); |
747 | connect(regBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); | 747 | m_rotate_action->addTo( view ); |
748 | 748 | ||
749 | regBar->setHorizontalStretchable( TRUE ); | 749 | m_inverse_action = new QAction( tr( "Invert" ), getmyicon( "invert" ), QString::null, 0, this, NULL, true ); |
750 | 750 | connect( m_inverse_action, SIGNAL( toggled(bool) ), this, SLOT( setinverted(bool) ) ); | |
751 | regEdit = new QLineEdit( regBar, "regEdit" ); | 751 | m_inverse_action->setOn(reader->bInverse); |
752 | // regEdit->setFont( f ); | 752 | m_inverse_action->addTo( view ); |
753 | 753 | ||
754 | regBar->setStretchableWidget( regEdit ); | 754 | view->insertSeparator(); |
755 | 755 | ||
756 | connect( regEdit, SIGNAL( returnPressed() ), | 756 | m_zoomin_action = new QAction( tr( "Zoom In" ), geticon( "zoom" ), QString::null, 0, this); |
757 | this, SLOT( do_regaction() ) ); | 757 | connect( m_zoomin_action, SIGNAL( activated() ), this, SLOT( zoomin() ) ); |
758 | 758 | m_zoomin_action->addTo( view ); | |
759 | a = new QAction( tr( "Do Reg" ), geticon( "enter" ), QString::null, 0, this, 0 ); | 759 | |
760 | connect( a, SIGNAL( activated() ), this, SLOT( do_regaction() ) ); | 760 | m_zoomout_action = new QAction( tr( "Zoom Out" ), geticon( "mag" ), QString::null, 0, this); |
761 | a->addTo( regBar ); | 761 | connect( m_zoomout_action, SIGNAL( activated() ), this, SLOT( zoomout() ) ); |
762 | 762 | m_zoomout_action->addTo( view ); | |
763 | a = new QAction( tr( "Close Edit" ), geticon( "close" ), QString::null, 0, this, 0 ); | 763 | |
764 | connect( a, SIGNAL( activated() ), this, SLOT( regClose() ) ); | 764 | view->insertSeparator(); |
765 | a->addTo( regBar ); | 765 | m_setfont_action = new QAction( tr( "Set Font" ), getmyicon( "font" ), QString::null, 0, this); |
766 | 766 | connect( m_setfont_action, SIGNAL( activated() ), this, SLOT( setfont() ) ); | |
767 | regBar->hide(); | 767 | m_setfont_action->addTo( view ); |
768 | 768 | ||
769 | m_fontBar = new QToolBar( "Autogen", this, QMainWindow::Top, TRUE ); | 769 | view->insertSeparator(); |
770 | 770 | m_setenc_action = new QAction( tr( "Set Encoding" ), getmyicon( "charset" ), QString::null, 0, this); | |
771 | m_fontBar->setHorizontalStretchable( TRUE ); | 771 | connect( m_setenc_action, SIGNAL( activated() ), this, SLOT( chooseencoding() ) ); |
772 | 772 | m_setenc_action->addTo( view ); | |
773 | // odebug << "Font selector" << oendl; | 773 | |
774 | m_fontSelector = new QComboBox(false, m_fontBar); | 774 | m_setmono_action = new QAction( tr( "Ideogram" ), getmyicon( "ideogram" ), QString::null, 0, this, NULL, true); |
775 | m_fontBar->setStretchableWidget( m_fontSelector ); | 775 | connect( m_setmono_action, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); |
776 | { | 776 | m_setmono_action->addTo( view ); |
777 | #ifndef USEQPE | 777 | m_setmono_action->setOn(reader->m_bMonoSpaced); |
778 | QFontDatabase f; | 778 | |
779 | #else | 779 | |
780 | FontDatabase f; | 780 | // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true ); |
781 | #endif | 781 | // a = new QAction( tr( "Zoom" ), geticon( "mag" ), QString::null, 0, this, 0 ); |
782 | QStringList flist = f.families(); | 782 | |
783 | bool realfont = false; | 783 | |
784 | for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) | 784 | |
785 | { | 785 | // a->addTo( filebar() ); |
786 | if (reader->m_fontname == *nm) | 786 | // view->insertSeparator(); |
787 | { | 787 | |
788 | realfont = true; | 788 | /* |
789 | } | 789 | a = new QAction( tr( "Ideogram/Word" ), QString::null, 0, this, NULL, true ); |
790 | if ((*nm).contains(FIXEDFONT,false)) reader->m_fontControl.hasCourier(true, *nm); | 790 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); |
791 | } | 791 | a->setOn(reader->m_bMonoSpaced); |
792 | if (!realfont) reader->m_fontname = flist[0]; | 792 | a->addTo( view ); |
793 | } // delete the FontDatabase!!! | 793 | */ |
794 | connect( m_fontSelector, SIGNAL( activated(const QString&) ), | 794 | /* |
795 | this, SLOT( do_setfont(const QString&) ) ); | 795 | a = new QAction( tr( "Set Width" ), QString::null, 0, this, NULL); |
796 | connect( m_fontSelector, SIGNAL( activated(int) ), | 796 | connect( a, SIGNAL( activated() ), this, SLOT( setspacing() ) ); |
797 | this, SLOT( do_setencoding(int) ) ); | 797 | a->addTo( view ); |
798 | 798 | */ | |
799 | m_fontBar->hide(); | 799 | |
800 | m_fontVisible = false; | 800 | m_mark_action = new QAction( tr( "Bookmark" ), getmyicon( "bookmark" ), QString::null, 0, this, NULL); |
801 | #ifdef USEMSGS | 801 | connect( m_mark_action, SIGNAL( activated() ), this, SLOT( addbkmk() ) ); |
802 | connect(qApp, SIGNAL( appMessage(const QCString&,const QByteArray&) ), | 802 | m_mark_action->addTo( marks ); |
803 | this, SLOT( msgHandler(const QCString&,const QByteArray&) ) ); | 803 | |
804 | #endif | 804 | m_annotate_action = new QAction( tr( "Annotate" ), getmyicon( "annotate" ), QString::null, 0, this, NULL); |
805 | // odebug << "Initing" << oendl; | 805 | connect( m_annotate_action, SIGNAL( activated() ), this, SLOT( addanno() ) ); |
806 | reader->init(); | 806 | m_annotate_action->addTo( marks ); |
807 | // odebug << "Inited" << oendl; | 807 | |
808 | // m_buttonAction[m_spaceTarget]->setOn(true); | 808 | m_goto_action = new QAction( tr( "Goto" ), getmyicon( "bookmark_goto" ), QString::null, 0, this, NULL, false ); |
809 | // odebug << "fonting" << oendl; | 809 | connect( m_goto_action, SIGNAL( activated() ), this, SLOT( do_gotomark() ) ); |
810 | do_setfont(reader->m_fontname); | 810 | m_goto_action->addTo( marks ); |
811 | if (!reader->m_lastfile.isEmpty()) | 811 | |
812 | { | 812 | m_delete_action = new QAction( tr( "Delete" ), getmyicon( "bookmark_delete" ), QString::null, 0, this, NULL); |
813 | // odebug << "doclnk" << oendl; | 813 | connect( m_delete_action, SIGNAL( activated() ), this, SLOT( do_delmark() ) ); |
814 | // doc = new DocLnk(reader->m_lastfile); | 814 | m_delete_action->addTo( marks ); |
815 | // odebug << "doclnk done" << oendl; | 815 | |
816 | if (pOpenlist != NULL) | 816 | m_autogen_action = new QAction( tr( "Autogen" ), geticon( "exec" ), QString::null, 0, this, NULL, false ); |
817 | { | 817 | connect( m_autogen_action, SIGNAL( activated() ), this, SLOT( do_autogen() ) ); |
818 | 818 | marks->insertSeparator(); | |
819 | /* | 819 | m_autogen_action->addTo( marks ); |
820 | int ind = 0; | 820 | |
821 | Bkmk* p = (*pOpenlist)[ind]; | 821 | m_clear_action = new QAction( tr( "Clear" ), getmyicon( "bookmark_clear" ), QString::null, 0, this, NULL); |
822 | while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) | 822 | connect( m_clear_action, SIGNAL( activated() ), this, SLOT( clearBkmkList() ) ); |
823 | { | 823 | m_clear_action->addTo( marks ); |
824 | p = (*pOpenlist)[++ind]; | 824 | |
825 | } | 825 | m_save_action = new QAction( tr( "Save" ), getmyicon( "bookmark_save" ), QString::null, 0, this, NULL ); |
826 | */ | 826 | connect( m_save_action, SIGNAL( activated() ), this, SLOT( savebkmks() ) ); |
827 | Bkmk* p = NULL; | 827 | m_save_action->addTo( marks ); |
828 | for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++) | 828 | |
829 | { | 829 | m_tidy_action = new QAction( tr( "Tidy" ), getmyicon( "bookmark_tidy" ), QString::null, 0, this, NULL); |
830 | p = iter.pContent(); | 830 | connect( m_tidy_action, SIGNAL( activated() ), this, SLOT( listBkmkFiles() ) ); |
831 | if (toQString(CFiledata(p->anno()).name()) == reader->m_lastfile) | 831 | marks->insertSeparator(); |
832 | { | 832 | m_tidy_action->addTo( marks ); |
833 | break; | 833 | |
834 | } | 834 | m_startBlock_action = new QAction( tr( "Start Block" ), geticon( "new" ), QString::null, 0, this, NULL); |
835 | // odebug << "Item:" << toQString(CFiledata(p->anno()).name()) << "" << oendl; | 835 | connect( m_startBlock_action, SIGNAL( activated() ), this, SLOT( editMark() ) ); |
836 | p = NULL; | 836 | marks->insertSeparator(); |
837 | } | 837 | m_startBlock_action->addTo( marks ); |
838 | if (p != NULL) | 838 | |
839 | { | 839 | m_endBlock_action = new QAction( tr( "Copy Block" ), geticon( "copy" ), QString::null, 0, this, NULL); |
840 | // odebug << "openfrombkmk" << oendl; | 840 | connect( m_endBlock_action, SIGNAL( activated() ), this, SLOT( editCopy() ) ); |
841 | if (!openfrombkmk(p)) | 841 | m_endBlock_action->addTo( marks ); |
842 | showEditTools(); | 842 | |
843 | } | 843 | m_bkmkAvail = NULL; |
844 | else | 844 | |
845 | { | 845 | |
846 | // odebug << "openfile" << oendl; | 846 | setToolBarsMovable(m_tbmove); |
847 | openFile( reader->m_lastfile ); | 847 | addtoolbars(&config); |
848 | } | 848 | |
849 | } | 849 | pbar = new QProgressBar(this); |
850 | else | 850 | pbar->hide(); |
851 | { | 851 | |
852 | // odebug << "Openfile 2" << oendl; | 852 | searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE ); |
853 | if (!reader->m_lastfile.isEmpty()) | 853 | |
854 | openFile( reader->m_lastfile ); | 854 | searchBar->setHorizontalStretchable( TRUE ); |
855 | } | 855 | |
856 | } | 856 | connect(searchBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); |
857 | else | 857 | |
858 | { | 858 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
859 | showEditTools(); | 859 | // QFont f("unifont", 16 /*, QFont::Bold*/); |
860 | } | 860 | // searchEdit->setFont( f ); |
861 | // qApp->processEvents(); | 861 | searchBar->setStretchableWidget( searchEdit ); |
862 | reader->bDoUpdates = true; | 862 | |
863 | reader->update(); | 863 | |
864 | config.setGroup("Version"); | 864 | #ifdef __ISEARCH |
865 | int major = config.readNumEntry("Major", 0); | 865 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
866 | int bkmktype = config.readNumEntry("BkmkType", 0); | 866 | this, SLOT( search( const QString& ) ) ); |
867 | char minor = config.readNumEntry("Minor", 0); | 867 | #else |
868 | if (CheckVersion(major, bkmktype, minor)) | 868 | connect( searchEdit, SIGNAL( returnPressed( ) ), |
869 | { | 869 | this, SLOT( search( ) ) ); |
870 | config.writeEntry("Major", major); | 870 | #endif |
871 | config.writeEntry("BkmkType", bkmktype); | 871 | QAction*a = new QAction( tr( "Find Next" ), geticon( "next" ), QString::null, 0, this, 0 ); |
872 | config.writeEntry("Minor", (int)minor); | 872 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); |
873 | } | 873 | a->addTo( searchBar ); |
874 | // odebug << "finished update" << oendl; | 874 | |
875 | } | 875 | a = new QAction( tr( "Close Find" ), geticon( "close" ), QString::null, 0, this, 0 ); |
876 | 876 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | |
877 | void QTReaderApp::addtoolbars(Config* config) | 877 | a->addTo( searchBar ); |
878 | { | 878 | |
879 | config->setGroup("Toolbar"); | 879 | searchBar->hide(); |
880 | 880 | ||
881 | if (fileBar != NULL) | 881 | regBar = new QFloatBar( "Autogen", this, QMainWindow::Top, TRUE ); |
882 | { | 882 | connect(regBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); |
883 | if (fileBar != menubar) | 883 | |
884 | { | 884 | regBar->setHorizontalStretchable( TRUE ); |
885 | fileBar->clear(); | 885 | |
886 | } | 886 | regEdit = new QLineEdit( regBar, "regEdit" ); |
887 | else | 887 | // regEdit->setFont( f ); |
888 | { | 888 | |
889 | m_preferences_action->removeFrom( filebar() ); | 889 | regBar->setStretchableWidget( regEdit ); |
890 | m_open_action->removeFrom( filebar() ); | 890 | |
891 | m_close_action->removeFrom( filebar() ); | 891 | connect( regEdit, SIGNAL( returnPressed( ) ), |
892 | m_info_action->removeFrom( filebar() ); | 892 | this, SLOT( do_regaction() ) ); |
893 | m_touch_action->removeFrom( filebar() ); | 893 | |
894 | m_find_action->removeFrom( filebar() ); | 894 | a = new QAction( tr( "Do Reg" ), geticon( "enter" ), QString::null, 0, this, 0 ); |
895 | } | 895 | connect( a, SIGNAL( activated() ), this, SLOT( do_regaction() ) ); |
896 | } | 896 | a->addTo( regBar ); |
897 | 897 | ||
898 | m_preferences_action->addTo( filebar() ); | 898 | a = new QAction( tr( "Close Edit" ), geticon( "close" ), QString::null, 0, this, 0 ); |
899 | addfilebar(config, "Open", m_open_action); | 899 | connect( a, SIGNAL( activated() ), this, SLOT( regClose() ) ); |
900 | addfilebar(config, "Close", m_close_action); | 900 | a->addTo( regBar ); |
901 | addfilebar(config, "Info", m_info_action); | 901 | |
902 | addfilebar(config, "Two/One Touch", m_touch_action); | 902 | regBar->hide(); |
903 | addfilebar(config, "Find", m_find_action); | 903 | |
904 | 904 | m_fontBar = new QToolBar( "Autogen", this, QMainWindow::Top, TRUE ); | |
905 | if (navBar != NULL) | 905 | |
906 | { | 906 | m_fontBar->setHorizontalStretchable( TRUE ); |
907 | if ((navBar == fileBar) && (fileBar == menubar)) | 907 | |
908 | { | 908 | // qDebug("Font selector"); |
909 | m_scrollButton->removeFrom( navbar() ); | 909 | m_fontSelector = new QComboBox(false, m_fontBar); |
910 | m_start_action->removeFrom( navbar() ); | 910 | m_fontBar->setStretchableWidget( m_fontSelector ); |
911 | m_end_action->removeFrom( navbar() ); | 911 | { |
912 | m_jump_action->removeFrom( navbar() ); | 912 | QFontDatabase f; |
913 | m_pageline_action->removeFrom( navbar() ); | 913 | QStringList flist = f.families(); |
914 | m_pageup_action->removeFrom( navbar() ); | 914 | bool realfont = false; |
915 | m_pagedn_action->removeFrom( navbar() ); | 915 | for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) |
916 | m_back_action->removeFrom( navbar() ); | 916 | { |
917 | m_home_action->removeFrom( navbar() ); | 917 | if (reader->m_fontname == *nm) |
918 | m_forward_action->removeFrom( navbar() ); | 918 | { |
919 | } | 919 | realfont = true; |
920 | else if (navBar != fileBar) | 920 | } |
921 | { | 921 | if ((*nm).contains(FIXEDFONT,false)) reader->m_fontControl.hasCourier(true, *nm); |
922 | navBar->clear(); | 922 | } |
923 | } | 923 | if (!realfont) reader->m_fontname = flist[0]; |
924 | } | 924 | } // delete the FontDatabase!!! |
925 | 925 | connect( m_fontSelector, SIGNAL( activated(const QString& ) ), | |
926 | addnavbar(config, "Scroll", m_scrollButton); | 926 | this, SLOT( do_setfont(const QString&) ) ); |
927 | addnavbar(config, "Goto Start", m_start_action); | 927 | connect( m_fontSelector, SIGNAL( activated(int ) ), |
928 | addnavbar(config, "Goto End", m_end_action); | 928 | this, SLOT( do_setencoding(int) ) ); |
929 | 929 | ||
930 | addnavbar(config, "Jump", m_jump_action); | 930 | m_fontBar->hide(); |
931 | addnavbar(config, "Page/Line Scroll", m_pageline_action); | 931 | m_fontVisible = false; |
932 | 932 | #ifdef USEMSGS | |
933 | addnavbar(config, "Page Up", m_pageup_action); | 933 | connect(qApp, SIGNAL( appMessage(const QCString&, const QByteArray& ) ), |
934 | addnavbar(config, "Page Down", m_pagedn_action); | 934 | this, SLOT( msgHandler(const QCString&, const QByteArray&) ) ); |
935 | 935 | #endif | |
936 | addnavbar(config, "Back", m_back_action); | 936 | // qDebug("Initing"); |
937 | addnavbar(config, "Home", m_home_action); | 937 | |
938 | addnavbar(config, "Forward", m_forward_action); | 938 | m_layout->addWidget(editorStack); |
939 | 939 | if (m_qtscroll != 0) | |
940 | if (viewBar != NULL) | 940 | { |
941 | { | 941 | /* |
942 | if ((viewBar == fileBar) && (fileBar == menubar)) | 942 | m_scrollbar = new QToolBar( "Autogen", this, (m_localscrollbar) ? QMainWindow::Left : QMainWindow::Right, TRUE ); |
943 | { | 943 | |
944 | m_actFullscreen->removeFrom( filebar() ); | 944 | m_scrollbar->setVerticalStretchable( TRUE ); |
945 | m_zoomin_action->removeFrom( viewbar() ); | 945 | */ |
946 | m_zoomout_action->removeFrom( viewbar() ); | 946 | scrollbar = m_scrollbar = new QScrollBar(QScrollBar::Vertical, widge); |
947 | m_setfont_action->removeFrom( viewbar() ); | 947 | m_layout->addWidget(scrollbar); |
948 | m_setenc_action->removeFrom( viewbar() ); | 948 | scrollbar->setTracking(false); |
949 | m_setmono_action->removeFrom( viewbar() ); | 949 | //connect(scrollbar, SIGNAL(sliderMoved(int)), this, SLOT(actionscroll(int)) ); |
950 | } | 950 | //m_scrollbar->setStretchableWidget( scrollbar ); |
951 | else if (viewBar != fileBar) | 951 | if (m_scrollishidden) |
952 | { | 952 | { |
953 | viewBar->clear(); | 953 | m_scrollbar->hide(); |
954 | } | 954 | } |
955 | } | 955 | else |
956 | 956 | { | |
957 | addviewbar(config, "Fullscreen", m_actFullscreen); | 957 | m_scrollbar->show(); |
958 | addviewbar(config, "Zoom In", m_zoomin_action); | 958 | } |
959 | addviewbar(config, "Zoom Out", m_zoomout_action); | 959 | |
960 | addviewbar(config, "Set Font", m_setfont_action); | 960 | setrotated(reader->m_rotated); |
961 | addviewbar(config, "Encoding Select", m_setenc_action); | 961 | } |
962 | addviewbar(config, "Ideogram Mode", m_setmono_action); | 962 | else |
963 | 963 | { | |
964 | if (markBar != NULL) | 964 | m_scrollbar = NULL; |
965 | { | 965 | } |
966 | if ((markBar == fileBar) && (fileBar == menubar)) | 966 | setBackgroundBitmap(); |
967 | { | 967 | m_inverse_action->setOn(reader->bInverse); |
968 | m_mark_action->removeFrom( markbar() ); | 968 | reader->init(); |
969 | m_annotate_action->removeFrom( markbar()); | 969 | |
970 | m_goto_action->removeFrom( markbar() ); | 970 | // qDebug("Inited"); |
971 | m_delete_action->removeFrom( markbar() ); | 971 | // m_buttonAction[m_spaceTarget]->setOn(true); |
972 | m_autogen_action->removeFrom( markbar() ); | 972 | // qDebug("fonting"); |
973 | m_clear_action->removeFrom( markbar() ); | 973 | do_setfont(reader->m_fontname); |
974 | m_save_action->removeFrom( markbar() ); | 974 | // qDebug("fonted"); |
975 | m_tidy_action->removeFrom( markbar() ); | 975 | QFont progfont(reader->m_fontname, reader->m_fontControl.getsize(0)); |
976 | m_startBlock_action->removeFrom( markbar() ); | 976 | m_prog->setFont( progfont ); |
977 | m_endBlock_action->removeFrom( markbar() ); | 977 | if (m_statusishidden) m_prog->hide(); |
978 | } | 978 | if (!reader->m_lastfile.isEmpty()) |
979 | else if (markBar != fileBar) | 979 | { |
980 | { | 980 | //qDebug("doclnk"); |
981 | markBar->clear(); | 981 | //doc = new DocLnk(reader->m_lastfile); |
982 | } | 982 | //qDebug("doclnk done"); |
983 | } | 983 | if (pOpenlist != NULL) |
984 | addmarkbar(config, "Mark", m_mark_action); | 984 | { |
985 | addmarkbar(config, "Annotate", m_annotate_action); | 985 | |
986 | addmarkbar(config, "Goto", m_goto_action); | 986 | /* |
987 | addmarkbar(config, "Delete", m_delete_action); | 987 | int ind = 0; |
988 | addmarkbar(config, "Autogen", m_autogen_action); | 988 | Bkmk* p = (*pOpenlist)[ind]; |
989 | addmarkbar(config, "Clear", m_clear_action); | 989 | while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) |
990 | addmarkbar(config, "Save", m_save_action); | 990 | { |
991 | addmarkbar(config, "Tidy", m_tidy_action); | 991 | p = (*pOpenlist)[++ind]; |
992 | addmarkbar(config, "Start Block", m_startBlock_action); | 992 | } |
993 | addmarkbar(config, "Copy Block", m_endBlock_action); | 993 | */ |
994 | if (checkbar(config, "Annotation indicator")) | 994 | Bkmk* p = NULL; |
995 | { | 995 | for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++) |
996 | if (m_bkmkAvail == NULL) | 996 | { |
997 | { | 997 | p = iter.pContent(); |
998 | m_bkmkAvail = new QAction( tr( "Annotation" ), geticon( "find" ), QString::null, 0, this, 0 ); | 998 | if (toQString(CFiledata(p->anno()).name()) == reader->m_lastfile) |
999 | connect( m_bkmkAvail, SIGNAL( activated() ), this, SLOT( showAnnotation() ) ); | 999 | { |
1000 | 1000 | break; | |
1001 | m_bkmkAvail->setEnabled(false); | 1001 | } |
1002 | } | 1002 | // qDebug("Item:%s", (const char*)toQString(CFiledata(p->anno()).name())); |
1003 | QLabel *spacer = new QLabel(markBar, ""); | 1003 | p = NULL; |
1004 | markbar()->setStretchableWidget(spacer); | 1004 | } |
1005 | m_bkmkAvail->removeFrom( markbar() ); | 1005 | if (p != NULL) |
1006 | m_bkmkAvail->addTo( markbar() ); | 1006 | { |
1007 | } | 1007 | if (!openfrombkmk(p)) |
1008 | else | 1008 | { |
1009 | { | 1009 | showEditTools(); |
1010 | if (m_bkmkAvail != NULL) | 1010 | } |
1011 | { | 1011 | } |
1012 | m_bkmkAvail->removeFrom( markbar() ); | 1012 | else |
1013 | delete m_bkmkAvail; | 1013 | { |
1014 | m_bkmkAvail = NULL; | 1014 | openFile( reader->m_lastfile ); |
1015 | } | 1015 | } |
1016 | } | 1016 | } |
1017 | } | 1017 | else |
1018 | 1018 | { | |
1019 | bool QTReaderApp::checkbar(Config* _config, const QString& key) | 1019 | if (!reader->m_lastfile.isEmpty()) |
1020 | { | 1020 | { |
1021 | return _config->readBoolEntry(key, false); | 1021 | openFile( reader->m_lastfile ); |
1022 | } | 1022 | } |
1023 | 1023 | } | |
1024 | 1024 | } | |
1025 | QToolBar* QTReaderApp::filebar() | 1025 | else |
1026 | { | 1026 | { |
1027 | if (fileBar == NULL) | 1027 | showEditTools(); |
1028 | { | 1028 | } |
1029 | switch (m_tbpol) | 1029 | // qApp->processEvents(); |
1030 | { | 1030 | if (m_scrollbar == NULL || m_scrollbar->isHidden()) |
1031 | case cesSingle: | 1031 | { |
1032 | // odebug << "Setting filebar to menubar" << oendl; | 1032 | reader->m_scrollpos = m_localscroll; |
1033 | fileBar = menubar; | 1033 | } |
1034 | break; | 1034 | else |
1035 | default: | 1035 | { |
1036 | odebug << "Incorrect toolbar policy set" << oendl; | 1036 | reader->m_scrollpos = (m_qtscroll == 0) ? m_localscroll : 0; |
1037 | case cesMenuTool: | 1037 | } |
1038 | case cesMultiple: | 1038 | reader->bDoUpdates = true; |
1039 | // odebug << "Creating new file bar" << oendl; | 1039 | reader->update(); |
1040 | fileBar = new QToolBar("File", this, m_tbposition); | 1040 | config.setGroup("Version"); |
1041 | break; | 1041 | int major = config.readNumEntry("Major", 0); |
1042 | } | 1042 | int bkmktype = config.readNumEntry("BkmkType", 0); |
1043 | // fileBar->setHorizontalStretchable( true ); | 1043 | char minor = config.readNumEntry("Minor", 0); |
1044 | } | 1044 | if (CheckVersion(major, bkmktype, minor)) |
1045 | return fileBar; | 1045 | { |
1046 | } | 1046 | config.writeEntry("Major", major); |
1047 | QToolBar* QTReaderApp::viewbar() | 1047 | config.writeEntry("BkmkType", bkmktype); |
1048 | { | 1048 | config.writeEntry("Minor", (int)minor); |
1049 | if (viewBar == NULL) | 1049 | } |
1050 | { | 1050 | // qDebug("finished update"); |
1051 | switch (m_tbpol) | 1051 | if (kmap.isEmpty()) |
1052 | { | 1052 | { |
1053 | case cesMultiple: | 1053 | QMessageBox::warning(this, PROGNAME, "You haven't mapped any keys yet!\n\nYou will be taken to the key\nmapping dialog.\nA few defaults are provided\nbut you can change then to\nsuit yourself.\n\nYou can change the key\nmapping at any time by\nselecting the Settings/Button\noption on the menu."); |
1054 | viewBar = new QToolBar("View", this, m_tbposition); | 1054 | |
1055 | break; | 1055 | m_buttonprefs->mapkey(Qt::NoButton, Key_Up, cesPageUp); |
1056 | default: | 1056 | m_buttonprefs->mapkey(Qt::NoButton, Key_Down, cesPageDown); |
1057 | odebug << "Incorrect toolbar policy set" << oendl; | 1057 | |
1058 | case cesSingle: | 1058 | m_buttonprefs->mapkey(Qt::NoButton, Key_Right, cesZoomIn); |
1059 | case cesMenuTool: | 1059 | m_buttonprefs->mapkey(Qt::NoButton, Key_Left, cesZoomOut); |
1060 | viewBar = fileBar; | 1060 | |
1061 | break; | 1061 | showbuttonprefs(); |
1062 | } | 1062 | } |
1063 | } | 1063 | } |
1064 | return viewBar; | 1064 | |
1065 | } | 1065 | void QTReaderApp::addtoolbars(Config* config) |
1066 | QToolBar* QTReaderApp::navbar() | 1066 | { |
1067 | { | 1067 | config->setGroup("Toolbar"); |
1068 | if (navBar == NULL) | 1068 | |
1069 | { | 1069 | if (fileBar != NULL) |
1070 | switch (m_tbpol) | 1070 | { |
1071 | { | 1071 | #ifdef USEQPE |
1072 | case cesMultiple: | 1072 | if (fileBar != menubar) |
1073 | // odebug << "Creating new nav bar" << oendl; | 1073 | { |
1074 | navBar = new QToolBar("Navigation", this, m_tbposition); | 1074 | fileBar->clear(); |
1075 | break; | 1075 | } |
1076 | default: | 1076 | else |
1077 | odebug << "Incorrect toolbar policy set" << oendl; | 1077 | { |
1078 | case cesSingle: | 1078 | m_preferences_action->removeFrom( filebar() ); |
1079 | case cesMenuTool: | 1079 | m_open_action->removeFrom( filebar() ); |
1080 | navBar = fileBar; | 1080 | m_close_action->removeFrom( filebar() ); |
1081 | // odebug << "Setting navbar to filebar" << oendl; | 1081 | m_info_action->removeFrom( filebar() ); |
1082 | break; | 1082 | m_touch_action->removeFrom( filebar() ); |
1083 | } | 1083 | m_find_action->removeFrom( filebar() ); |
1084 | } | 1084 | } |
1085 | return navBar; | 1085 | #else |
1086 | } | 1086 | fileBar->clear(); |
1087 | QToolBar* QTReaderApp::markbar() | 1087 | #endif |
1088 | { | 1088 | } |
1089 | if (markBar == NULL) | 1089 | |
1090 | { | 1090 | m_preferences_action->addTo( filebar() ); |
1091 | switch (m_tbpol) | 1091 | addfilebar(config, "Open", m_open_action); |
1092 | { | 1092 | addfilebar(config, "Close", m_close_action); |
1093 | case cesMultiple: | 1093 | addfilebar(config, "Info", m_info_action); |
1094 | markBar = new QToolBar("Marks", this, m_tbposition); | 1094 | addfilebar(config, "Two/One Touch", m_touch_action); |
1095 | break; | 1095 | addfilebar(config, "Find", m_find_action); |
1096 | default: | 1096 | |
1097 | odebug << "Incorrect toolbar policy set" << oendl; | 1097 | if (navBar != NULL) |
1098 | case cesSingle: | 1098 | { |
1099 | case cesMenuTool: | 1099 | #ifdef USEQPE |
1100 | markBar = fileBar; | 1100 | if ((navBar == fileBar) && (fileBar == menubar)) |
1101 | break; | 1101 | #else |
1102 | } | 1102 | if (navBar == fileBar) |
1103 | } | 1103 | #endif |
1104 | return markBar; | 1104 | { |
1105 | } | 1105 | m_scrollButton->removeFrom( navbar() ); |
1106 | 1106 | m_start_action->removeFrom( navbar() ); | |
1107 | void QTReaderApp::addfilebar(Config* _config, const QString& key, QAction* a) | 1107 | m_end_action->removeFrom( navbar() ); |
1108 | { | 1108 | m_jump_action->removeFrom( navbar() ); |
1109 | if (_config->readBoolEntry(key, false)) a->addTo( filebar() ); | 1109 | m_pageline_action->removeFrom( navbar() ); |
1110 | } | 1110 | m_pageup_action->removeFrom( navbar() ); |
1111 | void QTReaderApp::addnavbar(Config* _config, const QString& key, QAction* a) | 1111 | m_pagedn_action->removeFrom( navbar() ); |
1112 | { | 1112 | m_back_action->removeFrom( navbar() ); |
1113 | if (_config->readBoolEntry(key, false)) a->addTo( navbar() ); | 1113 | m_home_action->removeFrom( navbar() ); |
1114 | } | 1114 | m_forward_action->removeFrom( navbar() ); |
1115 | void QTReaderApp::addmarkbar(Config* _config, const QString& key, QAction* a) | 1115 | } |
1116 | { | 1116 | else if (navBar != fileBar) |
1117 | if (_config->readBoolEntry(key, false)) a->addTo( markbar() ); | 1117 | { |
1118 | } | 1118 | navBar->clear(); |
1119 | void QTReaderApp::addviewbar(Config* _config, const QString& key, QAction* a) | 1119 | } |
1120 | { | 1120 | } |
1121 | if (_config->readBoolEntry(key, false)) a->addTo( viewbar() ); | 1121 | |
1122 | } | 1122 | addnavbar(config, "Scroll", m_scrollButton); |
1123 | 1123 | addnavbar(config, "Goto Start", m_start_action); | |
1124 | void QTReaderApp::suspend() { reader->suspend(); } | 1124 | addnavbar(config, "Goto End", m_end_action); |
1125 | 1125 | ||
1126 | #ifdef USEMSGS | 1126 | addnavbar(config, "Jump", m_jump_action); |
1127 | void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | 1127 | addnavbar(config, "Page/Line Scroll", m_pageline_action); |
1128 | { | 1128 | |
1129 | QString msg = QString::fromUtf8(_msg); | 1129 | addnavbar(config, "Page Up", m_pageup_action); |
1130 | 1130 | addnavbar(config, "Page Down", m_pagedn_action); | |
1131 | //// odebug << "Received:" << msg << "" << oendl; | 1131 | |
1132 | 1132 | addnavbar(config, "Back", m_back_action); | |
1133 | QDataStream stream( _data, IO_ReadOnly ); | 1133 | addnavbar(config, "Home", m_home_action); |
1134 | if ( msg == "info(QString)" ) | 1134 | addnavbar(config, "Forward", m_forward_action); |
1135 | { | 1135 | |
1136 | QString info; | 1136 | if (viewBar != NULL) |
1137 | stream >> info; | 1137 | { |
1138 | QMessageBox::information(this, PROGNAME, info); | 1138 | #ifdef USEQPE |
1139 | } | 1139 | if ((viewBar == fileBar) && (fileBar == menubar)) |
1140 | else if ( msg == "Update(int)" ) | 1140 | #else |
1141 | { | 1141 | if (viewBar == fileBar) |
1142 | int info; | 1142 | #endif |
1143 | stream >> info; | 1143 | { |
1144 | if (info) | 1144 | m_actFullscreen->removeFrom( filebar() ); |
1145 | { | 1145 | m_rotate_action->removeFrom( viewbar() ); |
1146 | reader->bDoUpdates = true; | 1146 | m_inverse_action->removeFrom( viewbar() ); |
1147 | reader->refresh(); | 1147 | m_zoomin_action->removeFrom( viewbar() ); |
1148 | } | 1148 | m_zoomout_action->removeFrom( viewbar() ); |
1149 | else | 1149 | m_setfont_action->removeFrom( viewbar() ); |
1150 | { | 1150 | m_setenc_action->removeFrom( viewbar() ); |
1151 | reader->bDoUpdates = false; | 1151 | m_setmono_action->removeFrom( viewbar() ); |
1152 | } | 1152 | } |
1153 | } | 1153 | else if (viewBar != fileBar) |
1154 | else if ( msg == "warn(QString)" ) | 1154 | { |
1155 | { | 1155 | viewBar->clear(); |
1156 | QString info; | 1156 | } |
1157 | stream >> info; | 1157 | } |
1158 | QMessageBox::warning(this, PROGNAME, info); | 1158 | |
1159 | } | 1159 | addviewbar(config, "Fullscreen", m_actFullscreen); |
1160 | else if ( msg == "exit()" ) | 1160 | addviewbar(config, "Rotate", m_rotate_action); |
1161 | { | 1161 | addviewbar(config, "Invert Action", m_inverse_action); |
1162 | m_dontSave = true; | 1162 | addviewbar(config, "Zoom In", m_zoomin_action); |
1163 | close(); | 1163 | addviewbar(config, "Zoom Out", m_zoomout_action); |
1164 | } | 1164 | addviewbar(config, "Set Font", m_setfont_action); |
1165 | else if ( msg == "pageDown()" ) | 1165 | addviewbar(config, "Encoding Select", m_setenc_action); |
1166 | { | 1166 | addviewbar(config, "Ideogram Mode", m_setmono_action); |
1167 | reader->dopagedn(); | 1167 | |
1168 | } | 1168 | if (markBar != NULL) |
1169 | else if ( msg == "pageUp()" ) | 1169 | { |
1170 | { | 1170 | #ifdef USEQPE |
1171 | reader->dopageup(); | 1171 | if ((markBar == fileBar) && (fileBar == menubar)) |
1172 | } | 1172 | #else |
1173 | else if ( msg == "lineDown()" ) | 1173 | if (markBar == fileBar) |
1174 | { | 1174 | #endif |
1175 | reader->lineDown(); | 1175 | { |
1176 | } | 1176 | m_mark_action->removeFrom( markbar() ); |
1177 | else if ( msg == "lineUp()" ) | 1177 | m_annotate_action->removeFrom( markbar()); |
1178 | { | 1178 | m_goto_action->removeFrom( markbar() ); |
1179 | reader->lineUp(); | 1179 | m_delete_action->removeFrom( markbar() ); |
1180 | } | 1180 | m_autogen_action->removeFrom( markbar() ); |
1181 | else if ( msg == "showText()" ) | 1181 | m_clear_action->removeFrom( markbar() ); |
1182 | { | 1182 | m_save_action->removeFrom( markbar() ); |
1183 | showEditTools(); | 1183 | m_tidy_action->removeFrom( markbar() ); |
1184 | } | 1184 | m_startBlock_action->removeFrom( markbar() ); |
1185 | else if ( msg == "home()" ) | 1185 | m_endBlock_action->removeFrom( markbar() ); |
1186 | { | 1186 | } |
1187 | reader->goHome(); | 1187 | else if (markBar != fileBar) |
1188 | } | 1188 | { |
1189 | else if ( msg == "back()" ) | 1189 | markBar->clear(); |
1190 | { | 1190 | } |
1191 | reader->goBack(); | 1191 | } |
1192 | } | 1192 | addmarkbar(config, "Mark", m_mark_action); |
1193 | else if ( msg == "forward()" ) | 1193 | addmarkbar(config, "Annotate", m_annotate_action); |
1194 | { | 1194 | addmarkbar(config, "Goto", m_goto_action); |
1195 | reader->goForward(); | 1195 | addmarkbar(config, "Delete", m_delete_action); |
1196 | } | 1196 | addmarkbar(config, "Autogen", m_autogen_action); |
1197 | else if ( msg == "File/Open(QString)" ) | 1197 | addmarkbar(config, "Clear", m_clear_action); |
1198 | { | 1198 | addmarkbar(config, "Save", m_save_action); |
1199 | QString info; | 1199 | addmarkbar(config, "Tidy", m_tidy_action); |
1200 | stream >> info; | 1200 | addmarkbar(config, "Start Block", m_startBlock_action); |
1201 | openFile( info ); | 1201 | addmarkbar(config, "Copy Block", m_endBlock_action); |
1202 | } | 1202 | if (checkbar(config, "Annotation indicator")) |
1203 | else if ( msg == "File/Info()" ) | 1203 | { |
1204 | { | 1204 | if (m_bkmkAvail == NULL) |
1205 | showinfo(); | 1205 | { |
1206 | } | 1206 | m_bkmkAvail = new QAction( tr( "Annotation" ), geticon( "find" ), QString::null, 0, this, 0 ); |
1207 | else if ( msg == "File/Action(QString)" ) | 1207 | connect( m_bkmkAvail, SIGNAL( activated() ), this, SLOT( showAnnotation() ) ); |
1208 | { | 1208 | |
1209 | QString info; | 1209 | m_bkmkAvail->setEnabled(false); |
1210 | stream >> info; | 1210 | } |
1211 | m_spaceTarget = ActNameToInt(info); | 1211 | QLabel *spacer = new QLabel(markBar, ""); |
1212 | } | 1212 | markbar()->setStretchableWidget(spacer); |
1213 | else if ( msg == "Navigation/Scroll(int)" ) | 1213 | m_bkmkAvail->removeFrom( markbar() ); |
1214 | { | 1214 | m_bkmkAvail->addTo( markbar() ); |
1215 | int info; | 1215 | } |
1216 | stream >> info; | 1216 | else |
1217 | autoScroll(info); | 1217 | { |
1218 | } | 1218 | if (m_bkmkAvail != NULL) |
1219 | 1219 | { | |
1220 | else if ( msg == "Navigation/GotoStart()" ) | 1220 | m_bkmkAvail->removeFrom( markbar() ); |
1221 | { | 1221 | delete m_bkmkAvail; |
1222 | gotoStart(); | 1222 | m_bkmkAvail = NULL; |
1223 | } | 1223 | } |
1224 | else if ( msg == "Navigation/GotoEnd()" ) | 1224 | } |
1225 | { | 1225 | } |
1226 | gotoEnd(); | 1226 | |
1227 | } | 1227 | bool QTReaderApp::checkbar(Config* _config, const QString& key) |
1228 | else if ( msg == "Navigation/Jump(int)" ) | 1228 | { |
1229 | { | 1229 | return _config->readBoolEntry(key, false); |
1230 | int info; | 1230 | } |
1231 | stream >> info; | 1231 | |
1232 | reader->locate(info); | 1232 | |
1233 | } | 1233 | QToolBar* QTReaderApp::filebar() |
1234 | else if ( msg == "Navigation/Page/LineScroll(int)" ) | 1234 | { |
1235 | { | 1235 | if (fileBar == NULL) |
1236 | int info; | 1236 | { |
1237 | stream >> info; | 1237 | switch (m_tbpol) |
1238 | pagemode(info); | 1238 | { |
1239 | } | 1239 | #ifdef USEQPE |
1240 | else if ( msg == "Navigation/SetOverlap(int)" ) | 1240 | case cesSingle: |
1241 | { | 1241 | // qDebug("Setting filebar to menubar"); |
1242 | int info; | 1242 | fileBar = menubar; |
1243 | stream >> info; | 1243 | break; |
1244 | reader->m_overlap = info; | 1244 | #endif |
1245 | } | 1245 | default: |
1246 | else if ( msg == "Navigation/SetMargin(int)" ) | 1246 | qDebug("Incorrect toolbar policy set"); |
1247 | { | 1247 | case cesMenuTool: |
1248 | int info; | 1248 | case cesMultiple: |
1249 | stream >> info; | 1249 | // qDebug("Creating new file bar"); |
1250 | do_margin(info); | 1250 | fileBar = new QToolBar("File", this, m_tbposition); |
1251 | } | 1251 | break; |
1252 | else if ( msg == "File/SetDictionary(QString)" ) | 1252 | } |
1253 | { | 1253 | //fileBar->setHorizontalStretchable( true ); |
1254 | QString info; | 1254 | } |
1255 | stream >> info; | 1255 | return fileBar; |
1256 | do_settarget(info); | 1256 | } |
1257 | } | 1257 | QToolBar* QTReaderApp::viewbar() |
1258 | #ifdef _SCROLLPIPE | 1258 | { |
1259 | else if ( msg == "File/SetScrollTarget(QString)" ) | 1259 | if (viewBar == NULL) |
1260 | { | 1260 | { |
1261 | QString info; | 1261 | switch (m_tbpol) |
1262 | stream >> info; | 1262 | { |
1263 | reader->m_pipetarget = info; | 1263 | case cesMultiple: |
1264 | } | 1264 | viewBar = new QToolBar("View", this, m_tbposition); |
1265 | #endif | 1265 | break; |
1266 | else if ( msg == "File/Two/OneTouch(int)" ) | 1266 | default: |
1267 | { | 1267 | qDebug("Incorrect toolbar policy set"); |
1268 | int info; | 1268 | #ifdef USEQPE |
1269 | stream >> info; | 1269 | case cesSingle: |
1270 | setTwoTouch(info); | 1270 | #endif |
1271 | } | 1271 | case cesMenuTool: |
1272 | else if ( msg == "Target/Annotation(int)" ) | 1272 | viewBar = fileBar; |
1273 | { | 1273 | break; |
1274 | int info; | 1274 | } |
1275 | stream >> info; | 1275 | } |
1276 | OnAnnotation(info); | 1276 | return viewBar; |
1277 | } | 1277 | } |
1278 | else if ( msg == "Target/Dictionary(int)" ) | 1278 | QToolBar* QTReaderApp::navbar() |
1279 | { | 1279 | { |
1280 | int info; | 1280 | if (navBar == NULL) |
1281 | stream >> info; | 1281 | { |
1282 | OnDictionary(info); | 1282 | switch (m_tbpol) |
1283 | } | 1283 | { |
1284 | else if ( msg == "Target/Clipboard(int)" ) | 1284 | case cesMultiple: |
1285 | { | 1285 | // qDebug("Creating new nav bar"); |
1286 | int info; | 1286 | navBar = new QToolBar("Navigation", this, m_tbposition); |
1287 | stream >> info; | 1287 | break; |
1288 | OnClipboard(info); | 1288 | default: |
1289 | } | 1289 | qDebug("Incorrect toolbar policy set"); |
1290 | else if ( msg == "File/Find(QString)" ) | 1290 | #ifdef USEQPE |
1291 | { | 1291 | case cesSingle: |
1292 | QString info; | 1292 | #endif |
1293 | stream >> info; | 1293 | case cesMenuTool: |
1294 | QRegExp arg(info); | 1294 | navBar = fileBar; |
1295 | size_t pos = reader->pagelocate(); | 1295 | // qDebug("Setting navbar to filebar"); |
1296 | size_t start = pos; | 1296 | break; |
1297 | CDrawBuffer test(&(reader->m_fontControl)); | 1297 | } |
1298 | reader->getline(&test); | 1298 | } |
1299 | while (arg.match(toQString(test.data())) == -1) | 1299 | return navBar; |
1300 | { | 1300 | } |
1301 | pos = reader->locate(); | 1301 | QToolBar* QTReaderApp::markbar() |
1302 | if (!reader->getline(&test)) | 1302 | { |
1303 | { | 1303 | if (markBar == NULL) |
1304 | QMessageBox::information(this, PROGNAME, QString("Can't find\n")+info); | 1304 | { |
1305 | pos = start; | 1305 | switch (m_tbpol) |
1306 | break; | 1306 | { |
1307 | } | 1307 | case cesMultiple: |
1308 | } | 1308 | markBar = new QToolBar("Marks", this, m_tbposition); |
1309 | reader->locate(pos); | 1309 | break; |
1310 | } | 1310 | default: |
1311 | else if ( msg == "File/Fullscreen(int)" ) | 1311 | qDebug("Incorrect toolbar policy set"); |
1312 | { | 1312 | #ifdef USEQPE |
1313 | int info; | 1313 | case cesSingle: |
1314 | stream >> info; | 1314 | #endif |
1315 | setfullscreen(info); | 1315 | case cesMenuTool: |
1316 | } | 1316 | markBar = fileBar; |
1317 | else if ( msg == "File/Continuous(int)" ) | 1317 | break; |
1318 | { | 1318 | } |
1319 | int info; | 1319 | } |
1320 | stream >> info; | 1320 | return markBar; |
1321 | setcontinuous(info); | 1321 | } |
1322 | } | 1322 | |
1323 | else if ( msg == "Markup(QString)" ) | 1323 | void QTReaderApp::addfilebar(Config* _config, const QString& key, QAction* a) |
1324 | { | 1324 | { |
1325 | QString info; | 1325 | if (_config->readBoolEntry(key, false)) a->addTo( filebar() ); |
1326 | stream >> info; | 1326 | } |
1327 | if (info == "Auto") | 1327 | void QTReaderApp::addnavbar(Config* _config, const QString& key, QAction* a) |
1328 | { | 1328 | { |
1329 | autofmt(true); | 1329 | if (_config->readBoolEntry(key, false)) a->addTo( navbar() ); |
1330 | } | 1330 | } |
1331 | if (info == "None") | 1331 | void QTReaderApp::addmarkbar(Config* _config, const QString& key, QAction* a) |
1332 | { | 1332 | { |
1333 | autofmt(false); | 1333 | if (_config->readBoolEntry(key, false)) a->addTo( markbar() ); |
1334 | textfmt(false); | 1334 | } |
1335 | striphtml(false); | 1335 | void QTReaderApp::addviewbar(Config* _config, const QString& key, QAction* a) |
1336 | peanut(false); | 1336 | { |
1337 | } | 1337 | if (_config->readBoolEntry(key, false)) a->addTo( viewbar() ); |
1338 | if (info == "Text") | 1338 | } |
1339 | { | 1339 | |
1340 | textfmt(true); | 1340 | void QTReaderApp::suspend() { reader->suspend(); } |
1341 | } | 1341 | |
1342 | if (info == "HTML") | 1342 | void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) |
1343 | { | 1343 | { |
1344 | striphtml(true); | 1344 | #ifndef USEMSGS |
1345 | } | 1345 | return; |
1346 | if (info == "Peanut/PML") | 1346 | #else |
1347 | { | 1347 | QString msg = QString::fromUtf8(_msg); |
1348 | peanut(true); | 1348 | |
1349 | } | 1349 | qDebug("Received:%s", (const char*)msg); |
1350 | } | 1350 | QDataStream stream( _data, IO_ReadOnly ); |
1351 | else if ( msg == "Layout/StripCR(int)" ) | 1351 | if ( msg == "suspend()" ) |
1352 | { | 1352 | { |
1353 | int info; | 1353 | qDebug("Suspending"); |
1354 | stream >> info; | 1354 | suspend(); |
1355 | stripcr(info); | 1355 | qDebug("Suspendedb"); |
1356 | } | 1356 | } |
1357 | else if ( msg == "Layout/Dehyphen(int)" ) | 1357 | return; |
1358 | { | 1358 | /* |
1359 | int info; | 1359 | QDataStream stream( _data, IO_ReadOnly ); |
1360 | stream >> info; | 1360 | if ( msg == "info(QString)" ) |
1361 | dehyphen(info); | 1361 | { |
1362 | } | 1362 | QString info; |
1363 | else if ( msg == "Layout/Depluck(int)" ) | 1363 | stream >> info; |
1364 | { | 1364 | QMessageBox::information(this, PROGNAME, info); |
1365 | int info; | 1365 | } |
1366 | stream >> info; | 1366 | else if ( msg == "Update(int)" ) |
1367 | depluck(info); | 1367 | { |
1368 | } | 1368 | int info; |
1369 | else if ( msg == "Layout/Dejpluck(int)" ) | 1369 | stream >> info; |
1370 | { | 1370 | if (info) |
1371 | int info; | 1371 | { |
1372 | stream >> info; | 1372 | reader->bDoUpdates = true; |
1373 | dejpluck(info); | 1373 | reader->refresh(); |
1374 | } | 1374 | } |
1375 | else if ( msg == "Layout/SingleSpace(int)" ) | 1375 | else |
1376 | { | 1376 | { |
1377 | int info; | 1377 | reader->bDoUpdates = false; |
1378 | stream >> info; | 1378 | } |
1379 | onespace(info); | 1379 | } |
1380 | } | 1380 | else if ( msg == "warn(QString)" ) |
1381 | #ifdef REPALM | 1381 | { |
1382 | else if ( msg == "Layout/Repalm(int)" ) | 1382 | QString info; |
1383 | { | 1383 | stream >> info; |
1384 | int info; | 1384 | QMessageBox::warning(this, PROGNAME, info); |
1385 | stream >> info; | 1385 | } |
1386 | repalm(info); | 1386 | else if ( msg == "exit()" ) |
1387 | } | 1387 | { |
1388 | #endif | 1388 | m_dontSave = true; |
1389 | else if ( msg == "Layout/Unindent(int)" ) | 1389 | close(); |
1390 | { | 1390 | } |
1391 | int info; | 1391 | else if ( msg == "pageDown()" ) |
1392 | stream >> info; | 1392 | { |
1393 | unindent(info); | 1393 | reader->dopagedn(); |
1394 | } | 1394 | } |
1395 | else if ( msg == "Layout/Re-paragraph(int)" ) | 1395 | else if ( msg == "pageUp()" ) |
1396 | { | 1396 | { |
1397 | int info; | 1397 | reader->dopageup(); |
1398 | stream >> info; | 1398 | } |
1399 | repara(info); | 1399 | else if ( msg == "lineDown()" ) |
1400 | } | 1400 | { |
1401 | else if ( msg == "Layout/DoubleSpace(int)" ) | 1401 | reader->lineDown(); |
1402 | { | 1402 | } |
1403 | int info; | 1403 | else if ( msg == "lineUp()" ) |
1404 | stream >> info; | 1404 | { |
1405 | dblspce(info); | 1405 | reader->lineUp(); |
1406 | } | 1406 | } |
1407 | else if ( msg == "Layout/Indent(int)" ) | 1407 | else if ( msg == "showText()" ) |
1408 | { | 1408 | { |
1409 | int info; | 1409 | showEditTools(); |
1410 | stream >> info; | 1410 | } |
1411 | reader->bindenter = info; | 1411 | else if ( msg == "home()" ) |
1412 | reader->setfilter(reader->getfilter()); | 1412 | { |
1413 | } | 1413 | reader->goHome(); |
1414 | else if ( msg == "Layout/Remap(int)" ) | 1414 | } |
1415 | { | 1415 | else if ( msg == "back()" ) |
1416 | int info; | 1416 | { |
1417 | stream >> info; | 1417 | reader->goBack(); |
1418 | remap(info); | 1418 | } |
1419 | } | 1419 | else if ( msg == "forward()" ) |
1420 | else if ( msg == "Layout/Embolden(int)" ) | 1420 | { |
1421 | { | 1421 | reader->goForward(); |
1422 | int info; | 1422 | } |
1423 | stream >> info; | 1423 | else if ( msg == "File/Open(QString)" ) |
1424 | embolden(info); | 1424 | { |
1425 | } | 1425 | QString info; |
1426 | else if ( msg == "Format/Ideogram/Word(int)" ) | 1426 | stream >> info; |
1427 | { | 1427 | openFile( info ); |
1428 | int info; | 1428 | } |
1429 | stream >> info; | 1429 | else if ( msg == "File/Info()" ) |
1430 | monospace(info); | 1430 | { |
1431 | } | 1431 | showinfo(); |
1432 | else if ( msg == "Format/SetWidth(int)" ) | 1432 | } |
1433 | { | 1433 | else if ( msg == "File/Action(QString)" ) |
1434 | int info; | 1434 | { |
1435 | stream >> info; | 1435 | QString info; |
1436 | reader->m_charpc = info; | 1436 | stream >> info; |
1437 | reader->setfont(); | 1437 | m_spaceTarget = ActNameToInt(info); |
1438 | reader->refresh(); | 1438 | } |
1439 | } | 1439 | else if ( msg == "Navigation/Scroll(int)" ) |
1440 | else if ( msg == "Format/SetFont(QString,int)" ) | 1440 | { |
1441 | { | 1441 | int info; |
1442 | QString fontname; | 1442 | stream >> info; |
1443 | int size; | 1443 | autoScroll(info); |
1444 | stream >> fontname; | 1444 | } |
1445 | stream >> size; | 1445 | |
1446 | setfontHelper(fontname, size); | 1446 | else if ( msg == "Navigation/GotoStart()" ) |
1447 | } | 1447 | { |
1448 | else if ( msg == "Marks/Autogen(QString)" ) | 1448 | gotoStart(); |
1449 | { | 1449 | } |
1450 | QString info; | 1450 | else if ( msg == "Navigation/GotoEnd()" ) |
1451 | stream >> info; | 1451 | { |
1452 | do_autogen(info); | 1452 | gotoEnd(); |
1453 | } | 1453 | } |
1454 | else if ( msg == "File/StartBlock()" ) | 1454 | else if ( msg == "Navigation/Jump(int)" ) |
1455 | { | 1455 | { |
1456 | editMark(); | 1456 | int info; |
1457 | } | 1457 | stream >> info; |
1458 | else if ( msg == "File/CopyBlock()" ) | 1458 | reader->locate(info); |
1459 | { | 1459 | } |
1460 | editCopy(); | 1460 | else if ( msg == "Navigation/Page/LineScroll(int)" ) |
1461 | } | 1461 | { |
1462 | } | 1462 | int info; |
1463 | #endif | 1463 | stream >> info; |
1464 | ActionTypes QTReaderApp::ActNameToInt(const QString& _enc) | 1464 | pagemode(info); |
1465 | { | 1465 | } |
1466 | for (int i = 0; i < MAX_ACTIONS; i++) | 1466 | else if ( msg == "Navigation/SetOverlap(int)" ) |
1467 | { | 1467 | { |
1468 | if (m_buttonAction[i]->text() == _enc) return (ActionTypes)i; | 1468 | int info; |
1469 | } | 1469 | stream >> info; |
1470 | return cesAutoScroll; | 1470 | reader->m_overlap = info; |
1471 | } | 1471 | } |
1472 | 1472 | else if ( msg == "Navigation/SetMargin(int)" ) | |
1473 | void QTReaderApp::setfullscreen(bool sfs) | 1473 | { |
1474 | { | 1474 | int info; |
1475 | reader->bDoUpdates = false; | 1475 | stream >> info; |
1476 | m_fullscreen = sfs; | 1476 | do_margin(info); |
1477 | showEditTools(); | 1477 | } |
1478 | // qApp->processEvents(); | 1478 | else if ( msg == "File/SetDictionary(QString)" ) |
1479 | reader->bDoUpdates = true; | 1479 | { |
1480 | reader->update(); | 1480 | QString info; |
1481 | } | 1481 | stream >> info; |
1482 | 1482 | do_settarget(info); | |
1483 | void QTReaderApp::buttonActionSelected(QAction* _a) | 1483 | } |
1484 | { | 1484 | #ifdef _SCROLLPIPE |
1485 | //// odebug << "es:" << _a << " : " << (const char *)(_a->text()) << " (" << ActNameToInt(_a->text()) << ")" << oendl; | 1485 | else if ( msg == "File/SetScrollTarget(QString)" ) |
1486 | m_spaceTarget = ActNameToInt(_a->text()); | 1486 | { |
1487 | } | 1487 | QString info; |
1488 | 1488 | stream >> info; | |
1489 | QTReaderApp::~QTReaderApp() | 1489 | reader->m_pipetarget = info; |
1490 | { | 1490 | } |
1491 | } | 1491 | #endif |
1492 | 1492 | else if ( msg == "File/Two/OneTouch(int)" ) | |
1493 | void QTReaderApp::autoScroll(bool _b) | 1493 | { |
1494 | { | 1494 | int info; |
1495 | reader->setautoscroll(_b); | 1495 | stream >> info; |
1496 | setScrollState(reader->m_autoScroll); | 1496 | setTwoTouch(info); |
1497 | } | 1497 | } |
1498 | 1498 | else if ( msg == "Target/Annotation(int)" ) | |
1499 | void QTReaderApp::zoomin() | 1499 | { |
1500 | { | 1500 | int info; |
1501 | reader->zoomin(); | 1501 | stream >> info; |
1502 | } | 1502 | OnAnnotation(info); |
1503 | 1503 | } | |
1504 | void QTReaderApp::zoomout() | 1504 | else if ( msg == "Target/Dictionary(int)" ) |
1505 | { | 1505 | { |
1506 | reader->zoomout(); | 1506 | int info; |
1507 | } | 1507 | stream >> info; |
1508 | 1508 | OnDictionary(info); | |
1509 | void QTReaderApp::clearBkmkList() | 1509 | } |
1510 | { | 1510 | else if ( msg == "Target/Clipboard(int)" ) |
1511 | delete pBkmklist; | 1511 | { |
1512 | pBkmklist = NULL; | 1512 | int info; |
1513 | m_fBkmksChanged = false; | 1513 | stream >> info; |
1514 | } | 1514 | OnClipboard(info); |
1515 | 1515 | } | |
1516 | void QTReaderApp::fileClose() | 1516 | else if ( msg == "File/Find(QString)" ) |
1517 | { | 1517 | { |
1518 | CCloseDialog* cd = new CCloseDialog(reader->m_string, false, this); | 1518 | QString info; |
1519 | if (cd->exec()) | 1519 | stream >> info; |
1520 | { | 1520 | QRegExp arg(info); |
1521 | if (pOpenlist != NULL) | 1521 | size_t pos = reader->pagelocate(); |
1522 | { | 1522 | size_t start = pos; |
1523 | int ind = 0; | 1523 | CDrawBuffer test(&(reader->m_fontControl)); |
1524 | Bkmk* p = (*pOpenlist)[ind]; | 1524 | reader->getline(&test); |
1525 | while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) | 1525 | while (arg.match(toQString(test.data())) == -1) |
1526 | { | 1526 | { |
1527 | p = (*pOpenlist)[++ind]; | 1527 | pos = reader->locate(); |
1528 | } | 1528 | if (!reader->getline(&test)) |
1529 | if (p != NULL) pOpenlist->erase(ind); | 1529 | { |
1530 | if (cd->delFile()) | 1530 | QMessageBox::information(this, PROGNAME, QString("Can't find\n")+info); |
1531 | { | 1531 | pos = start; |
1532 | unlink((const char*)reader->m_lastfile); | 1532 | break; |
1533 | } | 1533 | } |
1534 | if (cd->delMarks()) | 1534 | } |
1535 | { | 1535 | reader->locate(pos); |
1536 | #ifndef USEQPE | 1536 | } |
1537 | QDir d = QDir::home(); // "/" | 1537 | else if ( msg == "File/Fullscreen(int)" ) |
1538 | d.cd(APPDIR); | 1538 | { |
1539 | d.remove(reader->m_string); | 1539 | int info; |
1540 | #else /* USEQPE */ | 1540 | stream >> info; |
1541 | unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string)); | 1541 | setfullscreen(info); |
1542 | #endif /* USEQPE */ | 1542 | } |
1543 | } | 1543 | else if ( msg == "File/Continuous(int)" ) |
1544 | if (cd->delConfig()) | 1544 | { |
1545 | { | 1545 | int info; |
1546 | #ifndef USEQPE | 1546 | stream >> info; |
1547 | QDir d = QDir::home(); // "/" | 1547 | setcontinuous(info); |
1548 | d.cd(APPDIR "/configs"); | 1548 | } |
1549 | d.remove(reader->m_string); | 1549 | else if ( msg == "Markup(QString)" ) |
1550 | #else /* USEQPE */ | 1550 | { |
1551 | unlink((const char *)Global::applicationFileName(APPDIR "/configs",reader->m_string)); | 1551 | QString info; |
1552 | #endif /* USEQPE */ | 1552 | stream >> info; |
1553 | } | 1553 | if (info == "Auto") |
1554 | } | 1554 | { |
1555 | 1555 | autofmt(true); | |
1556 | fileOpen2(); | 1556 | } |
1557 | } | 1557 | if (info == "None") |
1558 | delete cd; | 1558 | { |
1559 | } | 1559 | autofmt(false); |
1560 | 1560 | textfmt(false); | |
1561 | void QTReaderApp::updatefileinfo() | 1561 | striphtml(false); |
1562 | { | 1562 | peanut(false); |
1563 | if (reader->m_string.isEmpty()) return; | 1563 | } |
1564 | if (reader->m_lastfile.isEmpty()) return; | 1564 | if (info == "Text") |
1565 | tchar* nm = fromQString(reader->m_string); | 1565 | { |
1566 | tchar* fl = fromQString(reader->m_lastfile); | 1566 | textfmt(true); |
1567 | // odebug << "Lastfile:" << fl << "" << oendl; | 1567 | } |
1568 | bool notadded = true; | 1568 | if (info == "HTML") |
1569 | if (pOpenlist == NULL) pOpenlist = new CList<Bkmk>; | 1569 | { |
1570 | else | 1570 | striphtml(true); |
1571 | { | 1571 | } |
1572 | for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++) | 1572 | if (info == "Peanut/PML") |
1573 | { | 1573 | { |
1574 | if (ustrcmp(CFiledata(iter->anno()).name(), fl) == 0) | 1574 | peanut(true); |
1575 | { | 1575 | } |
1576 | iter->value(reader->pagelocate()); | 1576 | } |
1577 | unsigned short dlen; | 1577 | else if ( msg == "Layout/StripCR(int)" ) |
1578 | unsigned char* data; | 1578 | { |
1579 | CFiledata fd(iter->anno()); | 1579 | int info; |
1580 | reader->setSaveData(data, dlen, fd.content(), fd.length()); | 1580 | stream >> info; |
1581 | // odebug << "Filedata(1):" << fd.length() << ", " << dlen << "" << oendl; | 1581 | stripcr(info); |
1582 | // getstate(data, dlen); | 1582 | } |
1583 | iter->setAnno(data, dlen); | 1583 | else if ( msg == "Layout/Dehyphen(int)" ) |
1584 | notadded = false; | 1584 | { |
1585 | delete [] data; | 1585 | int info; |
1586 | break; | 1586 | stream >> info; |
1587 | } | 1587 | dehyphen(info); |
1588 | } | 1588 | } |
1589 | } | 1589 | else if ( msg == "Layout/Depluck(int)" ) |
1590 | // odebug << "Added?:" << notadded << "" << oendl; | 1590 | { |
1591 | if (notadded) | 1591 | int info; |
1592 | { | 1592 | stream >> info; |
1593 | struct stat fnstat; | 1593 | depluck(info); |
1594 | stat((const char *)reader->m_lastfile, &fnstat); | 1594 | } |
1595 | CFiledata fd(fnstat.st_mtime, fl); | 1595 | else if ( msg == "Layout/Dejpluck(int)" ) |
1596 | unsigned short dlen; | 1596 | { |
1597 | unsigned char* data; | 1597 | int info; |
1598 | reader->setSaveData(data, dlen, fd.content(), fd.length()); | 1598 | stream >> info; |
1599 | pOpenlist->push_front(Bkmk(nm, data, dlen, reader->pagelocate())); | 1599 | dejpluck(info); |
1600 | // odebug << "Filedata(2):" << fd.length() << ", " << dlen << "" << oendl; | 1600 | } |
1601 | delete [] data; | 1601 | else if ( msg == "Layout/SingleSpace(int)" ) |
1602 | } | 1602 | { |
1603 | delete [] nm; | 1603 | int info; |
1604 | delete [] fl; | 1604 | stream >> info; |
1605 | } | 1605 | onespace(info); |
1606 | 1606 | } | |
1607 | void QTReaderApp::fileOpen() | 1607 | else if ( msg == "Layout/Repalm(int)" ) |
1608 | { | 1608 | { |
1609 | /* | 1609 | int info; |
1610 | menu->hide(); | 1610 | stream >> info; |
1611 | fileBar->hide(); | 1611 | repalm(info); |
1612 | if (regVisible) regBar->hide(); | 1612 | } |
1613 | if (searchVisible) searchBar->hide(); | 1613 | else if ( msg == "Layout/Unindent(int)" ) |
1614 | */ | 1614 | { |
1615 | // odebug << "fileOpen" << oendl; | 1615 | int info; |
1616 | // if (!reader->m_lastfile.isEmpty()) | 1616 | stream >> info; |
1617 | updatefileinfo(); | 1617 | unindent(info); |
1618 | fileOpen2(); | 1618 | } |
1619 | } | 1619 | else if ( msg == "Layout/Re-paragraph(int)" ) |
1620 | 1620 | { | |
1621 | void QTReaderApp::fileOpen2() | 1621 | int info; |
1622 | { | 1622 | stream >> info; |
1623 | if (pBkmklist != NULL) | 1623 | repara(info); |
1624 | { | 1624 | } |
1625 | if (m_fBkmksChanged) | 1625 | else if ( msg == "Layout/DoubleSpace(int)" ) |
1626 | { | 1626 | { |
1627 | if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) | 1627 | int info; |
1628 | savebkmks(); | 1628 | stream >> info; |
1629 | } | 1629 | dblspce(info); |
1630 | delete pBkmklist; | 1630 | } |
1631 | pBkmklist = NULL; | 1631 | else if ( msg == "Layout/Indent(int)" ) |
1632 | m_fBkmksChanged = false; | 1632 | { |
1633 | } | 1633 | int info; |
1634 | reader->disableAutoscroll(); | 1634 | stream >> info; |
1635 | /* | 1635 | reader->bindenter = info; |
1636 | editorStack->raiseWidget( fileSelector ); | 1636 | reader->setfilter(reader->getfilter()); |
1637 | fileSelector->reread(); | 1637 | } |
1638 | */ | 1638 | else if ( msg == "Layout/Remap(int)" ) |
1639 | bool usebrowser = true; | 1639 | { |
1640 | if (pOpenlist != NULL) | 1640 | int info; |
1641 | { | 1641 | stream >> info; |
1642 | m_nBkmkAction = cOpenFile; | 1642 | remap(info); |
1643 | if (listbkmk(pOpenlist, "Browse")) usebrowser = false; | 1643 | } |
1644 | } | 1644 | else if ( msg == "Layout/Embolden(int)" ) |
1645 | if (usebrowser) | 1645 | { |
1646 | { | 1646 | int info; |
1647 | QString fn = usefilebrowser(); | 1647 | stream >> info; |
1648 | // qApp->processEvents(); | 1648 | embolden(info); |
1649 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) | 1649 | } |
1650 | { | 1650 | else if ( msg == "Format/Ideogram/Word(int)" ) |
1651 | openFile(fn); | 1651 | { |
1652 | } | 1652 | int info; |
1653 | reader->setFocus(); | 1653 | stream >> info; |
1654 | } | 1654 | monospace(info); |
1655 | // reader->refresh(); | 1655 | } |
1656 | // odebug << "HEIGHT:" << reader->m_lastheight << "" << oendl; | 1656 | else if ( msg == "Format/SetWidth(int)" ) |
1657 | } | 1657 | { |
1658 | 1658 | int info; | |
1659 | QString QTReaderApp::usefilebrowser() | 1659 | stream >> info; |
1660 | { | 1660 | reader->m_charpc = info; |
1661 | #ifndef USEQPE | 1661 | reader->setfont(); |
1662 | QString s( QFileDialog::getOpenFileName( reader->m_lastfile, QString::null, this ) ); | 1662 | reader->refresh(); |
1663 | return s; | 1663 | } |
1664 | #else | 1664 | else if ( msg == "Format/SetFont(QString,int)" ) |
1665 | fileBrowser* fb = new fileBrowser(false, this,"OpieReader",!m_bFloatingDialog, | 1665 | { |
1666 | 0, | 1666 | QString fontname; |
1667 | // WStyle_Customize | WStyle_NoBorderEx, | 1667 | int size; |
1668 | "*", QFileInfo(reader->m_lastfile).dirPath(true)); | 1668 | stream >> fontname; |
1669 | 1669 | stream >> size; | |
1670 | 1670 | setfontHelper(fontname, size); | |
1671 | QString fn; | 1671 | } |
1672 | if (fb->exec()) | 1672 | else if ( msg == "Marks/Autogen(QString)" ) |
1673 | { | 1673 | { |
1674 | fn = fb->getCurrentFile(); | 1674 | QString info; |
1675 | } | 1675 | stream >> info; |
1676 | // odebug << "Selected " << fn << "" << oendl; | 1676 | do_autogen(info); |
1677 | delete fb; | 1677 | } |
1678 | showEditTools(); | 1678 | else if ( msg == "File/StartBlock()" ) |
1679 | return fn; | 1679 | { |
1680 | #endif | 1680 | editMark(); |
1681 | } | 1681 | } |
1682 | 1682 | else if ( msg == "File/CopyBlock()" ) | |
1683 | void QTReaderApp::showgraphic(QImage& pm) | 1683 | { |
1684 | { | 1684 | editCopy(); |
1685 | QPixmap pc; | 1685 | } |
1686 | pc.convertFromImage(pm); | 1686 | */ |
1687 | m_graphicwin->setPixmap(pc); | 1687 | #endif |
1688 | editorStack->raiseWidget( m_graphicwin ); | 1688 | } |
1689 | m_graphicwin->setFocus(); | 1689 | |
1690 | } | 1690 | ActionTypes QTReaderApp::ActNameToInt(const QString& _enc) |
1691 | 1691 | { | |
1692 | 1692 | for (int i = 0; i < MAX_ACTIONS; i++) | |
1693 | void QTReaderApp::showprefs() | 1693 | { |
1694 | { | 1694 | if (m_buttonAction[i]->text() == _enc) return (ActionTypes)i; |
1695 | CPrefs* prefwin = new CPrefs(!m_bFloatingDialog, this); | 1695 | } |
1696 | 1696 | return cesAutoScroll; | |
1697 | prefwin->twotouch(m_twoTouch); | 1697 | } |
1698 | prefwin->propfontchange(m_propogatefontchange); | 1698 | |
1699 | prefwin->StripCR(reader->bstripcr); | 1699 | void QTReaderApp::setinverted(bool sfs) |
1700 | prefwin->Dehyphen(reader->bdehyphen); | 1700 | { |
1701 | prefwin->SingleSpace(reader->bonespace); | 1701 | reader->setInverse(sfs); |
1702 | prefwin->Unindent(reader->bunindent); | 1702 | reader->setfilter(reader->getfilter()); |
1703 | prefwin->Reparagraph(reader->brepara); | 1703 | reader->refresh(); |
1704 | prefwin->DoubleSpace(reader->bdblspce); | 1704 | } |
1705 | prefwin->Remap(reader->bremap); | 1705 | |
1706 | prefwin->Embolden(reader->bmakebold); | 1706 | void QTReaderApp::setrotated(bool sfs) |
1707 | prefwin->FullJustify(reader->bfulljust); | 1707 | { |
1708 | prefwin->ParaLead(reader->getextraspace()); | 1708 | reader->setrotated(sfs); |
1709 | prefwin->LineLead(reader->getlead()); | 1709 | if (sfs) |
1710 | prefwin->Margin(reader->m_border); | 1710 | { |
1711 | prefwin->Indent(reader->bindenter); | 1711 | m_layout->setDirection( (m_qtscroll == 2) ? QBoxLayout::BottomToTop : QBoxLayout::TopToBottom ); |
1712 | if (reader->bautofmt) | 1712 | if (m_scrollbar != NULL) |
1713 | { | 1713 | { |
1714 | prefwin->Markup(0); | 1714 | scrollbar->disconnect(); |
1715 | } | 1715 | m_scrollbar->setOrientation(Qt::Horizontal); |
1716 | else if (reader->btextfmt) | 1716 | connect(scrollbar, SIGNAL(nextLine()), reader, SLOT(lineUp()) ); |
1717 | { | 1717 | connect(scrollbar, SIGNAL(prevLine()), reader, SLOT(lineDown()) ); |
1718 | prefwin->Markup(2); | 1718 | connect(scrollbar, SIGNAL(nextPage()), reader, SLOT(dopageup()) ); |
1719 | } | 1719 | connect(scrollbar, SIGNAL(prevPage()), reader, SLOT(dopagedn()) ); |
1720 | else if (reader->bstriphtml) | 1720 | connect(scrollbar, SIGNAL(sliderMoved(int)), this, SLOT(actionscroll(int)) ); |
1721 | { | 1721 | } |
1722 | prefwin->Markup(3); | 1722 | //reader->repaint(0, reader->m_left_border, reader->width(), reader->height()-2*reader->m_border); |
1723 | } | 1723 | reader->repaint(); |
1724 | else if (reader->bpeanut) | 1724 | } |
1725 | { | 1725 | else |
1726 | prefwin->Markup(4); | 1726 | { |
1727 | } | 1727 | m_layout->setDirection( (m_qtscroll == 2) ? QBoxLayout::RightToLeft : QBoxLayout::LeftToRight ); |
1728 | else | 1728 | if (m_scrollbar != NULL) |
1729 | { | 1729 | { |
1730 | prefwin->Markup(1); | 1730 | scrollbar->disconnect(); |
1731 | } | 1731 | m_scrollbar->setOrientation(Qt::Vertical); |
1732 | prefwin->Depluck(reader->bdepluck); | 1732 | connect(scrollbar, SIGNAL(nextLine()), reader, SLOT(lineDown()) ); |
1733 | prefwin->Dejpluck(reader->bdejpluck); | 1733 | connect(scrollbar, SIGNAL(prevLine()), reader, SLOT(lineUp()) ); |
1734 | prefwin->Continuous(reader->m_continuousDocument); | 1734 | connect(scrollbar, SIGNAL(nextPage()), reader, SLOT(dopagedn()) ); |
1735 | 1735 | connect(scrollbar, SIGNAL(prevPage()), reader, SLOT(dopageup()) ); | |
1736 | prefwin->dictApplication(m_targetapp); | 1736 | connect(scrollbar, SIGNAL(sliderMoved(int)), this, SLOT(actionscroll(int)) ); |
1737 | prefwin->dictMessage(m_targetmsg); | 1737 | } |
1738 | 1738 | //reader->repaint(reader->m_border, 0, reader->width()-2*reader->m_border, reader->height()); | |
1739 | prefwin->spaceAction(m_spaceTarget); | 1739 | reader->repaint(); |
1740 | prefwin->escapeAction(m_escapeTarget); | 1740 | } |
1741 | prefwin->returnAction(m_returnTarget); | 1741 | // reader->update(); |
1742 | prefwin->leftAction(m_leftTarget); | 1742 | } |
1743 | prefwin->rightAction(m_rightTarget); | 1743 | |
1744 | prefwin->upAction(m_upTarget); | 1744 | void QTReaderApp::setgrab(bool sfs) |
1745 | prefwin->downAction(m_downTarget); | 1745 | { |
1746 | 1746 | #ifdef USEQPE | |
1747 | prefwin->leftScroll(m_leftScroll); | 1747 | m_grabkeyboard = sfs; |
1748 | prefwin->rightScroll(m_rightScroll); | 1748 | if (m_grabkeyboard) |
1749 | prefwin->upScroll(m_upScroll); | 1749 | { |
1750 | prefwin->downScroll(m_downScroll); | 1750 | ((QPEApplication*)qApp)->grabKeyboard(); |
1751 | 1751 | } | |
1752 | prefwin->miscannotation(m_doAnnotation); | 1752 | else |
1753 | prefwin->miscdictionary(m_doDictionary); | 1753 | { |
1754 | prefwin->miscclipboard(m_doClipboard); | 1754 | ((QPEApplication*)qApp)->ungrabKeyboard(); |
1755 | 1755 | } | |
1756 | prefwin->SwapMouse(reader->m_swapmouse); | 1756 | #endif |
1757 | 1757 | } | |
1758 | prefwin->Font(reader->m_fontname); | 1758 | |
1759 | 1759 | void QTReaderApp::setfullscreen(bool sfs) | |
1760 | prefwin->gfxsize(reader->getBaseSize()); | 1760 | { |
1761 | 1761 | reader->bDoUpdates = false; | |
1762 | prefwin->pageoverlap(reader->m_overlap); | 1762 | m_fullscreen = sfs; |
1763 | 1763 | showEditTools(); | |
1764 | prefwin->ideogram(reader->m_bMonoSpaced); | 1764 | // qApp->processEvents(); |
1765 | 1765 | reader->bDoUpdates = true; | |
1766 | prefwin->encoding(reader->m_encd); | 1766 | reader->update(); |
1767 | 1767 | } | |
1768 | prefwin->ideogramwidth(reader->m_charpc); | 1768 | /* |
1769 | 1769 | void QTReaderApp::buttonActionSelected(QAction* _a) | |
1770 | if (prefwin->exec()) | 1770 | { |
1771 | { | 1771 | //// qDebug("es:%x : %s (%u)", _a, (const char *)(_a->text()), ActNameToInt(_a->text())); |
1772 | m_twoTouch = prefwin->twotouch(); | 1772 | m_spaceTarget = ActNameToInt(_a->text()); |
1773 | reader->setTwoTouch(m_twoTouch); | 1773 | } |
1774 | m_touch_action->setOn(m_twoTouch); | 1774 | */ |
1775 | 1775 | QTReaderApp::~QTReaderApp() | |
1776 | reader->bstripcr = prefwin->StripCR(); | 1776 | { |
1777 | reader->bdehyphen = prefwin->Dehyphen(); | 1777 | } |
1778 | reader->bonespace = prefwin->SingleSpace(); | 1778 | |
1779 | reader->bunindent = prefwin->Unindent(); | 1779 | void QTReaderApp::autoScroll(bool _b) |
1780 | reader->brepara = prefwin->Reparagraph(); | 1780 | { |
1781 | reader->bdblspce = prefwin->DoubleSpace(); | 1781 | reader->setautoscroll(_b); |
1782 | reader->bremap = prefwin->Remap(); | 1782 | setScrollState(reader->m_autoScroll); |
1783 | reader->bmakebold = prefwin->Embolden(); | 1783 | } |
1784 | reader->bfulljust = prefwin->FullJustify(); | 1784 | |
1785 | reader->setextraspace(prefwin->ParaLead()); | 1785 | void QTReaderApp::zoomin() |
1786 | reader->setlead(prefwin->LineLead()); | 1786 | { |
1787 | reader->m_border = prefwin->Margin(); | 1787 | reader->zoomin(); |
1788 | reader->bindenter = prefwin->Indent(); | 1788 | QFont f(reader->m_fontname, reader->m_fontControl.getsize(0)); |
1789 | reader->bautofmt = reader->btextfmt = reader->bstriphtml = reader->bpeanut = false; | 1789 | m_prog->setFont( f ); |
1790 | switch (prefwin->Markup()) | 1790 | } |
1791 | { | 1791 | |
1792 | case 0: | 1792 | void QTReaderApp::zoomout() |
1793 | reader->bautofmt = true; | 1793 | { |
1794 | break; | 1794 | reader->zoomout(); |
1795 | case 1: | 1795 | QFont f(reader->m_fontname, reader->m_fontControl.getsize(0)); |
1796 | break; | 1796 | m_prog->setFont( f ); |
1797 | case 2: | 1797 | } |
1798 | reader->btextfmt = true; | 1798 | |
1799 | break; | 1799 | void QTReaderApp::clearBkmkList() |
1800 | case 3: | 1800 | { |
1801 | reader->bstriphtml = true; | 1801 | delete pBkmklist; |
1802 | break; | 1802 | reader->pBkmklist = pBkmklist = NULL; |
1803 | case 4: | 1803 | m_fBkmksChanged = false; |
1804 | reader->bpeanut = true; | 1804 | reader->refresh(true); |
1805 | break; | 1805 | } |
1806 | default: | 1806 | |
1807 | odebug << "Format out of range" << oendl; | 1807 | void QTReaderApp::fileClose() |
1808 | } | 1808 | { |
1809 | reader->bdepluck = prefwin->Depluck(); | 1809 | CCloseDialog* cd = new CCloseDialog(reader->m_string, false, this); |
1810 | reader->bdejpluck = prefwin->Dejpluck(); | 1810 | if (cd->exec()) |
1811 | reader->setContinuous(prefwin->Continuous()); | 1811 | { |
1812 | 1812 | if (pOpenlist != NULL) | |
1813 | m_spaceTarget = (ActionTypes)prefwin->spaceAction(); | 1813 | { |
1814 | m_escapeTarget = (ActionTypes)prefwin->escapeAction(); | 1814 | int ind = 0; |
1815 | m_returnTarget = (ActionTypes)prefwin->returnAction(); | 1815 | Bkmk* p = (*pOpenlist)[ind]; |
1816 | m_leftTarget = (ActionTypes)prefwin->leftAction(); | 1816 | while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) |
1817 | m_rightTarget = (ActionTypes)prefwin->rightAction(); | 1817 | { |
1818 | m_upTarget = (ActionTypes)prefwin->upAction(); | 1818 | p = (*pOpenlist)[++ind]; |
1819 | m_downTarget = (ActionTypes)prefwin->downAction(); | 1819 | } |
1820 | m_leftScroll = prefwin->leftScroll(); | 1820 | if (p != NULL) pOpenlist->erase(ind); |
1821 | m_rightScroll = prefwin->rightScroll(); | 1821 | if (cd->delFile()) |
1822 | m_upScroll = prefwin->upScroll(); | 1822 | { |
1823 | m_downScroll = prefwin->downScroll(); | 1823 | unlink((const char*)reader->m_lastfile); |
1824 | 1824 | } | |
1825 | m_targetapp = prefwin->dictApplication(); | 1825 | if (cd->delMarks()) |
1826 | m_targetmsg = prefwin->dictMessage(); | 1826 | { |
1827 | 1827 | #ifndef USEQPE | |
1828 | m_doAnnotation = prefwin->miscannotation(); | 1828 | QDir d = QDir::home(); // "/" |
1829 | m_doDictionary = prefwin->miscdictionary(); | 1829 | d.cd(APPDIR); |
1830 | m_doClipboard = prefwin->miscclipboard(); | 1830 | d.remove(reader->m_string); |
1831 | reader->m_swapmouse = prefwin->SwapMouse(); | 1831 | #else /* USEQPE */ |
1832 | reader->setBaseSize(prefwin->gfxsize()); | 1832 | unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string)); |
1833 | reader->m_overlap = prefwin->pageoverlap(); | 1833 | #endif /* USEQPE */ |
1834 | reader->m_bMonoSpaced = prefwin->ideogram(); | 1834 | } |
1835 | m_setmono_action->setOn(reader->m_bMonoSpaced); | 1835 | if (cd->delConfig()) |
1836 | reader->m_encd = prefwin->encoding(); | 1836 | { |
1837 | reader->m_charpc = prefwin->ideogramwidth(); | 1837 | #ifndef USEQPE |
1838 | 1838 | QDir d = QDir::home(); // "/" | |
1839 | if ( | 1839 | d.cd(APPDIR "/configs"); |
1840 | reader->m_fontname != prefwin->Font() | 1840 | d.remove(reader->m_string); |
1841 | || | 1841 | #else /* USEQPE */ |
1842 | m_propogatefontchange != prefwin->propfontchange()) | 1842 | unlink((const char *)Global::applicationFileName(APPDIR "/configs",reader->m_string)); |
1843 | { | 1843 | #endif /* USEQPE */ |
1844 | m_propogatefontchange = prefwin->propfontchange(); | 1844 | } |
1845 | setfontHelper(prefwin->Font()); | 1845 | } |
1846 | } | 1846 | |
1847 | delete prefwin; | 1847 | fileOpen2(); |
1848 | reader->setfilter(reader->getfilter()); | 1848 | } |
1849 | reader->refresh(); | 1849 | delete cd; |
1850 | 1850 | } | |
1851 | } | 1851 | |
1852 | else | 1852 | void QTReaderApp::updatefileinfo() |
1853 | { | 1853 | { |
1854 | delete prefwin; | 1854 | if (reader->m_string.isEmpty()) return; |
1855 | } | 1855 | if (reader->m_lastfile.isEmpty()) return; |
1856 | } | 1856 | tchar* nm = fromQString(reader->m_string); |
1857 | 1857 | tchar* fl = fromQString(reader->m_lastfile); | |
1858 | void QTReaderApp::showtoolbarprefs() | 1858 | // qDebug("Lastfile:%x", fl); |
1859 | { | 1859 | bool notadded = true; |
1860 | #ifdef USEQPE | 1860 | if (pOpenlist == NULL) pOpenlist = new CList<Bkmk>; |
1861 | CBarPrefs* prefwin = new CBarPrefs(APPDIR, !m_bFloatingDialog, this); | 1861 | else |
1862 | #else | 1862 | { |
1863 | QFileInfo fi; | 1863 | for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++) |
1864 | QDir d = QDir::home(); // "/" | 1864 | { |
1865 | if ( !d.cd(APPDIR) ) | 1865 | if (ustrcmp(CFiledata(iter->anno()).name(), fl) == 0) |
1866 | { // "/tmp" | 1866 | { |
1867 | owarn << "Cannot find the \"~/" << APPDIR << "\" directory" << oendl; | 1867 | iter->value(reader->pagelocate()); |
1868 | d = QDir::home(); | 1868 | unsigned short dlen; |
1869 | d.mkdir(APPDIR); | 1869 | unsigned char* data; |
1870 | d.cd(APPDIR); | 1870 | CFiledata fd(iter->anno()); |
1871 | } | 1871 | reader->setSaveData(data, dlen, fd.content(), fd.length()); |
1872 | fi.setFile(d, INIFILE); | 1872 | // qDebug("Filedata(1):%u, %u", fd.length(), dlen); |
1873 | CBarPrefs* prefwin = new CBarPrefs(fi.absFilePath(), !m_bFloatingDialog, this); | 1873 | // getstate(data, dlen); |
1874 | #endif | 1874 | iter->setAnno(data, dlen); |
1875 | prefwin->tbpolicy(m_tbpolsave); | 1875 | notadded = false; |
1876 | prefwin->tbposition(m_tbposition-2); | 1876 | delete [] data; |
1877 | prefwin->tbmovable(m_tbmovesave); | 1877 | break; |
1878 | prefwin->floating(m_bFloatingDialog); | 1878 | } |
1879 | if (prefwin->exec()) | 1879 | } |
1880 | { | 1880 | } |
1881 | m_bFloatingDialog = prefwin->floating(); | 1881 | // qDebug("Added?:%x", notadded); |
1882 | if ( | 1882 | if (notadded) |
1883 | m_tbpolsave != (ToolbarPolicy)prefwin->tbpolicy() | 1883 | { |
1884 | || | 1884 | struct stat fnstat; |
1885 | m_tbposition != (ToolBarDock)(prefwin->tbposition()+2) | 1885 | stat((const char *)reader->m_lastfile, &fnstat); |
1886 | || | 1886 | CFiledata fd(fnstat.st_mtime, fl); |
1887 | m_tbmovesave != prefwin->tbmovable() | 1887 | unsigned short dlen; |
1888 | ) | 1888 | unsigned char* data; |
1889 | { | 1889 | reader->setSaveData(data, dlen, fd.content(), fd.length()); |
1890 | QMessageBox::warning(this, PROGNAME, "Some changes won't take effect\nuntil the next time the\napplication is started"); | 1890 | pOpenlist->push_front(Bkmk(nm, data, dlen, reader->pagelocate())); |
1891 | } | 1891 | //qDebug("Filedata(2):%u, %u", fd.length(), dlen); |
1892 | m_tbpolsave = (ToolbarPolicy)prefwin->tbpolicy(); | 1892 | delete [] data; |
1893 | m_tbposition = (ToolBarDock)(prefwin->tbposition()+2); | 1893 | } |
1894 | m_tbmovesave = prefwin->tbmovable(); | 1894 | delete [] nm; |
1895 | bool isChanged = prefwin->isChanged(); | 1895 | delete [] fl; |
1896 | delete prefwin; | 1896 | } |
1897 | #ifdef USEQPE | 1897 | |
1898 | Config config( APPDIR ); | 1898 | void QTReaderApp::fileOpen() |
1899 | #else | 1899 | { |
1900 | QFileInfo fi; | 1900 | /* |
1901 | QDir d = QDir::home(); // "/" | 1901 | menu->hide(); |
1902 | if ( !d.cd(APPDIR) ) | 1902 | fileBar->hide(); |
1903 | { // "/tmp" | 1903 | if (regVisible) regBar->hide(); |
1904 | owarn << "Cannot find the \"~/" << APPDIR << "\" directory" << oendl; | 1904 | if (searchVisible) searchBar->hide(); |
1905 | d = QDir::home(); | 1905 | */ |
1906 | d.mkdir(APPDIR); | 1906 | // qDebug("fileOpen"); |
1907 | d.cd(APPDIR); | 1907 | // if (!reader->m_lastfile.isEmpty()) |
1908 | } | 1908 | updatefileinfo(); |
1909 | fi.setFile(d, INIFILE); | 1909 | fileOpen2(); |
1910 | Config config( fi.absFilePath() ); | 1910 | } |
1911 | #endif | 1911 | |
1912 | if (isChanged) addtoolbars(&config); | 1912 | void QTReaderApp::fileOpen2() |
1913 | } | 1913 | { |
1914 | else | 1914 | if (pBkmklist != NULL) |
1915 | { | 1915 | { |
1916 | delete prefwin; | 1916 | if (m_fBkmksChanged) |
1917 | } | 1917 | { |
1918 | } | 1918 | if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) |
1919 | 1919 | savebkmks(); | |
1920 | void QTReaderApp::showinfo() | 1920 | } |
1921 | { | 1921 | delete pBkmklist; |
1922 | unsigned long fs, ts, pl; | 1922 | reader->pBkmklist = pBkmklist = NULL; |
1923 | if (reader->empty()) | 1923 | m_fBkmksChanged = false; |
1924 | { | 1924 | } |
1925 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); | 1925 | reader->disableAutoscroll(); |
1926 | } | 1926 | /* |
1927 | else | 1927 | editorStack->raiseWidget( fileSelector ); |
1928 | { | 1928 | fileSelector->reread(); |
1929 | reader->sizes(fs,ts); | 1929 | */ |
1930 | pl = reader->pagelocate(); | 1930 | bool usebrowser = true; |
1931 | m_infoWin->setFileSize(fs); | 1931 | if (pOpenlist != NULL) |
1932 | m_infoWin->setTextSize(ts); | 1932 | { |
1933 | m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts); | 1933 | m_nBkmkAction = cOpenFile; |
1934 | m_infoWin->setLocation(pl); | 1934 | if (listbkmk(pOpenlist, "Browse")) usebrowser = false; |
1935 | m_infoWin->setRead((100*pl + (ts >> 1))/ts); | 1935 | } |
1936 | editorStack->raiseWidget( m_infoWin ); | 1936 | if (usebrowser) |
1937 | m_infoWin->setFocus(); | 1937 | { |
1938 | } | 1938 | QString fn = usefilebrowser(); |
1939 | } | 1939 | //qApp->processEvents(); |
1940 | 1940 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) | |
1941 | void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn) | 1941 | { |
1942 | { | 1942 | openFile(fn); |
1943 | if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>; | 1943 | } |
1944 | #ifdef _UNICODE | 1944 | reader->setFocus(); |
1945 | CBuffer buff(name.length()+1); | 1945 | } |
1946 | int i; | 1946 | // reader->refresh(); |
1947 | for (i = 0; i < name.length(); i++) | 1947 | // qDebug("HEIGHT:%d", reader->m_lastheight); |
1948 | { | 1948 | } |
1949 | buff[i] = name[i].unicode(); | 1949 | |
1950 | } | 1950 | QString QTReaderApp::usefilebrowser() |
1951 | buff[i] = 0; | 1951 | { |
1952 | CBuffer buff2(text.length()+1); | 1952 | #ifndef USEQPE |
1953 | for (i = 0; i < text.length(); i++) | 1953 | QString s( QFileDialog::getOpenFileName( reader->m_lastfile, QString::null, this ) ); |
1954 | { | 1954 | return s; |
1955 | buff2[i] = text[i].unicode(); | 1955 | #else |
1956 | } | 1956 | QString fn; |
1957 | buff2[i] = 0; | 1957 | #ifdef OPIE |
1958 | pBkmklist->push_front(Bkmk(buff.data(), buff2.data(), posn)); | 1958 | QMap<QString, QStringList> mimeTypes; |
1959 | #else | 1959 | QStringList etypes; |
1960 | pBkmklist->push_front(Bkmk((const tchar*)text,posn)); | 1960 | etypes << "etext/*"; |
1961 | #endif | 1961 | mimeTypes.insert( tr("eText"), etypes ); |
1962 | m_fBkmksChanged = true; | 1962 | QStringList types; |
1963 | pBkmklist->sort(); | 1963 | types << "text/*"; |
1964 | } | 1964 | mimeTypes.insert( tr("Text"), types ); |
1965 | 1965 | mimeTypes.insert( tr("All"), "*/*" ); | |
1966 | void QTReaderApp::addAnno(const QString& name, const QString& text) | 1966 | fn = OFileDialog::getOpenFileName(OFileSelector::EXTENDED_ALL, QFileInfo(reader->m_lastfile).dirPath(true), QString::null, mimeTypes, 0, "OpieReader"); |
1967 | { | 1967 | #else |
1968 | if (m_annoIsEditing) | 1968 | fileBrowser* fb = new fileBrowser(false, this,"OpieReader",!m_bFloatingDialog, |
1969 | { | 1969 | 0, |
1970 | if (name.isEmpty()) | 1970 | // WStyle_Customize | WStyle_NoBorderEx, |
1971 | { | 1971 | "*", QFileInfo(reader->m_lastfile).dirPath(true)); |
1972 | QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nPlease try again", 1); | 1972 | |
1973 | } | 1973 | |
1974 | else | 1974 | if (fb->exec()) |
1975 | { | 1975 | { |
1976 | addAnno(name, text, m_annoWin->getPosn()); | 1976 | fn = fb->getCurrentFile(); |
1977 | } | 1977 | } |
1978 | showEditTools(); | 1978 | // qDebug("Selected %s", (const char*)fn); |
1979 | } | 1979 | delete fb; |
1980 | else | 1980 | #endif |
1981 | { | 1981 | showEditTools(); |
1982 | if (m_annoWin->edited()) | 1982 | return fn; |
1983 | { | 1983 | #endif |
1984 | CBuffer buff(text.length()+1); | 1984 | } |
1985 | int i; | 1985 | |
1986 | for (i = 0; i < text.length(); i++) | 1986 | void QTReaderApp::showgraphic(QImage& pm) |
1987 | { | 1987 | { |
1988 | buff[i] = text[i].unicode(); | 1988 | m_graphicwin->setImage(pm); |
1989 | } | 1989 | editorStack->raiseWidget( m_graphicwin ); |
1990 | buff[i] = 0; | 1990 | hidetoolbars(); |
1991 | m_fBkmksChanged = true; | 1991 | m_graphicwin->setFocus(); |
1992 | m_anno->setAnno(buff.data()); | 1992 | } |
1993 | } | 1993 | |
1994 | bool found = findNextBookmark(m_anno->value()+1); | 1994 | void QTReaderApp::showbuttonprefs() |
1995 | if (found) | 1995 | { |
1996 | { | 1996 | editorStack->raiseWidget( m_buttonprefs ); |
1997 | m_annoWin->setName(toQString(m_anno->name())); | 1997 | hidetoolbars(); |
1998 | m_annoWin->setAnno(toQString(m_anno->anno())); | 1998 | m_buttonprefs->setFocus(); |
1999 | } | 1999 | m_kmapchanged = true; |
2000 | else | 2000 | } |
2001 | { | 2001 | |
2002 | showEditTools(); | 2002 | void QTReaderApp::showprefs() |
2003 | } | 2003 | { |
2004 | } | 2004 | CPrefs* prefwin = new CPrefs(reader->width(), !m_bFloatingDialog, this); |
2005 | } | 2005 | |
2006 | 2006 | // prefwin->Debounce(m_debounce); | |
2007 | bool QTReaderApp::findNextBookmark(size_t start) | 2007 | prefwin->bgtype(m_bgtype); |
2008 | { | 2008 | prefwin->repalm(reader->brepalm); |
2009 | bool found = false; | 2009 | prefwin->kern(reader->bkern); |
2010 | for (CList<Bkmk>::iterator iter = pBkmklist->begin(); iter != pBkmklist->end(); iter++) | 2010 | prefwin->hyphenate(reader->hyphenate); |
2011 | { | 2011 | // prefwin->customhyphen(reader->buffdoc.getCustomHyphen()); |
2012 | if (iter->value() >= start) | 2012 | prefwin->scrolltype(reader->m_scrolltype); |
2013 | { | 2013 | prefwin->scrollstep(reader->m_scrollstep); |
2014 | if (iter->value() < reader->locate()) | 2014 | prefwin->scrollcolor(m_scrollcolor); |
2015 | { | 2015 | prefwin->minibarcol(m_scrollbarcolor); |
2016 | found = true; | 2016 | prefwin->foreground(m_foreground); |
2017 | m_anno = iter.pContent(); | 2017 | prefwin->background(m_background); |
2018 | } | 2018 | prefwin->twotouch(m_twoTouch); |
2019 | break; | 2019 | prefwin->propfontchange(m_propogatefontchange); |
2020 | } | 2020 | prefwin->StripCR(reader->bstripcr); |
2021 | } | 2021 | prefwin->Dehyphen(reader->bdehyphen); |
2022 | return found; | 2022 | prefwin->SingleSpace(reader->bonespace); |
2023 | } | 2023 | prefwin->Unindent(reader->bunindent); |
2024 | 2024 | prefwin->Reparagraph(reader->brepara); | |
2025 | void QTReaderApp::addanno() | 2025 | prefwin->DoubleSpace(reader->bdblspce); |
2026 | { | 2026 | prefwin->Remap(reader->bremap); |
2027 | if (reader->empty()) | 2027 | prefwin->Embolden(reader->bmakebold); |
2028 | { | 2028 | prefwin->FullJustify(reader->bfulljust); |
2029 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); | 2029 | // prefwin->Inverse(reader->bInverse); |
2030 | } | 2030 | // prefwin->Negative(reader->bNegative); |
2031 | else | 2031 | prefwin->FixGraphics(reader->m_fontControl.FixGraphics()); |
2032 | { | 2032 | prefwin->ParaLead(reader->getextraspace()); |
2033 | m_annoWin->setName(""); | 2033 | prefwin->LineLead(reader->getlead()); |
2034 | m_annoWin->setAnno(""); | 2034 | prefwin->TopMargin(reader->m_abstopmargin); |
2035 | m_annoWin->setPosn(reader->pagelocate()); | 2035 | prefwin->BottomMargin(reader->m_absbottommargin); |
2036 | m_annoIsEditing = true; | 2036 | prefwin->LeftMargin(reader->m_absleft_border); |
2037 | editorStack->raiseWidget( m_annoWin ); | 2037 | prefwin->RightMargin(reader->m_absright_border); |
2038 | #ifdef USEQPE | 2038 | prefwin->Indent(reader->bindenter); |
2039 | Global::showInputMethod(); | 2039 | if (reader->bautofmt) |
2040 | #endif | 2040 | { |
2041 | m_annoWin->setFocus(); | 2041 | prefwin->Markup(0); |
2042 | } | 2042 | } |
2043 | } | 2043 | else if (reader->btextfmt) |
2044 | 2044 | { | |
2045 | void QTReaderApp::infoClose() | 2045 | prefwin->Markup(2); |
2046 | { | 2046 | } |
2047 | showEditTools(); | 2047 | else if (reader->bstriphtml) |
2048 | } | 2048 | { |
2049 | 2049 | prefwin->Markup(3); | |
2050 | /* | 2050 | } |
2051 | void QTReaderApp::fileRevert() | 2051 | else if (reader->bpeanut) |
2052 | { | 2052 | { |
2053 | clear(); | 2053 | prefwin->Markup(4); |
2054 | fileOpen(); | 2054 | } |
2055 | } | 2055 | else |
2056 | 2056 | { | |
2057 | void QTReaderApp::editCut() | 2057 | prefwin->Markup(1); |
2058 | { | 2058 | } |
2059 | #ifndef QT_NO_CLIPBOARD | 2059 | prefwin->Depluck(reader->bdepluck); |
2060 | editor->cut(); | 2060 | prefwin->Dejpluck(reader->bdejpluck); |
2061 | #endif | 2061 | prefwin->Continuous(reader->m_continuousDocument); |
2062 | } | 2062 | |
2063 | */ | 2063 | prefwin->dictApplication(m_targetapp); |
2064 | void QTReaderApp::editMark() | 2064 | prefwin->dictMessage(m_targetmsg); |
2065 | { | 2065 | |
2066 | m_savedpos = reader->pagelocate(); | 2066 | /* |
2067 | } | 2067 | prefwin->leftScroll(m_leftScroll); |
2068 | 2068 | prefwin->rightScroll(m_rightScroll); | |
2069 | void QTReaderApp::editCopy() | 2069 | prefwin->upScroll(m_upScroll); |
2070 | { | 2070 | prefwin->downScroll(m_downScroll); |
2071 | QClipboard* cb = QApplication::clipboard(); | 2071 | */ |
2072 | QString text; | 2072 | |
2073 | int ch; | 2073 | prefwin->miscannotation(m_doAnnotation); |
2074 | unsigned long currentpos = reader->pagelocate(); | 2074 | prefwin->miscdictionary(m_doDictionary); |
2075 | unsigned long endpos = reader->locate(); | 2075 | prefwin->miscclipboard(m_doClipboard); |
2076 | if (m_savedpos == 0xffffffff) | 2076 | |
2077 | { | 2077 | prefwin->SwapMouse(reader->m_swapmouse); |
2078 | m_savedpos = currentpos; | 2078 | |
2079 | } | 2079 | prefwin->Font(reader->m_fontname); |
2080 | reader->jumpto(m_savedpos); | 2080 | |
2081 | while (reader->explocate() < endpos && (ch = reader->getch()) != UEOF) | 2081 | prefwin->gfxsize(reader->getBaseSize()); |
2082 | { | 2082 | |
2083 | text += ch; | 2083 | prefwin->pageoverlap(reader->m_overlap); |
2084 | } | 2084 | |
2085 | cb->setText(text); | 2085 | prefwin->ideogram(reader->m_bMonoSpaced); |
2086 | reader->locate(currentpos); | 2086 | |
2087 | m_savedpos = 0xffffffff; | 2087 | prefwin->encoding(reader->m_encd); |
2088 | } | 2088 | |
2089 | 2089 | prefwin->ideogramwidth(reader->m_charpc); | |
2090 | void QTReaderApp::gotoStart() | 2090 | |
2091 | { | 2091 | if (prefwin->exec()) |
2092 | reader->locate(reader->buffdoc.startSection()); | 2092 | { |
2093 | } | 2093 | // m_debounce = prefwin->Debounce(); |
2094 | 2094 | reader->brepalm = prefwin->repalm(); | |
2095 | void QTReaderApp::gotoEnd() | 2095 | reader->bkern = prefwin->kern(); |
2096 | { | 2096 | reader->hyphenate = prefwin->hyphenate(); |
2097 | reader->dopageup(reader->buffdoc.endSection()); | 2097 | // reader->buffdoc.setCustomHyphen(prefwin->customhyphen()); |
2098 | } | 2098 | reader->m_scrolltype = prefwin->scrolltype(); |
2099 | 2099 | reader->m_scrollstep = prefwin->scrollstep(); | |
2100 | void QTReaderApp::pageup() | 2100 | m_scrollcolor = prefwin->scrollcolor(); |
2101 | { | 2101 | setscrollcolour(); |
2102 | reader->NavUp(); | 2102 | m_scrollbarcolor = prefwin->minibarcol(); |
2103 | } | 2103 | setscrollbarcolour(); |
2104 | 2104 | m_foreground = prefwin->foreground(); | |
2105 | void QTReaderApp::pagedn() | 2105 | reader->setForeground(getcolour(m_foreground)); |
2106 | { | 2106 | m_background = prefwin->background(); |
2107 | reader->NavDown(); | 2107 | reader->setBackground(getcolour(m_background)); |
2108 | } | 2108 | m_twoTouch = prefwin->twotouch(); |
2109 | 2109 | reader->setTwoTouch(m_twoTouch); | |
2110 | void QTReaderApp::pagemode(bool _b) | 2110 | m_touch_action->setOn(m_twoTouch); |
2111 | { | 2111 | |
2112 | reader->setpagemode(_b); | 2112 | reader->bstripcr = prefwin->StripCR(); |
2113 | } | 2113 | reader->bdehyphen = prefwin->Dehyphen(); |
2114 | 2114 | reader->bonespace = prefwin->SingleSpace(); | |
2115 | /* | 2115 | reader->bunindent = prefwin->Unindent(); |
2116 | void QTReaderApp::setspacing() | 2116 | reader->brepara = prefwin->Reparagraph(); |
2117 | { | 2117 | reader->bdblspce = prefwin->DoubleSpace(); |
2118 | m_nRegAction = cMonoSpace; | 2118 | reader->bremap = prefwin->Remap(); |
2119 | char lcn[20]; | 2119 | reader->bmakebold = prefwin->Embolden(); |
2120 | sprintf(lcn, "%lu", reader->m_charpc); | 2120 | reader->bfulljust = prefwin->FullJustify(); |
2121 | regEdit->setText(lcn); | 2121 | //if (reader->bInverse != prefwin->Inverse()) reader->setInverse(prefwin->Inverse()); |
2122 | do_regedit(); | 2122 | //if (reader->bNegative != prefwin->Negative()) reader->setNegative(); |
2123 | } | 2123 | reader->m_fontControl.FixGraphics(prefwin->FixGraphics()); |
2124 | */ | 2124 | |
2125 | void QTReaderApp::settarget() | 2125 | reader->setextraspace(prefwin->ParaLead()); |
2126 | { | 2126 | reader->setlead(prefwin->LineLead()); |
2127 | m_nRegAction = cSetTarget; | 2127 | reader->m_abstopmargin = prefwin->TopMargin(); |
2128 | QString text = ((m_targetapp.isEmpty()) ? QString("") : m_targetapp) | 2128 | reader->m_absbottommargin = prefwin->BottomMargin(); |
2129 | + "/" | 2129 | reader->m_absleft_border = prefwin->LeftMargin(); |
2130 | + ((m_targetmsg.isEmpty()) ? QString("") : m_targetmsg); | 2130 | reader->m_absright_border = prefwin->RightMargin(); |
2131 | regEdit->setText(text); | 2131 | reader->bindenter = prefwin->Indent(); |
2132 | do_regedit(); | 2132 | reader->bautofmt = reader->btextfmt = reader->bstriphtml = reader->bpeanut = false; |
2133 | } | 2133 | switch (prefwin->Markup()) |
2134 | 2134 | { | |
2135 | /* | 2135 | case 0: |
2136 | void QTReaderApp::do_mono(const QString& lcn) | 2136 | reader->bautofmt = true; |
2137 | { | 2137 | break; |
2138 | bool ok; | 2138 | case 1: |
2139 | unsigned long ulcn = lcn.toULong(&ok); | 2139 | break; |
2140 | if (ok) | 2140 | case 2: |
2141 | { | 2141 | reader->btextfmt = true; |
2142 | reader->m_charpc = ulcn; | 2142 | break; |
2143 | reader->setfont(); | 2143 | case 3: |
2144 | reader->refresh(); | 2144 | reader->bstriphtml = true; |
2145 | // reader->setmono(true); | 2145 | break; |
2146 | } | 2146 | case 4: |
2147 | else | 2147 | reader->bpeanut = true; |
2148 | QMessageBox::information(this, PROGNAME, "Must be a number"); | 2148 | break; |
2149 | } | 2149 | default: |
2150 | */ | 2150 | qDebug("Format out of range"); |
2151 | /* | 2151 | } |
2152 | void QTReaderApp::editPaste() | 2152 | reader->bdepluck = prefwin->Depluck(); |
2153 | { | 2153 | reader->bdejpluck = prefwin->Dejpluck(); |
2154 | #ifndef QT_NO_CLIPBOARD | 2154 | reader->setContinuous(prefwin->Continuous()); |
2155 | editor->paste(); | 2155 | |
2156 | #endif | 2156 | /* |
2157 | } | 2157 | m_leftScroll = prefwin->leftScroll(); |
2158 | */ | 2158 | m_rightScroll = prefwin->rightScroll(); |
2159 | 2159 | m_upScroll = prefwin->upScroll(); | |
2160 | void QTReaderApp::editFind() | 2160 | m_downScroll = prefwin->downScroll(); |
2161 | { | 2161 | */ |
2162 | searchStart = reader->pagelocate(); | 2162 | m_targetapp = prefwin->dictApplication(); |
2163 | #ifdef __ISEARCH | 2163 | m_targetmsg = prefwin->dictMessage(); |
2164 | searchStack = new QStack<searchrecord>; | 2164 | |
2165 | #endif | 2165 | m_doAnnotation = prefwin->miscannotation(); |
2166 | #ifdef USEQPE | 2166 | m_doDictionary = prefwin->miscdictionary(); |
2167 | Global::showInputMethod(); | 2167 | m_doClipboard = prefwin->miscclipboard(); |
2168 | #endif | 2168 | reader->m_swapmouse = prefwin->SwapMouse(); |
2169 | searchBar->show(); | 2169 | reader->setBaseSize(prefwin->gfxsize()); |
2170 | searchVisible = TRUE; | 2170 | reader->m_overlap = prefwin->pageoverlap(); |
2171 | searchEdit->setFocus(); | 2171 | reader->m_bMonoSpaced = prefwin->ideogram(); |
2172 | #ifdef __ISEARCH | 2172 | m_setmono_action->setOn(reader->m_bMonoSpaced); |
2173 | searchStack->push(new searchrecord("",reader->pagelocate())); | 2173 | reader->m_encd = prefwin->encoding(); |
2174 | #endif | 2174 | reader->m_charpc = prefwin->ideogramwidth(); |
2175 | } | 2175 | |
2176 | 2176 | if ( | |
2177 | void QTReaderApp::findNext() | 2177 | reader->m_fontname != prefwin->Font() |
2178 | { | 2178 | || |
2179 | // // odebug << "findNext called\n" << oendl; | 2179 | m_propogatefontchange != prefwin->propfontchange()) |
2180 | #ifdef __ISEARCH | 2180 | { |
2181 | QString arg = searchEdit->text(); | 2181 | m_propogatefontchange = prefwin->propfontchange(); |
2182 | #else | 2182 | setfontHelper(prefwin->Font()); |
2183 | QRegExp arg = searchEdit->text(); | 2183 | } |
2184 | #endif | 2184 | if (m_bgtype != (bground)prefwin->bgtype()) |
2185 | CDrawBuffer test(&(reader->m_fontControl)); | 2185 | { |
2186 | size_t start = reader->pagelocate(); | 2186 | m_bgtype = (bground)prefwin->bgtype(); |
2187 | reader->jumpto(start); | 2187 | setBackgroundBitmap(); |
2188 | reader->getline(&test); | 2188 | } |
2189 | dosearch(start, test, arg); | 2189 | delete prefwin; |
2190 | } | 2190 | reader->setfilter(reader->getfilter()); |
2191 | 2191 | reader->refresh(); | |
2192 | void QTReaderApp::findClose() | 2192 | } |
2193 | { | 2193 | else |
2194 | searchVisible = FALSE; | 2194 | { |
2195 | searchEdit->setText(""); | 2195 | delete prefwin; |
2196 | #ifdef USEQPE | 2196 | } |
2197 | Global::hideInputMethod(); | 2197 | } |
2198 | #endif | 2198 | |
2199 | searchBar->hide(); | 2199 | void QTReaderApp::showtoolbarprefs() |
2200 | #ifdef __ISEARCH | 2200 | { |
2201 | // searchStack = new QStack<searchrecord>; | 2201 | #ifdef USEQPE |
2202 | while (!searchStack->isEmpty()) | 2202 | CBarPrefs* prefwin = new CBarPrefs(APPDIR, !m_bFloatingDialog, this); |
2203 | { | 2203 | #else |
2204 | delete searchStack->pop(); | 2204 | QFileInfo fi; |
2205 | } | 2205 | QDir d = QDir::home(); // "/" |
2206 | delete searchStack; | 2206 | if ( !d.cd(APPDIR) ) |
2207 | #endif | 2207 | { // "/tmp" |
2208 | reader->setFocus(); | 2208 | qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); |
2209 | } | 2209 | d = QDir::home(); |
2210 | 2210 | d.mkdir(APPDIR); | |
2211 | void QTReaderApp::regClose() | 2211 | d.cd(APPDIR); |
2212 | { | 2212 | } |
2213 | regVisible = FALSE; | 2213 | fi.setFile(d, INIFILE); |
2214 | regEdit->setText(""); | 2214 | CBarPrefs* prefwin = new CBarPrefs(fi.absFilePath(), !m_bFloatingDialog, this); |
2215 | regBar->hide(); | 2215 | #endif |
2216 | #ifdef USEQPE | 2216 | prefwin->tbpolicy(m_tbpolsave); |
2217 | Global::hideInputMethod(); | 2217 | prefwin->tbposition(m_tbposition-2); |
2218 | #endif | 2218 | prefwin->tbmovable(m_tbmovesave); |
2219 | reader->setFocus(); | 2219 | prefwin->floating(m_bFloatingDialog); |
2220 | } | 2220 | prefwin->qtscroll(m_qtscroll); |
2221 | 2221 | prefwin->localscroll(m_localscroll); | |
2222 | #ifdef __ISEARCH | 2222 | if (prefwin->exec()) |
2223 | bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QString& arg) | 2223 | { |
2224 | #else | 2224 | m_bFloatingDialog = prefwin->floating(); |
2225 | bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg) | 2225 | if ( |
2226 | #endif | 2226 | m_tbpolsave != (ToolbarPolicy)prefwin->tbpolicy() |
2227 | { | 2227 | || |
2228 | bool ret = true; | 2228 | m_tbposition != (ToolBarDock)(prefwin->tbposition()+2) |
2229 | unsigned long fs, ts; | 2229 | || |
2230 | reader->sizes(fs,ts); | 2230 | m_tbmovesave != prefwin->tbmovable() |
2231 | size_t pos = reader->locate(); | 2231 | || |
2232 | pbar->setGeometry(searchBar->x(),searchBar->y(),searchBar->width(), searchBar->height()); | 2232 | m_qtscroll != prefwin->qtscroll() |
2233 | pbar->show(); | 2233 | // || |
2234 | pbar->raise(); | 2234 | // m_localscrollbar != prefwin->scrollonleft() |
2235 | pbar->reset(); | 2235 | ) |
2236 | int offset; | 2236 | { |
2237 | int lastpc = (100*pos)/ts; | 2237 | QMessageBox::warning(this, PROGNAME, "Some changes won't take effect\nuntil the next time the\napplication is started"); |
2238 | pbar->setProgress(lastpc); | 2238 | } |
2239 | // qApp->processEvents(); | 2239 | m_tbpolsave = (ToolbarPolicy)prefwin->tbpolicy(); |
2240 | if (reader->buffdoc.getpara(test) >= 0) | 2240 | m_tbposition = (ToolBarDock)(prefwin->tbposition()+2); |
2241 | { | 2241 | m_tbmovesave = prefwin->tbmovable(); |
2242 | reader->setFocus(); | 2242 | reader->m_scrollpos = m_localscroll = prefwin->localscroll(); |
2243 | #ifdef __ISEARCH | 2243 | if (m_qtscroll != prefwin->qtscroll()) |
2244 | while (strstr(test.data(),(const tchar*)arg) == NULL) | 2244 | { |
2245 | #else | 2245 | m_qtscroll = prefwin->qtscroll(); |
2246 | #ifdef _UNICODE | 2246 | setrotated(reader->m_rotated); |
2247 | while ((offset = arg.match(toQString(test.data()))) == -1) | 2247 | } |
2248 | #else | 2248 | if (m_scrollbar == NULL || m_scrollbar->isHidden()) |
2249 | while (arg.match(test.data()) == -1) | 2249 | { |
2250 | #endif | 2250 | reader->m_scrollpos = m_localscroll; |
2251 | #endif | 2251 | } |
2252 | { | 2252 | else |
2253 | pos = reader->locate(); | 2253 | { |
2254 | int pc = (100*pos)/ts; | 2254 | reader->m_scrollpos = (m_qtscroll == 0) ? m_localscroll : 0; |
2255 | if (pc != lastpc) | 2255 | } |
2256 | { | 2256 | bool isChanged = prefwin->isChanged(); |
2257 | pbar->setProgress(pc); | 2257 | delete prefwin; |
2258 | qApp->processEvents(); | 2258 | #ifdef USEQPE |
2259 | reader->setFocus(); | 2259 | Config config( APPDIR ); |
2260 | lastpc = pc; | 2260 | #else |
2261 | } | 2261 | QFileInfo fi; |
2262 | 2262 | QDir d = QDir::home(); // "/" | |
2263 | if (reader->buffdoc.getpara(test) < 0) | 2263 | if ( !d.cd(APPDIR) ) |
2264 | { | 2264 | { // "/tmp" |
2265 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) | 2265 | qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); |
2266 | pos = searchStart; | 2266 | d = QDir::home(); |
2267 | else | 2267 | d.mkdir(APPDIR); |
2268 | pos = start; | 2268 | d.cd(APPDIR); |
2269 | findClose(); | 2269 | } |
2270 | pbar->hide(); | 2270 | fi.setFile(d, INIFILE); |
2271 | reader->locate(pos); | 2271 | Config config( fi.absFilePath() ); |
2272 | return false; | 2272 | #endif |
2273 | } | 2273 | if (isChanged) addtoolbars(&config); |
2274 | } | 2274 | } |
2275 | // odebug << "Found it at " << pos << ":" << offset << "" << oendl; | 2275 | else |
2276 | pbar->hide(); | 2276 | { |
2277 | // odebug << "Hid" << oendl; | 2277 | delete prefwin; |
2278 | reader->locate(pos+offset); | 2278 | } |
2279 | // odebug << "Loacted" << oendl; | 2279 | } |
2280 | // odebug << "page up" << oendl; | 2280 | |
2281 | ret = true; | 2281 | void QTReaderApp::showinfo() |
2282 | } | 2282 | { |
2283 | else | 2283 | unsigned long ds, fs, ts, pl, dl; |
2284 | { | 2284 | if (reader->empty()) |
2285 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) | 2285 | { |
2286 | pos = searchStart; | 2286 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); |
2287 | else | 2287 | } |
2288 | pos = start; | 2288 | else |
2289 | ret = false; | 2289 | { |
2290 | findClose(); | 2290 | reader->sizes(fs,ts); |
2291 | } | 2291 | ds = reader->buffdoc.endSection() - reader->buffdoc.startSection(); |
2292 | return ret; | 2292 | pl = reader->pagelocate(); |
2293 | } | 2293 | dl = pl - reader->buffdoc.startSection(); |
2294 | 2294 | m_infoWin->setFileSize(fs); | |
2295 | #ifdef __ISEARCH | 2295 | m_infoWin->setTextSize(ts); |
2296 | void QTReaderApp::search(const QString & arg) | 2296 | m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts); |
2297 | { | 2297 | m_infoWin->setLocation(pl); |
2298 | searchrecord* ss = searchStack->top(); | 2298 | m_infoWin->setRead((100*pl + (ts >> 1))/ts); |
2299 | CBuffer test; | 2299 | m_infoWin->setDocSize(ds); |
2300 | size_t start = reader->pagelocate(); | 2300 | m_infoWin->setDocLocation(dl); |
2301 | bool haspopped = false; | 2301 | m_infoWin->setDocRead((100*dl + (ds >> 1))/ds); |
2302 | while (arg.left(ss->s.length()) != ss->s) | 2302 | m_infoWin->setZoom(reader->m_fontControl.currentsize()*10); |
2303 | { | 2303 | m_infoWin->setAbout(QString("\nApplication (c) Tim Wentford\n")+reader->about()); |
2304 | haspopped = true; | 2304 | editorStack->raiseWidget( m_infoWin ); |
2305 | start = ss->pos; | 2305 | hidetoolbars(); |
2306 | // reader->locate(start); | 2306 | m_infoWin->setFocus(); |
2307 | searchStack->pop(); | 2307 | } |
2308 | delete ss; | 2308 | } |
2309 | } | 2309 | |
2310 | if (haspopped) reader->locate(start); | 2310 | void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn, size_t posn2) |
2311 | /* | 2311 | { |
2312 | if (arg.length() < ss->len) | 2312 | if (pBkmklist == NULL) reader->pBkmklist = pBkmklist = new CList<Bkmk>; |
2313 | { | 2313 | #ifdef _UNICODE |
2314 | start = ss->pos; | 2314 | CBuffer buff(name.length()+1); |
2315 | reader->locate(start); | 2315 | int i; |
2316 | searchStack->pop(); | 2316 | for (i = 0; i < name.length(); i++) |
2317 | delete ss; | 2317 | { |
2318 | } | 2318 | buff[i] = name[i].unicode(); |
2319 | */ | 2319 | } |
2320 | else | 2320 | buff[i] = 0; |
2321 | { | 2321 | CBuffer buff2(text.length()+1); |
2322 | start = reader->pagelocate(); | 2322 | for (i = 0; i < text.length(); i++) |
2323 | reader->jumpto(start); | 2323 | { |
2324 | searchStack->push(new searchrecord(arg,start)); | 2324 | buff2[i] = text[i].unicode(); |
2325 | } | 2325 | } |
2326 | dosearch(start, test, arg); | 2326 | buff2[i] = 0; |
2327 | } | 2327 | Bkmk b(buff.data(), buff2.data(), posn, posn2); |
2328 | #else | 2328 | QColor c = m_annoWin->getColor(); |
2329 | void QTReaderApp::search() | 2329 | int red,green,blue; |
2330 | { | 2330 | c.rgb(&red, &green, &blue); |
2331 | findNext(); | 2331 | b.red(red); |
2332 | } | 2332 | b.green(green); |
2333 | #endif | 2333 | b.blue(blue); |
2334 | 2334 | pBkmklist->push_front(b); | |
2335 | void QTReaderApp::openFile( const QString &f ) | 2335 | #else |
2336 | { | 2336 | pBkmklist->push_front(Bkmk((const tchar*)text,posn)); |
2337 | // odebug << "File:" << f << "" << oendl; | 2337 | #endif |
2338 | // openFile(DocLnk(f)); | 2338 | m_fBkmksChanged = true; |
2339 | //} | 2339 | pBkmklist->sort(); |
2340 | // | 2340 | } |
2341 | //void QTReaderApp::openFile( const DocLnk &f ) | 2341 | |
2342 | //{ | 2342 | void QTReaderApp::addAnno(const QString& name, const QString& text) |
2343 | clear(); | 2343 | { |
2344 | QFileInfo fm(f); | 2344 | if (m_annoIsEditing) |
2345 | if ( fm.exists() ) | 2345 | { |
2346 | { | 2346 | if (name.isEmpty()) |
2347 | // QMessageBox::information(0, "Progress", "Calling fileNew()"); | 2347 | { |
2348 | #ifdef USEQPE | 2348 | QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nPlease try again", 1); |
2349 | if (fm.extension( FALSE ) == "desktop") | 2349 | } |
2350 | { | 2350 | else |
2351 | DocLnk d(f); | 2351 | { |
2352 | QFileInfo fnew(d.file()); | 2352 | addAnno(name, text, m_annoWin->getPosn(), m_annoWin->getPosn2()); |
2353 | fm = fnew; | 2353 | } |
2354 | if (!fm.exists()) return; | 2354 | showEditTools(); |
2355 | } | 2355 | } |
2356 | #endif | 2356 | else |
2357 | clear(); | 2357 | { |
2358 | 2358 | if (m_annoWin->edited()) | |
2359 | reader->setText(fm.baseName(), fm.absFilePath()); | 2359 | { |
2360 | m_loadedconfig = readconfig(reader->m_string, false); | 2360 | CBuffer buff(text.length()+1); |
2361 | showEditTools(); | 2361 | int i; |
2362 | readbkmks(); | 2362 | for (i = 0; i < text.length(); i++) |
2363 | m_savedpos = 0xffffffff; | 2363 | { |
2364 | } | 2364 | buff[i] = text[i].unicode(); |
2365 | else | 2365 | } |
2366 | { | 2366 | buff[i] = 0; |
2367 | QMessageBox::information(this, PROGNAME, "File does not exist"); | 2367 | m_fBkmksChanged = true; |
2368 | reader->m_lastfile = QString::null; | 2368 | m_anno->setAnno(buff.data()); |
2369 | } | 2369 | } |
2370 | 2370 | QColor c = m_annoWin->getColor(); | |
2371 | } | 2371 | int red,green,blue; |
2372 | /* | 2372 | c.rgb(&red, &green, &blue); |
2373 | void QTReaderApp::resizeEvent(QResizeEvent* e) | 2373 | m_anno->red(red); |
2374 | { | 2374 | m_anno->green(green); |
2375 | if (m_fullscreen) | 2375 | m_anno->blue(blue); |
2376 | { | 2376 | bool found = findNextBookmark(m_anno->value()+1); |
2377 | showNormal(); | 2377 | if (found) |
2378 | showFullScreen(); | 2378 | { |
2379 | } | 2379 | m_annoWin->setName(toQString(m_anno->name())); |
2380 | } | 2380 | m_annoWin->setAnno(toQString(m_anno->anno())); |
2381 | */ | 2381 | m_annoWin->setColor(QColor(m_anno->red(), m_anno->green(), m_anno->blue())); |
2382 | void QTReaderApp::handlekey(QKeyEvent* e) | 2382 | } |
2383 | { | 2383 | else |
2384 | // odebug << "Keypress event" << oendl; | 2384 | { |
2385 | timeb now; | 2385 | showEditTools(); |
2386 | ftime(&now); | 2386 | } |
2387 | unsigned long etime = (1000*(now.time - m_lastkeytime.time) + now.millitm)-m_lastkeytime.millitm; | 2387 | } |
2388 | if (etime < m_debounce) | 2388 | } |
2389 | { | 2389 | |
2390 | return; | 2390 | bool QTReaderApp::findNextBookmark(size_t start) |
2391 | } | 2391 | { |
2392 | m_lastkeytime = now; | 2392 | bool found = false; |
2393 | switch(e->key()) | 2393 | for (CList<Bkmk>::iterator iter = pBkmklist->begin(); iter != pBkmklist->end(); iter++) |
2394 | { | 2394 | { |
2395 | case Key_Escape: | 2395 | if (iter->value() >= start) |
2396 | // odebug << "escape event" << oendl; | 2396 | { |
2397 | if (m_disableesckey) | 2397 | if (iter->value() < reader->locate()) |
2398 | { | 2398 | { |
2399 | m_disableesckey = false; | 2399 | found = true; |
2400 | } | 2400 | m_anno = iter.pContent(); |
2401 | else | 2401 | } |
2402 | { | 2402 | break; |
2403 | m_bcloseDisabled = true; | 2403 | } |
2404 | if (m_fullscreen) | 2404 | } |
2405 | { | 2405 | return found; |
2406 | m_actFullscreen->setOn(false); | 2406 | } |
2407 | e->accept(); | 2407 | |
2408 | } | 2408 | void QTReaderApp::addanno() |
2409 | else | 2409 | { |
2410 | { | 2410 | if (reader->empty()) |
2411 | // odebug << "escape action" << oendl; | 2411 | { |
2412 | doAction(m_escapeTarget, e); | 2412 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); |
2413 | } | 2413 | } |
2414 | } | 2414 | else |
2415 | break; | 2415 | { |
2416 | case Key_Space: | 2416 | m_annoWin->setName(""); |
2417 | { | 2417 | m_annoWin->setAnno(""); |
2418 | doAction(m_spaceTarget, e); | 2418 | m_annoWin->setPosn(reader->pagelocate()); |
2419 | } | 2419 | m_annoIsEditing = true; |
2420 | break; | 2420 | editorStack->raiseWidget( m_annoWin ); |
2421 | case Key_Return: | 2421 | hidetoolbars(); |
2422 | { | 2422 | #ifdef USEQPE |
2423 | doAction(m_returnTarget, e); | 2423 | Global::showInputMethod(); |
2424 | } | 2424 | #endif |
2425 | break; | 2425 | m_annoWin->setFocus(); |
2426 | case Key_Left: | 2426 | } |
2427 | { | 2427 | } |
2428 | if (reader->m_autoScroll && m_leftScroll) | 2428 | |
2429 | { | 2429 | void QTReaderApp::infoClose() |
2430 | reader->reduceScroll(); | 2430 | { |
2431 | } | 2431 | m_debounce = m_buttonprefs->Debounce(); |
2432 | else | 2432 | if (m_kmapchanged) |
2433 | { | 2433 | { |
2434 | doAction(m_leftTarget, e); | 2434 | m_kmapchanged = false; |
2435 | } | 2435 | #ifndef USEQPE |
2436 | } | 2436 | QDir d = QDir::home(); // "/" |
2437 | break; | 2437 | d.cd(APPDIR); |
2438 | case Key_Right: | 2438 | QFileInfo fi(d, ".keymap"); |
2439 | { | 2439 | FILE* f = fopen((const char *)fi.absFilePath(), "w"); |
2440 | if (reader->m_autoScroll && m_rightScroll) | 2440 | #else /* USEQPE */ |
2441 | { | 2441 | FILE* f = fopen((const char *)Global::applicationFileName(APPDIR,".keymap"), "w"); |
2442 | reader->increaseScroll(); | 2442 | #endif /* USEQPE */ |
2443 | } | 2443 | if (f != NULL) |
2444 | else | 2444 | { |
2445 | { | 2445 | uint cnt = KEYMAPVERSION; |
2446 | doAction(m_rightTarget, e); | 2446 | fwrite(&cnt, sizeof(cnt), 1, f); |
2447 | } | 2447 | cnt = kmap.count(); |
2448 | } | 2448 | fwrite(&cnt, sizeof(cnt), 1, f); |
2449 | break; | 2449 | for (QMap<orKey,int>::Iterator i = kmap.begin(); i != kmap.end(); i++) |
2450 | case Key_Up: | 2450 | { |
2451 | { | 2451 | orKey key = i.key(); |
2452 | if (reader->m_autoScroll && m_upScroll) | 2452 | int data = i.data(); |
2453 | { | 2453 | fwrite(&key, sizeof(key), 1, f); |
2454 | reader->increaseScroll(); | 2454 | fwrite(&data, sizeof(data), 1, f); |
2455 | } | 2455 | qDebug("Saved %s as %u", (const char*)key.text(), data); |
2456 | else | 2456 | } |
2457 | { | 2457 | fclose(f); |
2458 | doAction(m_upTarget, e); | 2458 | } |
2459 | } | 2459 | } |
2460 | } | 2460 | showEditTools(); |
2461 | break; | 2461 | } |
2462 | case Key_Down: | 2462 | |
2463 | { | 2463 | /* |
2464 | if (reader->m_autoScroll && m_downScroll) | 2464 | void QTReaderApp::fileRevert() |
2465 | { | 2465 | { |
2466 | reader->reduceScroll(); | 2466 | clear(); |
2467 | } | 2467 | fileOpen(); |
2468 | else | 2468 | } |
2469 | { | 2469 | |
2470 | doAction(m_downTarget, e); | 2470 | void QTReaderApp::editCut() |
2471 | } | 2471 | { |
2472 | } | 2472 | #ifndef QT_NO_CLIPBOARD |
2473 | break; | 2473 | editor->cut(); |
2474 | default: | 2474 | #endif |
2475 | { | 2475 | } |
2476 | e->ignore(); | 2476 | */ |
2477 | } | 2477 | void QTReaderApp::editMark() |
2478 | 2478 | { | |
2479 | /* | 2479 | m_savedpos = reader->pagelocate(); |
2480 | QString msg("Key press was:"); | 2480 | } |
2481 | QString key; | 2481 | |
2482 | msg += key.setNum(e->key()); | 2482 | void QTReaderApp::editCopy() |
2483 | QMessageBox::information(this, PROGNAME, msg); | 2483 | { |
2484 | */ | 2484 | QClipboard* cb = QApplication::clipboard(); |
2485 | } | 2485 | QString text; |
2486 | } | 2486 | int ch; |
2487 | 2487 | unsigned long currentpos = reader->pagelocate(); | |
2488 | void QTReaderApp::showEditTools() | 2488 | unsigned long endpos = reader->locate(); |
2489 | { | 2489 | if (m_savedpos == 0xffffffff) |
2490 | // if ( !doc ) | 2490 | { |
2491 | // close(); | 2491 | m_savedpos = currentpos; |
2492 | if (m_fullscreen) | 2492 | } |
2493 | { | 2493 | reader->jumpto(m_savedpos); |
2494 | if (menubar != NULL) menubar->hide(); | 2494 | while (reader->explocate() < endpos && (ch = reader->getch()) != UEOF) |
2495 | if (fileBar != NULL) fileBar->hide(); | 2495 | { |
2496 | if (viewBar != NULL) viewBar->hide(); | 2496 | text += ch; |
2497 | if (navBar != NULL) navBar->hide(); | 2497 | } |
2498 | if (markBar != NULL) markBar->hide(); | 2498 | cb->setText(text); |
2499 | searchBar->hide(); | 2499 | reader->locate(currentpos); |
2500 | regBar->hide(); | 2500 | m_savedpos = 0xffffffff; |
2501 | #ifdef USEQPE | 2501 | } |
2502 | Global::hideInputMethod(); | 2502 | |
2503 | #endif | 2503 | void QTReaderApp::gotoStart() |
2504 | m_fontBar->hide(); | 2504 | { |
2505 | // showNormal(); | 2505 | reader->locate(reader->buffdoc.startSection()); |
2506 | showFullScreen(); | 2506 | } |
2507 | } | 2507 | |
2508 | else | 2508 | void QTReaderApp::gotoEnd() |
2509 | { | 2509 | { |
2510 | // odebug << "him" << oendl; | 2510 | reader->dopageup(reader->buffdoc.endSection()); |
2511 | #ifdef USEQPE | 2511 | } |
2512 | Global::hideInputMethod(); | 2512 | |
2513 | #endif | 2513 | void QTReaderApp::pageup() |
2514 | // odebug << "eb" << oendl; | 2514 | { |
2515 | menubar->show(); | 2515 | reader->NavUp(); |
2516 | if (fileBar != NULL) fileBar->show(); | 2516 | } |
2517 | if (viewBar != NULL) viewBar->show(); | 2517 | |
2518 | if (navBar != NULL) navBar->show(); | 2518 | void QTReaderApp::pagedn() |
2519 | if (markBar != NULL) markBar->show(); | 2519 | { |
2520 | mb->show(); | 2520 | reader->NavDown(); |
2521 | if ( searchVisible ) | 2521 | } |
2522 | { | 2522 | |
2523 | #ifdef USEQPE | 2523 | void QTReaderApp::pagemode(bool _b) |
2524 | Global::showInputMethod(); | 2524 | { |
2525 | #endif | 2525 | reader->setpagemode(_b); |
2526 | searchBar->show(); | 2526 | } |
2527 | } | 2527 | |
2528 | if ( regVisible ) | 2528 | /* |
2529 | { | 2529 | void QTReaderApp::setspacing() |
2530 | #ifdef USEQPE | 2530 | { |
2531 | Global::showInputMethod(); | 2531 | m_nRegAction = cMonoSpace; |
2532 | #endif | 2532 | char lcn[20]; |
2533 | regBar->show(); | 2533 | sprintf(lcn, "%lu", reader->m_charpc); |
2534 | } | 2534 | regEdit->setText(lcn); |
2535 | if (m_fontVisible) m_fontBar->show(); | 2535 | do_regedit(); |
2536 | // odebug << "sn" << oendl; | 2536 | } |
2537 | showNormal(); | 2537 | */ |
2538 | // odebug << "sm" << oendl; | 2538 | void QTReaderApp::settarget() |
2539 | #ifdef USEQPE | 2539 | { |
2540 | showMaximized(); | 2540 | m_nRegAction = cSetTarget; |
2541 | #endif | 2541 | QString text = ((m_targetapp.isEmpty()) ? QString("") : m_targetapp) |
2542 | // setCentralWidget(reader); | 2542 | + "/" |
2543 | } | 2543 | + ((m_targetmsg.isEmpty()) ? QString("") : m_targetmsg); |
2544 | 2544 | regEdit->setText(text); | |
2545 | // odebug << "uc" << oendl; | 2545 | do_regedit(); |
2546 | updateCaption(); | 2546 | } |
2547 | // odebug << "rw" << oendl; | 2547 | |
2548 | editorStack->raiseWidget( reader ); | 2548 | /* |
2549 | // odebug << "sf" << oendl; | 2549 | void QTReaderApp::do_mono(const QString& lcn) |
2550 | reader->setFocus(); | 2550 | { |
2551 | reader->refresh(); | 2551 | bool ok; |
2552 | } | 2552 | unsigned long ulcn = lcn.toULong(&ok); |
2553 | /* | 2553 | if (ok) |
2554 | void QTReaderApp::save() | 2554 | { |
2555 | { | 2555 | reader->m_charpc = ulcn; |
2556 | if ( !doc ) | 2556 | reader->setfont(); |
2557 | return; | 2557 | reader->refresh(); |
2558 | if ( !editor->edited() ) | 2558 | //reader->setmono(true); |
2559 | return; | 2559 | } |
2560 | 2560 | else | |
2561 | QString rt = editor->text(); | 2561 | QMessageBox::information(this, PROGNAME, "Must be a number"); |
2562 | QString pt = rt; | 2562 | } |
2563 | 2563 | */ | |
2564 | if ( doc->name().isEmpty() ) { | 2564 | /* |
2565 | unsigned ispace = pt.find( ' ' ); | 2565 | void QTReaderApp::editPaste() |
2566 | unsigned ienter = pt.find( '\n' ); | 2566 | { |
2567 | int i = (ispace < ienter) ? ispace : ienter; | 2567 | #ifndef QT_NO_CLIPBOARD |
2568 | QString docname; | 2568 | editor->paste(); |
2569 | if ( i == -1 ) { | 2569 | #endif |
2570 | if ( pt.isEmpty() ) | 2570 | } |
2571 | docname = "Empty Text"; | 2571 | */ |
2572 | else | 2572 | |
2573 | docname = pt; | 2573 | void QTReaderApp::editFind() |
2574 | } else { | 2574 | { |
2575 | docname = pt.left( i ); | 2575 | searchStart = reader->pagelocate(); |
2576 | } | 2576 | #ifdef __ISEARCH |
2577 | doc->setName(docname); | 2577 | searchStack = new QStack<searchrecord>; |
2578 | } | 2578 | #endif |
2579 | FileManager fm; | 2579 | #ifdef USEQPE |
2580 | fm.saveFile( *doc, rt ); | 2580 | Global::showInputMethod(); |
2581 | } | 2581 | #endif |
2582 | */ | 2582 | searchBar->show(); |
2583 | 2583 | searchVisible = TRUE; | |
2584 | void QTReaderApp::clear() | 2584 | searchEdit->setFocus(); |
2585 | { | 2585 | #ifdef __ISEARCH |
2586 | // if (doc != 0) | 2586 | searchStack->push(new searchrecord("",reader->pagelocate())); |
2587 | // { | 2587 | #endif |
2588 | // QMessageBox::information(this, PROGNAME, "Deleting doc", 1); | 2588 | } |
2589 | // delete doc; | 2589 | |
2590 | // QMessageBox::information(this, PROGNAME, "Deleted doc", 1); | 2590 | void QTReaderApp::findNext() |
2591 | // doc = 0; | 2591 | { |
2592 | // } | 2592 | // // qDebug("findNext called\n"); |
2593 | reader->clear(); | 2593 | #ifdef __ISEARCH |
2594 | } | 2594 | QString arg = searchEdit->text(); |
2595 | 2595 | #else | |
2596 | void QTReaderApp::updateCaption() | 2596 | QRegExp arg = searchEdit->text(); |
2597 | { | 2597 | #endif |
2598 | // if ( !doc ) | 2598 | CDrawBuffer test(&(reader->m_fontControl)); |
2599 | // setCaption( tr("QTReader") ); | 2599 | size_t start = reader->pagelocate(); |
2600 | // else { | 2600 | reader->jumpto(start); |
2601 | // QString s = doc->name(); | 2601 | reader->getline(&test); |
2602 | // if ( s.isEmpty() ) | 2602 | dosearch(start, test, arg); |
2603 | // s = tr( "Unnamed" ); | 2603 | } |
2604 | setCaption( reader->m_string + " - " + tr("Reader") ); | 2604 | |
2605 | // } | 2605 | void QTReaderApp::findClose() |
2606 | } | 2606 | { |
2607 | 2607 | searchVisible = FALSE; | |
2608 | void QTReaderApp::setDocument(const QString& fileref) | 2608 | searchEdit->setText(""); |
2609 | { | 2609 | #ifdef USEQPE |
2610 | bFromDocView = TRUE; | 2610 | Global::hideInputMethod(); |
2611 | //QMessageBox::information(0, "setDocument", fileref); | 2611 | #endif |
2612 | openFile(fileref); | 2612 | searchBar->hide(); |
2613 | // showEditTools(); | 2613 | #ifdef __ISEARCH |
2614 | } | 2614 | // searchStack = new QStack<searchrecord>; |
2615 | 2615 | while (!searchStack->isEmpty()) | |
2616 | void QTReaderApp::closeEvent( QCloseEvent *e ) | 2616 | { |
2617 | { | 2617 | delete searchStack->pop(); |
2618 | // odebug << "Close event" << oendl; | 2618 | } |
2619 | if (m_fullscreen) | 2619 | delete searchStack; |
2620 | { | 2620 | #endif |
2621 | m_fullscreen = false; | 2621 | reader->setFocus(); |
2622 | showEditTools(); | 2622 | } |
2623 | e->accept(); | 2623 | |
2624 | } | 2624 | void QTReaderApp::regClose() |
2625 | else if (m_dontSave) | 2625 | { |
2626 | { | 2626 | regVisible = FALSE; |
2627 | e->accept(); | 2627 | regEdit->setText(""); |
2628 | } | 2628 | regBar->hide(); |
2629 | else | 2629 | #ifdef USEQPE |
2630 | { | 2630 | Global::hideInputMethod(); |
2631 | if (editorStack->visibleWidget() == reader) | 2631 | #endif |
2632 | { | 2632 | reader->setFocus(); |
2633 | if ((m_escapeTarget != cesNone) && m_bcloseDisabled) | 2633 | } |
2634 | { | 2634 | |
2635 | // odebug << "Close disabled" << oendl; | 2635 | #ifdef __ISEARCH |
2636 | m_bcloseDisabled = false; | 2636 | bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QString& arg) |
2637 | e->ignore(); | 2637 | #else |
2638 | } | 2638 | bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg) |
2639 | else | 2639 | #endif |
2640 | { | 2640 | { |
2641 | if (m_fontVisible) | 2641 | bool ret = true; |
2642 | { | 2642 | unsigned long fs, ts; |
2643 | m_fontBar->hide(); | 2643 | reader->sizes(fs,ts); |
2644 | m_fontVisible = false; | 2644 | size_t pos = reader->locate(); |
2645 | } | 2645 | pbar->setGeometry(searchBar->x(),searchBar->y(),searchBar->width(), searchBar->height()); |
2646 | if (regVisible) | 2646 | pbar->show(); |
2647 | { | 2647 | pbar->raise(); |
2648 | regBar->hide(); | 2648 | pbar->reset(); |
2649 | #ifdef USEQPE | 2649 | int offset; |
2650 | Global::hideInputMethod(); | 2650 | int lastpc = (100*pos)/ts; |
2651 | #endif | 2651 | pbar->setProgress(lastpc); |
2652 | regVisible = false; | 2652 | // qApp->processEvents(); |
2653 | return; | 2653 | if (reader->buffdoc.getpara(test) >= 0) |
2654 | } | 2654 | { |
2655 | if (searchVisible) | 2655 | reader->setFocus(); |
2656 | { | 2656 | #ifdef __ISEARCH |
2657 | searchBar->hide(); | 2657 | while (strstr(test.data(),(const tchar*)arg) == NULL) |
2658 | #ifdef USEQPE | 2658 | #else |
2659 | Global::hideInputMethod(); | 2659 | #ifdef _UNICODE |
2660 | #endif | 2660 | while ((offset = arg.match(toQString(test.data()))) == -1) |
2661 | searchVisible = false; | 2661 | #else |
2662 | return; | 2662 | while (arg.match(test.data()) == -1) |
2663 | } | 2663 | #endif |
2664 | if (m_fBkmksChanged && pBkmklist != NULL) | 2664 | #endif |
2665 | { | 2665 | { |
2666 | if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) | 2666 | pos = reader->locate(); |
2667 | savebkmks(); | 2667 | int pc = (100*pos)/ts; |
2668 | delete pBkmklist; | 2668 | if (pc != lastpc) |
2669 | pBkmklist = NULL; | 2669 | { |
2670 | m_fBkmksChanged = false; | 2670 | pbar->setProgress(pc); |
2671 | } | 2671 | qApp->processEvents(); |
2672 | bFromDocView = FALSE; | 2672 | reader->setFocus(); |
2673 | updatefileinfo(); | 2673 | lastpc = pc; |
2674 | saveprefs(); | 2674 | } |
2675 | e->accept(); | 2675 | |
2676 | } | 2676 | if (reader->buffdoc.getpara(test) < 0) |
2677 | } | 2677 | { |
2678 | else | 2678 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) |
2679 | { | 2679 | pos = searchStart; |
2680 | showEditTools(); | 2680 | else |
2681 | m_disableesckey = true; | 2681 | pos = start; |
2682 | } | 2682 | findClose(); |
2683 | } | 2683 | pbar->hide(); |
2684 | } | 2684 | reader->locate(pos); |
2685 | 2685 | return false; | |
2686 | void QTReaderApp::do_gotomark() | 2686 | } |
2687 | { | 2687 | } |
2688 | m_nBkmkAction = cGotoBkmk; | 2688 | // qDebug("Found it at %u:%u", pos, offset); |
2689 | if (!listbkmk(pBkmklist)) | 2689 | pbar->hide(); |
2690 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); | 2690 | // qDebug("Hid"); |
2691 | } | 2691 | reader->locate(pos+offset); |
2692 | 2692 | // qDebug("Loacted"); | |
2693 | void QTReaderApp::do_delmark() | 2693 | // qDebug("page up"); |
2694 | { | 2694 | ret = true; |
2695 | m_nBkmkAction = cDelBkmk; | 2695 | } |
2696 | if (!listbkmk(pBkmklist)) | 2696 | else |
2697 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); | 2697 | { |
2698 | } | 2698 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) |
2699 | 2699 | pos = searchStart; | |
2700 | bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab) | 2700 | else |
2701 | { | 2701 | pos = start; |
2702 | bkmkselector->clear(); | 2702 | ret = false; |
2703 | if (_lab.isEmpty()) | 2703 | findClose(); |
2704 | bkmkselector->setText("Cancel"); | 2704 | } |
2705 | else | 2705 | return ret; |
2706 | bkmkselector->setText(_lab); | 2706 | } |
2707 | int cnt = 0; | 2707 | |
2708 | if (plist != NULL) | 2708 | #ifdef __ISEARCH |
2709 | { | 2709 | void QTReaderApp::search(const QString & arg) |
2710 | for (CList<Bkmk>::iterator i = plist->begin(); i != plist->end(); i++) | 2710 | { |
2711 | { | 2711 | searchrecord* ss = searchStack->top(); |
2712 | #ifdef _UNICODE | 2712 | CBuffer test; |
2713 | // odebug << "Item:" << toQString(i->name()) << "" << oendl; | 2713 | size_t start = reader->pagelocate(); |
2714 | bkmkselector->insertItem(toQString(i->name())); | 2714 | bool haspopped = false; |
2715 | #else | 2715 | while (arg.left(ss->s.length()) != ss->s) |
2716 | bkmkselector->insertItem(i->name()); | 2716 | { |
2717 | #endif | 2717 | haspopped = true; |
2718 | cnt++; | 2718 | start = ss->pos; |
2719 | } | 2719 | // reader->locate(start); |
2720 | } | 2720 | searchStack->pop(); |
2721 | if (cnt > 0) | 2721 | delete ss; |
2722 | { | 2722 | } |
2723 | hidetoolbars(); | 2723 | if (haspopped) reader->locate(start); |
2724 | editorStack->raiseWidget( bkmkselector ); | 2724 | /* |
2725 | return true; | 2725 | if (arg.length() < ss->len) |
2726 | } | 2726 | { |
2727 | else | 2727 | start = ss->pos; |
2728 | return false; | 2728 | reader->locate(start); |
2729 | } | 2729 | searchStack->pop(); |
2730 | 2730 | delete ss; | |
2731 | void QTReaderApp::do_autogen() | 2731 | } |
2732 | { | 2732 | */ |
2733 | m_nRegAction = cAutoGen; | 2733 | else |
2734 | regEdit->setText(m_autogenstr); | 2734 | { |
2735 | do_regedit(); | 2735 | start = reader->pagelocate(); |
2736 | } | 2736 | reader->jumpto(start); |
2737 | 2737 | searchStack->push(new searchrecord(arg,start)); | |
2738 | void QTReaderApp::do_regedit() | 2738 | } |
2739 | { | 2739 | dosearch(start, test, arg); |
2740 | // fileBar->hide(); | 2740 | } |
2741 | reader->bDoUpdates = false; | 2741 | #else |
2742 | // odebug << "Showing regbar" << oendl; | 2742 | void QTReaderApp::search() |
2743 | regBar->show(); | 2743 | { |
2744 | // odebug << "Showing kbd" << oendl; | 2744 | findNext(); |
2745 | #ifdef USEQPE | 2745 | } |
2746 | Global::showInputMethod(); | 2746 | #endif |
2747 | #endif | 2747 | |
2748 | regVisible = true; | 2748 | void QTReaderApp::openFile( const QString &f ) |
2749 | regEdit->setFocus(); | 2749 | { |
2750 | // qApp->processEvents(); | 2750 | // qDebug("File:%s", (const char*)f); |
2751 | reader->bDoUpdates = true; | 2751 | // openFile(DocLnk(f)); |
2752 | reader->update(); | 2752 | //} |
2753 | } | 2753 | // |
2754 | 2754 | //void QTReaderApp::openFile( const DocLnk &f ) | |
2755 | bool QTReaderApp::openfrombkmk(Bkmk* bk) | 2755 | //{ |
2756 | { | 2756 | clear(); |
2757 | QString fn = toQString( | 2757 | QFileInfo fm(f); |
2758 | CFiledata(bk->anno()).name() | 2758 | if ( fm.exists() ) |
2759 | ); | 2759 | { |
2760 | // odebug << "fileinfo" << oendl; | 2760 | // QMessageBox::information(0, "Progress", "Calling fileNew()"); |
2761 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) | 2761 | #ifdef USEQPE |
2762 | { | 2762 | if (fm.extension( FALSE ) == "desktop") |
2763 | // odebug << "Opening" << oendl; | 2763 | { |
2764 | openFile(fn); | 2764 | DocLnk d(f); |
2765 | struct stat fnstat; | 2765 | QFileInfo fnew(d.file()); |
2766 | stat((const char *)reader->m_lastfile, &fnstat); | 2766 | fm = fnew; |
2767 | 2767 | if (!fm.exists()) return; | |
2768 | if (CFiledata(bk->anno()).date() | 2768 | } |
2769 | != fnstat.st_mtime) | 2769 | #endif |
2770 | { | 2770 | clear(); |
2771 | CFiledata fd(bk->anno()); | 2771 | reader->setText(fm.baseName(), fm.absFilePath()); |
2772 | fd.setdate(fnstat.st_mtime); | 2772 | m_loadedconfig = readconfig(APPDIR "/configs", reader->m_string, false); |
2773 | bk->value(0); | 2773 | qDebug("Showing tools"); |
2774 | } | 2774 | showEditTools(); |
2775 | else | 2775 | qDebug("Shown tools"); |
2776 | { | 2776 | readbkmks(); |
2777 | unsigned short svlen = bk->filedatalen(); | 2777 | qDebug("read markss"); |
2778 | unsigned char* svdata = bk->filedata(); | 2778 | m_savedpos = 0xffffffff; |
2779 | reader->putSaveData(svdata, svlen); | 2779 | } |
2780 | // setstate(svdata, svlen); | 2780 | else |
2781 | if (svlen != 0) | 2781 | { |
2782 | { | 2782 | QString msg = f; |
2783 | QMessageBox::warning(this, PROGNAME, "Not all file data used\nNew version?"); | 2783 | msg += "\nFile does not exist"; |
2784 | } | 2784 | QMessageBox::information(this, PROGNAME, msg); |
2785 | // odebug << "updating" << oendl; | 2785 | reader->m_lastfile = QString::null; |
2786 | // showEditTools(); | 2786 | } |
2787 | reader->locate(bk->value()); | 2787 | |
2788 | } | 2788 | } |
2789 | return true; | 2789 | /* |
2790 | } | 2790 | void QTReaderApp::resizeEvent(QResizeEvent* e) |
2791 | else | 2791 | { |
2792 | { | 2792 | if (m_fullscreen) |
2793 | return false; | 2793 | { |
2794 | } | 2794 | showNormal(); |
2795 | } | 2795 | showFullScreen(); |
2796 | 2796 | } | |
2797 | void QTReaderApp::gotobkmk(int ind) | 2797 | } |
2798 | { | 2798 | */ |
2799 | showEditTools(); | 2799 | void QTReaderApp::handlekey(QKeyEvent* e) |
2800 | switch (m_nBkmkAction) | 2800 | { |
2801 | { | 2801 | // qDebug("Keypress event"); |
2802 | case cOpenFile: | 2802 | timeb now; |
2803 | { | 2803 | ftime(&now); |
2804 | // qApp->processEvents(); | 2804 | unsigned long etime = (1000*(now.time - m_lastkeytime.time) + now.millitm)-m_lastkeytime.millitm; |
2805 | if (!openfrombkmk((*pOpenlist)[ind])) | 2805 | if (etime < m_debounce) |
2806 | { | 2806 | { |
2807 | pOpenlist->erase(ind); | 2807 | return; |
2808 | QMessageBox::information(this, PROGNAME, "Can't find file"); | 2808 | } |
2809 | } | 2809 | switch(e->key()) |
2810 | } | 2810 | { |
2811 | break; | 2811 | case Key_Escape: |
2812 | case cGotoBkmk: | 2812 | // qDebug("escape event"); |
2813 | reader->locate((*pBkmklist)[ind]->value()); | 2813 | if (m_disableesckey) |
2814 | break; | 2814 | { |
2815 | case cDelBkmk: | 2815 | m_disableesckey = false; |
2816 | //// odebug << "Deleting:" << (*pBkmklist)[ind]->name() << "\n" << oendl; | 2816 | } |
2817 | pBkmklist->erase(ind); | 2817 | else |
2818 | m_fBkmksChanged = true; | 2818 | { |
2819 | // pBkmklist->sort(); | 2819 | m_bcloseDisabled = true; |
2820 | break; | 2820 | if (m_fullscreen) |
2821 | case cRmBkmkFile: | 2821 | { |
2822 | { | 2822 | m_actFullscreen->setOn(false); |
2823 | #ifndef USEQPE | 2823 | e->accept(); |
2824 | QDir d = QDir::home(); // "/" | 2824 | } |
2825 | d.cd(APPDIR); | 2825 | else |
2826 | d.remove(bkmkselector->text(ind)); | 2826 | { |
2827 | #else /* USEQPE */ | 2827 | // qDebug("escape action"); |
2828 | unlink((const char *)Global::applicationFileName(APPDIR,bkmkselector->text(ind))); | 2828 | doAction(e); |
2829 | #endif /* USEQPE */ | 2829 | } |
2830 | } | 2830 | } |
2831 | break; | 2831 | break; |
2832 | case cLdConfig: | 2832 | /* |
2833 | readconfig(bkmkselector->text(ind), false); | 2833 | case Key_Left: |
2834 | break; | 2834 | { |
2835 | case cRmConfig: | 2835 | if (reader->m_autoScroll) |
2836 | { | 2836 | { |
2837 | #ifndef USEQPE | 2837 | reader->reduceScroll(); |
2838 | QDir d = QDir::home(); // "/" | 2838 | } |
2839 | d.cd(APPDIR "/configs"); | 2839 | else |
2840 | d.remove(bkmkselector->text(ind)); | 2840 | { |
2841 | #else /* USEQPE */ | 2841 | doAction(e); |
2842 | unlink((const char *)Global::applicationFileName(APPDIR "/configs",bkmkselector->text(ind))); | 2842 | } |
2843 | #endif /* USEQPE */ | 2843 | } |
2844 | } | 2844 | break; |
2845 | break; | 2845 | case Key_Right: |
2846 | case cExportLinks: | 2846 | { |
2847 | { | 2847 | if (reader->m_autoScroll) |
2848 | #ifndef USEQPE | 2848 | { |
2849 | QDir d = QDir::home(); // "/" | 2849 | reader->increaseScroll(); |
2850 | d.cd(APPDIR "/urls"); | 2850 | } |
2851 | QFileInfo fi(d, bkmkselector->text(ind)); | 2851 | else |
2852 | if (fi.exists()) | 2852 | { |
2853 | { | 2853 | doAction(e); |
2854 | QString outfile( QFileDialog::getSaveFileName( QString::null, QString::null, this ) ); | 2854 | } |
2855 | if (!outfile.isEmpty()) | 2855 | } |
2856 | { | 2856 | break; |
2857 | FILE* fout = fopen((const char *)outfile, "w"); | 2857 | case Key_Up: |
2858 | if (fout != NULL) | 2858 | { |
2859 | { | 2859 | if (reader->m_autoScroll) |
2860 | FILE* fin = fopen((const char *)fi.absFilePath(), "r"); | 2860 | { |
2861 | if (fin != NULL) | 2861 | reader->increaseScroll(); |
2862 | { | 2862 | } |
2863 | fprintf(fout, "<html><body>\n"); | 2863 | else |
2864 | int ch = 0; | 2864 | { |
2865 | while ((ch = fgetc(fin)) != EOF) | 2865 | doAction(e); |
2866 | { | 2866 | } |
2867 | fputc(ch, fout); | 2867 | } |
2868 | } | 2868 | break; |
2869 | fclose(fin); | 2869 | case Key_Down: |
2870 | fprintf(fout, "</html></body>\n"); | 2870 | { |
2871 | d.remove(bkmkselector->text(ind)); | 2871 | if (reader->m_autoScroll) |
2872 | } | 2872 | { |
2873 | fclose(fout); | 2873 | reader->reduceScroll(); |
2874 | } | 2874 | } |
2875 | else | 2875 | else |
2876 | QMessageBox::information(this, PROGNAME, "Couldn't open output"); | 2876 | { |
2877 | } | 2877 | doAction(e); |
2878 | } | 2878 | } |
2879 | #else /* USEQPE */ | 2879 | } |
2880 | FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); | 2880 | break; |
2881 | if (fin != NULL) | 2881 | */ |
2882 | { | 2882 | default: |
2883 | bool allok = false; | 2883 | { |
2884 | fileBrowser* fb = new fileBrowser(true, this,"OpieReader",!m_bFloatingDialog, 0, "*", QString::null); | 2884 | doAction(e); |
2885 | if (fb->exec()) | 2885 | } |
2886 | { | 2886 | |
2887 | QString outfile = fb->getCurrentFile(); | 2887 | /* |
2888 | FILE* fout = fopen((const char *)outfile, "w"); | 2888 | QString msg("Key press was:"); |
2889 | if (fout != NULL) | 2889 | QString key; |
2890 | { | 2890 | msg += key.setNum(e->key()); |
2891 | fprintf(fout, "<html><body>\n"); | 2891 | QMessageBox::information(this, PROGNAME, msg); |
2892 | int ch = 0; | 2892 | */ |
2893 | while ((ch = fgetc(fin)) != EOF) | 2893 | } |
2894 | { | 2894 | ftime(&m_lastkeytime); |
2895 | fputc(ch, fout); | 2895 | } |
2896 | } | 2896 | |
2897 | fprintf(fout, "</html></body>\n"); | 2897 | #ifdef NEWFULLSCREEN |
2898 | fclose(fout); | 2898 | void QTReaderApp::enableFullscreen() |
2899 | allok = true; | 2899 | { |
2900 | } | 2900 | setFixedSize(qApp->desktop()->size()); |
2901 | else | 2901 | showNormal(); |
2902 | QMessageBox::information(this, PROGNAME, "Couldn't open output"); | 2902 | reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0)); |
2903 | } | 2903 | showFullScreen(); |
2904 | delete fb; | 2904 | } |
2905 | fclose(fin); | 2905 | |
2906 | if (allok) unlink((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind))); | 2906 | void QTReaderApp::resizeEvent(QResizeEvent *) |
2907 | } | 2907 | { |
2908 | else | 2908 | if (m_fullscreen && (size() != qApp->desktop()->size())) |
2909 | { | 2909 | { |
2910 | QMessageBox::information(this, PROGNAME, "Couldn't open input"); | 2910 | enableFullscreen(); |
2911 | } | 2911 | } |
2912 | 2912 | } | |
2913 | /* | 2913 | |
2914 | CFileSelector *f = new CFileSelector("text/html", this, NULL, !m_bFloatingDialog, TRUE, TRUE ); | 2914 | void QTReaderApp::focusInEvent(QFocusEvent*) |
2915 | int ret = f->exec(); | 2915 | { |
2916 | odebug << "Return:" << ret << "" << oendl; | 2916 | if (m_fullscreen) |
2917 | DocLnk* doc = f->getDoc(); | 2917 | { |
2918 | if (doc != NULL) | 2918 | enableFullscreen(); |
2919 | { | 2919 | raise(); |
2920 | FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); | 2920 | } |
2921 | QString rt; | 2921 | } |
2922 | rt = "<html><body>\n"; | 2922 | #endif |
2923 | int ch = 0; | 2923 | |
2924 | while ((ch = fgetc(fin)) != EOF) | 2924 | void QTReaderApp::showEditTools() |
2925 | { | 2925 | { |
2926 | rt += (char)ch; | 2926 | // if ( !doc ) |
2927 | } | 2927 | //close(); |
2928 | fclose(fin); | 2928 | if (m_fullscreen) |
2929 | rt += "</html></body>\n"; | 2929 | { |
2930 | if ( doc->name().isEmpty() ) | 2930 | #ifdef USEQPE |
2931 | { | 2931 | if (menubar != NULL) menubar->hide(); |
2932 | doc->setName(bkmkselector->text(ind)); | 2932 | #endif |
2933 | } | 2933 | if (fileBar != NULL) fileBar->hide(); |
2934 | FileManager fm; | 2934 | if (viewBar != NULL) viewBar->hide(); |
2935 | fm.saveFile( *doc, rt ); | 2935 | if (navBar != NULL) navBar->hide(); |
2936 | odebug << "YES" << oendl; | 2936 | if (markBar != NULL) markBar->hide(); |
2937 | } | 2937 | if (m_prog != NULL) |
2938 | else | 2938 | { |
2939 | { | 2939 | // qDebug("Hiding status"); |
2940 | odebug << "NO" << oendl; | 2940 | m_prog->hide(); |
2941 | } | 2941 | } |
2942 | delete f; | 2942 | searchBar->hide(); |
2943 | */ | 2943 | regBar->hide(); |
2944 | 2944 | #ifdef USEQPE | |
2945 | #endif /* USEQPE */ | 2945 | Global::hideInputMethod(); |
2946 | } | 2946 | #endif |
2947 | break; | 2947 | if (m_scrollbar != NULL) m_scrollbar->hide(); |
2948 | } | 2948 | m_fontBar->hide(); |
2949 | } | 2949 | //showNormal(); |
2950 | 2950 | #ifdef NEWFULLSCREEN | |
2951 | void QTReaderApp::cancelbkmk() | 2951 | enableFullscreen(); |
2952 | { | 2952 | #else |
2953 | if (m_nBkmkAction == cOpenFile) | 2953 | showFullScreen(); |
2954 | { | 2954 | #endif |
2955 | QString fn = usefilebrowser(); | 2955 | } |
2956 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn); | 2956 | else |
2957 | } | 2957 | { |
2958 | showEditTools(); | 2958 | //qDebug("him"); |
2959 | } | 2959 | #ifdef USEQPE |
2960 | 2960 | Global::hideInputMethod(); | |
2961 | void QTReaderApp::jump() | 2961 | #endif |
2962 | { | 2962 | //qDebug("eb"); |
2963 | m_nRegAction = cJump; | 2963 | if (m_scrollbar != NULL) |
2964 | char lcn[20]; | 2964 | { |
2965 | sprintf(lcn, "%lu", reader->pagelocate()); | 2965 | if (m_scrollishidden) |
2966 | regEdit->setText(lcn); | 2966 | { |
2967 | do_regedit(); | 2967 | m_scrollbar->hide(); |
2968 | } | 2968 | } |
2969 | 2969 | else | |
2970 | void QTReaderApp::do_jump(const QString& lcn) | 2970 | { |
2971 | { | 2971 | m_scrollbar->show(); |
2972 | bool ok; | 2972 | } |
2973 | unsigned long ulcn = lcn.toULong(&ok); | 2973 | } |
2974 | if (ok) | 2974 | if (!m_hidebars) |
2975 | reader->locate(ulcn); | 2975 | { |
2976 | else | 2976 | #ifdef USEQPE |
2977 | QMessageBox::information(this, PROGNAME, "Must be a number"); | 2977 | menubar->show(); |
2978 | } | 2978 | #endif |
2979 | 2979 | if (fileBar != NULL) fileBar->show(); | |
2980 | void QTReaderApp::do_regaction() | 2980 | if (viewBar != NULL) viewBar->show(); |
2981 | { | 2981 | if (navBar != NULL) navBar->show(); |
2982 | reader->bDoUpdates = false; | 2982 | if (markBar != NULL) markBar->show(); |
2983 | regBar->hide(); | 2983 | if (m_prog != NULL && !m_statusishidden) |
2984 | #ifdef USEQPE | 2984 | { |
2985 | Global::hideInputMethod(); | 2985 | // qDebug("Showing status"); |
2986 | #endif | 2986 | m_prog->show(); |
2987 | regVisible = false; | 2987 | // qDebug("Shown status"); |
2988 | switch(m_nRegAction) | 2988 | } |
2989 | { | 2989 | // qDebug("Showing mb"); |
2990 | case cAutoGen: | 2990 | mb->show(); |
2991 | do_autogen(regEdit->text()); | 2991 | } |
2992 | break; | 2992 | if ( searchVisible ) |
2993 | case cAddBkmk: | 2993 | { |
2994 | do_addbkmk(regEdit->text()); | 2994 | #ifdef USEQPE |
2995 | break; | 2995 | Global::showInputMethod(); |
2996 | case cJump: | 2996 | #endif |
2997 | do_jump(regEdit->text()); | 2997 | searchBar->show(); |
2998 | break; | 2998 | } |
2999 | /* | 2999 | if ( regVisible ) |
3000 | case cMonoSpace: | 3000 | { |
3001 | do_mono(regEdit->text()); | 3001 | #ifdef USEQPE |
3002 | break; | 3002 | Global::showInputMethod(); |
3003 | */ | 3003 | #endif |
3004 | case cSetTarget: | 3004 | regBar->show(); |
3005 | do_settarget(regEdit->text()); | 3005 | } |
3006 | break; | 3006 | if (m_fontVisible) m_fontBar->show(); |
3007 | #ifdef _SCROLLPIPE | 3007 | //qDebug("sn"); |
3008 | case cSetPipeTarget: | 3008 | showNormal(); |
3009 | do_setpipetarget(regEdit->text()); | 3009 | //qDebug("sm"); |
3010 | break; | 3010 | #ifdef USEQPE |
3011 | #endif | 3011 | showMaximized(); |
3012 | case cSetConfigName: | 3012 | #endif |
3013 | // odebug << "Saving config" << oendl; | 3013 | //setCentralWidget(reader); |
3014 | do_saveconfig(regEdit->text(), false); | 3014 | } |
3015 | break; | 3015 | |
3016 | } | 3016 | // qDebug("uc"); |
3017 | // reader->restore(); | 3017 | updateCaption(); |
3018 | // fileBar->show(); | 3018 | // qDebug("rw"); |
3019 | reader->setFocus(); | 3019 | editorStack->raiseWidget( reader ); |
3020 | // qApp->processEvents(); | 3020 | // qDebug("sf"); |
3021 | reader->bDoUpdates = true; | 3021 | reader->setFocus(); |
3022 | reader->update(); | 3022 | // qDebug("ref"); |
3023 | } | 3023 | reader->refresh(true); |
3024 | 3024 | // qDebug("done"); | |
3025 | void QTReaderApp::do_settarget(const QString& _txt) | 3025 | } |
3026 | { | 3026 | /* |
3027 | int ind = _txt.find('/'); | 3027 | void QTReaderApp::save() |
3028 | if (ind == -1) | 3028 | { |
3029 | { | 3029 | if ( !doc ) |
3030 | m_targetapp = ""; | 3030 | return; |
3031 | m_targetmsg = ""; | 3031 | if ( !editor->edited() ) |
3032 | QMessageBox::information(this, PROGNAME, "Format is\nappname/messagename"); | 3032 | return; |
3033 | } | 3033 | |
3034 | else | 3034 | QString rt = editor->text(); |
3035 | { | 3035 | QString pt = rt; |
3036 | m_targetapp = _txt.left(ind); | 3036 | |
3037 | m_targetmsg = _txt.right(_txt.length()-ind-1); | 3037 | if ( doc->name().isEmpty() ) { |
3038 | } | 3038 | unsigned ispace = pt.find( ' ' ); |
3039 | } | 3039 | unsigned ienter = pt.find( '\n' ); |
3040 | 3040 | int i = (ispace < ienter) ? ispace : ienter; | |
3041 | void QTReaderApp::chooseencoding() | 3041 | QString docname; |
3042 | { | 3042 | if ( i == -1 ) { |
3043 | m_fontSelector->clear(); | 3043 | if ( pt.isEmpty() ) |
3044 | m_fontSelector->insertItem("Ascii"); | 3044 | docname = "Empty Text"; |
3045 | m_fontSelector->insertItem("UTF-8"); | 3045 | else |
3046 | m_fontSelector->insertItem("UCS-2(BE)"); | 3046 | docname = pt; |
3047 | m_fontSelector->insertItem("USC-2(LE)"); | 3047 | } else { |
3048 | m_fontSelector->insertItem("Palm"); | 3048 | docname = pt.left( i ); |
3049 | for (unicodetable::iterator iter = unicodetable::begin(); iter != unicodetable::end(); iter++) | 3049 | } |
3050 | { | 3050 | doc->setName(docname); |
3051 | m_fontSelector->insertItem(iter->mime); | 3051 | } |
3052 | } // delete the FontDatabase!!! | 3052 | FileManager fm; |
3053 | m_fontSelector->setCurrentItem (reader->m_encd); | 3053 | fm.saveFile( *doc, rt ); |
3054 | m_fontAction = cChooseEncoding; | 3054 | } |
3055 | m_fontBar->show(); | 3055 | */ |
3056 | m_fontVisible = true; | 3056 | |
3057 | } | 3057 | void QTReaderApp::clear() |
3058 | 3058 | { | |
3059 | void QTReaderApp::setfont() | 3059 | // if (doc != 0) |
3060 | { | 3060 | // { |
3061 | m_fontSelector->clear(); | 3061 | // QMessageBox::information(this, PROGNAME, "Deleting doc", 1); |
3062 | { | 3062 | //delete doc; |
3063 | #ifdef USEQPE | 3063 | // QMessageBox::information(this, PROGNAME, "Deleted doc", 1); |
3064 | FontDatabase f; | 3064 | //doc = 0; |
3065 | #else | 3065 | // } |
3066 | QFontDatabase f; | 3066 | reader->clear(); |
3067 | #endif | 3067 | } |
3068 | QStringList flist = f.families(); | 3068 | |
3069 | m_fontSelector->insertStringList(flist); | 3069 | void QTReaderApp::updateCaption() |
3070 | } // delete the FontDatabase!!! | 3070 | { |
3071 | 3071 | // if ( !doc ) | |
3072 | for (int i = 1; i <= m_fontSelector->count(); i++) | 3072 | //setCaption( tr("QTReader") ); |
3073 | { | 3073 | // else { |
3074 | if (m_fontSelector->text(i) == reader->m_fontname) | 3074 | //QString s = doc->name(); |
3075 | { | 3075 | //if ( s.isEmpty() ) |
3076 | m_fontSelector->setCurrentItem(i); | 3076 | // s = tr( "Unnamed" ); |
3077 | break; | 3077 | setCaption( reader->m_string + " - " + tr(SHORTPROGNAME) ); |
3078 | } | 3078 | // } |
3079 | } | 3079 | } |
3080 | m_fontAction = cChooseFont; | 3080 | |
3081 | m_fontBar->show(); | 3081 | void QTReaderApp::setDocument(const QString& fileref) |
3082 | m_fontVisible = true; | 3082 | { |
3083 | } | 3083 | //QMessageBox::information(0, "setDocument", fileref); |
3084 | 3084 | openFile(fileref); | |
3085 | void QTReaderApp::setfontHelper(const QString& lcn, int size) | 3085 | // showEditTools(); |
3086 | { | 3086 | } |
3087 | if (size == 0) size = reader->m_fontControl.currentsize(); | 3087 | |
3088 | if (m_propogatefontchange) | 3088 | void QTReaderApp::closeEvent( QCloseEvent *e ) |
3089 | { | 3089 | { |
3090 | QFont f(lcn, 10); | 3090 | // qDebug("Close event"); |
3091 | bkmkselector->setFont( f ); | 3091 | if (m_fullscreen) |
3092 | regEdit->setFont( f ); | 3092 | { |
3093 | searchEdit->setFont( f ); | 3093 | m_fullscreen = false; |
3094 | m_annoWin->setFont( f ); | 3094 | showEditTools(); |
3095 | } | 3095 | e->ignore(); |
3096 | reader->m_fontname = lcn; | 3096 | } |
3097 | if (!reader->ChangeFont(size)) | 3097 | else if (editorStack->visibleWidget() == m_buttonprefs) |
3098 | { | 3098 | { |
3099 | reader->ChangeFont(size); | 3099 | m_buttonprefs->mapkey(Qt::NoButton, Key_Escape); |
3100 | } | 3100 | e->ignore(); |
3101 | } | 3101 | } |
3102 | 3102 | else if (m_dontSave) | |
3103 | void QTReaderApp::do_setencoding(int i) | 3103 | { |
3104 | { | 3104 | e->accept(); |
3105 | // odebug << "setencoding:" << i << "" << oendl; | 3105 | } |
3106 | if (m_fontAction == cChooseEncoding) | 3106 | else |
3107 | { | 3107 | { |
3108 | reader->setencoding(i); | 3108 | if (editorStack->visibleWidget() == reader) |
3109 | } | 3109 | { |
3110 | reader->refresh(); | 3110 | if ((kmap.find(orKey(Qt::NoButton,Key_Escape,false)) != kmap.end()) && m_bcloseDisabled) |
3111 | m_fontBar->hide(); | 3111 | { |
3112 | m_fontVisible = false; | 3112 | //qDebug("Close disabled"); |
3113 | // odebug << "showedit" << oendl; | 3113 | m_bcloseDisabled = false; |
3114 | if (reader->isVisible()) showEditTools(); | 3114 | e->ignore(); |
3115 | // odebug << "showeditdone" << oendl; | 3115 | } |
3116 | } | 3116 | else |
3117 | 3117 | { | |
3118 | void QTReaderApp::do_setfont(const QString& lcn) | 3118 | if (m_fontVisible) |
3119 | { | 3119 | { |
3120 | if (m_fontAction == cChooseFont) | 3120 | m_fontBar->hide(); |
3121 | { | 3121 | m_fontVisible = false; |
3122 | setfontHelper(lcn); | 3122 | e->ignore(); |
3123 | } | 3123 | return; |
3124 | reader->refresh(); | 3124 | } |
3125 | m_fontBar->hide(); | 3125 | if (regVisible) |
3126 | m_fontVisible = false; | 3126 | { |
3127 | // odebug << "showedit" << oendl; | 3127 | regBar->hide(); |
3128 | //if (reader->isVisible()) | 3128 | #ifdef USEQPE |
3129 | showEditTools(); | 3129 | Global::hideInputMethod(); |
3130 | // odebug << "showeditdone" << oendl; | 3130 | #endif |
3131 | } | 3131 | regVisible = false; |
3132 | 3132 | e->ignore(); | |
3133 | void QTReaderApp::do_autogen(const QString& regText) | 3133 | return; |
3134 | { | 3134 | } |
3135 | unsigned long fs, ts; | 3135 | if (searchVisible) |
3136 | reader->sizes(fs,ts); | 3136 | { |
3137 | // // odebug << "Reg:" << (const tchar*)(regEdit->text()) << "\n" << oendl; | 3137 | searchBar->hide(); |
3138 | m_autogenstr = regText; | 3138 | #ifdef USEQPE |
3139 | QRegExp re(regText); | 3139 | Global::hideInputMethod(); |
3140 | CBuffer buff; | 3140 | #endif |
3141 | if (pBkmklist != NULL) delete pBkmklist; | 3141 | searchVisible = false; |
3142 | pBkmklist = new CList<Bkmk>; | 3142 | e->ignore(); |
3143 | m_fBkmksChanged = true; | 3143 | return; |
3144 | 3144 | } | |
3145 | pbar->setGeometry(regBar->x(),regBar->y(),regBar->width(), regBar->height()); | 3145 | if (m_fBkmksChanged && pBkmklist != NULL) |
3146 | pbar->show(); | 3146 | { |
3147 | pbar->raise(); | 3147 | if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) |
3148 | pbar->reset(); | 3148 | savebkmks(); |
3149 | reader->update(); | 3149 | delete pBkmklist; |
3150 | qApp->processEvents(); | 3150 | reader->pBkmklist = pBkmklist = NULL; |
3151 | reader->setFocus(); | 3151 | m_fBkmksChanged = false; |
3152 | reader->jumpto(0); | 3152 | } |
3153 | int lastpc = 0; | 3153 | updatefileinfo(); |
3154 | int i = 0; | 3154 | saveprefs(); |
3155 | while (i >= 0) | 3155 | e->accept(); |
3156 | { | 3156 | } |
3157 | unsigned int lcn = reader->locate(); | 3157 | } |
3158 | int pc = (100*lcn)/ts; | 3158 | else |
3159 | if (pc != lastpc) | 3159 | { |
3160 | { | 3160 | showEditTools(); |
3161 | pbar->setProgress(pc); | 3161 | m_disableesckey = true; |
3162 | qApp->processEvents(); | 3162 | } |
3163 | if (reader->locate() != lcn) reader->jumpto(lcn); | 3163 | } |
3164 | reader->setFocus(); | 3164 | } |
3165 | lastpc = pc; | 3165 | |
3166 | } | 3166 | void QTReaderApp::do_gotomark() |
3167 | i = reader->buffdoc.getpara(buff); | 3167 | { |
3168 | #ifdef _UNICODE | 3168 | m_nBkmkAction = cGotoBkmk; |
3169 | if (re.match(toQString(buff.data())) != -1) | 3169 | if (!listbkmk(pBkmklist)) |
3170 | #else | 3170 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); |
3171 | if (re.match(buff.data()) != -1) | 3171 | } |
3172 | #endif | 3172 | |
3173 | pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn)); | 3173 | void QTReaderApp::do_delmark() |
3174 | } | 3174 | { |
3175 | pBkmklist->sort(); | 3175 | m_nBkmkAction = cDelBkmk; |
3176 | pbar->setProgress(100); | 3176 | if (!listbkmk(pBkmklist)) |
3177 | qApp->processEvents(); | 3177 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); |
3178 | pbar->hide(); | 3178 | } |
3179 | reader->refresh(); | 3179 | |
3180 | } | 3180 | bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab) |
3181 | 3181 | { | |
3182 | void QTReaderApp::saveprefs() | 3182 | bkmkselector->clear(); |
3183 | { | 3183 | if (_lab.isEmpty()) |
3184 | // odebug << "saveprefs" << oendl; | 3184 | bkmkselector->setText("Cancel"); |
3185 | // reader->saveprefs("uqtreader"); | 3185 | else |
3186 | // if (!m_loadedconfig) | 3186 | bkmkselector->setText(_lab); |
3187 | do_saveconfig( APPDIR, true ); | 3187 | int cnt = 0; |
3188 | 3188 | if (plist != NULL) | |
3189 | /* | 3189 | { |
3190 | Config config( APPDIR ); | 3190 | for (CList<Bkmk>::iterator i = plist->begin(); i != plist->end(); i++) |
3191 | config.setGroup( "View" ); | 3191 | { |
3192 | 3192 | #ifdef _UNICODE | |
3193 | reader->m_lastposn = reader->pagelocate(); | 3193 | // qDebug("Item:%s", (const char*)toQString(i->name())); |
3194 | 3194 | bkmkselector->insertItem(toQString(i->name())); | |
3195 | config.writeEntry("FloatDialogs", m_bFloatingDialog); | 3195 | #else |
3196 | config.writeEntry( "StripCr", reader->bstripcr ); | 3196 | bkmkselector->insertItem(i->name()); |
3197 | config.writeEntry( "AutoFmt", reader->bautofmt ); | 3197 | #endif |
3198 | config.writeEntry( "TextFmt", reader->btextfmt ); | 3198 | cnt++; |
3199 | config.writeEntry( "StripHtml", reader->bstriphtml ); | 3199 | } |
3200 | config.writeEntry( "Dehyphen", reader->bdehyphen ); | 3200 | } |
3201 | config.writeEntry( "Depluck", reader->bdepluck ); | 3201 | if (cnt > 0) |
3202 | config.writeEntry( "Dejpluck", reader->bdejpluck ); | 3202 | { |
3203 | config.writeEntry( "OneSpace", reader->bonespace ); | 3203 | hidetoolbars(); |
3204 | config.writeEntry( "Unindent", reader->bunindent ); | 3204 | editorStack->raiseWidget( bkmkselector ); |
3205 | config.writeEntry( "Repara", reader->brepara ); | 3205 | return true; |
3206 | config.writeEntry( "DoubleSpace", reader->bdblspce ); | 3206 | } |
3207 | config.writeEntry( "Indent", reader->bindenter ); | 3207 | else |
3208 | config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) ); | 3208 | return false; |
3209 | config.writeEntry( "ScrollDelay", reader->m_delay); | 3209 | } |
3210 | config.writeEntry( "LastFile", reader->m_lastfile ); | 3210 | |
3211 | config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); | 3211 | void QTReaderApp::do_autogen() |
3212 | config.writeEntry( "PageMode", reader->m_bpagemode ); | 3212 | { |
3213 | config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); | 3213 | m_nRegAction = cAutoGen; |
3214 | config.writeEntry( "SwapMouse", reader->m_swapmouse); | 3214 | regEdit->setText(m_autogenstr); |
3215 | config.writeEntry( "Fontname", reader->m_fontname ); | 3215 | do_regedit(); |
3216 | config.writeEntry( "Encoding", reader->m_encd ); | 3216 | } |
3217 | config.writeEntry( "CharSpacing", reader->m_charpc ); | 3217 | |
3218 | config.writeEntry( "Overlap", (int)(reader->m_overlap) ); | 3218 | void QTReaderApp::do_regedit() |
3219 | config.writeEntry( "Margin", (int)reader->m_border ); | 3219 | { |
3220 | config.writeEntry( "TargetApp", m_targetapp ); | 3220 | // fileBar->hide(); |
3221 | config.writeEntry( "TargetMsg", m_targetmsg ); | 3221 | reader->bDoUpdates = false; |
3222 | #ifdef _SCROLLPIPE | 3222 | // qDebug("Showing regbar"); |
3223 | config.writeEntry( "PipeTarget", reader->m_pipetarget ); | 3223 | regBar->show(); |
3224 | config.writeEntry( "PauseAfterPara", reader->m_pauseAfterEachPara ); | 3224 | // qDebug("Showing kbd"); |
3225 | #endif | 3225 | #ifdef USEQPE |
3226 | config.writeEntry( "TwoTouch", m_twoTouch ); | 3226 | Global::showInputMethod(); |
3227 | config.writeEntry( "Annotation", m_doAnnotation); | 3227 | #endif |
3228 | config.writeEntry( "Dictionary", m_doDictionary); | 3228 | regVisible = true; |
3229 | config.writeEntry( "Clipboard", m_doClipboard); | 3229 | regEdit->setFocus(); |
3230 | config.writeEntry( "SpaceTarget", m_spaceTarget); | 3230 | // qApp->processEvents(); |
3231 | config.writeEntry( "EscapeTarget", m_escapeTarget); | 3231 | reader->bDoUpdates = true; |
3232 | config.writeEntry( "ReturnTarget", m_returnTarget); | 3232 | reader->update(); |
3233 | config.writeEntry( "LeftTarget", m_leftTarget); | 3233 | } |
3234 | config.writeEntry( "RightTarget", m_rightTarget); | 3234 | |
3235 | config.writeEntry( "UpTarget", m_upTarget); | 3235 | bool QTReaderApp::openfrombkmk(Bkmk* bk) |
3236 | config.writeEntry( "DownTarget", m_downTarget); | 3236 | { |
3237 | config.writeEntry("LeftScroll", m_leftScroll); | 3237 | QString fn = toQString( |
3238 | config.writeEntry("RightScroll", m_rightScroll); | 3238 | CFiledata(bk->anno()).name() |
3239 | config.writeEntry("UpScroll", m_upScroll); | 3239 | ); |
3240 | config.writeEntry("DownScroll", m_downScroll); | 3240 | //qDebug("fileinfo"); |
3241 | #ifdef REPALM | 3241 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) |
3242 | config.writeEntry( "Repalm", reader->brepalm ); | 3242 | { |
3243 | #endif | 3243 | //qDebug("Opening"); |
3244 | config.writeEntry( "Remap", reader->bremap ); | 3244 | openFile(fn); |
3245 | config.writeEntry( "Peanut", reader->bpeanut ); | 3245 | struct stat fnstat; |
3246 | config.writeEntry( "MakeBold", reader->bmakebold ); | 3246 | stat((const char *)reader->m_lastfile, &fnstat); |
3247 | config.writeEntry( "Continuous", reader->m_continuousDocument ); | 3247 | |
3248 | config.writeEntry( "FullJust", reader->bfulljust ); | 3248 | if (CFiledata(bk->anno()).date() |
3249 | config.writeEntry( "ExtraSpace", reader->getextraspace() ); | 3249 | != fnstat.st_mtime) |
3250 | config.writeEntry( "ExtraLead", reader->getlead() ); | 3250 | { |
3251 | config.writeEntry( "Basesize", (int)reader->getBaseSize()); | 3251 | CFiledata fd(bk->anno()); |
3252 | config.writeEntry( "RequestorFontChange", m_propogatefontchange); | 3252 | fd.setdate(fnstat.st_mtime); |
3253 | 3253 | bk->value(0); | |
3254 | config.setGroup( "Toolbar" ); | 3254 | } |
3255 | config.writeEntry("Movable", m_tbmovesave); | 3255 | else |
3256 | config.writeEntry("Policy", m_tbpolsave); | 3256 | { |
3257 | config.writeEntry("Position", m_tbposition); | 3257 | unsigned short svlen = bk->filedatalen(); |
3258 | */ | 3258 | unsigned char* svdata = bk->filedata(); |
3259 | savefilelist(); | 3259 | reader->putSaveData(svdata, svlen); |
3260 | } | 3260 | // setstate(svdata, svlen); |
3261 | 3261 | if (svlen != 0) | |
3262 | /* | 3262 | { |
3263 | void QTReaderApp::oldFile() | 3263 | QMessageBox::warning(this, PROGNAME, "Not all file data used\nNew version?"); |
3264 | { | 3264 | } |
3265 | // odebug << "oldFile called" << oendl; | 3265 | // qDebug("updating"); |
3266 | reader->setText(true); | 3266 | // showEditTools(); |
3267 | // odebug << "settext called" << oendl; | 3267 | reader->locate(bk->value()); |
3268 | showEditTools(); | 3268 | } |
3269 | // odebug << "showedit called" << oendl; | 3269 | return true; |
3270 | } | 3270 | } |
3271 | */ | 3271 | else |
3272 | 3272 | { | |
3273 | /* | 3273 | return false; |
3274 | void info_cb(Fl_Widget* o, void* _data) | 3274 | } |
3275 | { | 3275 | } |
3276 | 3276 | ||
3277 | if (infowin == NULL) | 3277 | void QTReaderApp::gotobkmk(int ind) |
3278 | { | 3278 | { |
3279 | 3279 | qDebug("gbkmk"); | |
3280 | infowin = new Fl_Window(160,240); | 3280 | showEditTools(); |
3281 | filename = new Fl_Output(45,5,110,14,"Filename"); | 3281 | switch (m_nBkmkAction) |
3282 | filesize = new Fl_Output(45,25,110,14,"Filesize"); | 3282 | { |
3283 | textsize = new Fl_Output(45,45,110,14,"Textsize"); | 3283 | case cOpenFile: |
3284 | comprat = new CBar(45,65,110,14,"Ratio %"); | 3284 | { |
3285 | posn = new Fl_Output(45,85,110,14,"Location"); | 3285 | // qApp->processEvents(); |
3286 | frcn = new CBar(45,105,110,14,"% Read"); | 3286 | if (!openfrombkmk((*pOpenlist)[ind])) |
3287 | about = new Fl_Multiline_Output(5,125,150,90); | 3287 | { |
3288 | about->value("TWReader - $Name$\n\nA file reader program for the Agenda\n\nReads text, PalmDoc and ppms format files"); | 3288 | pOpenlist->erase(ind); |
3289 | Fl_Button *jump_accept = new Fl_Button(62,220,35,14,"Okay"); | 3289 | QMessageBox::information(this, PROGNAME, "Can't find file"); |
3290 | infowin->set_modal(); | 3290 | } |
3291 | } | 3291 | } |
3292 | if (((reader_ui *)_data)->g_filename[0] != '\0') | 3292 | break; |
3293 | { | 3293 | case cGotoBkmk: |
3294 | unsigned long fs,ts; | 3294 | reader->buffdoc.saveposn(reader->m_lastfile, reader->pagelocate()); |
3295 | tchar sz[20]; | 3295 | reader->locate((*pBkmklist)[ind]->value()); |
3296 | ((reader_ui *)_data)->input->sizes(fs,ts); | 3296 | break; |
3297 | unsigned long pl = ((reader_ui *)_data)->input->locate(); | 3297 | case cDelBkmk: |
3298 | 3298 | //// qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name()); | |
3299 | filename->value(((reader_ui *)_data)->g_filename); | 3299 | pBkmklist->erase(ind); |
3300 | 3300 | m_fBkmksChanged = true; | |
3301 | sprintf(sz,"%u",fs); | 3301 | reader->refresh(true); |
3302 | filesize->value(sz); | 3302 | // pBkmklist->sort(); |
3303 | 3303 | break; | |
3304 | sprintf(sz,"%u",ts); | 3304 | case cRmBkmkFile: |
3305 | textsize->value(sz); | 3305 | { |
3306 | 3306 | #ifndef USEQPE | |
3307 | comprat->value(100-(100*fs + (ts >> 1))/ts); | 3307 | QDir d = QDir::home(); // "/" |
3308 | 3308 | d.cd(APPDIR); | |
3309 | sprintf(sz,"%u",pl); | 3309 | d.remove(bkmkselector->text(ind)); |
3310 | posn->value(sz); | 3310 | #else /* USEQPE */ |
3311 | 3311 | unlink((const char *)Global::applicationFileName(APPDIR,bkmkselector->text(ind))); | |
3312 | frcn->value((100*pl + (ts >> 1))/ts); | 3312 | #endif /* USEQPE */ |
3313 | } | 3313 | } |
3314 | infowin->show(); | 3314 | break; |
3315 | } | 3315 | case cLdConfig: |
3316 | */ | 3316 | readconfig(APPDIR "/configs", bkmkselector->text(ind), false); |
3317 | 3317 | break; | |
3318 | void QTReaderApp::savebkmks() | 3318 | case cLdTheme: |
3319 | { | 3319 | m_themename = bkmkselector->text(ind); |
3320 | if (pBkmklist != NULL) | 3320 | readconfig(QString(APPDIR "/Themes/")+m_themename , "config", false); |
3321 | { | 3321 | setBackgroundBitmap(); |
3322 | #ifndef USEQPE | 3322 | break; |
3323 | QDir d = QDir::home(); // "/" | 3323 | case cRmConfig: |
3324 | d.cd(APPDIR); | 3324 | { |
3325 | QFileInfo fi(d, reader->m_string); | 3325 | #ifndef USEQPE |
3326 | BkmkFile bf((const char *)fi.absFilePath(), true); | 3326 | QDir d = QDir::home(); // "/" |
3327 | #else /* USEQPE */ | 3327 | d.cd(APPDIR "/configs"); |
3328 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string), true); | 3328 | d.remove(bkmkselector->text(ind)); |
3329 | #endif /* USEQPE */ | 3329 | #else /* USEQPE */ |
3330 | bf.write(*pBkmklist); | 3330 | unlink((const char *)Global::applicationFileName(APPDIR "/configs",bkmkselector->text(ind))); |
3331 | } | 3331 | #endif /* USEQPE */ |
3332 | m_fBkmksChanged = false; | 3332 | } |
3333 | } | 3333 | break; |
3334 | 3334 | case cExportLinks: | |
3335 | void QTReaderApp::readfilelist() | 3335 | { |
3336 | { | 3336 | #ifndef USEQPE |
3337 | #ifndef USEQPE | 3337 | QDir d = QDir::home(); // "/" |
3338 | QDir d = QDir::home(); // "/" | 3338 | d.cd(APPDIR "/urls"); |
3339 | d.cd(APPDIR); | 3339 | QFileInfo fi(d, bkmkselector->text(ind)); |
3340 | QFileInfo fi(d, ".openfiles"); | 3340 | if (fi.exists()) |
3341 | BkmkFile bf((const char *)fi.absFilePath()); | 3341 | { |
3342 | #else /* USEQPE */ | 3342 | QString outfile( QFileDialog::getSaveFileName( QString::null, QString::null, this ) ); |
3343 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles")); | 3343 | if (!outfile.isEmpty()) |
3344 | #endif /* USEQPE */ | 3344 | { |
3345 | // odebug << "Reading open files" << oendl; | 3345 | FILE* fout = fopen((const char *)outfile, "w"); |
3346 | pOpenlist = bf.readall(); | 3346 | if (fout != NULL) |
3347 | // if (pOpenlist != NULL) odebug << "...with success" << oendl; | 3347 | { |
3348 | // else odebug << "...without success!" << oendl; | 3348 | FILE* fin = fopen((const char *)fi.absFilePath(), "r"); |
3349 | } | 3349 | if (fin != NULL) |
3350 | 3350 | { | |
3351 | void QTReaderApp::savefilelist() | 3351 | fprintf(fout, "<html><body>\n"); |
3352 | { | 3352 | int ch = 0; |
3353 | if (pOpenlist != NULL) | 3353 | while ((ch = fgetc(fin)) != EOF) |
3354 | { | 3354 | { |
3355 | #ifndef USEQPE | 3355 | fputc(ch, fout); |
3356 | QDir d = QDir::home(); // "/" | 3356 | } |
3357 | d.cd(APPDIR); | 3357 | fclose(fin); |
3358 | QFileInfo fi(d, ".openfiles"); | 3358 | fprintf(fout, "</html></body>\n"); |
3359 | BkmkFile bf((const char *)fi.absFilePath(), true); | 3359 | d.remove(bkmkselector->text(ind)); |
3360 | #else /* USEQPE */ | 3360 | } |
3361 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles"), true); | 3361 | fclose(fout); |
3362 | #endif /* USEQPE */ | 3362 | } |
3363 | // odebug << "Writing open files" << oendl; | 3363 | else |
3364 | bf.write(*pOpenlist); | 3364 | QMessageBox::information(this, PROGNAME, "Couldn't open output"); |
3365 | } | 3365 | } |
3366 | } | 3366 | } |
3367 | 3367 | #else /* USEQPE */ | |
3368 | void QTReaderApp::readbkmks() | 3368 | FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); |
3369 | { | 3369 | if (fin != NULL) |
3370 | if (pBkmklist != NULL) | 3370 | { |
3371 | { | 3371 | bool allok = false; |
3372 | delete pBkmklist; | 3372 | #ifdef OPIE |
3373 | } | 3373 | QString outfile = OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL, QString::null, QString::null, MimeTypes(), 0, "OpieReader"); |
3374 | struct stat fnstat; | 3374 | if (!outfile.isEmpty()) |
3375 | struct stat bkstat; | 3375 | { |
3376 | #ifndef USEQPE | 3376 | FILE* fout = fopen((const char *)outfile, "w"); |
3377 | QDir d = QDir::home(); // "/" | 3377 | if (fout != NULL) |
3378 | d.cd(APPDIR); | 3378 | { |
3379 | QFileInfo fi(d, reader->m_string); | 3379 | fprintf(fout, "<html><body>\n"); |
3380 | #endif /* ! USEQPE */ | 3380 | int ch = 0; |
3381 | if ( | 3381 | while ((ch = fgetc(fin)) != EOF) |
3382 | stat((const char *)reader->m_lastfile, &fnstat) == 0 | 3382 | { |
3383 | && | 3383 | fputc(ch, fout); |
3384 | #ifndef USEQPE | 3384 | } |
3385 | stat((const char *)fi.absFilePath(), &bkstat) == 0 | 3385 | fprintf(fout, "</html></body>\n"); |
3386 | #else /* USEQPE */ | 3386 | fclose(fout); |
3387 | stat((const char *)Global::applicationFileName(APPDIR,reader->m_string), &bkstat) == 0 | 3387 | allok = true; |
3388 | #endif /* USEQPE */ | 3388 | } |
3389 | ) | 3389 | else |
3390 | { | 3390 | QMessageBox::information(this, PROGNAME, "Couldn't open output"); |
3391 | if (bkstat.st_mtime < fnstat.st_mtime) | 3391 | } |
3392 | { | 3392 | fclose(fin); |
3393 | #ifndef USEQPE | 3393 | if (allok) unlink((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind))); |
3394 | unlink((const char *)fi.absFilePath()); | 3394 | #else |
3395 | #else /* USEQPE */ | 3395 | fileBrowser* fb = new fileBrowser(true, this,"OpieReader",!m_bFloatingDialog, 0, "*", QString::null); |
3396 | unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string)); | 3396 | if (fb->exec()) |
3397 | #endif /* USEQPE */ | 3397 | { |
3398 | } | 3398 | QString outfile = fb->getCurrentFile(); |
3399 | } | 3399 | FILE* fout = fopen((const char *)outfile, "w"); |
3400 | 3400 | if (fout != NULL) | |
3401 | #ifndef USEQPE | 3401 | { |
3402 | BkmkFile bf((const char *)fi.absFilePath()); | 3402 | fprintf(fout, "<html><body>\n"); |
3403 | #else /* USEQPE */ | 3403 | int ch = 0; |
3404 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string)); | 3404 | while ((ch = fgetc(fin)) != EOF) |
3405 | #endif /* USEQPE */ | 3405 | { |
3406 | 3406 | fputc(ch, fout); | |
3407 | pBkmklist = bf.readall(); | 3407 | } |
3408 | m_fBkmksChanged = bf.upgraded(); | 3408 | fprintf(fout, "</html></body>\n"); |
3409 | if (pBkmklist == NULL) | 3409 | fclose(fout); |
3410 | { | 3410 | allok = true; |
3411 | pBkmklist = reader->getbkmklist(); | 3411 | } |
3412 | } | 3412 | else |
3413 | if (pBkmklist != NULL) | 3413 | QMessageBox::information(this, PROGNAME, "Couldn't open output"); |
3414 | pBkmklist->sort(); | 3414 | } |
3415 | } | 3415 | delete fb; |
3416 | 3416 | fclose(fin); | |
3417 | void QTReaderApp::addbkmk() | 3417 | if (allok) unlink((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind))); |
3418 | { | 3418 | #endif |
3419 | m_nRegAction = cAddBkmk; | 3419 | } |
3420 | regEdit->setText(reader->firstword()); | 3420 | else |
3421 | do_regedit(); | 3421 | { |
3422 | } | 3422 | QMessageBox::information(this, PROGNAME, "Couldn't open input"); |
3423 | 3423 | } | |
3424 | void QTReaderApp::do_addbkmk(const QString& text) | 3424 | |
3425 | { | 3425 | /* |
3426 | if (text.isEmpty()) | 3426 | CFileSelector *f = new CFileSelector("text/html", this, NULL, !m_bFloatingDialog, TRUE, TRUE ); |
3427 | { | 3427 | int ret = f->exec(); |
3428 | QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nSelect add again", 1); | 3428 | qDebug("Return:%d", ret); |
3429 | } | 3429 | DocLnk* doc = f->getDoc(); |
3430 | else | 3430 | if (doc != NULL) |
3431 | { | 3431 | { |
3432 | if (pBkmklist == NULL) pBkmklist = new CList<Bkmk>; | 3432 | FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); |
3433 | #ifdef _UNICODE | 3433 | QString rt; |
3434 | CBuffer buff; | 3434 | rt = "<html><body>\n"; |
3435 | int i = 0; | 3435 | int ch = 0; |
3436 | for (i = 0; i < text.length(); i++) | 3436 | while ((ch = fgetc(fin)) != EOF) |
3437 | { | 3437 | { |
3438 | buff[i] = text[i].unicode(); | 3438 | rt += (char)ch; |
3439 | } | 3439 | } |
3440 | buff[i] = 0; | 3440 | fclose(fin); |
3441 | pBkmklist->push_front(Bkmk(buff.data(), NULL, reader->pagelocate())); | 3441 | rt += "</html></body>\n"; |
3442 | #else | 3442 | if ( doc->name().isEmpty() ) |
3443 | pBkmklist->push_front(Bkmk((const tchar*)text, reader->pagelocate())); | 3443 | { |
3444 | #endif | 3444 | doc->setName(bkmkselector->text(ind)); |
3445 | m_fBkmksChanged = true; | 3445 | } |
3446 | pBkmklist->sort(); | 3446 | FileManager fm; |
3447 | } | 3447 | fm.saveFile( *doc, rt ); |
3448 | } | 3448 | qDebug("YES"); |
3449 | 3449 | } | |
3450 | void QTReaderApp::OnRedraw() | 3450 | else |
3451 | { | 3451 | { |
3452 | if ((pBkmklist != NULL) && (m_bkmkAvail != NULL)) | 3452 | qDebug("NO"); |
3453 | { | 3453 | } |
3454 | bool found = findNextBookmark(reader->pagelocate()); | 3454 | delete f; |
3455 | m_bkmkAvail->setEnabled(found); | 3455 | */ |
3456 | } | 3456 | |
3457 | } | 3457 | #endif /* USEQPE */ |
3458 | 3458 | } | |
3459 | void QTReaderApp::showAnnotation() | 3459 | break; |
3460 | { | 3460 | } |
3461 | m_annoWin->setName(toQString(m_anno->name())); | 3461 | } |
3462 | m_annoWin->setAnno(toQString(m_anno->anno())); | 3462 | |
3463 | m_annoIsEditing = false; | 3463 | void QTReaderApp::cancelbkmk() |
3464 | #ifdef USEQPE | 3464 | { |
3465 | Global::showInputMethod(); | 3465 | if (m_nBkmkAction == cOpenFile) |
3466 | #endif | 3466 | { |
3467 | editorStack->raiseWidget( m_annoWin ); | 3467 | QString fn = usefilebrowser(); |
3468 | m_annoWin->setFocus(); | 3468 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn); |
3469 | } | 3469 | } |
3470 | 3470 | showEditTools(); | |
3471 | void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString& line) | 3471 | } |
3472 | { | 3472 | |
3473 | //// odebug << "OnWordSelected(" << posn << "):" << wrd << "" << oendl; | 3473 | void QTReaderApp::reparastring() |
3474 | 3474 | { | |
3475 | if (m_doClipboard) | 3475 | m_nRegAction = cRepara; |
3476 | { | 3476 | regEdit->setText(reader->m_reparastring); |
3477 | QClipboard* cb = QApplication::clipboard(); | 3477 | do_regedit(); |
3478 | cb->setText(wrd); | 3478 | } |
3479 | #ifdef USEQPE | 3479 | |
3480 | if (wrd.length() > 10) | 3480 | void QTReaderApp::do_reparastring(const QString& _lcn) |
3481 | { | 3481 | { |
3482 | Global::statusMessage(wrd.left(8) + ".."); | 3482 | reader->m_reparastring = _lcn; |
3483 | } | 3483 | if (reader->brepara) |
3484 | else | 3484 | { |
3485 | { | 3485 | reader->bDoUpdates = true; |
3486 | Global::statusMessage(wrd); | 3486 | reader->setfilter(reader->getfilter()); |
3487 | } | 3487 | } |
3488 | #endif | 3488 | } |
3489 | } | 3489 | |
3490 | if (m_doAnnotation) | 3490 | void QTReaderApp::jump() |
3491 | { | 3491 | { |
3492 | // addAnno(wrd, "Need to be able to edit this", posn); | 3492 | m_nRegAction = cJump; |
3493 | m_annoWin->setName(line); | 3493 | char lcn[20]; |
3494 | m_annoWin->setAnno(""); | 3494 | sprintf(lcn, "%lu", reader->pagelocate()); |
3495 | m_annoWin->setPosn(posn); | 3495 | regEdit->setText(lcn); |
3496 | m_annoIsEditing = true; | 3496 | do_regedit(); |
3497 | #ifdef USEQPE | 3497 | } |
3498 | Global::showInputMethod(); | 3498 | |
3499 | #endif | 3499 | void QTReaderApp::do_jump(const QString& _lcn) |
3500 | editorStack->raiseWidget( m_annoWin ); | 3500 | { |
3501 | } | 3501 | bool ok; |
3502 | #ifdef USEQPE | 3502 | QString lcn = _lcn.stripWhiteSpace(); |
3503 | if (m_doDictionary) | 3503 | unsigned long ulcn = lcn.toULong(&ok); |
3504 | { | 3504 | if (!ok) |
3505 | if (!m_targetapp.isEmpty() && !m_targetmsg.isEmpty()) | 3505 | { |
3506 | { | 3506 | double pc = 0.0; |
3507 | QCopEnvelope e(("QPE/Application/"+m_targetapp).utf8(), (m_targetmsg+"(QString)").utf8()); | 3507 | #ifdef _WINDOWS |
3508 | e << wrd; | 3508 | if (lcn.at(lcn.length()-1) == '%') |
3509 | } | 3509 | #else |
3510 | } | 3510 | if (lcn[lcn.length()-1] == '%') |
3511 | #endif | 3511 | #endif |
3512 | } | 3512 | { |
3513 | 3513 | lcn = lcn.left(lcn.length()-1); | |
3514 | void QTReaderApp::doAction(ActionTypes a, QKeyEvent* e) | 3514 | pc = lcn.toDouble(&ok); |
3515 | { | 3515 | } |
3516 | if (a == 0) | 3516 | else |
3517 | { | 3517 | { |
3518 | e->ignore(); | 3518 | pc = lcn.toDouble(&ok); |
3519 | } | 3519 | } |
3520 | else | 3520 | if (ok && 0 <= pc && pc <= 100) |
3521 | { | 3521 | { |
3522 | e->accept(); | 3522 | ulcn = (pc*(reader->buffdoc.endSection()-reader->buffdoc.startSection()))/100 + reader->buffdoc.startSection(); |
3523 | // odebug << "Accepted" << oendl; | 3523 | } |
3524 | switch (a) | 3524 | else |
3525 | { | 3525 | { |
3526 | case cesOpenFile: | 3526 | ok = false; |
3527 | { | 3527 | } |
3528 | fileOpen(); | 3528 | } |
3529 | } | 3529 | if (ok) |
3530 | break; | 3530 | reader->locate(ulcn); |
3531 | case cesAutoScroll: | 3531 | else |
3532 | { | 3532 | QMessageBox::information(this, PROGNAME, "Must be a number\nor a percentage"); |
3533 | reader->setautoscroll(!reader->m_autoScroll); | 3533 | } |
3534 | setScrollState(reader->m_autoScroll); | 3534 | |
3535 | } | 3535 | void QTReaderApp::do_regaction() |
3536 | break; | 3536 | { |
3537 | case cesActionMark: | 3537 | reader->bDoUpdates = false; |
3538 | { | 3538 | regBar->hide(); |
3539 | addbkmk(); | 3539 | #ifdef USEQPE |
3540 | } | 3540 | Global::hideInputMethod(); |
3541 | break; | 3541 | #endif |
3542 | case cesFullScreen: | 3542 | regVisible = false; |
3543 | { | 3543 | switch(m_nRegAction) |
3544 | m_actFullscreen->setOn(!m_fullscreen); | 3544 | { |
3545 | } | 3545 | case cAutoGen: |
3546 | break; | 3546 | do_autogen(regEdit->text()); |
3547 | case cesActionAnno: | 3547 | break; |
3548 | { | 3548 | case cAddBkmk: |
3549 | addanno(); | 3549 | do_addbkmk(regEdit->text()); |
3550 | } | 3550 | break; |
3551 | break; | 3551 | case cRepara: |
3552 | case cesZoomIn: | 3552 | do_reparastring(regEdit->text()); |
3553 | zoomin(); | 3553 | break; |
3554 | break; | 3554 | case cJump: |
3555 | case cesZoomOut: | 3555 | do_jump(regEdit->text()); |
3556 | zoomout(); | 3556 | break; |
3557 | break; | 3557 | /* |
3558 | case cesBack: | 3558 | case cMonoSpace: |
3559 | reader->goBack(); | 3559 | do_mono(regEdit->text()); |
3560 | break; | 3560 | break; |
3561 | case cesForward: | 3561 | */ |
3562 | reader->goForward(); | 3562 | case cSetTarget: |
3563 | break; | 3563 | do_settarget(regEdit->text()); |
3564 | case cesHome: | 3564 | break; |
3565 | reader->goHome(); | 3565 | #ifdef _SCROLLPIPE |
3566 | break; | 3566 | case cSetPipeTarget: |
3567 | case cesPageUp: | 3567 | do_setpipetarget(regEdit->text()); |
3568 | reader->dopageup(); | 3568 | break; |
3569 | break; | 3569 | #endif |
3570 | case cesPageDown: | 3570 | case cSetConfigName: |
3571 | reader->dopagedn(); | 3571 | // qDebug("Saving config"); |
3572 | break; | 3572 | do_saveconfig(regEdit->text(), false); |
3573 | case cesLineUp: | 3573 | break; |
3574 | reader->lineUp(); | 3574 | } |
3575 | break; | 3575 | // reader->restore(); |
3576 | case cesLineDown: | 3576 | // fileBar->show(); |
3577 | reader->lineDown(); | 3577 | reader->setFocus(); |
3578 | break; | 3578 | // qApp->processEvents(); |
3579 | case cesStartDoc: | 3579 | reader->bDoUpdates = true; |
3580 | gotoStart(); | 3580 | reader->update(); |
3581 | break; | 3581 | } |
3582 | case cesEndDoc: | 3582 | |
3583 | gotoEnd(); | 3583 | void QTReaderApp::do_settarget(const QString& _txt) |
3584 | break; | 3584 | { |
3585 | default: | 3585 | int ind = _txt.find('/'); |
3586 | odebug << "Unknown ActionType:" << a << "" << oendl; | 3586 | if (ind == -1) |
3587 | break; | 3587 | { |
3588 | } | 3588 | m_targetapp = ""; |
3589 | } | 3589 | m_targetmsg = ""; |
3590 | } | 3590 | QMessageBox::information(this, PROGNAME, "Format is\nappname/messagename"); |
3591 | 3591 | } | |
3592 | void QTReaderApp::setTwoTouch(bool _b) { reader->setTwoTouch(_b); } | 3592 | else |
3593 | void QTReaderApp::restoreFocus() { reader->setFocus(); } | 3593 | { |
3594 | 3594 | m_targetapp = _txt.left(ind); | |
3595 | void QTReaderApp::SaveConfig() | 3595 | m_targetmsg = _txt.right(_txt.length()-ind-1); |
3596 | { | 3596 | } |
3597 | m_nRegAction = cSetConfigName; | 3597 | } |
3598 | regEdit->setText(reader->m_string); | 3598 | |
3599 | do_regedit(); | 3599 | void QTReaderApp::chooseencoding() |
3600 | } | 3600 | { |
3601 | 3601 | m_fontSelector->clear(); | |
3602 | void QTReaderApp::do_saveconfig(const QString& _txt, bool full) | 3602 | m_fontSelector->insertItem("Ascii"); |
3603 | { | 3603 | m_fontSelector->insertItem("UTF-8"); |
3604 | // odebug << "do_saveconfig:" << _txt << "" << oendl; | 3604 | m_fontSelector->insertItem("UCS-2(BE)"); |
3605 | #ifdef USEQPE | 3605 | m_fontSelector->insertItem("USC-2(LE)"); |
3606 | QString configname; | 3606 | m_fontSelector->insertItem("Palm"); |
3607 | Config::Domain dom; | 3607 | for (unicodetable::iterator iter = unicodetable::begin(); iter != unicodetable::end(); iter++) |
3608 | 3608 | { | |
3609 | if (full) | 3609 | m_fontSelector->insertItem(iter->mime); |
3610 | { | 3610 | } // delete the FontDatabase!!! |
3611 | configname = _txt; | 3611 | m_fontSelector->setCurrentItem (reader->m_encd); |
3612 | dom = Config::User; | 3612 | m_fontAction = cChooseEncoding; |
3613 | } | 3613 | m_fontBar->show(); |
3614 | else | 3614 | m_fontVisible = true; |
3615 | { | 3615 | } |
3616 | configname = Global::applicationFileName(APPDIR "/configs", _txt); | 3616 | |
3617 | dom = Config::File; | 3617 | void QTReaderApp::setfont() |
3618 | } | 3618 | { |
3619 | 3619 | m_fontSelector->clear(); | |
3620 | Config config(configname, dom); | 3620 | { |
3621 | config.setGroup( "View" ); | 3621 | QFontDatabase f; |
3622 | 3622 | QStringList flist = f.families(); | |
3623 | #else | 3623 | m_fontSelector->insertStringList(flist); |
3624 | QFileInfo fi; | 3624 | } // delete the FontDatabase!!! |
3625 | if (full) | 3625 | |
3626 | { | 3626 | for (int i = 1; i <= m_fontSelector->count(); i++) |
3627 | // odebug << "full:" << _txt << "" << oendl; | 3627 | { |
3628 | QDir d = QDir::home(); // "/" | 3628 | if (m_fontSelector->text(i) == reader->m_fontname) |
3629 | if ( !d.cd(_txt) ) | 3629 | { |
3630 | { // "/tmp" | 3630 | m_fontSelector->setCurrentItem(i); |
3631 | owarn << "Cannot find the \"~/" << _txt << "\" directory" << oendl; | 3631 | break; |
3632 | d = QDir::home(); | 3632 | } |
3633 | d.mkdir(_txt); | 3633 | } |
3634 | d.cd(_txt); | 3634 | m_fontAction = cChooseFont; |
3635 | } | 3635 | m_fontBar->show(); |
3636 | fi.setFile(d, INIFILE); | 3636 | m_fontVisible = true; |
3637 | } | 3637 | } |
3638 | else | 3638 | |
3639 | { | 3639 | void QTReaderApp::setfontHelper(const QString& lcn, int size) |
3640 | QDir d = QDir::home(); // "/" | 3640 | { |
3641 | if ( !d.cd(APPDIR) ) | 3641 | if (size == 0) size = reader->m_fontControl.currentsize(); |
3642 | { // "/tmp" | 3642 | if (m_propogatefontchange) |
3643 | owarn << "Cannot find the \"~/" APPDIR "\" directory" << oendl; | 3643 | { |
3644 | d = QDir::home(); | 3644 | QFont f(lcn, 10); |
3645 | d.mkdir(APPDIR); | 3645 | bkmkselector->setFont( f ); |
3646 | d.cd(APPDIR); | 3646 | regEdit->setFont( f ); |
3647 | } | 3647 | searchEdit->setFont( f ); |
3648 | if ( !d.cd("configs") ) | 3648 | m_annoWin->setFont( f ); |
3649 | { // "/tmp" | 3649 | } |
3650 | owarn << "Cannot find the \"~/" APPDIR "/configs\" directory" << oendl; | 3650 | reader->m_fontname = lcn; |
3651 | d = QDir::home(); | 3651 | if (!reader->ChangeFont(size)) |
3652 | d.cd(APPDIR); | 3652 | { |
3653 | d.mkdir("configs"); | 3653 | reader->ChangeFont(size); |
3654 | d.cd("configs"); | 3654 | } |
3655 | } | 3655 | } |
3656 | fi.setFile(d, _txt); | 3656 | |
3657 | } | 3657 | void QTReaderApp::do_setencoding(int i) |
3658 | // odebug << "Path:" << fi.absFilePath() << "" << oendl; | 3658 | { |
3659 | Config config(fi.absFilePath()); | 3659 | qDebug("setencoding:%d", i); |
3660 | #endif | 3660 | if (m_fontAction == cChooseEncoding) |
3661 | 3661 | { | |
3662 | 3662 | reader->setencoding(i); | |
3663 | config.writeEntry( "StripCr", reader->bstripcr ); | 3663 | } |
3664 | config.writeEntry( "AutoFmt", reader->bautofmt ); | 3664 | reader->refresh(); |
3665 | config.writeEntry( "TextFmt", reader->btextfmt ); | 3665 | m_fontBar->hide(); |
3666 | config.writeEntry( "StripHtml", reader->bstriphtml ); | 3666 | m_fontVisible = false; |
3667 | config.writeEntry( "Dehyphen", reader->bdehyphen ); | 3667 | // qDebug("showedit"); |
3668 | config.writeEntry( "Depluck", reader->bdepluck ); | 3668 | if (reader->isVisible()) showEditTools(); |
3669 | config.writeEntry( "Dejpluck", reader->bdejpluck ); | 3669 | // qDebug("showeditdone"); |
3670 | config.writeEntry( "OneSpace", reader->bonespace ); | 3670 | } |
3671 | config.writeEntry( "Unindent", reader->bunindent ); | 3671 | |
3672 | config.writeEntry( "Repara", reader->brepara ); | 3672 | void QTReaderApp::do_setfont(const QString& lcn) |
3673 | config.writeEntry( "DoubleSpace", reader->bdblspce ); | 3673 | { |
3674 | config.writeEntry( "Indent", reader->bindenter ); | 3674 | if (m_fontAction == cChooseFont) |
3675 | config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) ); | 3675 | { |
3676 | config.writeEntry( "ScrollDelay", reader->m_delay); | 3676 | setfontHelper(lcn); |
3677 | if (full) | 3677 | } |
3678 | { | 3678 | reader->refresh(); |
3679 | config.writeEntry("Debounce", m_debounce); | 3679 | m_fontBar->hide(); |
3680 | config.writeEntry("FloatDialogs", m_bFloatingDialog); | 3680 | m_fontVisible = false; |
3681 | reader->m_lastposn = reader->pagelocate(); | 3681 | // qDebug("setfont"); |
3682 | config.writeEntry( "LastFile", reader->m_lastfile ); | 3682 | //if (reader->isVisible()) |
3683 | config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); | 3683 | showEditTools(); |
3684 | } | 3684 | // qDebug("showeditdone"); |
3685 | config.writeEntry( "PageMode", reader->m_bpagemode ); | 3685 | } |
3686 | config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); | 3686 | |
3687 | config.writeEntry( "SwapMouse", reader->m_swapmouse); | 3687 | void QTReaderApp::do_autogen(const QString& regText) |
3688 | config.writeEntry( "Fontname", reader->m_fontname ); | 3688 | { |
3689 | config.writeEntry( "Encoding", reader->m_encd ); | 3689 | unsigned long fs, ts; |
3690 | config.writeEntry( "CharSpacing", reader->m_charpc ); | 3690 | reader->sizes(fs,ts); |
3691 | config.writeEntry( "Overlap", (int)(reader->m_overlap) ); | 3691 | // // qDebug("Reg:%s\n", (const tchar*)(regEdit->text())); |
3692 | config.writeEntry( "Margin", (int)reader->m_border ); | 3692 | m_autogenstr = regText; |
3693 | config.writeEntry( "TargetApp", m_targetapp ); | 3693 | QRegExp re(regText); |
3694 | config.writeEntry( "TargetMsg", m_targetmsg ); | 3694 | CBuffer buff; |
3695 | #ifdef _SCROLLPIPE | 3695 | if (pBkmklist != NULL) delete pBkmklist; |
3696 | config.writeEntry( "PipeTarget", reader->m_pipetarget ); | 3696 | reader->pBkmklist = pBkmklist = new CList<Bkmk>; |
3697 | config.writeEntry( "PauseAfterPara", reader->m_pauseAfterEachPara ); | 3697 | m_fBkmksChanged = true; |
3698 | #endif | 3698 | |
3699 | config.writeEntry( "TwoTouch", m_twoTouch ); | 3699 | pbar->setGeometry(regBar->x(),regBar->y(),regBar->width(), regBar->height()); |
3700 | config.writeEntry( "Annotation", m_doAnnotation); | 3700 | pbar->show(); |
3701 | config.writeEntry( "Dictionary", m_doDictionary); | 3701 | pbar->raise(); |
3702 | config.writeEntry( "Clipboard", m_doClipboard); | 3702 | pbar->reset(); |
3703 | config.writeEntry( "SpaceTarget", m_spaceTarget); | 3703 | reader->update(); |
3704 | config.writeEntry( "EscapeTarget", m_escapeTarget); | 3704 | qApp->processEvents(); |
3705 | config.writeEntry( "ReturnTarget", m_returnTarget); | 3705 | reader->setFocus(); |
3706 | config.writeEntry( "LeftTarget", m_leftTarget); | 3706 | reader->jumpto(0); |
3707 | config.writeEntry( "RightTarget", m_rightTarget); | 3707 | int lastpc = 0; |
3708 | config.writeEntry( "UpTarget", m_upTarget); | 3708 | int i = 0; |
3709 | config.writeEntry( "DownTarget", m_downTarget); | 3709 | while (i >= 0) |
3710 | config.writeEntry("LeftScroll", m_leftScroll); | 3710 | { |
3711 | config.writeEntry("RightScroll", m_rightScroll); | 3711 | unsigned int lcn = reader->locate(); |
3712 | config.writeEntry("UpScroll", m_upScroll); | 3712 | int pc = (100*lcn)/ts; |
3713 | config.writeEntry("DownScroll", m_downScroll); | 3713 | if (pc != lastpc) |
3714 | #ifdef REPALM | 3714 | { |
3715 | config.writeEntry( "Repalm", reader->brepalm ); | 3715 | pbar->setProgress(pc); |
3716 | #endif | 3716 | qApp->processEvents(); |
3717 | config.writeEntry( "Remap", reader->bremap ); | 3717 | if (reader->locate() != lcn) reader->jumpto(lcn); |
3718 | config.writeEntry( "Peanut", reader->bpeanut ); | 3718 | reader->setFocus(); |
3719 | config.writeEntry( "MakeBold", reader->bmakebold ); | 3719 | lastpc = pc; |
3720 | config.writeEntry( "Continuous", reader->m_continuousDocument ); | 3720 | } |
3721 | config.writeEntry( "FullJust", reader->bfulljust ); | 3721 | i = reader->buffdoc.getpara(buff); |
3722 | config.writeEntry( "ExtraSpace", reader->getextraspace() ); | 3722 | #ifdef _UNICODE |
3723 | config.writeEntry( "ExtraLead", reader->getlead() ); | 3723 | if (re.match(toQString(buff.data())) != -1) |
3724 | config.writeEntry( "Basesize", (int)reader->getBaseSize()); | 3724 | #else |
3725 | config.writeEntry( "RequestorFontChange", m_propogatefontchange); | 3725 | if (re.match(buff.data()) != -1) |
3726 | if (full) | 3726 | #endif |
3727 | { | 3727 | pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn)); |
3728 | config.setGroup( "Toolbar" ); | 3728 | } |
3729 | config.writeEntry("Movable", m_tbmovesave); | 3729 | pBkmklist->sort(); |
3730 | config.writeEntry("Policy", m_tbpolsave); | 3730 | pbar->setProgress(100); |
3731 | config.writeEntry("Position", m_tbposition); | 3731 | qApp->processEvents(); |
3732 | #ifndef USEQPE | 3732 | pbar->hide(); |
3733 | config.setGroup( "Geometry" ); | 3733 | reader->refresh(); |
3734 | config.writeEntry( "x", x() ); | 3734 | } |
3735 | config.writeEntry( "y", y() ); | 3735 | |
3736 | config.writeEntry( "width", width() ); | 3736 | void QTReaderApp::saveprefs() |
3737 | config.writeEntry( "height", height() ); | 3737 | { |
3738 | #endif | 3738 | do_saveconfig( APPDIR, true ); |
3739 | } | 3739 | savefilelist(); |
3740 | } | 3740 | } |
3741 | 3741 | ||
3742 | /* | 3742 | /* |
3743 | void QTReaderApp::setstate(unsigned char* _sd, unsigned short _sdlen) | 3743 | void QTReaderApp::oldFile() |
3744 | { | 3744 | { |
3745 | unsigned short sdlen; | 3745 | // qDebug("oldFile called"); |
3746 | memcpy(&sdlen, _sd, sizeof(sdlen)); | 3746 | reader->setText(true); |
3747 | sdlen -= sizeof(sdlen); | 3747 | // qDebug("settext called"); |
3748 | _sd += sizeof(sdlen); | 3748 | showEditTools(); |
3749 | statedata* sd; | 3749 | // qDebug("showedit called"); |
3750 | char* data; | 3750 | } |
3751 | if (sdlen < sizeof(statedata)+1) | 3751 | */ |
3752 | { | 3752 | |
3753 | sdlen = sizeof(statedata)+1; | 3753 | /* |
3754 | } | 3754 | void info_cb(Fl_Widget* o, void* _data) |
3755 | data = new char[sdlen]; | 3755 | { |
3756 | sd = (statedata*)data; | 3756 | |
3757 | memcpy(sd, _sd, sdlen); | 3757 | if (infowin == NULL) |
3758 | data[sdlen] = 0; | 3758 | { |
3759 | reader->setstate(*sd); | 3759 | |
3760 | delete [] data; | 3760 | infowin = new Fl_Window(160,240); |
3761 | } | 3761 | filename = new Fl_Output(45,5,110,14,"Filename"); |
3762 | 3762 | filesize = new Fl_Output(45,25,110,14,"Filesize"); | |
3763 | void QTReaderApp::getstate(unsigned char*& data, unsigned short& len) | 3763 | textsize = new Fl_Output(45,45,110,14,"Textsize"); |
3764 | { | 3764 | comprat = new CBar(45,65,110,14,"Ratio %"); |
3765 | unsigned char* olddata = data; | 3765 | posn = new Fl_Output(45,85,110,14,"Location"); |
3766 | unsigned short oldlen = len; | 3766 | frcn = new CBar(45,105,110,14,"% Read"); |
3767 | len = oldlen+sizeof(unsigned short)+sizeof(statedata)+reader->m_fontname.length(); | 3767 | about = new Fl_Multiline_Output(5,125,150,90); |
3768 | data = new unsigned char[len]; | 3768 | about->value("TWReader - $Name$\n\nA file reader program for the Agenda\n\nReads text, PalmDoc and ppms format files"); |
3769 | memcpy(data, olddata, oldlen); | 3769 | Fl_Button *jump_accept = new Fl_Button(62,220,35,14,"Okay"); |
3770 | delete [] olddata; | 3770 | infowin->set_modal(); |
3771 | memcpy(data+oldlen, &len, sizeof(len)); | 3771 | } |
3772 | statedata* sd = (statedata*)(data+oldlen+sizeof(unsigned short)); | 3772 | if (((reader_ui *)_data)->g_filename[0] != '\0') |
3773 | 3773 | { | |
3774 | sd->bstripcr = reader->bstripcr; | 3774 | unsigned long fs,ts; |
3775 | sd->btextfmt = reader->btextfmt; | 3775 | tchar sz[20]; |
3776 | sd->bautofmt = reader->bautofmt; | 3776 | ((reader_ui *)_data)->input->sizes(fs,ts); |
3777 | sd->bstriphtml = reader->bstriphtml; | 3777 | unsigned long pl = ((reader_ui *)_data)->input->locate(); |
3778 | sd->bpeanut = reader->bpeanut; | 3778 | |
3779 | sd->bdehyphen = reader->bdehyphen; | 3779 | filename->value(((reader_ui *)_data)->g_filename); |
3780 | sd->bdepluck = reader->bdepluck; | 3780 | |
3781 | sd->bdejpluck = reader->bdejpluck; | 3781 | sprintf(sz,"%u",fs); |
3782 | sd->bonespace = reader->bonespace; | 3782 | filesize->value(sz); |
3783 | sd->bunindent = reader->bunindent; | 3783 | |
3784 | sd->brepara = reader->brepara; | 3784 | sprintf(sz,"%u",ts); |
3785 | sd->bdblspce = reader->bdblspce; | 3785 | textsize->value(sz); |
3786 | sd->m_bpagemode = reader->m_bpagemode; | 3786 | |
3787 | sd->m_bMonoSpaced = reader->m_bMonoSpaced; | 3787 | comprat->value(100-(100*fs + (ts >> 1))/ts); |
3788 | sd->bremap = reader->bremap; | 3788 | |
3789 | sd->bmakebold = reader->bmakebold; | 3789 | sprintf(sz,"%u",pl); |
3790 | sd->Continuous = reader->m_continuousDocument; | 3790 | posn->value(sz); |
3791 | #ifdef REPALM | 3791 | |
3792 | sd->brepalm = reader->brepalm; | 3792 | frcn->value((100*pl + (ts >> 1))/ts); |
3793 | #endif | 3793 | } |
3794 | sd->bindenter = reader->bindenter; | 3794 | infowin->show(); |
3795 | sd->m_textsize = reader->m_textsize; //reader->m_fontControl.currentsize() | 3795 | } |
3796 | sd->m_encd = reader->m_encd; | 3796 | */ |
3797 | sd->m_charpc = reader->m_charpc; | 3797 | |
3798 | strcpy(sd->m_fontname, reader->m_fontname.latin1()); | 3798 | void QTReaderApp::savebkmks() |
3799 | } | 3799 | { |
3800 | */ | 3800 | if (pBkmklist != NULL) |
3801 | #ifdef _SCRIPT | 3801 | { |
3802 | void QTReaderApp::RunScript() | 3802 | #ifndef USEQPE |
3803 | { | 3803 | QDir d = QDir::home(); // "/" |
3804 | fileBrowser* fb = new fileBrowser(this,"OpieReader",!m_bFloatingDialog, | 3804 | d.cd(APPDIR); |
3805 | 0, | 3805 | QFileInfo fi(d, reader->m_string); |
3806 | // WStyle_Customize | WStyle_NoBorderEx, | 3806 | BkmkFile bf((const char *)fi.absFilePath(), true, true); |
3807 | "*", Global::applicationFileName(APPDIR "/scripts", "")); | 3807 | #else /* USEQPE */ |
3808 | 3808 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string), true, true); | |
3809 | QString fn; | 3809 | #endif /* USEQPE */ |
3810 | if (fb->exec()) | 3810 | bf.write(*pBkmklist); |
3811 | { | 3811 | } |
3812 | fn = fb->fileList[0]; | 3812 | m_fBkmksChanged = false; |
3813 | } | 3813 | } |
3814 | delete fb; | 3814 | |
3815 | if ( !fn.isEmpty() && fork() == 0 ) | 3815 | void QTReaderApp::readfilelist() |
3816 | { | 3816 | { |
3817 | execlp((const char *)fn,(const char *)fn,NULL); | 3817 | #ifndef USEQPE |
3818 | } | 3818 | QDir d = QDir::home(); // "/" |
3819 | } | 3819 | d.cd(APPDIR); |
3820 | 3820 | QFileInfo fi(d, ".openfiles"); | |
3821 | void QTReaderApp::SaveScript(const char* sname) | 3821 | BkmkFile bf((const char *)fi.absFilePath(), false, false); |
3822 | { | 3822 | #else /* USEQPE */ |
3823 | FILE* f = fopen(sname,"w"); | 3823 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles"), false, false); |
3824 | if (f != NULL) | 3824 | #endif /* USEQPE */ |
3825 | { | 3825 | // qDebug("Reading open files"); |
3826 | #ifdef OPIE | 3826 | pOpenlist = bf.readall(); |
3827 | fprintf(f, "#!/bin/sh\nmsg() {\n\tqcop QPE/Application/reader \"$1\" \"$2\" \"$3\"\n}\n"); | 3827 | // if (pOpenlist != NULL) qDebug("...with success"); |
3828 | #else | 3828 | // else qDebug("...without success!"); |
3829 | fprintf(f, "#!/bin/bash\nmsg() {\n\tqcop QPE/Application/uqtreader \"$1\" \"$2\" \"$3\"\n}\n"); | 3829 | } |
3830 | #endif | 3830 | |
3831 | fprintf(f, "msg \"Update(int)\" 0\n"); | 3831 | void QTReaderApp::savefilelist() |
3832 | fprintf(f, "msg \"Layout/StripCR(int)\" %d\n", (reader->bstripcr) ? 1:0); | 3832 | { |
3833 | if (reader->btextfmt) fprintf(f, "msg \"Markup(QString)\" \"Text\"\n"); | 3833 | if (pOpenlist != NULL) |
3834 | else if (reader->bautofmt) fprintf(f, "msg \"Markup(QString)\" \"Auto\"\n"); | 3834 | { |
3835 | else if (reader->bstriphtml) fprintf(f, "msg \"Markup(QString)\" \"HTML\"\n"); | 3835 | #ifndef USEQPE |
3836 | else if (reader->bpeanut) fprintf(f, "msg \"Markup(QString)\" \"Peanut/PML\"\n"); | 3836 | QDir d = QDir::home(); // "/" |
3837 | else fprintf(f, "msg \"Markup(QString)\" \"None\"\n"); | 3837 | d.cd(APPDIR); |
3838 | fprintf(f, "msg \"Layout/Dehyphen(int)\" %d\n", (reader->bdehyphen) ? 1:0); | 3838 | QFileInfo fi(d, ".openfiles"); |
3839 | fprintf(f, "msg \"Layout/Depluck(int)\" %d\n", (reader->bdepluck) ? 1:0); | 3839 | BkmkFile bf((const char *)fi.absFilePath(), true, false); |
3840 | fprintf(f, "msg \"Layout/Dejpluck(int)\" %d\n", (reader->bdejpluck) ? 1:0); | 3840 | #else /* USEQPE */ |
3841 | fprintf(f, "msg \"Layout/SingleSpace(int)\" %d\n", (reader->bonespace) ? 1:0); | 3841 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles"), true, false); |
3842 | fprintf(f, "msg \"Layout/Unindent(int)\" %d\n", (reader->bunindent) ? 1:0); | 3842 | #endif /* USEQPE */ |
3843 | fprintf(f, "msg \"Layout/Re-paragraph(int)\" %d\n", (reader->brepara) ? 1:0); | 3843 | //qDebug("Writing open files"); |
3844 | fprintf(f, "msg \"Layout/DoubleSpace(int)\" %d\n", (reader->bdblspce) ? 1:0); | 3844 | bf.write(*pOpenlist); |
3845 | fprintf(f, "msg \"Layout/Indent(int)\" %d\n", reader->bindenter); | 3845 | } |
3846 | fprintf(f, "msg \"Format/SetFont(QString,int)\" \"%s\" %d\n", (const char*)reader->m_fontname, reader->m_textsize); | 3846 | } |
3847 | fprintf(f, "msg \"Navigation/Page/LineScroll(int)\" %d\n", (reader->m_bpagemode) ? 1:0); | 3847 | |
3848 | fprintf(f, "msg \"Format/Ideogram/Word(int)\" %d\n", (reader->m_bMonoSpaced) ? 1:0); | 3848 | void QTReaderApp::readbkmks() |
3849 | fprintf(f, "msg \"Format/Encoding(QString)\" \"%s\"\n", (const char*)m_EncodingAction[reader->m_encd]->text()); | 3849 | { |
3850 | fprintf(f, "msg \"Format/SetWidth(int)\" %d\n", reader->m_charpc); | 3850 | if (pBkmklist != NULL) |
3851 | fprintf(f, "msg \"Navigation/SetOverlap(int)\" %d\n", reader->m_overlap); | 3851 | { |
3852 | fprintf(f, "msg \"Layout/Remap(int)\" %d\n", (reader->bremap) ? 1:0); | 3852 | delete pBkmklist; |
3853 | fprintf(f, "msg \"Layout/Embolden(int)\" %d\n", (reader->bmakebold) ? 1:0); | 3853 | } |
3854 | fprintf(f, "msg \"File/Continuous(int)\" %d\n", (reader->m_continuousDocument) ? 1:0); | 3854 | struct stat fnstat; |
3855 | fprintf(f, "msg \"File/SetDictionary(QString)\" \"%s/%s\"\n", (const char *)m_targetapp, (const char *)m_targetmsg); | 3855 | struct stat bkstat; |
3856 | #ifdef _SCROLLPIPE | 3856 | #ifndef USEQPE |
3857 | fprintf(f, "msg \"File/SetScrollTarget(QString)\" \"%s\"\n", (const char *)reader->m_pipetarget); | 3857 | QDir d = QDir::home(); // "/" |
3858 | #endif | 3858 | d.cd(APPDIR); |
3859 | fprintf(f, "msg \"File/Two/OneTouch(int)\" %d\n", (m_twoTouch) ? 1:0); | 3859 | QFileInfo fi(d, reader->m_string); |
3860 | fprintf(f, "msg \"Target/Annotation(int)\" %d\n", (m_doAnnotation) ? 1:0); | 3860 | #endif /* ! USEQPE */ |
3861 | fprintf(f, "msg \"Target/Dictionary(int)\" %d\n", (m_doDictionary) ? 1:0); | 3861 | if ( |
3862 | fprintf(f, "msg \"Target/Clipboard(int)\" %d\n", (m_doClipboard) ? 1:0); | 3862 | stat((const char *)reader->m_lastfile, &fnstat) == 0 |
3863 | fprintf(f, "msg \"File/Action(QString)\" \"%s\"\n", (const char *)m_buttonAction[m_spaceTarget]->text()); | 3863 | && |
3864 | fprintf(f, "msg \"Update(int)\" 1\n"); | 3864 | #ifndef USEQPE |
3865 | fprintf(f, "msg \"info(QString)\" \"All Done\"\n"); | 3865 | stat((const char *)fi.absFilePath(), &bkstat) == 0 |
3866 | fclose(f); | 3866 | #else /* USEQPE */ |
3867 | chmod(sname, S_IXUSR | S_IXGRP | S_IXOTH); | 3867 | stat((const char *)Global::applicationFileName(APPDIR,reader->m_string), &bkstat) == 0 |
3868 | } | 3868 | #endif /* USEQPE */ |
3869 | } | 3869 | ) |
3870 | 3870 | { | |
3871 | void QTReaderApp::SaveConfig() | 3871 | if (bkstat.st_mtime < fnstat.st_mtime) |
3872 | { | 3872 | { |
3873 | m_nRegAction = cSetConfigName; | 3873 | #ifndef USEQPE |
3874 | regEdit->setText(""); | 3874 | unlink((const char *)fi.absFilePath()); |
3875 | do_regedit(); | 3875 | #else /* USEQPE */ |
3876 | } | 3876 | unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string)); |
3877 | 3877 | #endif /* USEQPE */ | |
3878 | void QTReaderApp::do_saveconfig(const QString& _txt) | 3878 | } |
3879 | { | 3879 | } |
3880 | SaveScript(Global::applicationFileName(APPDIR "/scripts", _txt)); | 3880 | |
3881 | } | 3881 | #ifndef USEQPE |
3882 | #endif | 3882 | BkmkFile bf((const char *)fi.absFilePath(), false, true); |
3883 | 3883 | #else /* USEQPE */ | |
3884 | #ifdef _SCROLLPIPE | 3884 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string), false, true); |
3885 | void QTReaderApp::setpipetarget() | 3885 | #endif /* USEQPE */ |
3886 | { | 3886 | |
3887 | m_nRegAction = cSetPipeTarget; | 3887 | reader->pBkmklist = pBkmklist = bf.readall(); |
3888 | QString text = (reader->m_pipetarget.isEmpty()) ? QString("") : reader->m_pipetarget; | 3888 | m_fBkmksChanged = bf.upgraded(); |
3889 | regEdit->setText(text); | 3889 | if (pBkmklist == NULL) |
3890 | do_regedit(); | 3890 | { |
3891 | } | 3891 | reader->pBkmklist = pBkmklist = reader->getbkmklist(); |
3892 | 3892 | } | |
3893 | void QTReaderApp::do_setpipetarget(const QString& _txt) | 3893 | if (pBkmklist != NULL) |
3894 | { | 3894 | pBkmklist->sort(); |
3895 | reader->m_pipetarget = _txt; | 3895 | } |
3896 | } | 3896 | |
3897 | 3897 | void QTReaderApp::addbkmk() | |
3898 | void QTReaderApp::setpause(bool sfs) | 3898 | { |
3899 | { | 3899 | m_nRegAction = cAddBkmk; |
3900 | reader->m_pauseAfterEachPara = sfs; | 3900 | regEdit->setText(reader->firstword()); |
3901 | } | 3901 | do_regedit(); |
3902 | #endif | 3902 | } |
3903 | 3903 | ||
3904 | void QTReaderApp::monospace(bool _b) | 3904 | void QTReaderApp::do_addbkmk(const QString& text) |
3905 | { | 3905 | { |
3906 | reader->setmono(_b); | 3906 | if (text.isEmpty()) |
3907 | } | 3907 | { |
3908 | 3908 | QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nSelect add again", 1); | |
3909 | bool QTReaderApp::readconfig(const QString& _txt, bool full=false) | 3909 | } |
3910 | { | 3910 | else |
3911 | #ifdef USEQPE | 3911 | { |
3912 | QString configname; | 3912 | if (pBkmklist == NULL) reader->pBkmklist = pBkmklist = new CList<Bkmk>; |
3913 | Config::Domain dom; | 3913 | #ifdef _UNICODE |
3914 | 3914 | CBuffer buff; | |
3915 | if (full) | 3915 | int i = 0; |
3916 | { | 3916 | for (i = 0; i < text.length(); i++) |
3917 | configname = _txt; | 3917 | { |
3918 | dom = Config::User; | 3918 | buff[i] = text[i].unicode(); |
3919 | } | 3919 | } |
3920 | else | 3920 | buff[i] = 0; |
3921 | { | 3921 | pBkmklist->push_front(Bkmk(buff.data(), NULL, reader->pagelocate())); |
3922 | configname = Global::applicationFileName(APPDIR "/configs", _txt); | 3922 | #else |
3923 | QFileInfo fm(configname); | 3923 | pBkmklist->push_front(Bkmk((const tchar*)text, reader->pagelocate())); |
3924 | if ( !fm.exists() ) return false; | 3924 | #endif |
3925 | dom = Config::File; | 3925 | m_fBkmksChanged = true; |
3926 | } | 3926 | pBkmklist->sort(); |
3927 | 3927 | reader->refresh(true); | |
3928 | Config config(configname, dom); | 3928 | } |
3929 | config.setGroup( "View" ); | 3929 | } |
3930 | 3930 | ||
3931 | #else | 3931 | void QTReaderApp::UpdateStatus() |
3932 | QFileInfo fi; | 3932 | { |
3933 | if (full) | 3933 | QString status; |
3934 | { | 3934 | for (int i = 0; i < m_statusstring.length(); i++) |
3935 | QDir d = QDir::home(); // "/" | 3935 | { |
3936 | if ( !d.cd(_txt) ) | 3936 | if (m_statusstring[i].unicode() == '%') |
3937 | { // "/tmp" | 3937 | { |
3938 | owarn << "Cannot find the \"~/" << _txt << "\" directory" << oendl; | 3938 | i++; |
3939 | d = QDir::home(); | 3939 | if (i < m_statusstring.length()) |
3940 | d.mkdir(_txt); | 3940 | { |
3941 | d.cd(_txt); | 3941 | switch (m_statusstring[i].unicode()) |
3942 | } | 3942 | { |
3943 | fi.setFile(d, INIFILE); | 3943 | case 'F': |
3944 | } | 3944 | { |
3945 | else | 3945 | unsigned long fs,ts; |
3946 | { | 3946 | reader->sizes(fs,ts); |
3947 | QDir d = QDir::home(); // "/" | 3947 | status += filesize(ts); |
3948 | if ( !d.cd(APPDIR) ) | 3948 | } |
3949 | { // "/tmp" | 3949 | break; |
3950 | owarn << "Cannot find the \"~/" APPDIR "\" directory" << oendl; | 3950 | case 'f': |
3951 | d = QDir::home(); | 3951 | { |
3952 | d.mkdir(APPDIR); | 3952 | status += filesize(reader->pagelocate()); |
3953 | d.cd(APPDIR); | 3953 | } |
3954 | } | 3954 | break; |
3955 | if ( !d.cd("configs") ) | 3955 | case 'D': |
3956 | { // "/tmp" | 3956 | { |
3957 | owarn << "Cannot find the \"~/" APPDIR "/configs\" directory" << oendl; | 3957 | status += filesize(reader->buffdoc.endSection()-reader->buffdoc.startSection()); |
3958 | d = QDir::home(); | 3958 | } |
3959 | d.mkdir("configs"); | 3959 | break; |
3960 | d.cd("configs"); | 3960 | case 'd': |
3961 | } | 3961 | { |
3962 | fi.setFile(d, _txt); | 3962 | status += filesize(reader->pagelocate()-reader->buffdoc.startSection()); |
3963 | } | 3963 | } |
3964 | #ifdef _WINDOWS | 3964 | break; |
3965 | struct stat fnstat; | 3965 | case 'P': |
3966 | if (stat((const char *)reader->m_lastfile, &fnstat) == 0) return false; // get round fileinfo bug on windows | 3966 | { |
3967 | #else | 3967 | unsigned long fs,ts; |
3968 | if (!fi.exists()) return false; | 3968 | reader->sizes(fs,ts); |
3969 | #endif | 3969 | status += percent(reader->pagelocate(),ts); |
3970 | Config config(fi.absFilePath()); | 3970 | } |
3971 | #endif | 3971 | break; |
3972 | if (full) | 3972 | case 'p': |
3973 | { | 3973 | { |
3974 | config.setGroup("Toolbar"); | 3974 | status += percent(reader->pagelocate()-reader->buffdoc.startSection(),reader->buffdoc.endSection()-reader->buffdoc.startSection()); |
3975 | m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false); | 3975 | } |
3976 | m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1); | 3976 | break; |
3977 | m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2); | 3977 | case 'z': |
3978 | } | 3978 | { |
3979 | config.setGroup( "View" ); | 3979 | // qDebug("case d"); |
3980 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false); | 3980 | status += QString().setNum(reader->m_fontControl.currentsize()*10); |
3981 | reader->bstripcr = config.readBoolEntry( "StripCr", true ); | 3981 | } |
3982 | reader->bfulljust = config.readBoolEntry( "FullJust", false ); | 3982 | break; |
3983 | reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 )); | 3983 | default: |
3984 | reader->setlead(config.readNumEntry( "ExtraLead", 0 )); | 3984 | status += m_statusstring[i]; |
3985 | reader->btextfmt = config.readBoolEntry( "TextFmt", false ); | 3985 | } |
3986 | reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); | 3986 | } |
3987 | reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); | 3987 | } |
3988 | reader->bpeanut = config.readBoolEntry( "Peanut", false ); | 3988 | else |
3989 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); | 3989 | { |
3990 | reader->bdepluck = config.readBoolEntry( "Depluck", false ); | 3990 | status += m_statusstring[i]; |
3991 | reader->bdejpluck = config.readBoolEntry( "Dejpluck", false ); | 3991 | } |
3992 | reader->bonespace = config.readBoolEntry( "OneSpace", false ); | 3992 | } |
3993 | reader->bunindent = config.readBoolEntry( "Unindent", false ); | 3993 | m_prog->setText(status); |
3994 | reader->brepara = config.readBoolEntry( "Repara", false ); | 3994 | } |
3995 | reader->bdblspce = config.readBoolEntry( "DoubleSpace", false ); | 3995 | |
3996 | reader->bindenter = config.readNumEntry( "Indent", 0 ); | 3996 | void QTReaderApp::OnRedraw() |
3997 | reader->m_textsize = config.readNumEntry( "FontSize", 12 ); | 3997 | { |
3998 | reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); | 3998 | if ((pBkmklist != NULL) && (m_bkmkAvail != NULL)) |
3999 | if (full) | 3999 | { |
4000 | { | 4000 | bool found = findNextBookmark(reader->pagelocate()); |
4001 | reader->m_lastfile = config.readEntry( "LastFile", QString::null ); | 4001 | m_bkmkAvail->setEnabled(found); |
4002 | reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); | 4002 | } |
4003 | } | 4003 | if (m_scrollbar != NULL) |
4004 | reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); | 4004 | { |
4005 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); | 4005 | //qDebug("OnRedraw:[%u, %u]", reader->buffdoc.startSection(), reader->buffdoc.endSection()); |
4006 | reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false); | 4006 | scrollbar->setRange(reader->buffdoc.startSection(), reader->buffdoc.endSection()-1); |
4007 | reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); | 4007 | scrollbar->setPageStep(reader->locate()-reader->pagelocate()); |
4008 | reader->m_encd = config.readNumEntry( "Encoding", 0 ); | 4008 | scrollbar->setValue((reader->m_rotated) ? |
4009 | reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); | 4009 | (reader->buffdoc.endSection() - reader->locate()+reader->buffdoc.startSection()) : |
4010 | reader->m_overlap = config.readNumEntry( "Overlap", 0 ); | 4010 | reader->pagelocate()); |
4011 | reader->m_border = config.readNumEntry( "Margin", 6 ); | 4011 | } |
4012 | #ifdef REPALM | 4012 | if (m_prog->isVisible()) |
4013 | reader->brepalm = config.readBoolEntry( "Repalm", true ); | 4013 | { |
4014 | #endif | 4014 | // qDebug("updating status"); |
4015 | reader->bremap = config.readBoolEntry( "Remap", true ); | 4015 | UpdateStatus(); |
4016 | reader->bmakebold = config.readBoolEntry( "MakeBold", false ); | 4016 | // qDebug("updated status"); |
4017 | reader->setContinuous(config.readBoolEntry( "Continuous", true )); | 4017 | } |
4018 | m_targetapp = config.readEntry( "TargetApp", QString::null ); | 4018 | } |
4019 | m_targetmsg = config.readEntry( "TargetMsg", QString::null ); | 4019 | |
4020 | #ifdef _SCROLLPIPE | 4020 | void QTReaderApp::showAnnotation() |
4021 | reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null ); | 4021 | { |
4022 | reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true ); | 4022 | m_annoWin->setName(toQString(m_anno->name())); |
4023 | #endif | 4023 | m_annoWin->setAnno(toQString(m_anno->anno())); |
4024 | m_twoTouch = config.readBoolEntry( "TwoTouch", false); | 4024 | m_annoWin->setColor(QColor(m_anno->red(), m_anno->green(), m_anno->blue())); |
4025 | m_doAnnotation = config.readBoolEntry( "Annotation", false); | 4025 | m_annoIsEditing = false; |
4026 | m_doDictionary = config.readBoolEntry( "Dictionary", false); | 4026 | #ifdef USEQPE |
4027 | m_doClipboard = config.readBoolEntry( "Clipboard", false); | 4027 | Global::showInputMethod(); |
4028 | m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll); | 4028 | #endif |
4029 | m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone); | 4029 | editorStack->raiseWidget( m_annoWin ); |
4030 | m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen); | 4030 | hidetoolbars(); |
4031 | m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut); | 4031 | m_annoWin->setFocus(); |
4032 | m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn); | 4032 | } |
4033 | m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp); | 4033 | |
4034 | m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown); | 4034 | void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, size_t posn2, const QString& line) |
4035 | 4035 | { | |
4036 | m_leftScroll = config.readBoolEntry("LeftScroll", false); | 4036 | //// qDebug("OnWordSelected(%u):%s", posn, (const char*)wrd); |
4037 | m_rightScroll = config.readBoolEntry("RightScroll", false); | 4037 | |
4038 | m_upScroll = config.readBoolEntry("UpScroll", true); | 4038 | if (m_doClipboard) |
4039 | m_downScroll = config.readBoolEntry("DownScroll", true); | 4039 | { |
4040 | m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false); | 4040 | QClipboard* cb = QApplication::clipboard(); |
4041 | reader->setBaseSize(config.readNumEntry( "Basesize", 10 )); | 4041 | cb->setText(wrd); |
4042 | reader->setTwoTouch(m_twoTouch); | 4042 | #ifdef USEQPE |
4043 | 4043 | if (wrd.length() > 10) | |
4044 | m_touch_action->setOn(m_twoTouch); | 4044 | { |
4045 | m_setmono_action->setOn(reader->m_bMonoSpaced); | 4045 | Global::statusMessage(wrd.left(8) + ".."); |
4046 | setfontHelper(reader->m_fontname); | 4046 | } |
4047 | if (full) | 4047 | else |
4048 | { | 4048 | { |
4049 | addtoolbars(&config); | 4049 | Global::statusMessage(wrd); |
4050 | } | 4050 | } |
4051 | reader->setfilter(reader->getfilter()); | 4051 | #endif |
4052 | reader->refresh(); | 4052 | } |
4053 | return true; | 4053 | if (m_doAnnotation) |
4054 | } | 4054 | { |
4055 | 4055 | //addAnno(wrd, "Need to be able to edit this", posn); | |
4056 | bool QTReaderApp::PopulateConfig(const char* tgtdir) | 4056 | m_annoWin->setName(line); |
4057 | { | 4057 | m_annoWin->setAnno(""); |
4058 | bkmkselector->clear(); | 4058 | m_annoWin->setPosn(posn); |
4059 | bkmkselector->setText("Cancel"); | 4059 | m_annoWin->setPosn2(posn2); |
4060 | #ifndef USEQPE | 4060 | m_annoIsEditing = true; |
4061 | int cnt = 0; | 4061 | #ifdef USEQPE |
4062 | 4062 | Global::showInputMethod(); | |
4063 | QDir d = QDir::home(); // "/" | 4063 | #endif |
4064 | if ( !d.cd(APPDIR) ) { // "/tmp" | 4064 | editorStack->raiseWidget( m_annoWin ); |
4065 | owarn << "Cannot find the \"~/" APPDIR "\" directory" << oendl; | 4065 | hidetoolbars(); |
4066 | d = QDir::home(); | 4066 | } |
4067 | d.mkdir(APPDIR); | 4067 | #ifdef USEQPE |
4068 | d.cd(APPDIR); | 4068 | if (m_doDictionary) |
4069 | } | 4069 | { |
4070 | if ( !d.cd(tgtdir) ) { // "/tmp" | 4070 | if (!m_targetapp.isEmpty() && !m_targetmsg.isEmpty()) |
4071 | owarn << "Cannot find the \"~/" APPDIR "/" << tgtdir << "\" directory" << oendl; | 4071 | { |
4072 | d = QDir::home(); | 4072 | QCopEnvelope e(("QPE/Application/"+m_targetapp).utf8(), (m_targetmsg+"(QString)").utf8()); |
4073 | d.mkdir(tgtdir); | 4073 | e << wrd; |
4074 | d.cd(tgtdir); | 4074 | } |
4075 | } | 4075 | } |
4076 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | 4076 | #endif |
4077 | // d.setSorting( QDir::Size | QDir::Reversed ); | 4077 | } |
4078 | 4078 | ||
4079 | const QFileInfoList *list = d.entryInfoList(); | 4079 | void QTReaderApp::doAction(QKeyEvent* e) |
4080 | QFileInfoListIterator it( *list ); // create list iterator | 4080 | { |
4081 | QFileInfo *fi; // pointer for traversing | 4081 | QMap<orKey,int>::Iterator f = kmap.end(); |
4082 | 4082 | ||
4083 | while ( (fi=it.current()) ) { // for each file... | 4083 | if (reader->m_autoScroll) |
4084 | 4084 | { | |
4085 | bkmkselector->insertItem(fi->fileName()); | 4085 | f = kmap.find(orKey(e->state(), e->key(), true)); |
4086 | cnt++; | 4086 | } |
4087 | 4087 | if (f == kmap.end()) | |
4088 | //odebug << "" << fi->size() << " " << fi->fileName().data() << "" << oendl; | 4088 | { |
4089 | ++it; // goto next list element | 4089 | f = kmap.find(orKey(e->state(), e->key(), false)); |
4090 | } | 4090 | } |
4091 | 4091 | ||
4092 | #else /* USEQPE */ | 4092 | if (f == kmap.end()) |
4093 | int cnt = 0; | 4093 | { |
4094 | DIR *d; | 4094 | qDebug("doaction (no action) : %d %d %d", e->key(), e->state(), f.data()); |
4095 | char* finaldir; | 4095 | e->ignore(); |
4096 | finaldir = new char[strlen(APPDIR)+1+strlen(tgtdir)+1]; | 4096 | } |
4097 | strcpy(finaldir, APPDIR); | 4097 | else |
4098 | strcat(finaldir, "/"); | 4098 | { |
4099 | strcat(finaldir, tgtdir); | 4099 | qDebug("doaction (some action) : %d %d %d", e->key(), e->state(), f.data()); |
4100 | d = opendir((const char *)Global::applicationFileName(finaldir,"")); | 4100 | ActionTypes a = (ActionTypes)f.data(); |
4101 | 4101 | e->accept(); | |
4102 | while(1) | 4102 | //qDebug("Accepted"); |
4103 | { | 4103 | switch (a) |
4104 | struct dirent* de; | 4104 | { |
4105 | struct stat buf; | 4105 | case cesGotoLink: |
4106 | de = readdir(d); | 4106 | { |
4107 | if (de == NULL) break; | 4107 | reader->gotoLink(); |
4108 | 4108 | } | |
4109 | if (lstat((const char *)Global::applicationFileName(finaldir,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) | 4109 | break; |
4110 | { | 4110 | case cesNextLink: |
4111 | bkmkselector->insertItem(de->d_name); | 4111 | { |
4112 | cnt++; | 4112 | reader->getNextLink(); |
4113 | } | 4113 | } |
4114 | } | 4114 | break; |
4115 | delete [] finaldir; | 4115 | case cesInvertColours: |
4116 | closedir(d); | 4116 | m_inverse_action->setOn(!reader->bInverse); |
4117 | #endif | 4117 | break; |
4118 | return (cnt > 0); | 4118 | case cesToggleBars: |
4119 | } | 4119 | m_hidebars = !m_hidebars; |
4120 | 4120 | if (m_hidebars) | |
4121 | void QTReaderApp::LoadConfig() | 4121 | { |
4122 | { | 4122 | #ifdef USEQPE |
4123 | if (PopulateConfig("configs")) | 4123 | menubar->hide(); |
4124 | { | 4124 | #endif |
4125 | editorStack->raiseWidget( bkmkselector ); | 4125 | if (fileBar != NULL) fileBar->hide(); |
4126 | hidetoolbars(); | 4126 | if (viewBar != NULL) viewBar->hide(); |
4127 | m_nBkmkAction = cLdConfig; | 4127 | if (navBar != NULL) navBar->hide(); |
4128 | } | 4128 | if (markBar != NULL) markBar->hide(); |
4129 | else | 4129 | mb->hide(); |
4130 | QMessageBox::information(this, PROGNAME, "No config files"); | 4130 | } |
4131 | } | 4131 | else |
4132 | 4132 | { | |
4133 | void QTReaderApp::TidyConfig() | 4133 | #ifdef USEQPE |
4134 | { | 4134 | menubar->show(); |
4135 | if (PopulateConfig("configs")) | 4135 | #endif |
4136 | { | 4136 | if (fileBar != NULL) fileBar->show(); |
4137 | editorStack->raiseWidget( bkmkselector ); | 4137 | if (viewBar != NULL) viewBar->show(); |
4138 | hidetoolbars(); | 4138 | if (navBar != NULL) navBar->show(); |
4139 | m_nBkmkAction = cRmConfig; | 4139 | if (markBar != NULL) markBar->show(); |
4140 | } | 4140 | mb->show(); |
4141 | else | 4141 | } |
4142 | QMessageBox::information(this, PROGNAME, "No config files"); | 4142 | break; |
4143 | } | 4143 | case cesToggleScrollBar: |
4144 | 4144 | if (m_scrollbar != NULL) | |
4145 | void QTReaderApp::ExportLinks() | 4145 | { |
4146 | { | 4146 | if (m_scrollbar->isHidden()) |
4147 | if (PopulateConfig("urls")) | 4147 | { |
4148 | { | 4148 | m_scrollishidden = false; |
4149 | editorStack->raiseWidget( bkmkselector ); | 4149 | m_scrollbar->show(); |
4150 | hidetoolbars(); | 4150 | reader->m_scrollpos = (m_qtscroll == 0) ? m_localscroll : 0; |
4151 | m_nBkmkAction = cExportLinks; | 4151 | } |
4152 | } | 4152 | else |
4153 | else | 4153 | { |
4154 | QMessageBox::information(this, PROGNAME, "No url files"); | 4154 | m_scrollishidden = true; |
4155 | } | 4155 | m_scrollbar->hide(); |
4156 | 4156 | reader->m_scrollpos = m_localscroll; | |
4157 | void QTReaderApp::OnURLSelected(const QString& href) | 4157 | } |
4158 | { | 4158 | } |
4159 | CURLDialog* urld = new CURLDialog(href, false, this); | 4159 | break; |
4160 | urld->clipboard(m_url_clipboard); | 4160 | case cesToggleStatusBar: |
4161 | urld->localfile(m_url_localfile); | 4161 | if (m_prog != NULL) |
4162 | urld->globalfile(m_url_globalfile); | 4162 | { |
4163 | if (urld->exec()) | 4163 | if (m_prog->isHidden()) |
4164 | { | 4164 | { |
4165 | m_url_clipboard = urld->clipboard(); | 4165 | m_statusishidden = false; |
4166 | m_url_localfile = urld->localfile(); | 4166 | m_prog->show(); |
4167 | m_url_globalfile = urld->globalfile(); | 4167 | } |
4168 | if (m_url_clipboard) | 4168 | else |
4169 | { | 4169 | { |
4170 | QClipboard* cb = QApplication::clipboard(); | 4170 | m_statusishidden = true; |
4171 | cb->setText(href); | 4171 | m_prog->hide(); |
4172 | odebug << "<a href=\"" << href << "\">" << href << "</a>" << oendl; | 4172 | } |
4173 | } | 4173 | } |
4174 | if (m_url_localfile) | 4174 | break; |
4175 | { | 4175 | case cesOpenFile: |
4176 | writeUrl(reader->m_string, href); | 4176 | { |
4177 | } | 4177 | qDebug("Open file"); |
4178 | if (m_url_globalfile) | 4178 | fileOpen(); |
4179 | { | 4179 | } |
4180 | writeUrl("GlobalURLFile", href); | 4180 | break; |
4181 | } | 4181 | case cesAutoScroll: |
4182 | } | 4182 | { |
4183 | delete urld; | 4183 | reader->setautoscroll(!reader->m_autoScroll); |
4184 | } | 4184 | setScrollState(reader->m_autoScroll); |
4185 | 4185 | } | |
4186 | void QTReaderApp::writeUrl(const QString& file, const QString& href) | 4186 | break; |
4187 | { | 4187 | case cesActionMark: |
4188 | QString filename; | 4188 | { |
4189 | #ifdef USEQPE | 4189 | addbkmk(); |
4190 | filename = Global::applicationFileName(APPDIR "/urls", file); | 4190 | } |
4191 | #else | 4191 | break; |
4192 | QFileInfo fi; | 4192 | case cesFullScreen: |
4193 | QDir d = QDir::home(); // "/" | 4193 | { |
4194 | if ( !d.cd(APPDIR) ) | 4194 | m_actFullscreen->setOn(!m_fullscreen); |
4195 | { // "/tmp" | 4195 | } |
4196 | owarn << "Cannot find the \"~/" APPDIR "\" directory" << oendl; | 4196 | break; |
4197 | d = QDir::home(); | 4197 | case cesRotate: |
4198 | d.mkdir(APPDIR); | 4198 | { |
4199 | d.cd(APPDIR); | 4199 | m_rotate_action->setOn(!reader->m_rotated); |
4200 | } | 4200 | } |
4201 | if ( !d.cd("urls") ) | 4201 | break; |
4202 | { // "/tmp" | 4202 | case cesActionAnno: |
4203 | owarn << "Cannot find the \"~/" APPDIR "/urls\" directory" << oendl; | 4203 | { |
4204 | d = QDir::home(); | 4204 | addanno(); |
4205 | d.cd(APPDIR); | 4205 | } |
4206 | d.mkdir("urls"); | 4206 | break; |
4207 | d.cd("urls"); | 4207 | case cesZoomIn: |
4208 | } | 4208 | zoomin(); |
4209 | fi.setFile(d, file); | 4209 | break; |
4210 | filename = fi.absFilePath(); | 4210 | case cesZoomOut: |
4211 | #endif | 4211 | zoomout(); |
4212 | FILE* fout = fopen(filename, "a"); | 4212 | break; |
4213 | if (fout != NULL) | 4213 | case cesBack: |
4214 | { | 4214 | reader->goBack(); |
4215 | fprintf(fout, "<p><a href=\"%s\">%s</a>\n", (const char*)href, (const char*)href); | 4215 | break; |
4216 | fclose(fout); | 4216 | case cesForward: |
4217 | } | 4217 | reader->goForward(); |
4218 | else | 4218 | break; |
4219 | { | 4219 | case cesHome: |
4220 | QMessageBox::warning(this, PROGNAME, "Problem with writing URL"); | 4220 | reader->goHome(); |
4221 | } | 4221 | break; |
4222 | } | 4222 | case cesPageUp: |
4223 | reader->dopageup(); | ||
4224 | /* | ||
4225 | ftime(&m_lastkeytime); | ||
4226 | m_fndelay = m_debounce; | ||
4227 | // | ||
4228 | { | ||
4229 | timeb now; | ||
4230 | ftime(&now); | ||
4231 | m_fndelay = (1000*(now.time - m_lastkeytime.time) + now.millitm)-m_lastkeytime.millitm+100; | ||
4232 | } | ||
4233 | */ | ||
4234 | break; | ||
4235 | case cesPageDown: | ||
4236 | reader->dopagedn(); | ||
4237 | /* | ||
4238 | ftime(&m_lastkeytime); | ||
4239 | m_fndelay = m_debounce; | ||
4240 | // | ||
4241 | if (m_debounce != 0) | ||
4242 | { | ||
4243 | timeb now; | ||
4244 | ftime(&now); | ||
4245 | m_fndelay = (1000*(now.time - m_lastkeytime.time) + now.millitm)-m_lastkeytime.millitm+10; | ||
4246 | } | ||
4247 | */ | ||
4248 | break; | ||
4249 | case cesLineUp: | ||
4250 | reader->lineUp(); | ||
4251 | break; | ||
4252 | case cesLineDown: | ||
4253 | reader->lineDown(); | ||
4254 | break; | ||
4255 | case cesStartDoc: | ||
4256 | gotoStart(); | ||
4257 | break; | ||
4258 | case cesEndDoc: | ||
4259 | gotoEnd(); | ||
4260 | break; | ||
4261 | case cesScrollMore: | ||
4262 | reader->increaseScroll(); | ||
4263 | break; | ||
4264 | case cesScrollLess: | ||
4265 | reader->reduceScroll(); | ||
4266 | break; | ||
4267 | default: | ||
4268 | qDebug("Unknown ActionType:%u", a); | ||
4269 | break; | ||
4270 | } | ||
4271 | } | ||
4272 | } | ||
4273 | |||
4274 | void QTReaderApp::setTwoTouch(bool _b) { reader->setTwoTouch(_b); } | ||
4275 | void QTReaderApp::restoreFocus() { reader->setFocus(); } | ||
4276 | |||
4277 | void QTReaderApp::SaveConfig() | ||
4278 | { | ||
4279 | m_nRegAction = cSetConfigName; | ||
4280 | regEdit->setText(reader->m_string); | ||
4281 | do_regedit(); | ||
4282 | } | ||
4283 | |||
4284 | void QTReaderApp::do_saveconfig(const QString& _txt, bool full) | ||
4285 | { | ||
4286 | // qDebug("do_saveconfig:%s", (const char*)_txt); | ||
4287 | #ifdef USEQPE | ||
4288 | QString configname; | ||
4289 | Config::Domain dom; | ||
4290 | |||
4291 | if (full) | ||
4292 | { | ||
4293 | configname = _txt; | ||
4294 | dom = Config::User; | ||
4295 | } | ||
4296 | else | ||
4297 | { | ||
4298 | configname = Global::applicationFileName(APPDIR "/configs", _txt); | ||
4299 | dom = Config::File; | ||
4300 | } | ||
4301 | |||
4302 | Config config(configname, dom); | ||
4303 | config.setGroup( "View" ); | ||
4304 | |||
4305 | #else | ||
4306 | QFileInfo fi; | ||
4307 | if (full) | ||
4308 | { | ||
4309 | // qDebug("full:%s", (const char*)_txt); | ||
4310 | QDir d = QDir::home(); // "/" | ||
4311 | if ( !d.cd(_txt) ) | ||
4312 | { // "/tmp" | ||
4313 | qWarning( "Cannot find the \"~/%s\" directory", (const char*)_txt ); | ||
4314 | d = QDir::home(); | ||
4315 | d.mkdir(_txt); | ||
4316 | d.cd(_txt); | ||
4317 | } | ||
4318 | fi.setFile(d, INIFILE); | ||
4319 | } | ||
4320 | else | ||
4321 | { | ||
4322 | QDir d = QDir::home(); // "/" | ||
4323 | if ( !d.cd(APPDIR) ) | ||
4324 | { // "/tmp" | ||
4325 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | ||
4326 | d = QDir::home(); | ||
4327 | d.mkdir(APPDIR); | ||
4328 | d.cd(APPDIR); | ||
4329 | } | ||
4330 | if ( !d.cd("configs") ) | ||
4331 | { // "/tmp" | ||
4332 | qWarning( "Cannot find the \"~/" APPDIR "/configs\" directory" ); | ||
4333 | d = QDir::home(); | ||
4334 | d.cd(APPDIR); | ||
4335 | d.mkdir("configs"); | ||
4336 | d.cd("configs"); | ||
4337 | } | ||
4338 | fi.setFile(d, _txt); | ||
4339 | } | ||
4340 | //qDebug("Path:%s", (const char*)fi.absFilePath()); | ||
4341 | Config config(fi.absFilePath()); | ||
4342 | #endif | ||
4343 | |||
4344 | |||
4345 | config.writeEntry( "StripCr", reader->bstripcr ); | ||
4346 | config.writeEntry( "AutoFmt", reader->bautofmt ); | ||
4347 | config.writeEntry( "TextFmt", reader->btextfmt ); | ||
4348 | config.writeEntry( "StripHtml", reader->bstriphtml ); | ||
4349 | config.writeEntry( "Dehyphen", reader->bdehyphen ); | ||
4350 | config.writeEntry( "Depluck", reader->bdepluck ); | ||
4351 | config.writeEntry( "Dejpluck", reader->bdejpluck ); | ||
4352 | config.writeEntry( "OneSpace", reader->bonespace ); | ||
4353 | config.writeEntry( "Unindent", reader->bunindent ); | ||
4354 | config.writeEntry( "Repara", reader->brepara ); | ||
4355 | config.writeEntry( "ReparaString", reader->m_reparastring); | ||
4356 | config.writeEntry( "BackgroundType" , (int)m_bgtype ); | ||
4357 | config.writeEntry( "Theme", m_themename ); | ||
4358 | config.writeEntry( "DoubleSpace", reader->bdblspce ); | ||
4359 | config.writeEntry( "Indent", reader->bindenter ); | ||
4360 | config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) ); | ||
4361 | config.writeEntry( "ScrollDelay", reader->m_delay); | ||
4362 | config.writeEntry( "ScrollStep", reader->m_scrollstep); | ||
4363 | config.writeEntry( "ScrollType", reader->m_scrolltype ); | ||
4364 | if (full) | ||
4365 | { | ||
4366 | config.writeEntry("Debounce", m_debounce); | ||
4367 | config.writeEntry("FloatDialogs", m_bFloatingDialog); | ||
4368 | reader->m_lastposn = reader->pagelocate(); | ||
4369 | config.writeEntry( "LastFile", reader->m_lastfile ); | ||
4370 | config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); | ||
4371 | } | ||
4372 | config.writeEntry( "PageMode", reader->m_bpagemode ); | ||
4373 | config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); | ||
4374 | config.writeEntry( "SwapMouse", reader->m_swapmouse); | ||
4375 | config.writeEntry( "IsRotated", reader->m_rotated ); | ||
4376 | config.writeEntry("StatusContent", m_statusstring); | ||
4377 | config.writeEntry("StatusHidden", m_statusishidden); | ||
4378 | config.writeEntry( "Background", m_background ); | ||
4379 | config.writeEntry( "Foreground", m_foreground ); | ||
4380 | config.writeEntry( "ScrollColour", m_scrollcolor ); | ||
4381 | config.writeEntry( "ScrollBarColour", m_scrollbarcolor ); | ||
4382 | config.writeEntry( "Hyphenate", reader->hyphenate ); | ||
4383 | // config.writeEntry( "CustomHyphen", reader->buffdoc.getCustomHyphen() ); | ||
4384 | config.writeEntry( "Fontname", reader->m_fontname ); | ||
4385 | config.writeEntry( "Encoding", reader->m_encd ); | ||
4386 | config.writeEntry( "CharSpacing", reader->m_charpc ); | ||
4387 | config.writeEntry( "Overlap", (int)(reader->m_overlap) ); | ||
4388 | config.writeEntry( "Top Margin", (int)reader->m_abstopmargin ); | ||
4389 | config.writeEntry( "Bottom Margin", (int)reader->m_absbottommargin ); | ||
4390 | config.writeEntry( "Left Margin", (int)reader->m_absleft_border ); | ||
4391 | config.writeEntry( "Right Margin", (int)reader->m_absright_border ); | ||
4392 | config.writeEntry( "TargetApp", m_targetapp ); | ||
4393 | config.writeEntry( "TargetMsg", m_targetmsg ); | ||
4394 | #ifdef _SCROLLPIPE | ||
4395 | config.writeEntry( "PipeTarget", reader->m_pipetarget ); | ||
4396 | config.writeEntry( "PauseAfterPara", reader->m_pauseAfterEachPara ); | ||
4397 | #endif | ||
4398 | config.writeEntry( "TwoTouch", m_twoTouch ); | ||
4399 | config.writeEntry( "Annotation", m_doAnnotation); | ||
4400 | config.writeEntry( "Dictionary", m_doDictionary); | ||
4401 | config.writeEntry( "Clipboard", m_doClipboard); | ||
4402 | /* | ||
4403 | config.writeEntry( "SpaceTarget", m_spaceTarget); | ||
4404 | config.writeEntry( "EscapeTarget", m_escapeTarget); | ||
4405 | config.writeEntry( "ReturnTarget", m_returnTarget); | ||
4406 | config.writeEntry( "LeftTarget", m_leftTarget); | ||
4407 | config.writeEntry( "RightTarget", m_rightTarget); | ||
4408 | config.writeEntry( "UpTarget", m_upTarget); | ||
4409 | config.writeEntry( "DownTarget", m_downTarget); | ||
4410 | config.writeEntry("LeftScroll", m_leftScroll); | ||
4411 | config.writeEntry("RightScroll", m_rightScroll); | ||
4412 | config.writeEntry("UpScroll", m_upScroll); | ||
4413 | config.writeEntry("DownScroll", m_downScroll); | ||
4414 | */ | ||
4415 | config.writeEntry( "Repalm", reader->brepalm ); | ||
4416 | config.writeEntry( "HideScrollBar", m_scrollishidden ); | ||
4417 | config.writeEntry( "Kern", reader->bkern ); | ||
4418 | config.writeEntry( "Remap", reader->bremap ); | ||
4419 | config.writeEntry( "Peanut", reader->bpeanut ); | ||
4420 | config.writeEntry( "MakeBold", reader->bmakebold ); | ||
4421 | config.writeEntry( "Continuous", reader->m_continuousDocument ); | ||
4422 | config.writeEntry( "FullJust", reader->bfulljust ); | ||
4423 | // config.writeEntry( "Negative", reader->bNegative ); | ||
4424 | config.writeEntry( "Inverse", reader->bInverse ); | ||
4425 | config.writeEntry( "FixGraphics", reader->m_fontControl.FixGraphics()); | ||
4426 | config.writeEntry( "ExtraSpace", reader->getextraspace() ); | ||
4427 | config.writeEntry( "ExtraLead", reader->getlead() ); | ||
4428 | config.writeEntry( "Basesize", (int)reader->getBaseSize()); | ||
4429 | config.writeEntry( "RequestorFontChange", m_propogatefontchange); | ||
4430 | #ifdef USEQPE | ||
4431 | config.writeEntry( "GrabKeyboard", m_grabkeyboard ); | ||
4432 | #endif | ||
4433 | if (full) | ||
4434 | { | ||
4435 | config.setGroup( "Toolbar" ); | ||
4436 | config.writeEntry("QTScrollBar", m_qtscroll); | ||
4437 | config.writeEntry("LocalScrollBar", m_localscroll); | ||
4438 | config.writeEntry("Movable", m_tbmovesave); | ||
4439 | config.writeEntry("Policy", m_tbpolsave); | ||
4440 | config.writeEntry("Position", m_tbposition); | ||
4441 | #ifndef USEQPE | ||
4442 | if (!isMaximized() && !isMinimized()) | ||
4443 | { | ||
4444 | config.setGroup( "Geometry" ); | ||
4445 | config.writeEntry( "x", x() ); | ||
4446 | config.writeEntry( "y", y() ); | ||
4447 | config.writeEntry( "width", width() ); | ||
4448 | config.writeEntry( "height", height() ); | ||
4449 | } | ||
4450 | #endif | ||
4451 | } | ||
4452 | } | ||
4453 | |||
4454 | #ifdef _SCROLLPIPE | ||
4455 | void QTReaderApp::setpipetarget() | ||
4456 | { | ||
4457 | m_nRegAction = cSetPipeTarget; | ||
4458 | QString text = (reader->m_pipetarget.isEmpty()) ? QString("") : reader->m_pipetarget; | ||
4459 | regEdit->setText(text); | ||
4460 | do_regedit(); | ||
4461 | } | ||
4462 | |||
4463 | void QTReaderApp::do_setpipetarget(const QString& _txt) | ||
4464 | { | ||
4465 | reader->m_pipetarget = _txt; | ||
4466 | } | ||
4467 | |||
4468 | void QTReaderApp::setpause(bool sfs) | ||
4469 | { | ||
4470 | reader->m_pauseAfterEachPara = sfs; | ||
4471 | } | ||
4472 | #endif | ||
4473 | |||
4474 | void QTReaderApp::monospace(bool _b) | ||
4475 | { | ||
4476 | reader->setmono(_b); | ||
4477 | } | ||
4478 | |||
4479 | bool QTReaderApp::readconfig(const QString& dirname, const QString& _txt, bool full=false) | ||
4480 | { | ||
4481 | #ifdef USEQPE | ||
4482 | QString configname; | ||
4483 | Config::Domain dom; | ||
4484 | |||
4485 | if (full) | ||
4486 | { | ||
4487 | configname = _txt; | ||
4488 | dom = Config::User; | ||
4489 | } | ||
4490 | else | ||
4491 | { | ||
4492 | configname = Global::applicationFileName(dirname, _txt); | ||
4493 | QFileInfo fm(configname); | ||
4494 | if ( !fm.exists() ) return false; | ||
4495 | dom = Config::File; | ||
4496 | } | ||
4497 | |||
4498 | Config config(configname, dom); | ||
4499 | config.setGroup( "View" ); | ||
4500 | |||
4501 | #else | ||
4502 | QString fullname; | ||
4503 | if (full) | ||
4504 | { | ||
4505 | fullname = QDir::homeDirPath() + "/" + _txt + "/" + INIFILE; | ||
4506 | } | ||
4507 | else | ||
4508 | { | ||
4509 | fullname = QDir::homeDirPath() + "/" + dirname + "/" + _txt; | ||
4510 | } | ||
4511 | if (!QFile::exists(fullname)) return false; | ||
4512 | |||
4513 | Config config(fullname); | ||
4514 | #endif | ||
4515 | if (full) | ||
4516 | { | ||
4517 | config.setGroup("Toolbar"); | ||
4518 | m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", m_tbmovesave); | ||
4519 | m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", m_tbpolsave); | ||
4520 | m_tbposition = (ToolBarDock)config.readNumEntry("Position", m_tbposition); | ||
4521 | } | ||
4522 | config.setGroup( "View" ); | ||
4523 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", m_bFloatingDialog); | ||
4524 | reader->bstripcr = config.readBoolEntry( "StripCr", reader->bstripcr ); | ||
4525 | reader->bfulljust = config.readBoolEntry( "FullJust", reader->bfulljust ); | ||
4526 | reader->bInverse = config.readBoolEntry( "Inverse", reader->bInverse ); | ||
4527 | // reader->bNegative = config.readBoolEntry( "Negative", false ); | ||
4528 | reader->m_fontControl.FixGraphics(config.readBoolEntry( "FixGraphics", reader->m_fontControl.FixGraphics() )); | ||
4529 | reader->setextraspace(config.readNumEntry( "ExtraSpace", reader->getextraspace() )); | ||
4530 | reader->setlead(config.readNumEntry( "ExtraLead", reader->getlead() )); | ||
4531 | reader->btextfmt = config.readBoolEntry( "TextFmt", reader->btextfmt ); | ||
4532 | reader->bautofmt = config.readBoolEntry( "AutoFmt", reader->bautofmt ); | ||
4533 | reader->bstriphtml = config.readBoolEntry( "StripHtml", reader->bstriphtml ); | ||
4534 | reader->bpeanut = config.readBoolEntry( "Peanut", reader->bpeanut ); | ||
4535 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", reader->bdehyphen ); | ||
4536 | reader->bdepluck = config.readBoolEntry( "Depluck", reader->bdepluck ); | ||
4537 | reader->bdejpluck = config.readBoolEntry( "Dejpluck", reader->bdejpluck ); | ||
4538 | reader->bonespace = config.readBoolEntry( "OneSpace", reader->bonespace ); | ||
4539 | reader->bunindent = config.readBoolEntry( "Unindent", reader->bunindent ); | ||
4540 | reader->brepara = config.readBoolEntry( "Repara", reader->brepara ); | ||
4541 | reader->m_reparastring = config.readEntry( "ReparaString", reader->m_reparastring); | ||
4542 | m_bgtype = (bground)config.readNumEntry( "BackgroundType" , m_bgtype ); | ||
4543 | m_themename = config.readEntry("Theme", m_themename ); | ||
4544 | reader->bdblspce = config.readBoolEntry( "DoubleSpace", reader->bdblspce ); | ||
4545 | reader->bindenter = config.readNumEntry( "Indent", reader->bindenter ); | ||
4546 | reader->m_textsize = config.readNumEntry( "FontSize", reader->m_textsize ); | ||
4547 | reader->m_delay = config.readNumEntry( "ScrollDelay", reader->m_delay); | ||
4548 | reader->m_scrollstep = config.readNumEntry( "ScrollStep", reader->m_scrollstep); | ||
4549 | reader->m_scrolltype = config.readNumEntry( "ScrollType", reader->m_scrolltype); | ||
4550 | if (full) | ||
4551 | { | ||
4552 | reader->m_lastfile = config.readEntry( "LastFile", reader->m_lastfile ); | ||
4553 | reader->m_lastposn = config.readNumEntry( "LastPosn", reader->m_lastposn ); | ||
4554 | } | ||
4555 | reader->m_bpagemode = config.readBoolEntry( "PageMode", reader->m_bpagemode ); | ||
4556 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", reader->m_bMonoSpaced); | ||
4557 | reader->m_rotated = config.readBoolEntry( "IsRotated", reader->m_rotated ); | ||
4558 | m_statusstring = config.readEntry("StatusContent", m_statusstring); | ||
4559 | m_statusishidden = config.readBoolEntry("StatusHidden", m_statusishidden); | ||
4560 | m_background = config.readNumEntry( "Background", m_background ); | ||
4561 | reader->setBackground(getcolour(m_background)); | ||
4562 | m_foreground = config.readNumEntry( "Foreground", m_foreground ); | ||
4563 | reader->setForeground(getcolour(m_foreground)); | ||
4564 | m_scrollcolor = config.readNumEntry( "ScrollColour", m_scrollcolor); | ||
4565 | setscrollcolour(); | ||
4566 | m_scrollbarcolor = config.readNumEntry( "ScrollBarColour", m_scrollbarcolor); | ||
4567 | setscrollbarcolour(); | ||
4568 | reader->hyphenate = config.readBoolEntry( "Hyphenate", reader->hyphenate ); | ||
4569 | // reader->buffdoc.setCustomHyphen(config.readBoolEntry( "CustomHyphen", false )); | ||
4570 | reader->m_swapmouse = config.readBoolEntry( "SwapMouse", reader->m_swapmouse); | ||
4571 | reader->m_fontname = config.readEntry( "Fontname", reader->m_fontname ); | ||
4572 | reader->m_encd = config.readNumEntry( "Encoding", reader->m_encd ); | ||
4573 | reader->m_charpc = config.readNumEntry( "CharSpacing", reader->m_charpc ); | ||
4574 | reader->m_overlap = config.readNumEntry( "Overlap", reader->m_overlap ); | ||
4575 | reader->m_abstopmargin = config.readNumEntry( "Top Margin", reader->m_abstopmargin ); | ||
4576 | reader->m_absbottommargin = config.readNumEntry( "Bottom Margin", reader->m_absbottommargin ); | ||
4577 | reader->m_absleft_border = config.readNumEntry( "Left Margin", reader->m_absleft_border ); | ||
4578 | reader->m_absright_border = config.readNumEntry( "Right Margin", reader->m_absright_border ); | ||
4579 | m_scrollishidden = config.readBoolEntry( "HideScrollBar", m_scrollishidden ); | ||
4580 | reader->brepalm = config.readBoolEntry( "Repalm", reader->brepalm ); | ||
4581 | reader->bkern = config.readBoolEntry( "Kern", reader->bkern ); | ||
4582 | reader->bremap = config.readBoolEntry( "Remap", reader->bremap ); | ||
4583 | reader->bmakebold = config.readBoolEntry( "MakeBold", reader->bmakebold ); | ||
4584 | reader->setContinuous(config.readBoolEntry( "Continuous", reader->m_continuousDocument )); | ||
4585 | m_targetapp = config.readEntry( "TargetApp", m_targetapp ); | ||
4586 | m_targetmsg = config.readEntry( "TargetMsg", m_targetmsg ); | ||
4587 | #ifdef _SCROLLPIPE | ||
4588 | reader->m_pipetarget = config.readEntry( "PipeTarget", reader->m_pipetarget ); | ||
4589 | reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", reader->m_pauseAfterEachPara ); | ||
4590 | #endif | ||
4591 | m_twoTouch = config.readBoolEntry( "TwoTouch", m_twoTouch); | ||
4592 | m_doAnnotation = config.readBoolEntry( "Annotation", m_doAnnotation); | ||
4593 | m_doDictionary = config.readBoolEntry( "Dictionary", m_doDictionary); | ||
4594 | m_doClipboard = config.readBoolEntry( "Clipboard", m_doClipboard); | ||
4595 | #ifdef USEQPE | ||
4596 | m_grabkeyboard = config.readBoolEntry( "GrabKeyboard", m_grabkeyboard); | ||
4597 | #endif | ||
4598 | m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", m_propogatefontchange); | ||
4599 | reader->setBaseSize(config.readNumEntry( "Basesize", reader->getBaseSize() )); | ||
4600 | reader->setTwoTouch(m_twoTouch); | ||
4601 | |||
4602 | m_touch_action->setOn(m_twoTouch); | ||
4603 | m_setmono_action->setOn(reader->m_bMonoSpaced); | ||
4604 | setfontHelper(reader->m_fontname); | ||
4605 | if (full) | ||
4606 | { | ||
4607 | addtoolbars(&config); | ||
4608 | } | ||
4609 | reader->setfilter(reader->getfilter()); | ||
4610 | reader->refresh(); | ||
4611 | return true; | ||
4612 | } | ||
4613 | |||
4614 | bool QTReaderApp::PopulateConfig(const char* tgtdir, bool usedirs) | ||
4615 | { | ||
4616 | bkmkselector->clear(); | ||
4617 | bkmkselector->setText("Cancel"); | ||
4618 | #ifndef USEQPE | ||
4619 | int cnt = 0; | ||
4620 | |||
4621 | QDir d = QDir::home(); // "/" | ||
4622 | if ( !d.cd(APPDIR) ) { // "/tmp" | ||
4623 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | ||
4624 | d = QDir::home(); | ||
4625 | d.mkdir(APPDIR); | ||
4626 | d.cd(APPDIR); | ||
4627 | } | ||
4628 | if ( !d.cd(tgtdir) ) { // "/tmp" | ||
4629 | qWarning( "Cannot find the \"~/" APPDIR "/%s\" directory", tgtdir ); | ||
4630 | d = QDir::home(); | ||
4631 | d.mkdir(tgtdir); | ||
4632 | d.cd(tgtdir); | ||
4633 | } | ||
4634 | d.setFilter( ((usedirs) ? QDir::Dirs : QDir::Files) | QDir::NoSymLinks ); | ||
4635 | // d.setSorting( QDir::Size | QDir::Reversed ); | ||
4636 | |||
4637 | const QFileInfoList *list = d.entryInfoList(); | ||
4638 | QFileInfoListIterator it( *list ); // create list iterator | ||
4639 | QFileInfo *fi; // pointer for traversing | ||
4640 | |||
4641 | while ( (fi=it.current()) ) { // for each file... | ||
4642 | |||
4643 | bkmkselector->insertItem(fi->fileName()); | ||
4644 | cnt++; | ||
4645 | |||
4646 | //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); | ||
4647 | ++it; // goto next list element | ||
4648 | } | ||
4649 | |||
4650 | #else /* USEQPE */ | ||
4651 | int cnt = 0; | ||
4652 | DIR *d; | ||
4653 | char* finaldir; | ||
4654 | finaldir = new char[strlen(APPDIR)+1+strlen(tgtdir)+1]; | ||
4655 | strcpy(finaldir, APPDIR); | ||
4656 | strcat(finaldir, "/"); | ||
4657 | strcat(finaldir, tgtdir); | ||
4658 | d = opendir((const char *)Global::applicationFileName(finaldir,"")); | ||
4659 | |||
4660 | while(1) | ||
4661 | { | ||
4662 | struct dirent* de; | ||
4663 | struct stat buf; | ||
4664 | de = readdir(d); | ||
4665 | if (de == NULL) break; | ||
4666 | |||
4667 | if (lstat((const char *)Global::applicationFileName(finaldir,de->d_name),&buf) == 0 && ((usedirs && S_ISDIR(buf.st_mode)) || (!usedirs && S_ISREG(buf.st_mode)))) | ||
4668 | { | ||
4669 | bkmkselector->insertItem(de->d_name); | ||
4670 | cnt++; | ||
4671 | } | ||
4672 | } | ||
4673 | delete [] finaldir; | ||
4674 | closedir(d); | ||
4675 | #endif | ||
4676 | return (cnt > 0); | ||
4677 | } | ||
4678 | |||
4679 | void QTReaderApp::LoadTheme() | ||
4680 | { | ||
4681 | if (PopulateConfig("Themes", true)) | ||
4682 | { | ||
4683 | editorStack->raiseWidget( bkmkselector ); | ||
4684 | hidetoolbars(); | ||
4685 | m_nBkmkAction = cLdTheme; | ||
4686 | } | ||
4687 | else | ||
4688 | QMessageBox::information(this, PROGNAME, "No config files"); | ||
4689 | } | ||
4690 | |||
4691 | void QTReaderApp::LoadConfig() | ||
4692 | { | ||
4693 | if (PopulateConfig("configs")) | ||
4694 | { | ||
4695 | editorStack->raiseWidget( bkmkselector ); | ||
4696 | hidetoolbars(); | ||
4697 | m_nBkmkAction = cLdConfig; | ||
4698 | } | ||
4699 | else | ||
4700 | QMessageBox::information(this, PROGNAME, "No config files"); | ||
4701 | } | ||
4702 | |||
4703 | void QTReaderApp::TidyConfig() | ||
4704 | { | ||
4705 | if (PopulateConfig("configs")) | ||
4706 | { | ||
4707 | editorStack->raiseWidget( bkmkselector ); | ||
4708 | hidetoolbars(); | ||
4709 | m_nBkmkAction = cRmConfig; | ||
4710 | } | ||
4711 | else | ||
4712 | QMessageBox::information(this, PROGNAME, "No config files"); | ||
4713 | } | ||
4714 | |||
4715 | void QTReaderApp::ExportLinks() | ||
4716 | { | ||
4717 | if (PopulateConfig("urls")) | ||
4718 | { | ||
4719 | editorStack->raiseWidget( bkmkselector ); | ||
4720 | hidetoolbars(); | ||
4721 | m_nBkmkAction = cExportLinks; | ||
4722 | } | ||
4723 | else | ||
4724 | QMessageBox::information(this, PROGNAME, "No url files"); | ||
4725 | } | ||
4726 | |||
4727 | void QTReaderApp::OnURLSelected(const QString& href, const size_t tgt) | ||
4728 | { | ||
4729 | #ifndef USEQPE | ||
4730 | qDebug("URL:%s", (const char*)href); | ||
4731 | int col = href.find(':'); | ||
4732 | if (col > 0) | ||
4733 | { | ||
4734 | QString type = href.left(col); | ||
4735 | qDebug("Type:%s", (const char*)type); | ||
4736 | } | ||
4737 | else | ||
4738 | { | ||
4739 | qDebug("No type"); | ||
4740 | } | ||
4741 | #else | ||
4742 | if (href.isEmpty()) | ||
4743 | { | ||
4744 | QMessageBox::information(this, PROGNAME, "No URL information supplied"); | ||
4745 | } | ||
4746 | else | ||
4747 | { | ||
4748 | CURLDialog* urld = new CURLDialog(href, false, this); | ||
4749 | urld->clipboard(m_url_clipboard); | ||
4750 | urld->localfile(m_url_localfile); | ||
4751 | urld->globalfile(m_url_globalfile); | ||
4752 | if (urld->exec()) | ||
4753 | { | ||
4754 | m_url_clipboard = urld->clipboard(); | ||
4755 | m_url_localfile = urld->localfile(); | ||
4756 | m_url_globalfile = urld->globalfile(); | ||
4757 | if (m_url_clipboard) | ||
4758 | { | ||
4759 | QClipboard* cb = QApplication::clipboard(); | ||
4760 | cb->setText(href); | ||
4761 | qDebug("<a href=\"%s\">%s</a>", (const char*)href, (const char*)href); | ||
4762 | } | ||
4763 | if (m_url_localfile) | ||
4764 | { | ||
4765 | writeUrl(reader->m_string, href); | ||
4766 | } | ||
4767 | if (m_url_globalfile) | ||
4768 | { | ||
4769 | writeUrl("GlobalURLFile", href); | ||
4770 | } | ||
4771 | } | ||
4772 | delete urld; | ||
4773 | } | ||
4774 | #endif | ||
4775 | } | ||
4776 | |||
4777 | void QTReaderApp::writeUrl(const QString& file, const QString& href) | ||
4778 | { | ||
4779 | QString filename; | ||
4780 | #ifdef USEQPE | ||
4781 | filename = Global::applicationFileName(APPDIR "/urls", file); | ||
4782 | #else | ||
4783 | QFileInfo fi; | ||
4784 | QDir d = QDir::home(); // "/" | ||
4785 | if ( !d.cd(APPDIR) ) | ||
4786 | { // "/tmp" | ||
4787 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | ||
4788 | d = QDir::home(); | ||
4789 | d.mkdir(APPDIR); | ||
4790 | d.cd(APPDIR); | ||
4791 | } | ||
4792 | if ( !d.cd("urls") ) | ||
4793 | { // "/tmp" | ||
4794 | qWarning( "Cannot find the \"~/" APPDIR "/urls\" directory" ); | ||
4795 | d = QDir::home(); | ||
4796 | d.cd(APPDIR); | ||
4797 | d.mkdir("urls"); | ||
4798 | d.cd("urls"); | ||
4799 | } | ||
4800 | fi.setFile(d, file); | ||
4801 | filename = fi.absFilePath(); | ||
4802 | #endif | ||
4803 | FILE* fout = fopen(filename, "a"); | ||
4804 | if (fout != NULL) | ||
4805 | { | ||
4806 | fprintf(fout, "<p><a href=\"%s\">%s</a>\n", (const char*)href, (const char*)href); | ||
4807 | fclose(fout); | ||
4808 | } | ||
4809 | else | ||
4810 | { | ||
4811 | QMessageBox::warning(this, PROGNAME, "Problem with writing URL"); | ||
4812 | } | ||
4813 | } | ||
4814 | |||
4815 | QColor QTReaderApp::getcolour(int _c) | ||
4816 | { | ||
4817 | QColor c = white; | ||
4818 | switch (_c) | ||
4819 | { | ||
4820 | case 0: | ||
4821 | c = white; | ||
4822 | break; | ||
4823 | case 1: | ||
4824 | c = black; | ||
4825 | break; | ||
4826 | case 2: | ||
4827 | c = darkGray; | ||
4828 | break; | ||
4829 | case 3: | ||
4830 | c = gray; | ||
4831 | break; | ||
4832 | case 4: | ||
4833 | c = lightGray; | ||
4834 | break; | ||
4835 | case 5: | ||
4836 | c = red; | ||
4837 | break; | ||
4838 | case 6: | ||
4839 | c = green; | ||
4840 | break; | ||
4841 | case 7: | ||
4842 | c = blue; | ||
4843 | break; | ||
4844 | case 8: | ||
4845 | c = cyan; | ||
4846 | break; | ||
4847 | case 9: | ||
4848 | c = magenta; | ||
4849 | break; | ||
4850 | case 10: | ||
4851 | c = yellow; | ||
4852 | break; | ||
4853 | case 11: | ||
4854 | c = darkRed; | ||
4855 | break; | ||
4856 | case 12: | ||
4857 | c = darkGreen; | ||
4858 | break; | ||
4859 | case 13: | ||
4860 | c = darkBlue; | ||
4861 | break; | ||
4862 | case 14: | ||
4863 | c = darkCyan; | ||
4864 | break; | ||
4865 | case 15: | ||
4866 | c = darkMagenta; | ||
4867 | break; | ||
4868 | case 16: | ||
4869 | c = darkYellow; | ||
4870 | break; | ||
4871 | default: | ||
4872 | c = lightGray; | ||
4873 | break; | ||
4874 | } | ||
4875 | return c; | ||
4876 | } | ||
4877 | |||
4878 | void QTReaderApp::setscrollcolour() | ||
4879 | { | ||
4880 | /* | ||
4881 | QColor xc = getcolour(m_scrollcolor); | ||
4882 | int r,g,b; | ||
4883 | xc.rgb(&r,&g,&b); | ||
4884 | reader->m_scrollcolor.setRgb(255^r, 255^g, 255^b); | ||
4885 | */ | ||
4886 | reader->m_scrollcolor = getcolour(m_scrollcolor); | ||
4887 | } | ||
4888 | |||
4889 | void QTReaderApp::setscrollbarcolour() | ||
4890 | { | ||
4891 | /* | ||
4892 | QColor xc = getcolour(m_scrollcolor); | ||
4893 | int r,g,b; | ||
4894 | xc.rgb(&r,&g,&b); | ||
4895 | reader->m_scrollcolor.setRgb(255^r, 255^g, 255^b); | ||
4896 | */ | ||
4897 | reader->m_scrollbarcolor = getcolour(m_scrollbarcolor); | ||
4898 | } | ||
4899 | |||
4900 | void QTReaderApp::forceopen(const QString& filename) | ||
4901 | { | ||
4902 | /* | ||
4903 | QFileInfo fi(reader->m_lastfile); | ||
4904 | fi = QFileInfo(filename); | ||
4905 | QString flnm = fi.absFilePath(); | ||
4906 | */ | ||
4907 | if (!filename.isEmpty()) | ||
4908 | { | ||
4909 | updatefileinfo(); | ||
4910 | if (pBkmklist != NULL) | ||
4911 | { | ||
4912 | if (m_fBkmksChanged) | ||
4913 | { | ||
4914 | savebkmks(); | ||
4915 | } | ||
4916 | delete pBkmklist; | ||
4917 | pBkmklist = NULL; | ||
4918 | m_fBkmksChanged = false; | ||
4919 | } | ||
4920 | reader->disableAutoscroll(); | ||
4921 | openFile(filename); | ||
4922 | reader->setFocus(); | ||
4923 | } | ||
4924 | } | ||
4925 | |||
4926 | void QTReaderApp::actionscroll(int v) | ||
4927 | { | ||
4928 | if (reader->m_rotated) | ||
4929 | { | ||
4930 | reader->dopageup(reader->buffdoc.startSection()+reader->buffdoc.endSection()-v); | ||
4931 | } | ||
4932 | else | ||
4933 | { | ||
4934 | /* | ||
4935 | if (reader->pagelocate() < v) | ||
4936 | { | ||
4937 | while (reader->pagelocate() < v) reader->lineDown(); | ||
4938 | } | ||
4939 | else | ||
4940 | */ | ||
4941 | reader->locate(v); | ||
4942 | } | ||
4943 | } | ||
4944 | |||
4945 | void QTReaderApp::setBackgroundBitmap() | ||
4946 | { | ||
4947 | #ifdef USEQPE | ||
4948 | QString file = APPDIR "/Themes/"; | ||
4949 | file += m_themename; | ||
4950 | QString tgt = Global::applicationFileName(file,"background"); | ||
4951 | #else | ||
4952 | QString tgt(QDir::homeDirPath()); | ||
4953 | tgt += QString("/" APPDIR "/Themes/") + m_themename + "/background"; | ||
4954 | #endif | ||
4955 | qDebug("Trying to load %s", (const char *)tgt); | ||
4956 | QPixmap pm(tgt); | ||
4957 | reader->setBackgroundBitmap(pm, m_bgtype); | ||
4958 | } | ||
4959 | |||
4960 | /* | ||
4961 | |||
4962 | myChannel = new QCopChannel( "QPE/FooBar", this ); | ||
4963 | connect( myChannel, SIGNAL(received(const QCString &, const QByteArray &)), | ||
4964 | this, SLOT(fooBarMessage( const QCString &, const QByteArray &)) ); | ||
4965 | |||
4966 | */ | ||