Diffstat (limited to 'noncore/apps/opie-reader/QTReaderApp.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/QTReaderApp.cpp | 811 |
1 files changed, 694 insertions, 117 deletions
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp index 8726df7..2044b1d 100644 --- a/noncore/apps/opie-reader/QTReaderApp.cpp +++ b/noncore/apps/opie-reader/QTReaderApp.cpp | |||
@@ -22,5 +22,8 @@ | |||
22 | #include <qwidgetstack.h> | 22 | #include <qwidgetstack.h> |
23 | #include <qpe/qpemenubar.h> | 23 | #include <qpe/qpemenubar.h> |
24 | #include <qpe/qpetoolbar.h> | 24 | //#include <qpe/qpetoolbar.h> |
25 | #include <qmenubar.h> | ||
26 | #include <qtoolbar.h> | ||
27 | #include <qpe/menubutton.h> | ||
25 | #include <qpe/fontdatabase.h> | 28 | #include <qpe/fontdatabase.h> |
26 | #include <qcombobox.h> | 29 | #include <qcombobox.h> |
@@ -43,4 +46,5 @@ | |||
43 | 46 | ||
44 | #include "QTReader.h" | 47 | #include "QTReader.h" |
48 | #include "GraphicWin.h" | ||
45 | #include "Bkmks.h" | 49 | #include "Bkmks.h" |
46 | #include "cbkmkselector.h" | 50 | #include "cbkmkselector.h" |
@@ -56,4 +60,14 @@ | |||
56 | #include "fileBrowser.h" | 60 | #include "fileBrowser.h" |
57 | #include "CDrawBuffer.h" | 61 | #include "CDrawBuffer.h" |
62 | #include "Filedata.h" | ||
63 | #include "opie.h" | ||
64 | #include "name.h" | ||
65 | #include "StateData.h" | ||
66 | |||
67 | #ifdef OPIE | ||
68 | #define PICDIR "opie-reader/" | ||
69 | #else | ||
70 | #define PICDIR | ||
71 | #endif | ||
58 | 72 | ||
59 | 73 | ||
@@ -69,7 +83,8 @@ void QTReaderApp::listBkmkFiles() | |||
69 | { | 83 | { |
70 | bkmkselector->clear(); | 84 | bkmkselector->clear(); |
85 | bkmkselector->setText("Cancel"); | ||
71 | int cnt = 0; | 86 | int cnt = 0; |
72 | DIR *d; | 87 | DIR *d; |
73 | d = opendir((const char *)Global::applicationFileName("uqtreader","")); | 88 | d = opendir((const char *)Global::applicationFileName(APPDIR,"")); |
74 | 89 | ||
75 | while(1) | 90 | while(1) |
@@ -80,5 +95,5 @@ void QTReaderApp::listBkmkFiles() | |||
80 | if (de == NULL) break; | 95 | if (de == NULL) break; |
81 | 96 | ||
82 | if (lstat((const char *)Global::applicationFileName("uqtreader",de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) | 97 | if (lstat((const char *)Global::applicationFileName(APPDIR,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) |
83 | { | 98 | { |
84 | bkmkselector->insertItem(de->d_name); | 99 | bkmkselector->insertItem(de->d_name); |
@@ -94,11 +109,19 @@ void QTReaderApp::listBkmkFiles() | |||
94 | editBar->hide(); | 109 | editBar->hide(); |
95 | if (m_fontVisible) m_fontBar->hide(); | 110 | if (m_fontVisible) m_fontBar->hide(); |
96 | if (regVisible) regBar->hide(); | 111 | if (regVisible) |
97 | if (searchVisible) searchBar->hide(); | 112 | { |
113 | Global::hideInputMethod(); | ||
114 | regBar->hide(); | ||
115 | } | ||
116 | if (searchVisible) | ||
117 | { | ||
118 | Global::hideInputMethod(); | ||
119 | searchBar->hide(); | ||
120 | } | ||
98 | m_nRegAction = cRmBkmkFile; | 121 | m_nRegAction = cRmBkmkFile; |
99 | editorStack->raiseWidget( bkmkselector ); | 122 | editorStack->raiseWidget( bkmkselector ); |
100 | } | 123 | } |
101 | else | 124 | else |
102 | QMessageBox::information(this, "OpieReader", "No bookmark files"); | 125 | QMessageBox::information(this, PROGNAME, "No bookmark files"); |
103 | } | 126 | } |
104 | 127 | ||
@@ -110,5 +133,6 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
110 | 133 | ||
111 | pBkmklist = NULL; | 134 | pBkmklist = NULL; |
112 | doc = 0; | 135 | pOpenlist = NULL; |
136 | // doc = 0; | ||
113 | 137 | ||
114 | m_fBkmksChanged = false; | 138 | m_fBkmksChanged = false; |
@@ -119,7 +143,8 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
119 | setToolBarsMovable( FALSE ); | 143 | setToolBarsMovable( FALSE ); |
120 | 144 | ||
121 | setIcon( Resource::loadPixmap( "opie-reader/uqtreader" ) ); | 145 | setIcon( Resource::loadPixmap( "uqtreader" ) ); |
122 | 146 | ||
123 | QPEToolBar *bar = new QPEToolBar( this ); | 147 | // QPEToolBar *bar = new QPEToolBar( this ); |
148 | QToolBar *bar = new QToolBar( this ); | ||
124 | bar->setHorizontalStretchable( TRUE ); | 149 | bar->setHorizontalStretchable( TRUE ); |
125 | addToolBar(bar, "tool",QMainWindow::Top, true); | 150 | addToolBar(bar, "tool",QMainWindow::Top, true); |
@@ -127,4 +152,5 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
127 | 152 | ||
128 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 153 | QPEMenuBar *mb = new QPEMenuBar( bar ); |
154 | // QMenuBar *mb = new QMenuBar( bar ); | ||
129 | QPopupMenu *file = new QPopupMenu( this ); | 155 | QPopupMenu *file = new QPopupMenu( this ); |
130 | QPopupMenu *format = new QPopupMenu( this ); | 156 | QPopupMenu *format = new QPopupMenu( this ); |
@@ -160,4 +186,8 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
160 | connect( m_infoWin, SIGNAL( Close() ), this, SLOT( infoClose() ) ); | 186 | connect( m_infoWin, SIGNAL( Close() ), this, SLOT( infoClose() ) ); |
161 | 187 | ||
188 | m_graphicwin = new GraphicWin(editorStack); | ||
189 | editorStack->addWidget(m_graphicwin, get_unique_id()); | ||
190 | connect( m_graphicwin, SIGNAL( Closed() ), this, SLOT( infoClose() ) ); | ||
191 | |||
162 | // bkmkselector = new QListBox(editorStack, "Bookmarks"); | 192 | // bkmkselector = new QListBox(editorStack, "Bookmarks"); |
163 | bkmkselector = new CBkmkSelector(editorStack, "Bookmarks"); | 193 | bkmkselector = new CBkmkSelector(editorStack, "Bookmarks"); |
@@ -176,10 +206,15 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
176 | importSelector->setCloseVisible( FALSE ); | 206 | importSelector->setCloseVisible( FALSE ); |
177 | */ | 207 | */ |
208 | qDebug("Reading file list"); | ||
209 | readfilelist(); | ||
178 | 210 | ||
179 | reader = new QTReader( editorStack ); | 211 | reader = new QTReader( editorStack ); |
180 | 212 | ||
213 | reader->bDoUpdates = false; | ||
214 | |||
181 | ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold); | 215 | ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold); |
182 | 216 | ||
183 | Config config( "uqtreader" ); | 217 | qDebug("Reading config"); |
218 | Config config( APPDIR ); | ||
184 | config.setGroup( "View" ); | 219 | config.setGroup( "View" ); |
185 | 220 | ||
@@ -190,4 +225,5 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
190 | reader->bpeanut = config.readBoolEntry( "Peanut", false ); | 225 | reader->bpeanut = config.readBoolEntry( "Peanut", false ); |
191 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); | 226 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); |
227 | reader->bonespace = config.readBoolEntry( "OneSpace", false ); | ||
192 | reader->bunindent = config.readBoolEntry( "Unindent", false ); | 228 | reader->bunindent = config.readBoolEntry( "Unindent", false ); |
193 | reader->brepara = config.readBoolEntry( "Repara", false ); | 229 | reader->brepara = config.readBoolEntry( "Repara", false ); |
@@ -199,4 +235,5 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
199 | reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); | 235 | reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); |
200 | reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); | 236 | reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); |
237 | reader->m_navkeys = config.readBoolEntry( "CursorNavigation", false ); | ||
201 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); | 238 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); |
202 | reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); | 239 | reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); |
@@ -204,6 +241,10 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
204 | reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); | 241 | reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); |
205 | reader->m_overlap = config.readNumEntry( "Overlap", 0 ); | 242 | reader->m_overlap = config.readNumEntry( "Overlap", 0 ); |
243 | #ifdef REPALM | ||
244 | reader->brepalm = config.readBoolEntry( "Repalm", true ); | ||
245 | #endif | ||
206 | reader->bremap = config.readBoolEntry( "Remap", true ); | 246 | reader->bremap = config.readBoolEntry( "Remap", true ); |
207 | reader->bmakebold = config.readBoolEntry( "MakeBold", false ); | 247 | reader->bmakebold = config.readBoolEntry( "MakeBold", false ); |
248 | reader->setContinuous(config.readBoolEntry( "Continuous", true )); | ||
208 | m_targetapp = config.readEntry( "TargetApp", QString::null ); | 249 | m_targetapp = config.readEntry( "TargetApp", QString::null ); |
209 | m_targetmsg = config.readEntry( "TargetMsg", QString::null ); | 250 | m_targetmsg = config.readEntry( "TargetMsg", QString::null ); |
@@ -216,4 +257,6 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
216 | 257 | ||
217 | 258 | ||
259 | connect( reader, SIGNAL( OnShowPicture(QPixmap&) ), this, SLOT( showgraphic(QPixmap&) ) ); | ||
260 | |||
218 | connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) ); | 261 | connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) ); |
219 | connect( reader, SIGNAL( OnActionPressed() ), this, SLOT( OnActionPressed() ) ); | 262 | connect( reader, SIGNAL( OnActionPressed() ), this, SLOT( OnActionPressed() ) ); |
@@ -226,4 +269,9 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
226 | a->addTo( file ); | 269 | a->addTo( file ); |
227 | 270 | ||
271 | a = new QAction( tr( "Close" ), Resource::loadPixmap( "fileclose" ), QString::null, 0, this, 0 ); | ||
272 | connect( a, SIGNAL( activated() ), this, SLOT( fileClose() ) ); | ||
273 | // a->addTo( bar ); | ||
274 | a->addTo( file ); | ||
275 | |||
228 | /* | 276 | /* |
229 | a = new QAction( tr( "Revert" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 277 | a = new QAction( tr( "Revert" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
@@ -251,16 +299,38 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
251 | m_buttonAction[2] = new QAction( tr( "Mark" ), QString::null, 0, ag, NULL, true ); | 299 | m_buttonAction[2] = new QAction( tr( "Mark" ), QString::null, 0, ag, NULL, true ); |
252 | 300 | ||
301 | m_buttonAction[3] = new QAction( tr( "Fullscreen" ), QString::null, 0, ag, NULL, true ); | ||
302 | |||
253 | ag->addTo(spacemenu); | 303 | ag->addTo(spacemenu); |
254 | 304 | ||
255 | connect(ag, SIGNAL( selected(QAction*) ), this, SLOT( buttonActionSelected(QAction*) ) ); | 305 | connect(ag, SIGNAL( selected(QAction*) ), this, SLOT( buttonActionSelected(QAction*) ) ); |
256 | 306 | ||
307 | file->insertSeparator(); | ||
308 | |||
309 | ag = new QActionGroup(this); | ||
310 | ag->setExclusive(false); | ||
311 | QPopupMenu *encoding = new QPopupMenu(this); | ||
312 | file->insertItem( tr( "Navigation" ), encoding ); | ||
313 | |||
314 | a = m_scrollButton = new QAction( tr( "Scroll" ), Resource::loadPixmap( PICDIR "panel-arrow-down" ), QString::null, 0, ag, 0, true ); | ||
257 | 315 | ||
258 | a = m_scrollButton = new QAction( tr( "Scroll" ), Resource::loadPixmap( "opie-reader/panel-arrow-down" ), QString::null, 0, this, 0, true ); | ||
259 | // connect( a, SIGNAL( activated() ), this, SLOT( autoScroll() ) ); | ||
260 | a->setOn(false); | 316 | a->setOn(false); |
261 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) ); | 317 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) ); |
262 | file->insertSeparator(); | ||
263 | a->addTo( bar ); | 318 | a->addTo( bar ); |
264 | a->addTo( file ); | 319 | |
320 | a = new QAction( tr( "Jump" ), QString::null, 0, ag, NULL); | ||
321 | connect( a, SIGNAL( activated() ), this, SLOT( jump() ) ); | ||
322 | |||
323 | a = new QAction( tr( "Page/Line Scroll" ), QString::null, 0, ag, NULL, true ); | ||
324 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) ); | ||
325 | a->setOn(reader->m_bpagemode); | ||
326 | |||
327 | a = new QAction( tr( "Set Overlap" ), QString::null, 0, ag, NULL); | ||
328 | connect( a, SIGNAL( activated() ), this, SLOT( setoverlap() ) ); | ||
329 | |||
330 | a = new QAction( tr( "Use Cursor" ), QString::null, 0, ag, NULL, true ); | ||
331 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( navkeys(bool) ) ); | ||
332 | a->setOn(reader->m_navkeys); | ||
333 | |||
334 | ag->addTo(encoding); | ||
265 | 335 | ||
266 | /* | 336 | /* |
@@ -273,16 +343,4 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
273 | a->addTo( file ); | 343 | a->addTo( file ); |
274 | */ | 344 | */ |
275 | a = new QAction( tr( "Jump" ), QString::null, 0, this, NULL); | ||
276 | connect( a, SIGNAL( activated() ), this, SLOT( jump() ) ); | ||
277 | a->addTo( file ); | ||
278 | |||
279 | a = new QAction( tr( "Page/Line Scroll" ), QString::null, 0, this, NULL, true ); | ||
280 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) ); | ||
281 | a->setOn(reader->m_bpagemode); | ||
282 | a->addTo( file ); | ||
283 | |||
284 | a = new QAction( tr( "Set Overlap" ), QString::null, 0, this, NULL); | ||
285 | connect( a, SIGNAL( activated() ), this, SLOT( setoverlap() ) ); | ||
286 | a->addTo( file ); | ||
287 | 345 | ||
288 | file->insertSeparator(); | 346 | file->insertSeparator(); |
@@ -299,5 +357,5 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
299 | ag = new QActionGroup(this); | 357 | ag = new QActionGroup(this); |
300 | ag->setExclusive(false); | 358 | ag->setExclusive(false); |
301 | QPopupMenu *encoding = new QPopupMenu(this); | 359 | encoding = new QPopupMenu(this); |
302 | file->insertItem( tr( "Target" ), encoding ); | 360 | file->insertItem( tr( "Target" ), encoding ); |
303 | 361 | ||
@@ -346,4 +404,15 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
346 | 404 | ||
347 | 405 | ||
406 | m_fullscreen = false; | ||
407 | a = m_actFullscreen = new QAction( tr( "Fullscreen" ), QString::null, 0, this, NULL, true ); | ||
408 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( setfullscreen(bool) ) ); | ||
409 | a->setOn(m_fullscreen); | ||
410 | a->addTo( file ); | ||
411 | |||
412 | a = new QAction( tr( "Continuous" ), QString::null, 0, ag, NULL, true ); | ||
413 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( setcontinuous(bool) ) ); | ||
414 | a->setOn(reader->m_continuousDocument); | ||
415 | a->addTo( file ); | ||
416 | |||
348 | a = m_bkmkAvail = new QAction( tr( "Annotation" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 417 | a = m_bkmkAvail = new QAction( tr( "Annotation" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); |
349 | connect( a, SIGNAL( activated() ), this, SLOT( showAnnotation() ) ); | 418 | connect( a, SIGNAL( activated() ), this, SLOT( showAnnotation() ) ); |
@@ -396,4 +465,8 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
396 | // a->addTo( format ); | 465 | // a->addTo( format ); |
397 | 466 | ||
467 | a = new QAction( tr( "Single Space" ), QString::null, 0, ag, NULL, true ); | ||
468 | a->setOn(reader->bonespace); | ||
469 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( onespace(bool) ) ); | ||
470 | |||
398 | a = new QAction( tr( "Unindent" ), QString::null, 0, ag, NULL, true ); | 471 | a = new QAction( tr( "Unindent" ), QString::null, 0, ag, NULL, true ); |
399 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( unindent(bool) ) ); | 472 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( unindent(bool) ) ); |
@@ -417,5 +490,9 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
417 | a = new QAction( tr( "Indent-" ), QString::null, 0, ag, NULL ); | 490 | a = new QAction( tr( "Indent-" ), QString::null, 0, ag, NULL ); |
418 | connect( a, SIGNAL( activated() ), this, SLOT( indentminus() ) ); | 491 | connect( a, SIGNAL( activated() ), this, SLOT( indentminus() ) ); |
419 | 492 | #ifdef REPALM | |
493 | a = new QAction( tr( "Repalm" ), QString::null, 0, ag, NULL, true ); | ||
494 | a->setOn(reader->brepalm); | ||
495 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( repalm(bool) ) ); | ||
496 | #endif | ||
420 | a = new QAction( tr( "Remap" ), QString::null, 0, ag, NULL, true ); | 497 | a = new QAction( tr( "Remap" ), QString::null, 0, ag, NULL, true ); |
421 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( remap(bool) ) ); | 498 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( remap(bool) ) ); |
@@ -430,9 +507,13 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
430 | // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true ); | 507 | // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true ); |
431 | // a = new QAction( tr( "Zoom" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); | 508 | // a = new QAction( tr( "Zoom" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); |
432 | a = new QAction( tr( "Zoom" ), QString::null, 0, this); | ||
433 | connect( a, SIGNAL( activated() ), this, SLOT( TBDzoom() ) ); | ||
434 | format->insertSeparator(); | 509 | format->insertSeparator(); |
510 | a = new QAction( tr( "Zoom In" ), QString::null, 0, this); | ||
511 | connect( a, SIGNAL( activated() ), this, SLOT( zoomin() ) ); | ||
512 | a->addTo( format ); | ||
513 | a = new QAction( tr( "Zoom Out" ), QString::null, 0, this); | ||
514 | connect( a, SIGNAL( activated() ), this, SLOT( zoomout() ) ); | ||
435 | a->addTo( format ); | 515 | a->addTo( format ); |
436 | // a->addTo( editBar ); | 516 | // a->addTo( editBar ); |
517 | format->insertSeparator(); | ||
437 | 518 | ||
438 | 519 | ||
@@ -440,5 +521,4 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
440 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); | 521 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); |
441 | a->setOn(reader->m_bMonoSpaced); | 522 | a->setOn(reader->m_bMonoSpaced); |
442 | format->insertSeparator(); | ||
443 | a->addTo( format ); | 523 | a->addTo( format ); |
444 | 524 | ||
@@ -580,4 +660,5 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
580 | m_fontBar->setHorizontalStretchable( TRUE ); | 660 | m_fontBar->setHorizontalStretchable( TRUE ); |
581 | 661 | ||
662 | qDebug("Font selector"); | ||
582 | m_fontSelector = new QComboBox(false, m_fontBar); | 663 | m_fontSelector = new QComboBox(false, m_fontBar); |
583 | m_fontBar->setStretchableWidget( m_fontSelector ); | 664 | m_fontBar->setStretchableWidget( m_fontSelector ); |
@@ -593,6 +674,6 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
593 | { | 674 | { |
594 | realfont = true; | 675 | realfont = true; |
595 | break; | ||
596 | } | 676 | } |
677 | if (*nm == "courier") reader->m_fontControl.hasCourier(true); | ||
597 | } | 678 | } |
598 | if (!realfont) reader->m_fontname = flist[0]; | 679 | if (!realfont) reader->m_fontname = flist[0]; |
@@ -608,15 +689,63 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
608 | this, SLOT( msgHandler(const QCString&, const QByteArray&) ) ); | 689 | this, SLOT( msgHandler(const QCString&, const QByteArray&) ) ); |
609 | 690 | ||
610 | 691 | qDebug("Initing"); | |
611 | reader->init(); | 692 | reader->init(); |
693 | qDebug("Inited"); | ||
694 | m_EncodingAction[reader->m_encd]->setOn(true); | ||
695 | m_buttonAction[m_spaceTarget]->setOn(true); | ||
696 | qDebug("fonting"); | ||
697 | do_setfont(reader->m_fontname); | ||
612 | if (!reader->m_lastfile.isEmpty()) | 698 | if (!reader->m_lastfile.isEmpty()) |
613 | { | 699 | { |
700 | qDebug("doclnk"); | ||
701 | //doc = new DocLnk(reader->m_lastfile); | ||
702 | qDebug("doclnk done"); | ||
703 | if (pOpenlist != NULL) | ||
704 | { | ||
705 | |||
706 | /* | ||
707 | int ind = 0; | ||
708 | Bkmk* p = (*pOpenlist)[ind]; | ||
709 | while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) | ||
710 | { | ||
711 | p = (*pOpenlist)[++ind]; | ||
712 | } | ||
713 | */ | ||
714 | Bkmk* p = NULL; | ||
715 | for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++) | ||
716 | { | ||
717 | p = iter.pContent(); | ||
718 | if (toQString(CFiledata(p->anno()).name()) == reader->m_lastfile) | ||
719 | { | ||
720 | break; | ||
721 | } | ||
722 | qDebug("Item:%s", (const char*)toQString(CFiledata(p->anno()).name())); | ||
723 | p = NULL; | ||
724 | } | ||
725 | if (p != NULL) | ||
726 | { | ||
727 | qDebug("openfrombkmk"); | ||
728 | openfrombkmk(p); | ||
729 | } | ||
730 | else | ||
731 | { | ||
732 | qDebug("openfile"); | ||
614 | openFile( reader->m_lastfile ); | 733 | openFile( reader->m_lastfile ); |
615 | doc = new DocLnk(reader->m_lastfile); | ||
616 | } | 734 | } |
617 | m_EncodingAction[reader->m_encd]->setOn(true); | ||
618 | m_buttonAction[m_spaceTarget]->setOn(true); | ||
619 | do_setfont(reader->m_fontname); | ||
620 | } | 735 | } |
736 | else | ||
737 | { | ||
738 | qDebug("Openfile 2"); | ||
739 | if (!reader->m_lastfile.isNull()) | ||
740 | openFile( reader->m_lastfile ); | ||
741 | } | ||
742 | } | ||
743 | qApp->processEvents(); | ||
744 | reader->bDoUpdates = true; | ||
745 | reader->update(); | ||
746 | qDebug("finished update"); | ||
747 | } | ||
748 | |||
749 | void QTReaderApp::suspend() { reader->suspend(); } | ||
621 | 750 | ||
622 | void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | 751 | void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) |
@@ -631,5 +760,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
631 | QString info; | 760 | QString info; |
632 | stream >> info; | 761 | stream >> info; |
633 | QMessageBox::information(this, "OpieReader", info); | 762 | QMessageBox::information(this, PROGNAME, info); |
634 | } | 763 | } |
635 | else if ( msg == "warn(QString)" ) | 764 | else if ( msg == "warn(QString)" ) |
@@ -637,5 +766,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
637 | QString info; | 766 | QString info; |
638 | stream >> info; | 767 | stream >> info; |
639 | QMessageBox::warning(this, "OpieReader", info); | 768 | QMessageBox::warning(this, PROGNAME, info); |
640 | } | 769 | } |
641 | 770 | ||
@@ -752,5 +881,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
752 | if (!reader->buffdoc.getline(&test,reader->width())) | 881 | if (!reader->buffdoc.getline(&test,reader->width())) |
753 | { | 882 | { |
754 | QMessageBox::information(this, "OpieReader", QString("Can't find\n")+info); | 883 | QMessageBox::information(this, PROGNAME, QString("Can't find\n")+info); |
755 | pos = start; | 884 | pos = start; |
756 | break; | 885 | break; |
@@ -765,4 +894,18 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
765 | stripcr(info); | 894 | stripcr(info); |
766 | } | 895 | } |
896 | else if ( msg == "Layout/Single Space" ) | ||
897 | { | ||
898 | int info; | ||
899 | stream >> info; | ||
900 | onespace(info); | ||
901 | } | ||
902 | #ifdef REPALM | ||
903 | else if ( msg == "Layout/Repalm(int)" ) | ||
904 | { | ||
905 | int info; | ||
906 | stream >> info; | ||
907 | repalm(info); | ||
908 | } | ||
909 | #endif | ||
767 | else if ( msg == "Markup/Auto(int)" ) | 910 | else if ( msg == "Markup/Auto(int)" ) |
768 | { | 911 | { |
@@ -877,4 +1020,20 @@ ActionTypes QTReaderApp::ActNameToInt(const QString& _enc) | |||
877 | } | 1020 | } |
878 | 1021 | ||
1022 | void QTReaderApp::setfullscreen(bool sfs) | ||
1023 | { | ||
1024 | reader->bDoUpdates = false; | ||
1025 | m_fullscreen = sfs; | ||
1026 | showEditTools(); | ||
1027 | qApp->processEvents(); | ||
1028 | reader->bDoUpdates = true; | ||
1029 | reader->update(); | ||
1030 | } | ||
1031 | |||
1032 | void QTReaderApp::setcontinuous(bool sfs) | ||
1033 | { | ||
1034 | reader->setContinuous(sfs); | ||
1035 | reader->refresh(); | ||
1036 | } | ||
1037 | |||
879 | int QTReaderApp::EncNameToInt(const QString& _enc) | 1038 | int QTReaderApp::EncNameToInt(const QString& _enc) |
880 | { | 1039 | { |
@@ -911,14 +1070,15 @@ void QTReaderApp::autoScroll(bool _b) | |||
911 | { | 1070 | { |
912 | reader->setautoscroll(_b); | 1071 | reader->setautoscroll(_b); |
1072 | setScrollState(reader->m_autoScroll); | ||
913 | } | 1073 | } |
914 | 1074 | ||
915 | void QTReaderApp::TBD() | 1075 | void QTReaderApp::zoomin() |
916 | { | 1076 | { |
917 | QMessageBox::information(this, "OpieReader", "Not yet implemented", 1); | 1077 | reader->zoomin(); |
918 | } | 1078 | } |
919 | 1079 | ||
920 | void QTReaderApp::TBDzoom() | 1080 | void QTReaderApp::zoomout() |
921 | { | 1081 | { |
922 | QMessageBox::information(this, "OpieReader", "Zooming is done interactively\nTry left/right cursor keys", 1); | 1082 | reader->zoomout(); |
923 | } | 1083 | } |
924 | 1084 | ||
@@ -930,4 +1090,76 @@ void QTReaderApp::clearBkmkList() | |||
930 | } | 1090 | } |
931 | 1091 | ||
1092 | void QTReaderApp::fileClose() | ||
1093 | { | ||
1094 | if (pOpenlist != NULL) | ||
1095 | { | ||
1096 | int ind = 0; | ||
1097 | Bkmk* p = (*pOpenlist)[ind]; | ||
1098 | while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) | ||
1099 | { | ||
1100 | p = (*pOpenlist)[++ind]; | ||
1101 | } | ||
1102 | if (p != NULL) pOpenlist->erase(ind); | ||
1103 | switch (QMessageBox::information ( this , PROGNAME, "What do you want to delete?", "Nothing", "Marks", "Marks\nFile", 1, 0 )) | ||
1104 | { | ||
1105 | case 0: | ||
1106 | default: | ||
1107 | break; | ||
1108 | case 2: | ||
1109 | unlink((const char*)reader->m_lastfile); | ||
1110 | case 1: | ||
1111 | unlink((const char *)Global::applicationFileName(APPDIR, reader->m_string)); | ||
1112 | } | ||
1113 | } | ||
1114 | |||
1115 | fileOpen2(); | ||
1116 | } | ||
1117 | |||
1118 | void QTReaderApp::updatefileinfo() | ||
1119 | { | ||
1120 | if (reader->m_string.isNull()) return; | ||
1121 | if (reader->m_lastfile.isNull()) return; | ||
1122 | tchar* nm = fromQString(reader->m_string); | ||
1123 | tchar* fl = fromQString(reader->m_lastfile); | ||
1124 | qDebug("Lastfile:%x", fl); | ||
1125 | bool notadded = true; | ||
1126 | if (pOpenlist == NULL) pOpenlist = new CList<Bkmk>; | ||
1127 | else | ||
1128 | { | ||
1129 | for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++) | ||
1130 | { | ||
1131 | if (ustrcmp(CFiledata(iter->anno()).name(), fl) == 0) | ||
1132 | { | ||
1133 | iter->value(reader->pagelocate()); | ||
1134 | unsigned short dlen; | ||
1135 | unsigned char* data; | ||
1136 | CFiledata fd(iter->anno()); | ||
1137 | reader->setSaveData(data, dlen, fd.content(), fd.length()); | ||
1138 | qDebug("Filedata(1):%u, %u", fd.length(), dlen); | ||
1139 | // getstate(data, dlen); | ||
1140 | iter->setAnno(data, dlen); | ||
1141 | notadded = false; | ||
1142 | delete [] data; | ||
1143 | break; | ||
1144 | } | ||
1145 | } | ||
1146 | } | ||
1147 | qDebug("Added?:%x", notadded); | ||
1148 | if (notadded) | ||
1149 | { | ||
1150 | struct stat fnstat; | ||
1151 | stat((const char *)reader->m_lastfile, &fnstat); | ||
1152 | CFiledata fd(fnstat.st_mtime, fl); | ||
1153 | unsigned short dlen; | ||
1154 | unsigned char* data; | ||
1155 | reader->setSaveData(data, dlen, fd.content(), fd.length()); | ||
1156 | pOpenlist->push_front(Bkmk(nm, data, dlen, reader->pagelocate())); | ||
1157 | qDebug("Filedata(2):%u, %u", fd.length(), dlen); | ||
1158 | delete [] data; | ||
1159 | } | ||
1160 | delete [] nm; | ||
1161 | delete [] fl; | ||
1162 | } | ||
1163 | |||
932 | void QTReaderApp::fileOpen() | 1164 | void QTReaderApp::fileOpen() |
933 | { | 1165 | { |
@@ -938,9 +1170,17 @@ void QTReaderApp::fileOpen() | |||
938 | if (searchVisible) searchBar->hide(); | 1170 | if (searchVisible) searchBar->hide(); |
939 | */ | 1171 | */ |
1172 | qDebug("fileOpen"); | ||
1173 | // if (!reader->m_lastfile.isEmpty()) | ||
1174 | updatefileinfo(); | ||
1175 | fileOpen2(); | ||
1176 | } | ||
1177 | |||
1178 | void QTReaderApp::fileOpen2() | ||
1179 | { | ||
940 | if (pBkmklist != NULL) | 1180 | if (pBkmklist != NULL) |
941 | { | 1181 | { |
942 | if (m_fBkmksChanged) | 1182 | if (m_fBkmksChanged) |
943 | { | 1183 | { |
944 | if (QMessageBox::warning(this, "OpieReader", "Save bookmarks?", "Save", "Don't bother") == 0) | 1184 | if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) |
945 | savebkmks(); | 1185 | savebkmks(); |
946 | } | 1186 | } |
@@ -954,17 +1194,43 @@ void QTReaderApp::fileOpen() | |||
954 | fileSelector->reread(); | 1194 | fileSelector->reread(); |
955 | */ | 1195 | */ |
956 | fileBrowser* fb = new fileBrowser(this,"OpieReader",TRUE, | 1196 | if (pOpenlist != NULL) |
1197 | { | ||
1198 | m_nRegAction = cOpenFile; | ||
1199 | listbkmk(pOpenlist, "Browse"); | ||
1200 | } | ||
1201 | else | ||
1202 | { | ||
1203 | QString fn = usefilebrowser(); | ||
1204 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) | ||
1205 | { | ||
1206 | openFile(fn); | ||
1207 | } | ||
1208 | reader->setFocus(); | ||
1209 | } | ||
1210 | } | ||
1211 | |||
1212 | QString QTReaderApp::usefilebrowser() | ||
1213 | { | ||
1214 | fileBrowser* fb = new fileBrowser(this,"QTReader",TRUE, | ||
957 | 0, | 1215 | 0, |
958 | // WStyle_Customize | WStyle_NoBorderEx, | 1216 | // WStyle_Customize | WStyle_NoBorderEx, |
959 | "*", QFileInfo(reader->m_lastfile).dirPath(true)); | 1217 | "*", QFileInfo(reader->m_lastfile).dirPath(true)); |
960 | 1218 | ||
1219 | |||
1220 | QString fn; | ||
961 | if (fb->exec()) | 1221 | if (fb->exec()) |
962 | { | 1222 | { |
963 | QString fn(fb->fileList[0]); | 1223 | fn = fb->fileList[0]; |
964 | // fb->populateList(); | ||
965 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn); | ||
966 | } | 1224 | } |
1225 | qDebug("Selected %s", (const char*)fn); | ||
967 | delete fb; | 1226 | delete fb; |
968 | reader->setFocus(); | 1227 | return fn; |
1228 | } | ||
1229 | |||
1230 | void QTReaderApp::showgraphic(QPixmap& pm) | ||
1231 | { | ||
1232 | m_graphicwin->setPixmap(pm); | ||
1233 | editorStack->raiseWidget( m_graphicwin ); | ||
1234 | m_graphicwin->setFocus(); | ||
969 | } | 1235 | } |
970 | 1236 | ||
@@ -974,5 +1240,5 @@ void QTReaderApp::showinfo() | |||
974 | if (reader->empty()) | 1240 | if (reader->empty()) |
975 | { | 1241 | { |
976 | QMessageBox::information(this, "OpieReader", "No file loaded", 1); | 1242 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); |
977 | } | 1243 | } |
978 | else | 1244 | else |
@@ -1021,5 +1287,5 @@ void QTReaderApp::addAnno(const QString& name, const QString& text) | |||
1021 | if (name.isEmpty()) | 1287 | if (name.isEmpty()) |
1022 | { | 1288 | { |
1023 | QMessageBox::information(this, "OpieReader", "Need a name for the bookmark\nPlease try again", 1); | 1289 | QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nPlease try again", 1); |
1024 | } | 1290 | } |
1025 | else | 1291 | else |
@@ -1078,5 +1344,5 @@ void QTReaderApp::addanno() | |||
1078 | if (reader->empty()) | 1344 | if (reader->empty()) |
1079 | { | 1345 | { |
1080 | QMessageBox::information(this, "OpieReader", "No file loaded", 1); | 1346 | QMessageBox::information(this, PROGNAME, "No file loaded", 1); |
1081 | } | 1347 | } |
1082 | else | 1348 | else |
@@ -1087,4 +1353,5 @@ void QTReaderApp::addanno() | |||
1087 | m_annoIsEditing = true; | 1353 | m_annoIsEditing = true; |
1088 | editorStack->raiseWidget( m_annoWin ); | 1354 | editorStack->raiseWidget( m_annoWin ); |
1355 | Global::showInputMethod(); | ||
1089 | m_annoWin->setFocus(); | 1356 | m_annoWin->setFocus(); |
1090 | } | 1357 | } |
@@ -1133,10 +1400,10 @@ void QTReaderApp::editCopy() | |||
1133 | void QTReaderApp::pageup() | 1400 | void QTReaderApp::pageup() |
1134 | { | 1401 | { |
1135 | reader->goUp(); | 1402 | reader->NavUp(); |
1136 | } | 1403 | } |
1137 | 1404 | ||
1138 | void QTReaderApp::pagedn() | 1405 | void QTReaderApp::pagedn() |
1139 | { | 1406 | { |
1140 | reader->goDown(); | 1407 | reader->NavDown(); |
1141 | } | 1408 | } |
1142 | 1409 | ||
@@ -1145,4 +1412,14 @@ void QTReaderApp::stripcr(bool _b) | |||
1145 | reader->setstripcr(_b); | 1412 | reader->setstripcr(_b); |
1146 | } | 1413 | } |
1414 | void QTReaderApp::onespace(bool _b) | ||
1415 | { | ||
1416 | reader->setonespace(_b); | ||
1417 | } | ||
1418 | #ifdef REPALM | ||
1419 | void QTReaderApp::repalm(bool _b) | ||
1420 | { | ||
1421 | reader->setrepalm(_b); | ||
1422 | } | ||
1423 | #endif | ||
1147 | void QTReaderApp::remap(bool _b) | 1424 | void QTReaderApp::remap(bool _b) |
1148 | { | 1425 | { |
@@ -1189,5 +1466,8 @@ void QTReaderApp::pagemode(bool _b) | |||
1189 | reader->setpagemode(_b); | 1466 | reader->setpagemode(_b); |
1190 | } | 1467 | } |
1191 | 1468 | void QTReaderApp::navkeys(bool _b) | |
1469 | { | ||
1470 | reader->m_navkeys = _b; | ||
1471 | } | ||
1192 | void QTReaderApp::monospace(bool _b) | 1472 | void QTReaderApp::monospace(bool _b) |
1193 | { | 1473 | { |
@@ -1232,5 +1512,5 @@ void QTReaderApp::do_overlap(const QString& lcn) | |||
1232 | } | 1512 | } |
1233 | else | 1513 | else |
1234 | QMessageBox::information(this, "OpieReader", "Must be a number"); | 1514 | QMessageBox::information(this, PROGNAME, "Must be a number"); |
1235 | } | 1515 | } |
1236 | 1516 | ||
@@ -1247,5 +1527,5 @@ void QTReaderApp::do_mono(const QString& lcn) | |||
1247 | } | 1527 | } |
1248 | else | 1528 | else |
1249 | QMessageBox::information(this, "OpieReader", "Must be a number"); | 1529 | QMessageBox::information(this, PROGNAME, "Must be a number"); |
1250 | } | 1530 | } |
1251 | 1531 | ||
@@ -1265,4 +1545,5 @@ void QTReaderApp::editFind() | |||
1265 | searchStack = new QStack<searchrecord>; | 1545 | searchStack = new QStack<searchrecord>; |
1266 | #endif | 1546 | #endif |
1547 | Global::showInputMethod(); | ||
1267 | searchBar->show(); | 1548 | searchBar->show(); |
1268 | searchVisible = TRUE; | 1549 | searchVisible = TRUE; |
@@ -1292,4 +1573,5 @@ void QTReaderApp::findClose() | |||
1292 | searchVisible = FALSE; | 1573 | searchVisible = FALSE; |
1293 | searchEdit->setText(""); | 1574 | searchEdit->setText(""); |
1575 | Global::hideInputMethod(); | ||
1294 | searchBar->hide(); | 1576 | searchBar->hide(); |
1295 | #ifdef __ISEARCH | 1577 | #ifdef __ISEARCH |
@@ -1309,4 +1591,5 @@ void QTReaderApp::regClose() | |||
1309 | regEdit->setText(""); | 1591 | regEdit->setText(""); |
1310 | regBar->hide(); | 1592 | regBar->hide(); |
1593 | Global::hideInputMethod(); | ||
1311 | reader->setFocus(); | 1594 | reader->setFocus(); |
1312 | } | 1595 | } |
@@ -1319,6 +1602,15 @@ bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg) | |||
1319 | { | 1602 | { |
1320 | bool ret = true; | 1603 | bool ret = true; |
1604 | unsigned long fs, ts; | ||
1605 | reader->sizes(fs,ts); | ||
1321 | size_t pos = reader->locate(); | 1606 | size_t pos = reader->locate(); |
1322 | reader->buffdoc.getline(&test,reader->width()); | 1607 | reader->buffdoc.getline(&test,reader->width()); |
1608 | pbar->show(); | ||
1609 | pbar->resize(width(), editBar->height()); | ||
1610 | pbar->reset(); | ||
1611 | int lastpc = (100*pos)/ts; | ||
1612 | pbar->setProgress(lastpc); | ||
1613 | qApp->processEvents(); | ||
1614 | reader->setFocus(); | ||
1323 | #ifdef __ISEARCH | 1615 | #ifdef __ISEARCH |
1324 | while (strstr(test.data(),(const tchar*)arg) == NULL) | 1616 | while (strstr(test.data(),(const tchar*)arg) == NULL) |
@@ -1332,4 +1624,14 @@ bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg) | |||
1332 | { | 1624 | { |
1333 | pos = reader->locate(); | 1625 | pos = reader->locate(); |
1626 | unsigned int lcn = reader->locate(); | ||
1627 | int pc = (100*pos)/ts; | ||
1628 | if (pc != lastpc) | ||
1629 | { | ||
1630 | pbar->setProgress(pc); | ||
1631 | qApp->processEvents(); | ||
1632 | reader->setFocus(); | ||
1633 | lastpc = pc; | ||
1634 | } | ||
1635 | |||
1334 | if (!reader->buffdoc.getline(&test,reader->width())) | 1636 | if (!reader->buffdoc.getline(&test,reader->width())) |
1335 | { | 1637 | { |
@@ -1343,4 +1645,5 @@ bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg) | |||
1343 | } | 1645 | } |
1344 | } | 1646 | } |
1647 | pbar->hide(); | ||
1345 | reader->locate(pos); | 1648 | reader->locate(pos); |
1346 | return ret; | 1649 | return ret; |
@@ -1389,54 +1692,122 @@ void QTReaderApp::search() | |||
1389 | void QTReaderApp::openFile( const QString &f ) | 1692 | void QTReaderApp::openFile( const QString &f ) |
1390 | { | 1693 | { |
1391 | openFile(DocLnk(f)); | 1694 | qDebug("File:%s", (const char*)f); |
1392 | } | 1695 | // openFile(DocLnk(f)); |
1393 | 1696 | //} | |
1394 | void QTReaderApp::openFile( const DocLnk &f ) | 1697 | // |
1395 | { | 1698 | //void QTReaderApp::openFile( const DocLnk &f ) |
1699 | //{ | ||
1396 | clear(); | 1700 | clear(); |
1397 | FileManager fm; | 1701 | QFileInfo fm(f); |
1398 | if ( fm.exists( f ) ) | 1702 | if ( fm.exists() ) |
1399 | { | 1703 | { |
1400 | // QMessageBox::information(0, "Progress", "Calling fileNew()"); | 1704 | // QMessageBox::information(0, "Progress", "Calling fileNew()"); |
1401 | 1705 | ||
1402 | clear(); | 1706 | if (fm.extension( FALSE ) == "desktop") |
1403 | 1707 | { | |
1404 | // editorStack->raiseWidget( reader ); | 1708 | DocLnk d(f); |
1405 | 1709 | QFileInfo fnew(d.file()); | |
1406 | // reader->setFocus(); | 1710 | fm = fnew; |
1711 | if (!fm.exists()) return; | ||
1712 | } | ||
1407 | 1713 | ||
1408 | // QMessageBox::information(0, "DocLnk", "Begin"); | 1714 | clear(); |
1409 | doc = new DocLnk(f); | ||
1410 | // QMessageBox::information(0, "DocLnk done", doc->file()); | ||
1411 | // QMessageBox::information(0, "Progress", "Calling setText()"); | ||
1412 | // QMessageBox::information(0, "Progress", "Textset"); | ||
1413 | 1715 | ||
1414 | // updateCaption(); | 1716 | reader->setText(fm.baseName(), fm.absFilePath()); |
1415 | showEditTools(); | 1717 | showEditTools(); |
1416 | reader->setText(doc->name(), doc->file()); | ||
1417 | readbkmks(); | 1718 | readbkmks(); |
1418 | } | 1719 | } |
1419 | else | 1720 | else |
1420 | { | 1721 | { |
1421 | QMessageBox::information(this, "OpieReader", "File does not exist"); | 1722 | QMessageBox::information(this, PROGNAME, "File does not exist"); |
1422 | } | 1723 | } |
1423 | 1724 | ||
1424 | } | 1725 | } |
1726 | /* | ||
1727 | void QTReaderApp::resizeEvent(QResizeEvent* e) | ||
1728 | { | ||
1729 | if (m_fullscreen) | ||
1730 | { | ||
1731 | showNormal(); | ||
1732 | showFullScreen(); | ||
1733 | } | ||
1734 | } | ||
1735 | */ | ||
1736 | void QTReaderApp::keyPressEvent(QKeyEvent* e) | ||
1737 | { | ||
1738 | if (m_fullscreen) | ||
1739 | { | ||
1740 | switch(e->key()) | ||
1741 | { | ||
1742 | case Key_Escape: | ||
1743 | m_actFullscreen->setOn(false); | ||
1744 | if (m_fullscreen) | ||
1745 | { | ||
1746 | qDebug("Fullscreen already set - remove this!"); | ||
1747 | } | ||
1748 | else | ||
1749 | { | ||
1750 | m_fullscreen = false; | ||
1751 | reader->bDoUpdates = false; | ||
1752 | showEditTools(); | ||
1753 | qApp->processEvents(); | ||
1754 | reader->bDoUpdates = true; | ||
1755 | reader->update(); | ||
1756 | } | ||
1757 | e->accept(); | ||
1758 | break; | ||
1759 | default: | ||
1760 | e->ignore(); | ||
1761 | } | ||
1762 | } | ||
1763 | else | ||
1764 | { | ||
1765 | e->ignore(); | ||
1766 | } | ||
1767 | } | ||
1425 | 1768 | ||
1426 | void QTReaderApp::showEditTools() | 1769 | void QTReaderApp::showEditTools() |
1427 | { | 1770 | { |
1428 | if ( !doc ) | 1771 | // if ( !doc ) |
1429 | close(); | 1772 | //close(); |
1430 | // fileSelector->hide(); | 1773 | if (m_fullscreen) |
1431 | //tjw menu->show(); | 1774 | { |
1775 | editBar->hide(); | ||
1776 | searchBar->hide(); | ||
1777 | regBar->hide(); | ||
1778 | Global::hideInputMethod(); | ||
1779 | m_fontBar->hide(); | ||
1780 | //showNormal(); | ||
1781 | showFullScreen(); | ||
1782 | } | ||
1783 | else | ||
1784 | { | ||
1785 | qDebug("him"); | ||
1786 | Global::hideInputMethod(); | ||
1787 | qDebug("eb"); | ||
1432 | editBar->show(); | 1788 | editBar->show(); |
1433 | if ( searchVisible ) | 1789 | if ( searchVisible ) |
1790 | { | ||
1791 | Global::showInputMethod(); | ||
1434 | searchBar->show(); | 1792 | searchBar->show(); |
1793 | } | ||
1435 | if ( regVisible ) | 1794 | if ( regVisible ) |
1795 | { | ||
1796 | Global::showInputMethod(); | ||
1436 | regBar->show(); | 1797 | regBar->show(); |
1798 | } | ||
1437 | if (m_fontVisible) m_fontBar->show(); | 1799 | if (m_fontVisible) m_fontBar->show(); |
1800 | qDebug("sn"); | ||
1801 | showNormal(); | ||
1802 | qDebug("sm"); | ||
1803 | showMaximized(); | ||
1804 | //setCentralWidget(reader); | ||
1805 | } | ||
1438 | 1806 | ||
1807 | qDebug("uc"); | ||
1439 | updateCaption(); | 1808 | updateCaption(); |
1809 | qDebug("rw"); | ||
1440 | editorStack->raiseWidget( reader ); | 1810 | editorStack->raiseWidget( reader ); |
1811 | qDebug("sf"); | ||
1441 | reader->setFocus(); | 1812 | reader->setFocus(); |
1442 | } | 1813 | } |
@@ -1474,11 +1845,11 @@ void QTReaderApp::save() | |||
1474 | void QTReaderApp::clear() | 1845 | void QTReaderApp::clear() |
1475 | { | 1846 | { |
1476 | if (doc != 0) | 1847 | // if (doc != 0) |
1477 | { | 1848 | // { |
1478 | // QMessageBox::information(this, "QTReader", "Deleting doc", 1); | 1849 | // QMessageBox::information(this, PROGNAME, "Deleting doc", 1); |
1479 | delete doc; | 1850 | //delete doc; |
1480 | // QMessageBox::information(this, "QTReader", "Deleted doc", 1); | 1851 | // QMessageBox::information(this, PROGNAME, "Deleted doc", 1); |
1481 | doc = 0; | 1852 | //doc = 0; |
1482 | } | 1853 | // } |
1483 | reader->clear(); | 1854 | reader->clear(); |
1484 | } | 1855 | } |
@@ -1486,12 +1857,12 @@ void QTReaderApp::clear() | |||
1486 | void QTReaderApp::updateCaption() | 1857 | void QTReaderApp::updateCaption() |
1487 | { | 1858 | { |
1488 | if ( !doc ) | 1859 | // if ( !doc ) |
1489 | setCaption( tr("OpieReader") ); | 1860 | //setCaption( tr("QTReader") ); |
1490 | else { | 1861 | // else { |
1491 | QString s = doc->name(); | 1862 | //QString s = doc->name(); |
1492 | if ( s.isEmpty() ) | 1863 | //if ( s.isEmpty() ) |
1493 | s = tr( "Unnamed" ); | 1864 | // s = tr( "Unnamed" ); |
1494 | setCaption( s + " - " + tr("OpieReader") ); | 1865 | setCaption( reader->m_string + " - " + tr(SHORTPROGNAME) ); |
1495 | } | 1866 | // } |
1496 | } | 1867 | } |
1497 | 1868 | ||
@@ -1500,5 +1871,5 @@ void QTReaderApp::setDocument(const QString& fileref) | |||
1500 | bFromDocView = TRUE; | 1871 | bFromDocView = TRUE; |
1501 | //QMessageBox::information(0, "setDocument", fileref); | 1872 | //QMessageBox::information(0, "setDocument", fileref); |
1502 | openFile(DocLnk(fileref)); | 1873 | openFile(fileref); |
1503 | // showEditTools(); | 1874 | // showEditTools(); |
1504 | } | 1875 | } |
@@ -1506,5 +1877,11 @@ void QTReaderApp::setDocument(const QString& fileref) | |||
1506 | void QTReaderApp::closeEvent( QCloseEvent *e ) | 1877 | void QTReaderApp::closeEvent( QCloseEvent *e ) |
1507 | { | 1878 | { |
1508 | if (m_dontSave) | 1879 | if (m_fullscreen) |
1880 | { | ||
1881 | m_fullscreen = false; | ||
1882 | showEditTools(); | ||
1883 | e->accept(); | ||
1884 | } | ||
1885 | else if (m_dontSave) | ||
1509 | { | 1886 | { |
1510 | e->accept(); | 1887 | e->accept(); |
@@ -1522,4 +1899,5 @@ void QTReaderApp::closeEvent( QCloseEvent *e ) | |||
1522 | { | 1899 | { |
1523 | regBar->hide(); | 1900 | regBar->hide(); |
1901 | Global::hideInputMethod(); | ||
1524 | regVisible = false; | 1902 | regVisible = false; |
1525 | return; | 1903 | return; |
@@ -1528,4 +1906,5 @@ void QTReaderApp::closeEvent( QCloseEvent *e ) | |||
1528 | { | 1906 | { |
1529 | searchBar->hide(); | 1907 | searchBar->hide(); |
1908 | Global::hideInputMethod(); | ||
1530 | searchVisible = false; | 1909 | searchVisible = false; |
1531 | return; | 1910 | return; |
@@ -1533,5 +1912,5 @@ void QTReaderApp::closeEvent( QCloseEvent *e ) | |||
1533 | if (m_fBkmksChanged && pBkmklist != NULL) | 1912 | if (m_fBkmksChanged && pBkmklist != NULL) |
1534 | { | 1913 | { |
1535 | if (QMessageBox::warning(this, "OpieReader", "Save bookmarks?", "Save", "Don't bother") == 0) | 1914 | if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) |
1536 | savebkmks(); | 1915 | savebkmks(); |
1537 | delete pBkmklist; | 1916 | delete pBkmklist; |
@@ -1540,4 +1919,5 @@ void QTReaderApp::closeEvent( QCloseEvent *e ) | |||
1540 | } | 1919 | } |
1541 | bFromDocView = FALSE; | 1920 | bFromDocView = FALSE; |
1921 | updatefileinfo(); | ||
1542 | saveprefs(); | 1922 | saveprefs(); |
1543 | e->accept(); | 1923 | e->accept(); |
@@ -1553,5 +1933,5 @@ void QTReaderApp::do_gotomark() | |||
1553 | { | 1933 | { |
1554 | m_nRegAction = cGotoBkmk; | 1934 | m_nRegAction = cGotoBkmk; |
1555 | listbkmk(); | 1935 | listbkmk(pBkmklist); |
1556 | } | 1936 | } |
1557 | 1937 | ||
@@ -1559,16 +1939,21 @@ void QTReaderApp::do_delmark() | |||
1559 | { | 1939 | { |
1560 | m_nRegAction = cDelBkmk; | 1940 | m_nRegAction = cDelBkmk; |
1561 | listbkmk(); | 1941 | listbkmk(pBkmklist); |
1562 | } | 1942 | } |
1563 | 1943 | ||
1564 | void QTReaderApp::listbkmk() | 1944 | void QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab) |
1565 | { | 1945 | { |
1566 | bkmkselector->clear(); | 1946 | bkmkselector->clear(); |
1947 | if (_lab.isNull()) | ||
1948 | bkmkselector->setText("Cancel"); | ||
1949 | else | ||
1950 | bkmkselector->setText(_lab); | ||
1567 | int cnt = 0; | 1951 | int cnt = 0; |
1568 | if (pBkmklist != NULL) | 1952 | if (plist != NULL) |
1569 | { | 1953 | { |
1570 | for (CList<Bkmk>::iterator i = pBkmklist->begin(); i != pBkmklist->end(); i++) | 1954 | for (CList<Bkmk>::iterator i = plist->begin(); i != plist->end(); i++) |
1571 | { | 1955 | { |
1572 | #ifdef _UNICODE | 1956 | #ifdef _UNICODE |
1957 | qDebug("Item:%s", (const char*)toQString(i->name())); | ||
1573 | bkmkselector->insertItem(toQString(i->name())); | 1958 | bkmkselector->insertItem(toQString(i->name())); |
1574 | #else | 1959 | #else |
@@ -1583,10 +1968,18 @@ void QTReaderApp::listbkmk() | |||
1583 | editBar->hide(); | 1968 | editBar->hide(); |
1584 | if (m_fontVisible) m_fontBar->hide(); | 1969 | if (m_fontVisible) m_fontBar->hide(); |
1585 | if (regVisible) regBar->hide(); | 1970 | if (regVisible) |
1586 | if (searchVisible) searchBar->hide(); | 1971 | { |
1972 | Global::hideInputMethod(); | ||
1973 | regBar->hide(); | ||
1974 | } | ||
1975 | if (searchVisible) | ||
1976 | { | ||
1977 | Global::hideInputMethod(); | ||
1978 | searchBar->hide(); | ||
1979 | } | ||
1587 | editorStack->raiseWidget( bkmkselector ); | 1980 | editorStack->raiseWidget( bkmkselector ); |
1588 | } | 1981 | } |
1589 | else | 1982 | else |
1590 | QMessageBox::information(this, "OpieReader", "No bookmarks in memory"); | 1983 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); |
1591 | } | 1984 | } |
1592 | 1985 | ||
@@ -1601,7 +1994,55 @@ void QTReaderApp::do_regedit() | |||
1601 | { | 1994 | { |
1602 | // editBar->hide(); | 1995 | // editBar->hide(); |
1996 | reader->bDoUpdates = false; | ||
1997 | qDebug("Showing regbar"); | ||
1603 | regBar->show(); | 1998 | regBar->show(); |
1999 | qDebug("Showing kbd"); | ||
2000 | Global::showInputMethod(); | ||
1604 | regVisible = true; | 2001 | regVisible = true; |
1605 | regEdit->setFocus(); | 2002 | regEdit->setFocus(); |
2003 | qApp->processEvents(); | ||
2004 | reader->bDoUpdates = true; | ||
2005 | reader->update(); | ||
2006 | } | ||
2007 | |||
2008 | bool QTReaderApp::openfrombkmk(Bkmk* bk) | ||
2009 | { | ||
2010 | QString fn = toQString( | ||
2011 | CFiledata(bk->anno()).name() | ||
2012 | ); | ||
2013 | qDebug("fileinfo"); | ||
2014 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) | ||
2015 | { | ||
2016 | qDebug("Opening"); | ||
2017 | openFile(fn); | ||
2018 | struct stat fnstat; | ||
2019 | stat((const char *)reader->m_lastfile, &fnstat); | ||
2020 | |||
2021 | if (CFiledata(bk->anno()).date() | ||
2022 | != fnstat.st_mtime) | ||
2023 | { | ||
2024 | CFiledata fd(bk->anno()); | ||
2025 | fd.setdate(fnstat.st_mtime); | ||
2026 | bk->value(0); | ||
2027 | } | ||
2028 | else | ||
2029 | { | ||
2030 | unsigned short svlen = bk->filedatalen(); | ||
2031 | unsigned char* svdata = bk->filedata(); | ||
2032 | reader->putSaveData(svdata, svlen); | ||
2033 | // setstate(svdata, svlen); | ||
2034 | if (svlen != 0) | ||
2035 | { | ||
2036 | QMessageBox::warning(this, PROGNAME, "Not all file data used\nNew version?"); | ||
2037 | } | ||
2038 | qDebug("updating"); | ||
2039 | reader->locate(bk->value()); | ||
2040 | } | ||
2041 | return true; | ||
2042 | } | ||
2043 | else | ||
2044 | { | ||
2045 | return false; | ||
2046 | } | ||
1606 | } | 2047 | } |
1607 | 2048 | ||
@@ -1610,4 +2051,13 @@ void QTReaderApp::gotobkmk(int ind) | |||
1610 | switch (m_nRegAction) | 2051 | switch (m_nRegAction) |
1611 | { | 2052 | { |
2053 | case cOpenFile: | ||
2054 | { | ||
2055 | if (!openfrombkmk((*pOpenlist)[ind])) | ||
2056 | { | ||
2057 | pOpenlist->erase(ind); | ||
2058 | QMessageBox::information(this, PROGNAME, "Can't find file"); | ||
2059 | } | ||
2060 | } | ||
2061 | break; | ||
1612 | case cGotoBkmk: | 2062 | case cGotoBkmk: |
1613 | reader->locate((*pBkmklist)[ind]->value()); | 2063 | reader->locate((*pBkmklist)[ind]->value()); |
@@ -1620,5 +2070,5 @@ void QTReaderApp::gotobkmk(int ind) | |||
1620 | break; | 2070 | break; |
1621 | case cRmBkmkFile: | 2071 | case cRmBkmkFile: |
1622 | unlink((const char *)Global::applicationFileName("uqtreader",bkmkselector->text(ind))); | 2072 | unlink((const char *)Global::applicationFileName(APPDIR,bkmkselector->text(ind))); |
1623 | break; | 2073 | break; |
1624 | } | 2074 | } |
@@ -1628,4 +2078,9 @@ void QTReaderApp::gotobkmk(int ind) | |||
1628 | void QTReaderApp::cancelbkmk() | 2078 | void QTReaderApp::cancelbkmk() |
1629 | { | 2079 | { |
2080 | if (m_nRegAction == cOpenFile) | ||
2081 | { | ||
2082 | QString fn = usefilebrowser(); | ||
2083 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn); | ||
2084 | } | ||
1630 | showEditTools(); | 2085 | showEditTools(); |
1631 | } | 2086 | } |
@@ -1647,10 +2102,12 @@ void QTReaderApp::do_jump(const QString& lcn) | |||
1647 | reader->locate(ulcn); | 2102 | reader->locate(ulcn); |
1648 | else | 2103 | else |
1649 | QMessageBox::information(this, "OpieReader", "Must be a number"); | 2104 | QMessageBox::information(this, PROGNAME, "Must be a number"); |
1650 | } | 2105 | } |
1651 | 2106 | ||
1652 | void QTReaderApp::do_regaction() | 2107 | void QTReaderApp::do_regaction() |
1653 | { | 2108 | { |
2109 | reader->bDoUpdates = false; | ||
1654 | regBar->hide(); | 2110 | regBar->hide(); |
2111 | Global::hideInputMethod(); | ||
1655 | regVisible = false; | 2112 | regVisible = false; |
1656 | switch(m_nRegAction) | 2113 | switch(m_nRegAction) |
@@ -1678,4 +2135,7 @@ void QTReaderApp::do_regaction() | |||
1678 | // editBar->show(); | 2135 | // editBar->show(); |
1679 | reader->setFocus(); | 2136 | reader->setFocus(); |
2137 | qApp->processEvents(); | ||
2138 | reader->bDoUpdates = true; | ||
2139 | reader->update(); | ||
1680 | } | 2140 | } |
1681 | 2141 | ||
@@ -1687,5 +2147,5 @@ void QTReaderApp::do_settarget(const QString& _txt) | |||
1687 | m_targetapp = ""; | 2147 | m_targetapp = ""; |
1688 | m_targetmsg = ""; | 2148 | m_targetmsg = ""; |
1689 | QMessageBox::information(this, "OpieReader", "Format is\nappname/messagename"); | 2149 | QMessageBox::information(this, PROGNAME, "Format is\nappname/messagename"); |
1690 | } | 2150 | } |
1691 | else | 2151 | else |
@@ -1710,21 +2170,30 @@ void QTReaderApp::setfont() | |||
1710 | } | 2170 | } |
1711 | 2171 | ||
1712 | void QTReaderApp::setfontHelper(const QString& lcn, int size) | 2172 | void QTReaderApp::setfontHelper(const QString& lcn, int size = 0) |
1713 | { | 2173 | { |
1714 | if (size == 0) size = reader->m_fontControl.currentsize(); | 2174 | if (size == 0) size = reader->m_fontControl.currentsize(); |
1715 | QFont f(lcn, 10 /*, QFont::Bold*/); | 2175 | QFont f(lcn, 10 /*, QFont::Bold*/); |
2176 | qDebug("bs"); | ||
1716 | bkmkselector->setFont( f ); | 2177 | bkmkselector->setFont( f ); |
2178 | qDebug("re"); | ||
1717 | regEdit->setFont( f ); | 2179 | regEdit->setFont( f ); |
2180 | qDebug("se"); | ||
1718 | searchEdit->setFont( f ); | 2181 | searchEdit->setFont( f ); |
2182 | qDebug("aw"); | ||
1719 | m_annoWin->setFont( f ); | 2183 | m_annoWin->setFont( f ); |
1720 | reader->m_fontname = lcn; | 2184 | reader->m_fontname = lcn; |
2185 | qDebug("cf1"); | ||
1721 | if (!reader->ChangeFont(size)) | 2186 | if (!reader->ChangeFont(size)) |
1722 | { | 2187 | { |
2188 | qDebug("cf2"); | ||
1723 | reader->ChangeFont(size); | 2189 | reader->ChangeFont(size); |
1724 | } | 2190 | } |
2191 | qDebug("ref"); | ||
1725 | reader->refresh(); | 2192 | reader->refresh(); |
1726 | m_fontBar->hide(); | 2193 | m_fontBar->hide(); |
1727 | m_fontVisible = false; | 2194 | m_fontVisible = false; |
1728 | showEditTools(); | 2195 | qDebug("showedit"); |
2196 | if (reader->isVisible()) showEditTools(); | ||
2197 | qDebug("showeditdone"); | ||
1729 | } | 2198 | } |
1730 | 2199 | ||
@@ -1782,5 +2251,5 @@ void QTReaderApp::saveprefs() | |||
1782 | { | 2251 | { |
1783 | // reader->saveprefs("uqtreader"); | 2252 | // reader->saveprefs("uqtreader"); |
1784 | Config config( "uqtreader" ); | 2253 | Config config( APPDIR ); |
1785 | config.setGroup( "View" ); | 2254 | config.setGroup( "View" ); |
1786 | 2255 | ||
@@ -1792,4 +2261,5 @@ void QTReaderApp::saveprefs() | |||
1792 | config.writeEntry( "StripHtml", reader->bstriphtml ); | 2261 | config.writeEntry( "StripHtml", reader->bstriphtml ); |
1793 | config.writeEntry( "Dehyphen", reader->bdehyphen ); | 2262 | config.writeEntry( "Dehyphen", reader->bdehyphen ); |
2263 | config.writeEntry( "OneSpace", reader->bonespace ); | ||
1794 | config.writeEntry( "Unindent", reader->bunindent ); | 2264 | config.writeEntry( "Unindent", reader->bunindent ); |
1795 | config.writeEntry( "Repara", reader->brepara ); | 2265 | config.writeEntry( "Repara", reader->brepara ); |
@@ -1801,4 +2271,5 @@ void QTReaderApp::saveprefs() | |||
1801 | config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); | 2271 | config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); |
1802 | config.writeEntry( "PageMode", reader->m_bpagemode ); | 2272 | config.writeEntry( "PageMode", reader->m_bpagemode ); |
2273 | config.writeEntry( "CursorNavigation", reader->m_navkeys ); | ||
1803 | config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); | 2274 | config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); |
1804 | config.writeEntry( "Fontname", reader->m_fontname ); | 2275 | config.writeEntry( "Fontname", reader->m_fontname ); |
@@ -1813,7 +2284,13 @@ void QTReaderApp::saveprefs() | |||
1813 | config.writeEntry( "Clipboard", m_doClipboard); | 2284 | config.writeEntry( "Clipboard", m_doClipboard); |
1814 | config.writeEntry( "SpaceTarget", m_spaceTarget); | 2285 | config.writeEntry( "SpaceTarget", m_spaceTarget); |
2286 | #ifdef REPALM | ||
2287 | config.writeEntry( "Repalm", reader->brepalm ); | ||
2288 | #endif | ||
1815 | config.writeEntry( "Remap", reader->bremap ); | 2289 | config.writeEntry( "Remap", reader->bremap ); |
1816 | config.writeEntry( "Peanut", reader->bpeanut ); | 2290 | config.writeEntry( "Peanut", reader->bpeanut ); |
1817 | config.writeEntry( "MakeBold", reader->bmakebold ); | 2291 | config.writeEntry( "MakeBold", reader->bmakebold ); |
2292 | config.writeEntry( "Continuous", reader->m_continuousDocument ); | ||
2293 | |||
2294 | savefilelist(); | ||
1818 | } | 2295 | } |
1819 | 2296 | ||
@@ -1888,5 +2365,5 @@ void QTReaderApp::savebkmks() | |||
1888 | if (pBkmklist != NULL) | 2365 | if (pBkmklist != NULL) |
1889 | { | 2366 | { |
1890 | BkmkFile bf((const char *)Global::applicationFileName("uqtreader",reader->m_string), true); | 2367 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR, reader->m_string), true); |
1891 | bf.write(*pBkmklist); | 2368 | bf.write(*pBkmklist); |
1892 | } | 2369 | } |
@@ -1894,4 +2371,23 @@ void QTReaderApp::savebkmks() | |||
1894 | } | 2371 | } |
1895 | 2372 | ||
2373 | void QTReaderApp::readfilelist() | ||
2374 | { | ||
2375 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR, ".openfiles")); | ||
2376 | qDebug("Reading open files"); | ||
2377 | pOpenlist = bf.readall(); | ||
2378 | if (pOpenlist != NULL) qDebug("...with success"); | ||
2379 | else qDebug("...without success!"); | ||
2380 | } | ||
2381 | |||
2382 | void QTReaderApp::savefilelist() | ||
2383 | { | ||
2384 | if (pOpenlist != NULL) | ||
2385 | { | ||
2386 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR, ".openfiles"), true); | ||
2387 | qDebug("Writing open files"); | ||
2388 | bf.write(*pOpenlist); | ||
2389 | } | ||
2390 | } | ||
2391 | |||
1896 | void QTReaderApp::readbkmks() | 2392 | void QTReaderApp::readbkmks() |
1897 | { | 2393 | { |
@@ -1900,5 +2396,20 @@ void QTReaderApp::readbkmks() | |||
1900 | delete pBkmklist; | 2396 | delete pBkmklist; |
1901 | } | 2397 | } |
1902 | BkmkFile bf((const char *)Global::applicationFileName("uqtreader",reader->m_string)); | 2398 | struct stat fnstat; |
2399 | struct stat bkstat; | ||
2400 | if ( | ||
2401 | stat((const char *)reader->m_lastfile, &fnstat) == 0 | ||
2402 | && | ||
2403 | stat((const char *)Global::applicationFileName(APPDIR, reader->m_string), &bkstat) == 0 | ||
2404 | ) | ||
2405 | { | ||
2406 | if (bkstat.st_mtime < fnstat.st_mtime) | ||
2407 | { | ||
2408 | unlink((const char *)Global::applicationFileName(APPDIR, reader->m_string)); | ||
2409 | } | ||
2410 | } | ||
2411 | |||
2412 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR, reader->m_string)); | ||
2413 | |||
1903 | pBkmklist = bf.readall(); | 2414 | pBkmklist = bf.readall(); |
1904 | m_fBkmksChanged = bf.upgraded(); | 2415 | m_fBkmksChanged = bf.upgraded(); |
@@ -1922,5 +2433,5 @@ void QTReaderApp::do_addbkmk(const QString& text) | |||
1922 | if (text.isEmpty()) | 2433 | if (text.isEmpty()) |
1923 | { | 2434 | { |
1924 | QMessageBox::information(this, "OpieReader", "Need a name for the bookmark\nSelect add again", 1); | 2435 | QMessageBox::information(this, PROGNAME, "Need a name for the bookmark\nSelect add again", 1); |
1925 | } | 2436 | } |
1926 | else | 2437 | else |
@@ -1958,4 +2469,5 @@ void QTReaderApp::showAnnotation() | |||
1958 | m_annoWin->setAnno(toQString(m_anno->anno())); | 2469 | m_annoWin->setAnno(toQString(m_anno->anno())); |
1959 | m_annoIsEditing = false; | 2470 | m_annoIsEditing = false; |
2471 | Global::showInputMethod(); | ||
1960 | editorStack->raiseWidget( m_annoWin ); | 2472 | editorStack->raiseWidget( m_annoWin ); |
1961 | m_annoWin->setFocus(); | 2473 | m_annoWin->setFocus(); |
@@ -1986,4 +2498,5 @@ void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString& | |||
1986 | m_annoWin->setPosn(posn); | 2498 | m_annoWin->setPosn(posn); |
1987 | m_annoIsEditing = true; | 2499 | m_annoIsEditing = true; |
2500 | Global::showInputMethod(); | ||
1988 | editorStack->raiseWidget( m_annoWin ); | 2501 | editorStack->raiseWidget( m_annoWin ); |
1989 | } | 2502 | } |
@@ -2018,4 +2531,9 @@ void QTReaderApp::OnActionPressed() | |||
2018 | } | 2531 | } |
2019 | break; | 2532 | break; |
2533 | case cesFullScreen: | ||
2534 | { | ||
2535 | m_actFullscreen->setOn(true); | ||
2536 | } | ||
2537 | break; | ||
2020 | default: | 2538 | default: |
2021 | { | 2539 | { |
@@ -2028,2 +2546,61 @@ void QTReaderApp::OnActionPressed() | |||
2028 | void QTReaderApp::setTwoTouch(bool _b) { reader->setTwoTouch(_b); } | 2546 | void QTReaderApp::setTwoTouch(bool _b) { reader->setTwoTouch(_b); } |
2029 | void QTReaderApp::restoreFocus() { reader->setFocus(); } | 2547 | void QTReaderApp::restoreFocus() { reader->setFocus(); } |
2548 | |||
2549 | /* | ||
2550 | void QTReaderApp::setstate(unsigned char* _sd, unsigned short _sdlen) | ||
2551 | { | ||
2552 | unsigned short sdlen; | ||
2553 | memcpy(&sdlen, _sd, sizeof(sdlen)); | ||
2554 | sdlen -= sizeof(sdlen); | ||
2555 | _sd += sizeof(sdlen); | ||
2556 | statedata* sd; | ||
2557 | char* data; | ||
2558 | if (sdlen < sizeof(statedata)+1) | ||
2559 | { | ||
2560 | sdlen = sizeof(statedata)+1; | ||
2561 | } | ||
2562 | data = new char[sdlen]; | ||
2563 | sd = (statedata*)data; | ||
2564 | memcpy(sd, _sd, sdlen); | ||
2565 | data[sdlen] = 0; | ||
2566 | reader->setstate(*sd); | ||
2567 | delete [] data; | ||
2568 | } | ||
2569 | |||
2570 | void QTReaderApp::getstate(unsigned char*& data, unsigned short& len) | ||
2571 | { | ||
2572 | unsigned char* olddata = data; | ||
2573 | unsigned short oldlen = len; | ||
2574 | len = oldlen+sizeof(unsigned short)+sizeof(statedata)+reader->m_fontname.length(); | ||
2575 | data = new unsigned char[len]; | ||
2576 | memcpy(data, olddata, oldlen); | ||
2577 | delete [] olddata; | ||
2578 | memcpy(data+oldlen, &len, sizeof(len)); | ||
2579 | statedata* sd = (statedata*)(data+oldlen+sizeof(unsigned short)); | ||
2580 | |||
2581 | sd->bstripcr = reader->bstripcr; | ||
2582 | sd->btextfmt = reader->btextfmt; | ||
2583 | sd->bautofmt = reader->bautofmt; | ||
2584 | sd->bstriphtml = reader->bstriphtml; | ||
2585 | sd->bpeanut = reader->bpeanut; | ||
2586 | sd->bdehyphen = reader->bdehyphen; | ||
2587 | sd->bonespace = reader->bonespace; | ||
2588 | sd->bunindent = reader->bunindent; | ||
2589 | sd->brepara = reader->brepara; | ||
2590 | sd->bdblspce = reader->bdblspce; | ||
2591 | sd->m_bpagemode = reader->m_bpagemode; | ||
2592 | sd->m_navkeys = reader->m_navkeys; | ||
2593 | sd->m_bMonoSpaced = reader->m_bMonoSpaced; | ||
2594 | sd->bremap = reader->bremap; | ||
2595 | sd->bmakebold = reader->bmakebold; | ||
2596 | sd->Continuous = reader->m_continuousDocument; | ||
2597 | #ifdef REPALM | ||
2598 | sd->brepalm = reader->brepalm; | ||
2599 | #endif | ||
2600 | sd->bindenter = reader->bindenter; | ||
2601 | sd->m_textsize = reader->m_textsize; //reader->m_fontControl.currentsize() | ||
2602 | sd->m_encd = reader->m_encd; | ||
2603 | sd->m_charpc = reader->m_charpc; | ||
2604 | strcpy(sd->m_fontname, reader->m_fontname.latin1()); | ||
2605 | } | ||
2606 | */ | ||