author | groucho <groucho> | 2003-05-07 09:01:39 (UTC) |
---|---|---|
committer | groucho <groucho> | 2003-05-07 09:01:39 (UTC) |
commit | 118d03d815a7615b9c53363218a7ac45b3f4c514 (patch) (unidiff) | |
tree | 356953e2413cddcec0f35bd47bb6439767da7051 /noncore/apps/opie-reader/QTReaderApp.cpp | |
parent | 00894537decf01c5a5cdc565b2740b5e67a2e90f (diff) | |
download | opie-118d03d815a7615b9c53363218a7ac45b3f4c514.zip opie-118d03d815a7615b9c53363218a7ac45b3f4c514.tar.gz opie-118d03d815a7615b9c53363218a7ac45b3f4c514.tar.bz2 |
Incorporated TimWs current source tree and make it compile
Diffstat (limited to 'noncore/apps/opie-reader/QTReaderApp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/QTReaderApp.cpp | 3074 |
1 files changed, 2345 insertions, 729 deletions
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp index 7333a28..af1da27 100644 --- a/noncore/apps/opie-reader/QTReaderApp.cpp +++ b/noncore/apps/opie-reader/QTReaderApp.cpp | |||
@@ -18,13 +18,18 @@ | |||
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | #include "useqpe.h" | |
21 | #include <qregexp.h> | ||
21 | #include <qclipboard.h> | 22 | #include <qclipboard.h> |
22 | #include <qwidgetstack.h> | 23 | #include <qwidgetstack.h> |
24 | #ifdef USEQPE | ||
23 | #include <qpe/qpemenubar.h> | 25 | #include <qpe/qpemenubar.h> |
24 | //#include <qpe/qpetoolbar.h> | 26 | #include <qpe/qpetoolbar.h> |
27 | #endif | ||
25 | #include <qmenubar.h> | 28 | #include <qmenubar.h> |
26 | #include <qtoolbar.h> | 29 | #include <qtoolbar.h> |
30 | #ifdef USEQPE | ||
27 | #include <qpe/menubutton.h> | 31 | #include <qpe/menubutton.h> |
28 | #include <qpe/fontdatabase.h> | 32 | #include <qpe/fontdatabase.h> |
33 | #endif | ||
29 | #include <qcombobox.h> | 34 | #include <qcombobox.h> |
30 | #include <qpopupmenu.h> | 35 | #include <qpopupmenu.h> |
@@ -35,14 +40,19 @@ | |||
35 | #include <qspinbox.h> | 40 | #include <qspinbox.h> |
36 | #include <qobjectlist.h> | 41 | #include <qobjectlist.h> |
42 | #ifdef USEQPE | ||
37 | #include <qpe/global.h> | 43 | #include <qpe/global.h> |
38 | #include <qpe/applnk.h> | 44 | #include <qpe/applnk.h> |
45 | #endif | ||
39 | #include <qfileinfo.h> | 46 | #include <qfileinfo.h> |
40 | #include <stdlib.h> //getenv | 47 | #include <stdlib.h> //getenv |
41 | #include <qprogressbar.h> | 48 | #include <qprogressbar.h> |
49 | #ifdef USEQPE | ||
42 | #include <qpe/config.h> | 50 | #include <qpe/config.h> |
51 | #endif | ||
43 | #include <qbuttongroup.h> | 52 | #include <qbuttongroup.h> |
44 | #include <qradiobutton.h> | 53 | #include <qradiobutton.h> |
54 | #ifdef USEQPE | ||
45 | #include <qpe/qcopenvelope_qws.h> | 55 | #include <qpe/qcopenvelope_qws.h> |
46 | 56 | #endif | |
47 | #include "QTReader.h" | 57 | #include "QTReader.h" |
48 | #include "GraphicWin.h" | 58 | #include "GraphicWin.h" |
@@ -50,25 +60,40 @@ | |||
50 | #include "cbkmkselector.h" | 60 | #include "cbkmkselector.h" |
51 | #include "infowin.h" | 61 | #include "infowin.h" |
62 | #include "ToolbarPrefs.h" | ||
63 | #include "Prefs.h" | ||
52 | #include "CAnnoEdit.h" | 64 | #include "CAnnoEdit.h" |
53 | #include "QFloatBar.h" | 65 | #include "QFloatBar.h" |
66 | #include "FixedFont.h" | ||
67 | #include "URLDialog.h" | ||
54 | //#include <qpe/fontdatabase.h> | 68 | //#include <qpe/fontdatabase.h> |
55 | 69 | ||
70 | #ifdef USEQPE | ||
56 | #include <qpe/resource.h> | 71 | #include <qpe/resource.h> |
57 | #include <qpe/qpeapplication.h> | 72 | #include <qpe/qpeapplication.h> |
73 | #include "fileBrowser.h" | ||
74 | #else | ||
75 | #include "qfiledialog.h" | ||
76 | #endif | ||
58 | 77 | ||
59 | #include "QTReaderApp.h" | 78 | #include "QTReaderApp.h" |
60 | #include "fileBrowser.h" | ||
61 | #include "CDrawBuffer.h" | 79 | #include "CDrawBuffer.h" |
62 | #include "Filedata.h" | 80 | #include "Filedata.h" |
63 | #include "opie.h" | 81 | #include "opie.h" |
64 | #include "name.h" | 82 | #include "useqpe.h" |
65 | #include "StateData.h" | 83 | #include "names.h" |
84 | #include "CEncoding_tables.h" | ||
85 | #include "CloseDialog.h" | ||
66 | 86 | ||
67 | #ifdef OPIE | 87 | bool CheckVersion(int&, int&, char&); |
88 | |||
89 | #ifdef _WINDOWS | ||
90 | #define PICDIR "c:\\uqtreader\\pics\\" | ||
91 | #else | ||
92 | #ifdef USEQPE | ||
68 | #define PICDIR "opie-reader/" | 93 | #define PICDIR "opie-reader/" |
69 | #else | 94 | #else |
70 | #define PICDIR | 95 | #define PICDIR "/home/tim/uqtreader/pics/" |
96 | #endif | ||
71 | #endif | 97 | #endif |
72 | |||
73 | 98 | ||
74 | unsigned long QTReaderApp::m_uid = 0; | 99 | unsigned long QTReaderApp::m_uid = 0; |
@@ -76,7 +101,20 @@ unsigned long QTReaderApp::m_uid = 0; | |||
76 | void QTReaderApp::setScrollState(bool _b) { m_scrollButton->setOn(_b); } | 101 | void QTReaderApp::setScrollState(bool _b) { m_scrollButton->setOn(_b); } |
77 | 102 | ||
103 | #ifdef USEQPE | ||
104 | #define geticon(iconname) Resource::loadPixmap( iconname ) | ||
105 | #define getmyicon(iconname) Resource::loadPixmap( PICDIR iconname ) | ||
106 | #else | ||
107 | #define geticon(iconname) QPixmap(PICDIR iconname ".png") | ||
108 | #define getmyicon(iconname) geticon(iconname) | ||
109 | //#define geticon(iconname) QIconSet( QPixmap(PICDIR iconname) ) | ||
110 | #endif | ||
111 | |||
112 | #ifndef _WINDOWS | ||
78 | #include <unistd.h> | 113 | #include <unistd.h> |
114 | #endif | ||
79 | #include <stddef.h> | 115 | #include <stddef.h> |
116 | #ifndef _WINDOWS | ||
80 | #include <dirent.h> | 117 | #include <dirent.h> |
118 | #endif | ||
81 | 119 | ||
82 | void QTReaderApp::listBkmkFiles() | 120 | void QTReaderApp::listBkmkFiles() |
@@ -84,4 +122,35 @@ void QTReaderApp::listBkmkFiles() | |||
84 | bkmkselector->clear(); | 122 | bkmkselector->clear(); |
85 | bkmkselector->setText("Cancel"); | 123 | bkmkselector->setText("Cancel"); |
124 | #ifndef USEQPE | ||
125 | int cnt = 0; | ||
126 | |||
127 | QDir d = QDir::home(); // "/" | ||
128 | if ( !d.cd(APPDIR) ) { // "/tmp" | ||
129 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | ||
130 | d = QDir::home(); | ||
131 | d.mkdir(APPDIR); | ||
132 | d.cd(APPDIR); | ||
133 | } | ||
134 | |||
135 | |||
136 | |||
137 | |||
138 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | ||
139 | // d.setSorting( QDir::Size | QDir::Reversed ); | ||
140 | |||
141 | const QFileInfoList *list = d.entryInfoList(); | ||
142 | QFileInfoListIterator it( *list ); // create list iterator | ||
143 | QFileInfo *fi; // pointer for traversing | ||
144 | |||
145 | while ( (fi=it.current()) ) { // for each file... | ||
146 | |||
147 | bkmkselector->insertItem(fi->fileName()); | ||
148 | cnt++; | ||
149 | |||
150 | //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); | ||
151 | ++it; // goto next list element | ||
152 | } | ||
153 | |||
154 | #else /* USEQPE */ | ||
86 | int cnt = 0; | 155 | int cnt = 0; |
87 | DIR *d; | 156 | DIR *d; |
@@ -103,22 +172,11 @@ void QTReaderApp::listBkmkFiles() | |||
103 | 172 | ||
104 | closedir(d); | 173 | closedir(d); |
105 | 174 | #endif | |
106 | if (cnt > 0) | 175 | if (cnt > 0) |
107 | { | 176 | { |
108 | //tjw menu->hide(); | 177 | //tjw menu->hide(); |
109 | editBar->hide(); | ||
110 | if (m_fontVisible) m_fontBar->hide(); | ||
111 | if (regVisible) | ||
112 | { | ||
113 | Global::hideInputMethod(); | ||
114 | regBar->hide(); | ||
115 | } | ||
116 | if (searchVisible) | ||
117 | { | ||
118 | Global::hideInputMethod(); | ||
119 | searchBar->hide(); | ||
120 | } | ||
121 | m_nRegAction = cRmBkmkFile; | ||
122 | editorStack->raiseWidget( bkmkselector ); | 178 | editorStack->raiseWidget( bkmkselector ); |
179 | hidetoolbars(); | ||
180 | m_nBkmkAction = cRmBkmkFile; | ||
123 | } | 181 | } |
124 | else | 182 | else |
@@ -126,10 +184,41 @@ void QTReaderApp::listBkmkFiles() | |||
126 | } | 184 | } |
127 | 185 | ||
128 | QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | 186 | void QTReaderApp::hidetoolbars() |
129 | : QMainWindow( parent, name, f ), bFromDocView( FALSE ), m_dontSave(false) | ||
130 | { | 187 | { |
131 | // qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir()); | 188 | menubar->hide(); |
132 | // qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml")); | 189 | if (fileBar != NULL) fileBar->hide(); |
190 | if (viewBar != NULL) viewBar->hide(); | ||
191 | if (navBar != NULL) navBar->hide(); | ||
192 | if (markBar != NULL) markBar->hide(); | ||
193 | if (m_fontVisible) m_fontBar->hide(); | ||
194 | if (regVisible) | ||
195 | { | ||
196 | #ifdef USEQPE | ||
197 | Global::hideInputMethod(); | ||
198 | #endif | ||
199 | regBar->hide(); | ||
200 | } | ||
201 | if (searchVisible) | ||
202 | { | ||
203 | #ifdef USEQPE | ||
204 | Global::hideInputMethod(); | ||
205 | #endif | ||
206 | searchBar->hide(); | ||
207 | } | ||
208 | } | ||
133 | 209 | ||
210 | QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | ||
211 | : QMainWindow( parent, name, f ), bFromDocView( FALSE ), m_dontSave(false), | ||
212 | fileBar(NULL), navBar(NULL), viewBar(NULL), markBar(NULL) | ||
213 | { | ||
214 | m_url_clipboard = false; | ||
215 | m_url_localfile = false; | ||
216 | m_url_globalfile = false; | ||
217 | ftime(&m_lastkeytime); | ||
218 | //// qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir()); | ||
219 | //// qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml")); | ||
220 | |||
221 | m_bcloseDisabled = true; | ||
222 | m_disableesckey = false; | ||
134 | pBkmklist = NULL; | 223 | pBkmklist = NULL; |
135 | pOpenlist = NULL; | 224 | pOpenlist = NULL; |
@@ -139,24 +228,90 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
139 | 228 | ||
140 | QString lang = getenv( "LANG" ); | 229 | QString lang = getenv( "LANG" ); |
230 | QString rot = getenv( "QWS_DISPLAY" ); | ||
141 | 231 | ||
142 | m_autogenstr = "^ *[A-Z].*[a-z] *$"; | 232 | /* |
143 | setToolBarsMovable( FALSE ); | 233 | int m_rot = 0; |
234 | if (rot.contains("Rot90")) | ||
235 | { | ||
236 | m_rot = 90; | ||
237 | } | ||
238 | else if (rot.contains("Rot180")) | ||
239 | { | ||
240 | m_rot = 180; | ||
241 | } | ||
242 | else if (rot.contains("Rot270")) | ||
243 | { | ||
244 | m_rot = 270; | ||
245 | } | ||
246 | |||
247 | // qDebug("Initial Rotation(%d):%s", m_rot, (const char*)rot); | ||
248 | */ | ||
249 | m_autogenstr = "^ *[A-Z].*[a-z] *$"; | ||
144 | 250 | ||
145 | setIcon( Resource::loadPixmap( "uqtreader" ) ); | 251 | #ifdef USEQPE |
252 | setIcon( Resource::loadPixmap( PICDIR "uqtreader") ); | ||
253 | #else | ||
254 | setIcon( QPixmap (PICDIR "uqtreader.png") ); | ||
255 | #endif /* USEQPE */ | ||
146 | 256 | ||
147 | // QPEToolBar *bar = new QPEToolBar( this ); | 257 | // QPEToolBar *bar = new QPEToolBar( this ); |
148 | QToolBar *bar = new QToolBar( this ); | 258 | // menubar = new QPEToolBar( this ); |
149 | bar->setHorizontalStretchable( TRUE ); | 259 | #ifdef USEQPE |
150 | addToolBar(bar, "tool",QMainWindow::Top, true); | 260 | Config config( APPDIR ); |
151 | //tjw menu = bar; | 261 | #else |
152 | 262 | QDir d = QDir::home(); // "/" | |
153 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 263 | if ( !d.cd(APPDIR) ) { // "/tmp" |
154 | // QMenuBar *mb = new QMenuBar( bar ); | 264 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); |
155 | QPopupMenu *file = new QPopupMenu( this ); | 265 | d = QDir::home(); |
156 | QPopupMenu *format = new QPopupMenu( this ); | 266 | d.mkdir(APPDIR); |
157 | // QPopupMenu *edit = new QPopupMenu( this ); | 267 | d.cd(APPDIR); |
268 | } | ||
269 | QFileInfo fi(d, INIFILE); | ||
270 | // qDebug("Path:%s", (const char*)fi.absFilePath()); | ||
271 | Config config(fi.absFilePath()); | ||
272 | #endif | ||
273 | config.setGroup("Toolbar"); | ||
274 | m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false); | ||
275 | m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1); | ||
276 | m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2); | ||
277 | menubar = new QToolBar("Menus", this, m_tbposition); | ||
278 | |||
279 | // fileBar = new QToolBar("File", this); | ||
280 | // QToolBar* viewBar = new QToolBar("File", this); | ||
281 | // QToolBar* navBar = new QToolBar("File", this); | ||
282 | // QToolBar* markBar = new QToolBar("File", this); | ||
283 | |||
284 | #ifdef USEQPE | ||
285 | mb = new QPEMenuBar( menubar ); | ||
286 | #else | ||
287 | mb = new QMenuBar( menubar ); | ||
288 | #endif | ||
158 | 289 | ||
159 | // bar = new QToolBar( this ); | 290 | //#ifdef USEQPE |
160 | editBar = bar; | 291 | QPopupMenu* tmp = new QPopupMenu(mb); |
292 | mb->insertItem( geticon( "AppsIcon" ), tmp ); | ||
293 | //#else | ||
294 | // QMenuBar* tmp = mb; | ||
295 | //#endif | ||
296 | |||
297 | QPopupMenu *file = new QPopupMenu( mb ); | ||
298 | tmp->insertItem( tr( "File" ), file ); | ||
299 | |||
300 | QPopupMenu *navigation = new QPopupMenu(mb); | ||
301 | tmp->insertItem( tr( "Navigation" ), navigation ); | ||
302 | |||
303 | QPopupMenu *view = new QPopupMenu( mb ); | ||
304 | tmp->insertItem( tr( "View" ), view ); | ||
305 | |||
306 | QPopupMenu *marks = new QPopupMenu( this ); | ||
307 | tmp->insertItem( tr( "Marks" ), marks ); | ||
308 | |||
309 | QPopupMenu *settings = new QPopupMenu( this ); | ||
310 | tmp->insertItem( tr( "Settings" ), settings ); | ||
311 | |||
312 | // addToolBar(menubar, "Menus",QMainWindow::Top); | ||
313 | // addToolBar(fileBar, "Toolbar",QMainWindow::Top); | ||
314 | |||
315 | // QPopupMenu *edit = new QPopupMenu( this ); | ||
161 | 316 | ||
162 | /* | 317 | /* |
@@ -174,7 +329,4 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
174 | m_fontVisible = false; | 329 | m_fontVisible = false; |
175 | 330 | ||
176 | pbar = new QProgressBar(this); | ||
177 | pbar->hide(); | ||
178 | |||
179 | m_annoWin = new CAnnoEdit(editorStack); | 331 | m_annoWin = new CAnnoEdit(editorStack); |
180 | editorStack->addWidget(m_annoWin, get_unique_id()); | 332 | editorStack->addWidget(m_annoWin, get_unique_id()); |
@@ -206,5 +358,5 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
206 | importSelector->setCloseVisible( FALSE ); | 358 | importSelector->setCloseVisible( FALSE ); |
207 | */ | 359 | */ |
208 | qDebug("Reading file list"); | 360 | // qDebug("Reading file list"); |
209 | readfilelist(); | 361 | readfilelist(); |
210 | 362 | ||
@@ -213,11 +365,21 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
213 | reader->bDoUpdates = false; | 365 | reader->bDoUpdates = false; |
214 | 366 | ||
367 | #ifdef USEQPE | ||
215 | ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold); | 368 | ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold); |
369 | #endif | ||
216 | 370 | ||
217 | qDebug("Reading config"); | 371 | // qDebug("Reading config"); |
218 | Config config( APPDIR ); | 372 | // Config config( APPDIR ); |
219 | config.setGroup( "View" ); | 373 | config.setGroup( "View" ); |
220 | 374 | m_debounce = config.readNumEntry("Debounce", 0); | |
375 | #ifdef USEQPE | ||
376 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false); | ||
377 | #else | ||
378 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", true); | ||
379 | #endif | ||
221 | reader->bstripcr = config.readBoolEntry( "StripCr", true ); | 380 | reader->bstripcr = config.readBoolEntry( "StripCr", true ); |
381 | reader->bfulljust = config.readBoolEntry( "FullJust", false ); | ||
382 | reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 )); | ||
383 | reader->setlead(config.readNumEntry( "ExtraLead", 0 )); | ||
222 | reader->btextfmt = config.readBoolEntry( "TextFmt", false ); | 384 | reader->btextfmt = config.readBoolEntry( "TextFmt", false ); |
223 | reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); | 385 | reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); |
@@ -225,4 +387,6 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
225 | reader->bpeanut = config.readBoolEntry( "Peanut", false ); | 387 | reader->bpeanut = config.readBoolEntry( "Peanut", false ); |
226 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); | 388 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); |
389 | reader->bdepluck = config.readBoolEntry( "Depluck", false ); | ||
390 | reader->bdejpluck = config.readBoolEntry( "Dejpluck", false ); | ||
227 | reader->bonespace = config.readBoolEntry( "OneSpace", false ); | 391 | reader->bonespace = config.readBoolEntry( "OneSpace", false ); |
228 | reader->bunindent = config.readBoolEntry( "Unindent", false ); | 392 | reader->bunindent = config.readBoolEntry( "Unindent", false ); |
@@ -235,10 +399,11 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
235 | reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); | 399 | reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); |
236 | reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); | 400 | reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); |
237 | reader->m_navkeys = config.readBoolEntry( "CursorNavigation", false ); | ||
238 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); | 401 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); |
402 | reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false); | ||
239 | reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); | 403 | reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); |
240 | reader->m_encd = config.readNumEntry( "Encoding", 0 ); | 404 | reader->m_encd = config.readNumEntry( "Encoding", 0 ); |
241 | reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); | 405 | reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); |
242 | reader->m_overlap = config.readNumEntry( "Overlap", 0 ); | 406 | reader->m_overlap = config.readNumEntry( "Overlap", 0 ); |
407 | reader->m_border = config.readNumEntry( "Margin", 6 ); | ||
243 | #ifdef REPALM | 408 | #ifdef REPALM |
244 | reader->brepalm = config.readBoolEntry( "Repalm", true ); | 409 | reader->brepalm = config.readBoolEntry( "Repalm", true ); |
@@ -249,4 +414,8 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
249 | m_targetapp = config.readEntry( "TargetApp", QString::null ); | 414 | m_targetapp = config.readEntry( "TargetApp", QString::null ); |
250 | m_targetmsg = config.readEntry( "TargetMsg", QString::null ); | 415 | m_targetmsg = config.readEntry( "TargetMsg", QString::null ); |
416 | #ifdef _SCROLLPIPE | ||
417 | reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null ); | ||
418 | reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true ); | ||
419 | #endif | ||
251 | m_twoTouch = config.readBoolEntry( "TwoTouch", false); | 420 | m_twoTouch = config.readBoolEntry( "TwoTouch", false); |
252 | m_doAnnotation = config.readBoolEntry( "Annotation", false); | 421 | m_doAnnotation = config.readBoolEntry( "Annotation", false); |
@@ -254,83 +423,145 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
254 | m_doClipboard = config.readBoolEntry( "Clipboard", false); | 423 | m_doClipboard = config.readBoolEntry( "Clipboard", false); |
255 | m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll); | 424 | m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll); |
256 | setTwoTouch(m_twoTouch); | 425 | m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone); |
426 | m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen); | ||
427 | m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut); | ||
428 | m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn); | ||
429 | m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp); | ||
430 | m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown); | ||
431 | |||
432 | m_leftScroll = config.readBoolEntry("LeftScroll", false); | ||
433 | m_rightScroll = config.readBoolEntry("RightScroll", false); | ||
434 | m_upScroll = config.readBoolEntry("UpScroll", true); | ||
435 | m_downScroll = config.readBoolEntry("DownScroll", true); | ||
436 | |||
437 | m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false); | ||
438 | reader->setBaseSize(config.readNumEntry( "Basesize", 10 )); | ||
439 | |||
440 | #ifndef USEQPE | ||
441 | config.setGroup( "Geometry" ); | ||
442 | setGeometry(0,0, | ||
443 | config.readNumEntry( "width", QApplication::desktop()->width()/2 ), | ||
444 | config.readNumEntry( "height", QApplication::desktop()->height()/2 )); | ||
445 | move( | ||
446 | config.readNumEntry( "x", 20 ), | ||
447 | config.readNumEntry( "y", 20 )); | ||
448 | #endif | ||
257 | 449 | ||
258 | 450 | ||
259 | connect( reader, SIGNAL( OnShowPicture(QPixmap&) ), this, SLOT( showgraphic(QPixmap&) ) ); | 451 | |
452 | setTwoTouch(m_twoTouch); | ||
453 | |||
454 | connect( reader, SIGNAL( OnShowPicture(QImage&) ), this, SLOT( showgraphic(QImage&) ) ); | ||
260 | 455 | ||
261 | connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) ); | 456 | connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) ); |
262 | connect( reader, SIGNAL( OnActionPressed() ), this, SLOT( OnActionPressed() ) ); | ||
263 | connect( reader, SIGNAL( OnWordSelected(const QString&, size_t, const QString&) ), this, SLOT( OnWordSelected(const QString&, size_t, const QString&) ) ); | 457 | connect( reader, SIGNAL( OnWordSelected(const QString&, size_t, const QString&) ), this, SLOT( OnWordSelected(const QString&, size_t, const QString&) ) ); |
458 | connect( reader, SIGNAL( OnURLSelected(const QString&) ), this, SLOT( OnURLSelected(const QString&) ) ); | ||
264 | editorStack->addWidget( reader, get_unique_id() ); | 459 | editorStack->addWidget( reader, get_unique_id() ); |
265 | 460 | ||
266 | QAction *a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); | 461 | m_preferences_action = new QAction( tr( "Configuration" ), geticon( "SettingsIcon" ), QString::null, 0, this, NULL); |
267 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); | 462 | connect( m_preferences_action, SIGNAL( activated() ), this, SLOT( showprefs() ) ); |
268 | a->addTo( bar ); | 463 | m_preferences_action->addTo( settings ); |
269 | a->addTo( file ); | ||
270 | 464 | ||
271 | a = new QAction( tr( "Close" ), Resource::loadPixmap( "fileclose" ), QString::null, 0, this, 0 ); | 465 | m_saveconfig_action = new QAction( tr( "Save Config" ), QString::null, 0, this, NULL); |
272 | connect( a, SIGNAL( activated() ), this, SLOT( fileClose() ) ); | 466 | connect( m_saveconfig_action, SIGNAL( activated() ), this, SLOT( SaveConfig() ) ); |
273 | // a->addTo( bar ); | 467 | m_saveconfig_action->addTo( settings ); |
274 | a->addTo( file ); | 468 | |
469 | m_loadconfig_action = new QAction( tr( "Load Config" ), QString::null, 0, this, NULL); | ||
470 | connect( m_loadconfig_action, SIGNAL( activated() ), this, SLOT( LoadConfig() ) ); | ||
471 | m_loadconfig_action->addTo( settings ); | ||
472 | |||
473 | m_tidyconfig_action = new QAction( tr( "Delete Config" ), QString::null, 0, this, NULL); | ||
474 | connect( m_tidyconfig_action, SIGNAL( activated() ), this, SLOT( TidyConfig() ) ); | ||
475 | m_tidyconfig_action->addTo( settings ); | ||
476 | |||
477 | settings->insertSeparator(); | ||
478 | m_toolbarprefs_action = new QAction( tr( "Toolbars" ), QString::null, 0, this, NULL); | ||
479 | connect( m_toolbarprefs_action, SIGNAL( activated() ), this, SLOT( showtoolbarprefs() ) ); | ||
480 | m_toolbarprefs_action->addTo( settings ); | ||
481 | |||
482 | m_open_action = new QAction( tr( "Open" ), geticon( "fileopen" ), QString::null, 0, this, 0 ); | ||
483 | connect( m_open_action, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); | ||
484 | m_open_action->addTo( file ); | ||
485 | |||
486 | m_close_action = new QAction( tr( "Close" ), geticon( "close" ), QString::null, 0, this, 0 ); | ||
487 | connect( m_close_action, SIGNAL( activated() ), this, SLOT( fileClose() ) ); | ||
488 | m_close_action->addTo( file ); | ||
275 | 489 | ||
490 | #ifdef _SCRIPT | ||
491 | a = new QAction( tr( "Run Script" ), QString::null, 0, this, NULL); | ||
492 | connect( a, SIGNAL( activated() ), this, SLOT( RunScript() ) ); | ||
493 | a->addTo( file ); | ||
494 | #endif | ||
276 | /* | 495 | /* |
277 | a = new QAction( tr( "Revert" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 496 | a = new QAction( tr( "Revert" ), geticon( "close" ), QString::null, 0, this, 0 ); |
278 | connect( a, SIGNAL( activated() ), this, SLOT( fileRevert() ) ); | 497 | connect( a, SIGNAL( activated() ), this, SLOT( fileRevert() ) ); |
279 | a->addTo( file ); | 498 | a->addTo( file ); |
280 | 499 | ||
281 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); | 500 | a = new QAction( tr( "Cut" ), geticon( "cut" ), QString::null, 0, this, 0 ); |
282 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); | 501 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); |
283 | a->addTo( editBar ); | 502 | a->addTo( filebar() ); |
284 | a->addTo( edit ); | 503 | a->addTo( edit ); |
285 | */ | 504 | */ |
286 | 505 | ||
287 | a = new QAction( tr( "Info" ), QString::null, 0, this, NULL); | 506 | m_info_action = new QAction( tr( "Info" ), geticon( "UtilsIcon" ), QString::null, 0, this, NULL); |
288 | connect( a, SIGNAL( activated() ), this, SLOT( showinfo() ) ); | 507 | connect( m_info_action, SIGNAL( activated() ), this, SLOT( showinfo() ) ); |
289 | a->addTo( file ); | 508 | m_info_action->addTo( file ); |
290 | |||
291 | QActionGroup* ag = new QActionGroup(this); | ||
292 | QPopupMenu *spacemenu = new QPopupMenu(this); | ||
293 | file->insertItem( tr( "On Action..." ), spacemenu ); | ||
294 | |||
295 | m_buttonAction[0] = new QAction( tr( "Open File" ), QString::null, 0, ag, NULL, true ); | ||
296 | |||
297 | m_buttonAction[1] = new QAction( tr( "Autoscroll" ), QString::null, 0, ag, NULL, true ); | ||
298 | |||
299 | m_buttonAction[2] = new QAction( tr( "Mark" ), QString::null, 0, ag, NULL, true ); | ||
300 | 509 | ||
301 | m_buttonAction[3] = new QAction( tr( "Fullscreen" ), QString::null, 0, ag, NULL, true ); | 510 | m_touch_action = new QAction( tr( "Two/One Touch" ), geticon( "1to1" ), QString::null, 0, this, NULL, true ); |
511 | connect( m_touch_action, SIGNAL( toggled(bool) ), this, SLOT( setTwoTouch(bool) ) ); | ||
512 | m_touch_action->setOn(m_twoTouch); | ||
513 | m_touch_action->addTo( file ); | ||
302 | 514 | ||
303 | ag->addTo(spacemenu); | 515 | m_find_action = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, NULL); |
516 | connect( m_find_action, SIGNAL( activated() ), this, SLOT( editFind() ) ); | ||
517 | file->insertSeparator(); | ||
518 | // a->addTo( bar ); | ||
519 | m_find_action->addTo( file ); | ||
304 | 520 | ||
305 | connect(ag, SIGNAL( selected(QAction*) ), this, SLOT( buttonActionSelected(QAction*) ) ); | 521 | m_exportlinks_action = new QAction( tr( "Export Links" ), QString::null, 0, this, NULL); |
522 | connect( m_exportlinks_action, SIGNAL( activated() ), this, SLOT( ExportLinks() ) ); | ||
523 | m_exportlinks_action->addTo( file ); | ||
306 | 524 | ||
307 | file->insertSeparator(); | 525 | m_scrollButton = new QAction( tr( "Scroll" ), getmyicon( "panel-arrow-down" ), QString::null, 0, this, 0, true ); |
526 | connect( m_scrollButton, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) ); | ||
527 | m_scrollButton->addTo(navigation); | ||
528 | m_scrollButton->setOn(false); | ||
308 | 529 | ||
309 | ag = new QActionGroup(this); | 530 | m_start_action = new QAction( tr( "Goto Start" ), geticon( "start" ), QString::null, 0, this, NULL); |
310 | ag->setExclusive(false); | 531 | connect( m_start_action, SIGNAL( activated() ), this, SLOT( gotoStart() ) ); |
311 | QPopupMenu *encoding = new QPopupMenu(this); | 532 | m_start_action->addTo(navigation); |
312 | file->insertItem( tr( "Navigation" ), encoding ); | ||
313 | 533 | ||
314 | a = m_scrollButton = new QAction( tr( "Scroll" ), Resource::loadPixmap( PICDIR "panel-arrow-down" ), QString::null, 0, ag, 0, true ); | 534 | m_end_action = new QAction( tr( "Goto End" ), geticon( "finish" ), QString::null, 0, this, NULL); |
535 | connect( m_end_action, SIGNAL( activated() ), this, SLOT( gotoEnd() ) ); | ||
536 | m_end_action->addTo(navigation); | ||
315 | 537 | ||
316 | a->setOn(false); | 538 | m_jump_action = new QAction( tr( "Jump" ), geticon( "rotate" ), QString::null, 0, this, NULL); |
317 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) ); | 539 | connect( m_jump_action, SIGNAL( activated() ), this, SLOT( jump() ) ); |
318 | a->addTo( bar ); | 540 | m_jump_action->addTo(navigation); |
319 | 541 | ||
320 | a = new QAction( tr( "Jump" ), QString::null, 0, ag, NULL); | 542 | m_pageline_action = new QAction( tr( "Page/Line Scroll" ), geticon( "pass" ), QString::null, 0, this, NULL, true ); |
321 | connect( a, SIGNAL( activated() ), this, SLOT( jump() ) ); | 543 | connect( m_pageline_action, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) ); |
544 | m_pageline_action->addTo(navigation); | ||
545 | m_pageline_action->setOn(reader->m_bpagemode); | ||
322 | 546 | ||
323 | a = new QAction( tr( "Page/Line Scroll" ), QString::null, 0, ag, NULL, true ); | 547 | m_pageup_action = new QAction( tr( "Up" ), geticon( "up" ), QString::null, 0, this, 0 ); |
324 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) ); | 548 | connect( m_pageup_action, SIGNAL( activated() ), this, SLOT( pageup() ) ); |
325 | a->setOn(reader->m_bpagemode); | 549 | m_pageup_action->addTo( navigation ); |
550 | |||
551 | m_pagedn_action = new QAction( tr( "Down" ), geticon( "down" ), QString::null, 0, this, 0 ); | ||
552 | connect( m_pagedn_action, SIGNAL( activated() ), this, SLOT( pagedn() ) ); | ||
553 | m_pagedn_action->addTo( navigation ); | ||
326 | 554 | ||
327 | a = new QAction( tr( "Set Overlap" ), QString::null, 0, ag, NULL); | 555 | m_back_action = new QAction( tr( "Back" ), geticon( "back" ), QString::null, 0, this, 0 ); |
328 | connect( a, SIGNAL( activated() ), this, SLOT( setoverlap() ) ); | 556 | connect( m_back_action, SIGNAL( activated() ), reader, SLOT( goBack() ) ); |
557 | m_back_action->addTo( navigation ); | ||
329 | 558 | ||
330 | a = new QAction( tr( "Use Cursor" ), QString::null, 0, ag, NULL, true ); | 559 | m_home_action = new QAction( tr( "Home" ), geticon( "home" ), QString::null, 0, this, 0 ); |
331 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( navkeys(bool) ) ); | 560 | connect( m_home_action, SIGNAL( activated() ), reader, SLOT( goHome() ) ); |
332 | a->setOn(reader->m_navkeys); | 561 | m_home_action->addTo( navigation ); |
333 | 562 | ||
334 | ag->addTo(encoding); | 563 | m_forward_action = new QAction( tr( "Forward" ), geticon( "forward" ), QString::null, 0, this, 0 ); |
564 | connect( m_forward_action, SIGNAL( activated() ), reader, SLOT( goForward() ) ); | ||
565 | m_forward_action->addTo( navigation ); | ||
335 | 566 | ||
336 | /* | 567 | /* |
@@ -344,34 +575,24 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
344 | */ | 575 | */ |
345 | 576 | ||
346 | file->insertSeparator(); | 577 | // file->insertSeparator(); |
347 | 578 | ||
348 | a = new QAction( tr( "Set Dictionary" ), QString::null, 0, this, NULL); | 579 | #ifdef _SCROLLPIPE |
349 | connect( a, SIGNAL( activated() ), this, SLOT( settarget() ) ); | ||
350 | a->addTo( file ); | ||
351 | 580 | ||
352 | a = new QAction( tr( "Two/One Touch" ), QString::null, 0, this, NULL, true ); | 581 | QActionGroup* ag = new QActionGroup(this); |
353 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( setTwoTouch(bool) ) ); | ||
354 | a->setOn(m_twoTouch); | ||
355 | a->addTo( file ); | ||
356 | |||
357 | ag = new QActionGroup(this); | ||
358 | ag->setExclusive(false); | 582 | ag->setExclusive(false); |
359 | encoding = new QPopupMenu(this); | 583 | spacemenu = new QPopupMenu(this); |
360 | file->insertItem( tr( "Target" ), encoding ); | 584 | file->insertItem( tr( "Scrolling" ), spacemenu ); |
361 | 585 | ||
362 | a = new QAction( tr( "Annotation" ), QString::null, 0, ag, NULL, true ); | 586 | a = new QAction( tr( "Set Target" ), QString::null, 0, ag, NULL); |
363 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnAnnotation(bool) ) ); | 587 | connect( a, SIGNAL( activated() ), this, SLOT( setpipetarget() ) ); |
364 | a->setOn(m_doAnnotation); | ||
365 | 588 | ||
366 | a = new QAction( tr( "Dictionary" ), QString::null, 0, ag, NULL, true ); | 589 | a = new QAction( tr( "Pause Paras" ), QString::null, 0, ag, NULL, true ); |
367 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnDictionary(bool) ) ); | 590 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( setpause(bool) ) ); |
368 | a->setOn(m_doDictionary); | 591 | a->setOn(reader->m_pauseAfterEachPara); |
369 | 592 | ||
370 | a = new QAction( tr( "Clipboard" ), QString::null, 0, ag, NULL, true ); | 593 | ag->addTo(spacemenu); |
371 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( OnClipboard(bool) ) ); | 594 | // file->insertSeparator(); |
372 | a->setOn(m_doClipboard); | ||
373 | |||
374 | ag->addTo(encoding); | ||
375 | 595 | ||
596 | #endif | ||
376 | 597 | ||
377 | /* | 598 | /* |
@@ -380,228 +601,117 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
380 | a->addTo( file ); | 601 | a->addTo( file ); |
381 | */ | 602 | */ |
382 | |||
383 | a = new QAction( tr( "Up" ), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); | ||
384 | connect( a, SIGNAL( activated() ), this, SLOT( pageup() ) ); | ||
385 | a->addTo( editBar ); | ||
386 | |||
387 | a = new QAction( tr( "Down" ), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); | ||
388 | connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); | ||
389 | a->addTo( editBar ); | ||
390 | 603 | ||
391 | /* | 604 | /* |
392 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 605 | a = new QAction( tr( "Paste" ), geticon( "paste" ), QString::null, 0, this, 0 ); |
393 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); | 606 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); |
394 | a->addTo( editBar ); | 607 | a->addTo( fileBar ); |
395 | a->addTo( edit ); | 608 | a->addTo( edit ); |
396 | */ | 609 | */ |
397 | 610 | ||
398 | // a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 611 | // a = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, 0 ); |
399 | a = new QAction( tr( "Find..." ), QString::null, 0, this, NULL); | ||
400 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); | ||
401 | file->insertSeparator(); | ||
402 | // a->addTo( bar ); | ||
403 | a->addTo( file ); | ||
404 | |||
405 | 612 | ||
406 | m_fullscreen = false; | 613 | m_fullscreen = false; |
407 | a = m_actFullscreen = new QAction( tr( "Fullscreen" ), QString::null, 0, this, NULL, true ); | 614 | m_actFullscreen = new QAction( tr( "Fullscreen" ), geticon( "fullscreen" ), QString::null, 0, this, NULL, true ); |
408 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( setfullscreen(bool) ) ); | 615 | connect( m_actFullscreen, SIGNAL( toggled(bool) ), this, SLOT( setfullscreen(bool) ) ); |
409 | a->setOn(m_fullscreen); | 616 | m_actFullscreen->setOn(m_fullscreen); |
410 | a->addTo( file ); | 617 | m_actFullscreen->addTo( view ); |
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 | |||
417 | a = m_bkmkAvail = new QAction( tr( "Annotation" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | ||
418 | connect( a, SIGNAL( activated() ), this, SLOT( showAnnotation() ) ); | ||
419 | a->addTo( bar ); | ||
420 | |||
421 | m_bkmkAvail->setEnabled(false); | ||
422 | 618 | ||
619 | view->insertSeparator(); | ||
423 | 620 | ||
424 | ag = new QActionGroup(this); | 621 | m_zoomin_action = new QAction( tr( "Zoom In" ), geticon( "zoom" ), QString::null, 0, this); |
425 | // ag->setExclusive(false); | 622 | connect( m_zoomin_action, SIGNAL( activated() ), this, SLOT( zoomin() ) ); |
426 | encoding = new QPopupMenu(this); | 623 | m_zoomin_action->addTo( view ); |
427 | format->insertItem( tr( "Markup" ), encoding ); | ||
428 | 624 | ||
429 | a = new QAction( tr( "Auto" ), QString::null, 0, ag, NULL, true ); | 625 | m_zoomout_action = new QAction( tr( "Zoom Out" ), geticon( "mag" ), QString::null, 0, this); |
430 | a->setOn(reader->bautofmt); | 626 | connect( m_zoomout_action, SIGNAL( activated() ), this, SLOT( zoomout() ) ); |
431 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( autofmt(bool) ) ); | 627 | m_zoomout_action->addTo( view ); |
432 | 628 | ||
433 | a = new QAction( tr( "None" ), QString::null, 0, ag, NULL, true ); | 629 | view->insertSeparator(); |
434 | a->setOn(!reader->bautofmt && !(reader->btextfmt || reader->bstriphtml || reader->bpeanut)); | 630 | m_setfont_action = new QAction( tr( "Set Font" ), getmyicon( "font" ), QString::null, 0, this); |
435 | // connect( a, SIGNAL( toggled(bool) ), this, SLOT( textfmt(bool) ) ); | 631 | connect( m_setfont_action, SIGNAL( activated() ), this, SLOT( setfont() ) ); |
632 | m_setfont_action->addTo( view ); | ||
436 | 633 | ||
437 | a = new QAction( tr( "Text" ), QString::null, 0, ag, NULL, true ); | 634 | view->insertSeparator(); |
438 | a->setOn(reader->btextfmt); | 635 | m_setenc_action = new QAction( tr( "Set Encoding" ), getmyicon( "charset" ), QString::null, 0, this); |
439 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( textfmt(bool) ) ); | 636 | connect( m_setenc_action, SIGNAL( activated() ), this, SLOT( chooseencoding() ) ); |
637 | m_setenc_action->addTo( view ); | ||
440 | 638 | ||
441 | a = new QAction( tr( "HTML" ), QString::null, 0, ag, NULL, true ); | 639 | m_setmono_action = new QAction( tr( "Ideogram" ), getmyicon( "ideogram" ), QString::null, 0, this, NULL, true); |
442 | a->setOn(reader->bstriphtml); | 640 | connect( m_setmono_action, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); |
443 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( striphtml(bool) ) ); | 641 | m_setmono_action->addTo( view ); |
642 | m_setmono_action->setOn(reader->m_bMonoSpaced); | ||
444 | 643 | ||
445 | a = new QAction( tr( "Peanut/PML" ), QString::null, 0, ag, NULL, true ); | ||
446 | a->setOn(reader->bpeanut); | ||
447 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( peanut(bool) ) ); | ||
448 | 644 | ||
449 | ag->addTo(encoding); | 645 | // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true ); |
450 | 646 | // a = new QAction( tr( "Zoom" ), geticon( "mag" ), QString::null, 0, this, 0 ); | |
451 | |||
452 | |||
453 | ag = new QActionGroup(this); | ||
454 | ag->setExclusive(false); | ||
455 | encoding = new QPopupMenu(this); | ||
456 | format->insertItem( tr( "Layout" ), encoding ); | ||
457 | |||
458 | a = new QAction( tr( "Strip CR" ), QString::null, 0, ag, NULL, true ); | ||
459 | a->setOn(reader->bstripcr); | ||
460 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( stripcr(bool) ) ); | ||
461 | |||
462 | a = new QAction( tr( "Dehyphen" ), QString::null, 0, ag, NULL, true ); | ||
463 | a->setOn(reader->bdehyphen); | ||
464 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( dehyphen(bool) ) ); | ||
465 | // a->addTo( format ); | ||
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 | |||
471 | a = new QAction( tr( "Unindent" ), QString::null, 0, ag, NULL, true ); | ||
472 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( unindent(bool) ) ); | ||
473 | a->setOn(reader->bunindent); | ||
474 | // a->addTo( format ); | ||
475 | |||
476 | a = new QAction( tr( "Re-paragraph" ), QString::null, 0, ag, NULL, true ); | ||
477 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( repara(bool) ) ); | ||
478 | a->setOn(reader->brepara); | ||
479 | // a->addTo( format ); | ||
480 | |||
481 | a = new QAction( tr( "Double Space" ), QString::null, 0, ag, NULL, true ); | ||
482 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( dblspce(bool) ) ); | ||
483 | a->setOn(reader->bdblspce); | ||
484 | // a->addTo( format ); | ||
485 | |||
486 | a = new QAction( tr( "Indent+" ), QString::null, 0, ag, NULL ); | ||
487 | connect( a, SIGNAL( activated() ), this, SLOT( indentplus() ) ); | ||
488 | // a->addTo( format ); | ||
489 | |||
490 | a = new QAction( tr( "Indent-" ), QString::null, 0, ag, NULL ); | ||
491 | connect( a, SIGNAL( activated() ), this, SLOT( indentminus() ) ); | ||
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 | ||
497 | a = new QAction( tr( "Remap" ), QString::null, 0, ag, NULL, true ); | ||
498 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( remap(bool) ) ); | ||
499 | a->setOn(reader->bremap); | ||
500 | |||
501 | a = new QAction( tr( "Embolden" ), QString::null, 0, ag, NULL, true ); | ||
502 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( embolden(bool) ) ); | ||
503 | a->setOn(reader->bmakebold); | ||
504 | 647 | ||
505 | ag->addTo(encoding); | ||
506 | 648 | ||
507 | // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true ); | ||
508 | // a = new QAction( tr( "Zoom" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); | ||
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() ) ); | ||
515 | a->addTo( format ); | ||
516 | // a->addTo( editBar ); | ||
517 | format->insertSeparator(); | ||
518 | 649 | ||
650 | // a->addTo( filebar() ); | ||
651 | // view->insertSeparator(); | ||
519 | 652 | ||
653 | /* | ||
520 | a = new QAction( tr( "Ideogram/Word" ), QString::null, 0, this, NULL, true ); | 654 | a = new QAction( tr( "Ideogram/Word" ), QString::null, 0, this, NULL, true ); |
521 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); | 655 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); |
522 | a->setOn(reader->m_bMonoSpaced); | 656 | a->setOn(reader->m_bMonoSpaced); |
523 | a->addTo( format ); | 657 | a->addTo( view ); |
524 | 658 | */ | |
525 | a = new QAction( tr( "Set width" ), QString::null, 0, this, NULL); | 659 | /* |
660 | a = new QAction( tr( "Set Width" ), QString::null, 0, this, NULL); | ||
526 | connect( a, SIGNAL( activated() ), this, SLOT( setspacing() ) ); | 661 | connect( a, SIGNAL( activated() ), this, SLOT( setspacing() ) ); |
527 | a->addTo( format ); | 662 | a->addTo( view ); |
528 | 663 | */ | |
529 | encoding = new QPopupMenu(this); | ||
530 | // format->insertSeparator(); | ||
531 | format->insertItem( tr( "Encoding" ), encoding ); | ||
532 | |||
533 | ag = new QActionGroup(this); | ||
534 | |||
535 | m_EncodingAction[0] = new QAction( tr( "Ascii" ), QString::null, 0, ag, NULL, true ); | ||
536 | |||
537 | m_EncodingAction[1] = new QAction( tr( "UTF-8" ), QString::null, 0, ag, NULL, true ); | ||
538 | |||
539 | m_EncodingAction[2] = new QAction( tr( "UCS-2(BE)" ), QString::null, 0, ag, NULL, true ); | ||
540 | |||
541 | m_EncodingAction[3] = new QAction( tr( "USC-2(LE)" ), QString::null, 0, ag, NULL, true ); | ||
542 | |||
543 | m_EncodingAction[4] = new QAction( tr( "Palm" ), QString::null, 0, ag, NULL, true ); | ||
544 | |||
545 | m_EncodingAction[5] = new QAction( tr( "Windows(1252)" ), QString::null, 0, ag, NULL, true ); | ||
546 | |||
547 | ag->addTo(encoding); | ||
548 | |||
549 | connect(ag, SIGNAL( selected(QAction*) ), this, SLOT( encodingSelected(QAction*) ) ); | ||
550 | |||
551 | a = new QAction( tr( "Set Font" ), QString::null, 0, this); | ||
552 | connect( a, SIGNAL( activated() ), this, SLOT( setfont() ) ); | ||
553 | format->insertSeparator(); | ||
554 | a->addTo( format ); | ||
555 | |||
556 | QPopupMenu *marks = new QPopupMenu( this ); | ||
557 | 664 | ||
558 | a = new QAction( tr( "Mark" ), QString::null, 0, this, NULL); | 665 | m_mark_action = new QAction( tr( "Bookmark" ), getmyicon( "bookmark" ), QString::null, 0, this, NULL); |
559 | connect( a, SIGNAL( activated() ), this, SLOT( addbkmk() ) ); | 666 | connect( m_mark_action, SIGNAL( activated() ), this, SLOT( addbkmk() ) ); |
560 | a->addTo( marks ); | 667 | m_mark_action->addTo( marks ); |
561 | 668 | ||
562 | a = new QAction( tr( "Annotate" ), QString::null, 0, this, NULL); | 669 | m_annotate_action = new QAction( tr( "Annotate" ), getmyicon( "annotate" ), QString::null, 0, this, NULL); |
563 | connect( a, SIGNAL( activated() ), this, SLOT( addanno() ) ); | 670 | connect( m_annotate_action, SIGNAL( activated() ), this, SLOT( addanno() ) ); |
564 | a->addTo( marks ); | 671 | m_annotate_action->addTo( marks ); |
565 | 672 | ||
566 | a = new QAction( tr( "Goto" ), QString::null, 0, this, NULL, false ); | 673 | m_goto_action = new QAction( tr( "Goto" ), getmyicon( "bookmark_goto" ), QString::null, 0, this, NULL, false ); |
567 | connect( a, SIGNAL( activated() ), this, SLOT( do_gotomark() ) ); | 674 | connect( m_goto_action, SIGNAL( activated() ), this, SLOT( do_gotomark() ) ); |
568 | a->addTo( marks ); | 675 | m_goto_action->addTo( marks ); |
569 | 676 | ||
570 | a = new QAction( tr( "Delete" ), QString::null, 0, this, NULL); | 677 | m_delete_action = new QAction( tr( "Delete" ), getmyicon( "bookmark_delete" ), QString::null, 0, this, NULL); |
571 | connect( a, SIGNAL( activated() ), this, SLOT( do_delmark() ) ); | 678 | connect( m_delete_action, SIGNAL( activated() ), this, SLOT( do_delmark() ) ); |
572 | a->addTo( marks ); | 679 | m_delete_action->addTo( marks ); |
573 | 680 | ||
574 | a = new QAction( tr( "Autogen" ), QString::null, 0, this, NULL, false ); | 681 | m_autogen_action = new QAction( tr( "Autogen" ), geticon( "exec" ), QString::null, 0, this, NULL, false ); |
575 | connect( a, SIGNAL( activated() ), this, SLOT( do_autogen() ) ); | 682 | connect( m_autogen_action, SIGNAL( activated() ), this, SLOT( do_autogen() ) ); |
576 | marks->insertSeparator(); | 683 | marks->insertSeparator(); |
577 | a->addTo( marks ); | 684 | m_autogen_action->addTo( marks ); |
578 | 685 | ||
579 | a = new QAction( tr( "Clear" ), QString::null, 0, this, NULL); | 686 | m_clear_action = new QAction( tr( "Clear" ), getmyicon( "bookmark_clear" ), QString::null, 0, this, NULL); |
580 | connect( a, SIGNAL( activated() ), this, SLOT( clearBkmkList() ) ); | 687 | connect( m_clear_action, SIGNAL( activated() ), this, SLOT( clearBkmkList() ) ); |
581 | a->addTo( marks ); | 688 | m_clear_action->addTo( marks ); |
582 | 689 | ||
583 | a = new QAction( tr( "Save" ), QString::null, 0, this, NULL ); | 690 | m_save_action = new QAction( tr( "Save" ), getmyicon( "bookmark_save" ), QString::null, 0, this, NULL ); |
584 | connect( a, SIGNAL( activated() ), this, SLOT( savebkmks() ) ); | 691 | connect( m_save_action, SIGNAL( activated() ), this, SLOT( savebkmks() ) ); |
585 | a->addTo( marks ); | 692 | m_save_action->addTo( marks ); |
586 | 693 | ||
587 | a = new QAction( tr( "Tidy" ), QString::null, 0, this, NULL); | 694 | m_tidy_action = new QAction( tr( "Tidy" ), getmyicon( "bookmark_tidy" ), QString::null, 0, this, NULL); |
588 | connect( a, SIGNAL( activated() ), this, SLOT( listBkmkFiles() ) ); | 695 | connect( m_tidy_action, SIGNAL( activated() ), this, SLOT( listBkmkFiles() ) ); |
589 | marks->insertSeparator(); | 696 | marks->insertSeparator(); |
590 | a->addTo( marks ); | 697 | m_tidy_action->addTo( marks ); |
591 | 698 | ||
592 | a = new QAction( tr( "Start Block" ), QString::null, 0, this, NULL); | 699 | m_startBlock_action = new QAction( tr( "Start Block" ), geticon( "new" ), QString::null, 0, this, NULL); |
593 | connect( a, SIGNAL( activated() ), this, SLOT( editMark() ) ); | 700 | connect( m_startBlock_action, SIGNAL( activated() ), this, SLOT( editMark() ) ); |
594 | marks->insertSeparator(); | 701 | marks->insertSeparator(); |
595 | a->addTo( marks ); | 702 | m_startBlock_action->addTo( marks ); |
703 | |||
704 | m_endBlock_action = new QAction( tr( "Copy Block" ), geticon( "copy" ), QString::null, 0, this, NULL); | ||
705 | connect( m_endBlock_action, SIGNAL( activated() ), this, SLOT( editCopy() ) ); | ||
706 | m_endBlock_action->addTo( marks ); | ||
596 | 707 | ||
597 | a = new QAction( tr( "Copy Block" ), QString::null, 0, this, NULL); | 708 | m_bkmkAvail = NULL; |
598 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); | ||
599 | a->addTo( marks ); | ||
600 | 709 | ||
601 | 710 | ||
602 | mb->insertItem( tr( "File" ), file ); | 711 | setToolBarsMovable(m_tbmove); |
603 | // mb->insertItem( tr( "Edit" ), edit ); | 712 | addtoolbars(&config); |
604 | mb->insertItem( tr( "Format" ), format ); | 713 | |
605 | mb->insertItem( tr( "Marks" ), marks ); | 714 | pbar = new QProgressBar(this); |
715 | pbar->hide(); | ||
606 | 716 | ||
607 | searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE ); | 717 | searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE ); |
@@ -616,4 +726,5 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
616 | searchBar->setStretchableWidget( searchEdit ); | 726 | searchBar->setStretchableWidget( searchEdit ); |
617 | 727 | ||
728 | |||
618 | #ifdef __ISEARCH | 729 | #ifdef __ISEARCH |
619 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 730 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
@@ -623,9 +734,9 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
623 | this, SLOT( search( ) ) ); | 734 | this, SLOT( search( ) ) ); |
624 | #endif | 735 | #endif |
625 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); | 736 | QAction*a = new QAction( tr( "Find Next" ), geticon( "next" ), QString::null, 0, this, 0 ); |
626 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); | 737 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); |
627 | a->addTo( searchBar ); | 738 | a->addTo( searchBar ); |
628 | 739 | ||
629 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 740 | a = new QAction( tr( "Close Find" ), geticon( "close" ), QString::null, 0, this, 0 ); |
630 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 741 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
631 | a->addTo( searchBar ); | 742 | a->addTo( searchBar ); |
@@ -646,9 +757,9 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
646 | this, SLOT( do_regaction() ) ); | 757 | this, SLOT( do_regaction() ) ); |
647 | 758 | ||
648 | a = new QAction( tr( "Do Reg" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); | 759 | a = new QAction( tr( "Do Reg" ), geticon( "enter" ), QString::null, 0, this, 0 ); |
649 | connect( a, SIGNAL( activated() ), this, SLOT( do_regaction() ) ); | 760 | connect( a, SIGNAL( activated() ), this, SLOT( do_regaction() ) ); |
650 | a->addTo( regBar ); | 761 | a->addTo( regBar ); |
651 | 762 | ||
652 | a = new QAction( tr( "Close Edit" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 763 | a = new QAction( tr( "Close Edit" ), geticon( "close" ), QString::null, 0, this, 0 ); |
653 | connect( a, SIGNAL( activated() ), this, SLOT( regClose() ) ); | 764 | connect( a, SIGNAL( activated() ), this, SLOT( regClose() ) ); |
654 | a->addTo( regBar ); | 765 | a->addTo( regBar ); |
@@ -660,12 +771,14 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
660 | m_fontBar->setHorizontalStretchable( TRUE ); | 771 | m_fontBar->setHorizontalStretchable( TRUE ); |
661 | 772 | ||
662 | qDebug("Font selector"); | 773 | // qDebug("Font selector"); |
663 | m_fontSelector = new QComboBox(false, m_fontBar); | 774 | m_fontSelector = new QComboBox(false, m_fontBar); |
664 | m_fontBar->setStretchableWidget( m_fontSelector ); | 775 | m_fontBar->setStretchableWidget( m_fontSelector ); |
665 | { | 776 | { |
777 | #ifndef USEQPE | ||
778 | QFontDatabase f; | ||
779 | #else | ||
666 | FontDatabase f; | 780 | FontDatabase f; |
781 | #endif | ||
667 | QStringList flist = f.families(); | 782 | QStringList flist = f.families(); |
668 | m_fontSelector->insertStringList(flist); | ||
669 | |||
670 | bool realfont = false; | 783 | bool realfont = false; |
671 | for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) | 784 | for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) |
@@ -675,30 +788,30 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
675 | realfont = true; | 788 | realfont = true; |
676 | } | 789 | } |
677 | if (*nm == "courier") reader->m_fontControl.hasCourier(true); | 790 | if ((*nm).contains(FIXEDFONT,false)) reader->m_fontControl.hasCourier(true, *nm); |
678 | } | 791 | } |
679 | if (!realfont) reader->m_fontname = flist[0]; | 792 | if (!realfont) reader->m_fontname = flist[0]; |
680 | } // delete the FontDatabase!!! | 793 | } // delete the FontDatabase!!! |
681 | |||
682 | connect( m_fontSelector, SIGNAL( activated(const QString& ) ), | 794 | connect( m_fontSelector, SIGNAL( activated(const QString& ) ), |
683 | this, SLOT( do_setfont(const QString&) ) ); | 795 | this, SLOT( do_setfont(const QString&) ) ); |
796 | connect( m_fontSelector, SIGNAL( activated(int ) ), | ||
797 | this, SLOT( do_setencoding(int) ) ); | ||
684 | 798 | ||
685 | m_fontBar->hide(); | 799 | m_fontBar->hide(); |
686 | m_fontVisible = false; | 800 | m_fontVisible = false; |
687 | 801 | #ifdef USEMSGS | |
688 | connect(qApp, SIGNAL( appMessage(const QCString&, const QByteArray& ) ), | 802 | connect(qApp, SIGNAL( appMessage(const QCString&, const QByteArray& ) ), |
689 | this, SLOT( msgHandler(const QCString&, const QByteArray&) ) ); | 803 | this, SLOT( msgHandler(const QCString&, const QByteArray&) ) ); |
690 | 804 | #endif | |
691 | qDebug("Initing"); | 805 | // qDebug("Initing"); |
692 | reader->init(); | 806 | reader->init(); |
693 | qDebug("Inited"); | 807 | // qDebug("Inited"); |
694 | m_EncodingAction[reader->m_encd]->setOn(true); | 808 | // m_buttonAction[m_spaceTarget]->setOn(true); |
695 | m_buttonAction[m_spaceTarget]->setOn(true); | 809 | // qDebug("fonting"); |
696 | qDebug("fonting"); | ||
697 | do_setfont(reader->m_fontname); | 810 | do_setfont(reader->m_fontname); |
698 | if (!reader->m_lastfile.isEmpty()) | 811 | if (!reader->m_lastfile.isEmpty()) |
699 | { | 812 | { |
700 | qDebug("doclnk"); | 813 | //qDebug("doclnk"); |
701 | //doc = new DocLnk(reader->m_lastfile); | 814 | //doc = new DocLnk(reader->m_lastfile); |
702 | qDebug("doclnk done"); | 815 | //qDebug("doclnk done"); |
703 | if (pOpenlist != NULL) | 816 | if (pOpenlist != NULL) |
704 | { | 817 | { |
@@ -720,15 +833,16 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
720 | break; | 833 | break; |
721 | } | 834 | } |
722 | qDebug("Item:%s", (const char*)toQString(CFiledata(p->anno()).name())); | 835 | // qDebug("Item:%s", (const char*)toQString(CFiledata(p->anno()).name())); |
723 | p = NULL; | 836 | p = NULL; |
724 | } | 837 | } |
725 | if (p != NULL) | 838 | if (p != NULL) |
726 | { | 839 | { |
727 | qDebug("openfrombkmk"); | 840 | //qDebug("openfrombkmk"); |
728 | openfrombkmk(p); | 841 | if (!openfrombkmk(p)) |
842 | showEditTools(); | ||
729 | } | 843 | } |
730 | else | 844 | else |
731 | { | 845 | { |
732 | qDebug("openfile"); | 846 | //qDebug("openfile"); |
733 | openFile( reader->m_lastfile ); | 847 | openFile( reader->m_lastfile ); |
734 | } | 848 | } |
@@ -736,22 +850,284 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
736 | else | 850 | else |
737 | { | 851 | { |
738 | qDebug("Openfile 2"); | 852 | // qDebug("Openfile 2"); |
739 | if (!reader->m_lastfile.isNull()) | 853 | if (!reader->m_lastfile.isEmpty()) |
740 | openFile( reader->m_lastfile ); | 854 | openFile( reader->m_lastfile ); |
741 | } | 855 | } |
742 | } | 856 | } |
743 | qApp->processEvents(); | 857 | else |
858 | { | ||
859 | showEditTools(); | ||
860 | } | ||
861 | // qApp->processEvents(); | ||
744 | reader->bDoUpdates = true; | 862 | reader->bDoUpdates = true; |
745 | reader->update(); | 863 | reader->update(); |
746 | qDebug("finished update"); | 864 | config.setGroup("Version"); |
865 | int major = config.readNumEntry("Major", 0); | ||
866 | int bkmktype = config.readNumEntry("BkmkType", 0); | ||
867 | char minor = config.readNumEntry("Minor", 0); | ||
868 | if (CheckVersion(major, bkmktype, minor)) | ||
869 | { | ||
870 | config.writeEntry("Major", major); | ||
871 | config.writeEntry("BkmkType", bkmktype); | ||
872 | config.writeEntry("Minor", (int)minor); | ||
873 | } | ||
874 | // qDebug("finished update"); | ||
875 | } | ||
876 | |||
877 | void QTReaderApp::addtoolbars(Config* config) | ||
878 | { | ||
879 | config->setGroup("Toolbar"); | ||
880 | |||
881 | if (fileBar != NULL) | ||
882 | { | ||
883 | if (fileBar != menubar) | ||
884 | { | ||
885 | fileBar->clear(); | ||
886 | } | ||
887 | else | ||
888 | { | ||
889 | m_preferences_action->removeFrom( filebar() ); | ||
890 | m_open_action->removeFrom( filebar() ); | ||
891 | m_close_action->removeFrom( filebar() ); | ||
892 | m_info_action->removeFrom( filebar() ); | ||
893 | m_touch_action->removeFrom( filebar() ); | ||
894 | m_find_action->removeFrom( filebar() ); | ||
895 | } | ||
896 | } | ||
897 | |||
898 | m_preferences_action->addTo( filebar() ); | ||
899 | addfilebar(config, "Open", m_open_action); | ||
900 | addfilebar(config, "Close", m_close_action); | ||
901 | addfilebar(config, "Info", m_info_action); | ||
902 | addfilebar(config, "Two/One Touch", m_touch_action); | ||
903 | addfilebar(config, "Find", m_find_action); | ||
904 | |||
905 | if (navBar != NULL) | ||
906 | { | ||
907 | if ((navBar == fileBar) && (fileBar == menubar)) | ||
908 | { | ||
909 | m_scrollButton->removeFrom( navbar() ); | ||
910 | m_start_action->removeFrom( navbar() ); | ||
911 | m_end_action->removeFrom( navbar() ); | ||
912 | m_jump_action->removeFrom( navbar() ); | ||
913 | m_pageline_action->removeFrom( navbar() ); | ||
914 | m_pageup_action->removeFrom( navbar() ); | ||
915 | m_pagedn_action->removeFrom( navbar() ); | ||
916 | m_back_action->removeFrom( navbar() ); | ||
917 | m_home_action->removeFrom( navbar() ); | ||
918 | m_forward_action->removeFrom( navbar() ); | ||
919 | } | ||
920 | else if (navBar != fileBar) | ||
921 | { | ||
922 | navBar->clear(); | ||
923 | } | ||
924 | } | ||
925 | |||
926 | addnavbar(config, "Scroll", m_scrollButton); | ||
927 | addnavbar(config, "Goto Start", m_start_action); | ||
928 | addnavbar(config, "Goto End", m_end_action); | ||
929 | |||
930 | addnavbar(config, "Jump", m_jump_action); | ||
931 | addnavbar(config, "Page/Line Scroll", m_pageline_action); | ||
932 | |||
933 | addnavbar(config, "Page Up", m_pageup_action); | ||
934 | addnavbar(config, "Page Down", m_pagedn_action); | ||
935 | |||
936 | addnavbar(config, "Back", m_back_action); | ||
937 | addnavbar(config, "Home", m_home_action); | ||
938 | addnavbar(config, "Forward", m_forward_action); | ||
939 | |||
940 | if (viewBar != NULL) | ||
941 | { | ||
942 | if ((viewBar == fileBar) && (fileBar == menubar)) | ||
943 | { | ||
944 | m_actFullscreen->removeFrom( filebar() ); | ||
945 | m_zoomin_action->removeFrom( viewbar() ); | ||
946 | m_zoomout_action->removeFrom( viewbar() ); | ||
947 | m_setfont_action->removeFrom( viewbar() ); | ||
948 | m_setenc_action->removeFrom( viewbar() ); | ||
949 | m_setmono_action->removeFrom( viewbar() ); | ||
950 | } | ||
951 | else if (viewBar != fileBar) | ||
952 | { | ||
953 | viewBar->clear(); | ||
954 | } | ||
955 | } | ||
956 | |||
957 | addviewbar(config, "Fullscreen", m_actFullscreen); | ||
958 | addviewbar(config, "Zoom In", m_zoomin_action); | ||
959 | addviewbar(config, "Zoom Out", m_zoomout_action); | ||
960 | addviewbar(config, "Set Font", m_setfont_action); | ||
961 | addviewbar(config, "Encoding Select", m_setenc_action); | ||
962 | addviewbar(config, "Ideogram Mode", m_setmono_action); | ||
963 | |||
964 | if (markBar != NULL) | ||
965 | { | ||
966 | if ((markBar == fileBar) && (fileBar == menubar)) | ||
967 | { | ||
968 | m_mark_action->removeFrom( markbar() ); | ||
969 | m_annotate_action->removeFrom( markbar()); | ||
970 | m_goto_action->removeFrom( markbar() ); | ||
971 | m_delete_action->removeFrom( markbar() ); | ||
972 | m_autogen_action->removeFrom( markbar() ); | ||
973 | m_clear_action->removeFrom( markbar() ); | ||
974 | m_save_action->removeFrom( markbar() ); | ||
975 | m_tidy_action->removeFrom( markbar() ); | ||
976 | m_startBlock_action->removeFrom( markbar() ); | ||
977 | m_endBlock_action->removeFrom( markbar() ); | ||
978 | } | ||
979 | else if (markBar != fileBar) | ||
980 | { | ||
981 | markBar->clear(); | ||
982 | } | ||
983 | } | ||
984 | addmarkbar(config, "Mark", m_mark_action); | ||
985 | addmarkbar(config, "Annotate", m_annotate_action); | ||
986 | addmarkbar(config, "Goto", m_goto_action); | ||
987 | addmarkbar(config, "Delete", m_delete_action); | ||
988 | addmarkbar(config, "Autogen", m_autogen_action); | ||
989 | addmarkbar(config, "Clear", m_clear_action); | ||
990 | addmarkbar(config, "Save", m_save_action); | ||
991 | addmarkbar(config, "Tidy", m_tidy_action); | ||
992 | addmarkbar(config, "Start Block", m_startBlock_action); | ||
993 | addmarkbar(config, "Copy Block", m_endBlock_action); | ||
994 | if (checkbar(config, "Annotation indicator")) | ||
995 | { | ||
996 | if (m_bkmkAvail == NULL) | ||
997 | { | ||
998 | m_bkmkAvail = new QAction( tr( "Annotation" ), geticon( "find" ), QString::null, 0, this, 0 ); | ||
999 | connect( m_bkmkAvail, SIGNAL( activated() ), this, SLOT( showAnnotation() ) ); | ||
1000 | |||
1001 | m_bkmkAvail->setEnabled(false); | ||
1002 | } | ||
1003 | QLabel *spacer = new QLabel(markBar, ""); | ||
1004 | markbar()->setStretchableWidget(spacer); | ||
1005 | m_bkmkAvail->removeFrom( markbar() ); | ||
1006 | m_bkmkAvail->addTo( markbar() ); | ||
1007 | } | ||
1008 | else | ||
1009 | { | ||
1010 | if (m_bkmkAvail != NULL) | ||
1011 | { | ||
1012 | m_bkmkAvail->removeFrom( markbar() ); | ||
1013 | delete m_bkmkAvail; | ||
1014 | m_bkmkAvail = NULL; | ||
1015 | } | ||
1016 | } | ||
1017 | } | ||
1018 | |||
1019 | bool QTReaderApp::checkbar(Config* _config, const QString& key) | ||
1020 | { | ||
1021 | return _config->readBoolEntry(key, false); | ||
1022 | } | ||
1023 | |||
1024 | |||
1025 | QToolBar* QTReaderApp::filebar() | ||
1026 | { | ||
1027 | if (fileBar == NULL) | ||
1028 | { | ||
1029 | switch (m_tbpol) | ||
1030 | { | ||
1031 | case cesSingle: | ||
1032 | // qDebug("Setting filebar to menubar"); | ||
1033 | fileBar = menubar; | ||
1034 | break; | ||
1035 | default: | ||
1036 | qDebug("Incorrect toolbar policy set"); | ||
1037 | case cesMenuTool: | ||
1038 | case cesMultiple: | ||
1039 | // qDebug("Creating new file bar"); | ||
1040 | fileBar = new QToolBar("File", this, m_tbposition); | ||
1041 | break; | ||
1042 | } | ||
1043 | //fileBar->setHorizontalStretchable( true ); | ||
1044 | } | ||
1045 | return fileBar; | ||
1046 | } | ||
1047 | QToolBar* QTReaderApp::viewbar() | ||
1048 | { | ||
1049 | if (viewBar == NULL) | ||
1050 | { | ||
1051 | switch (m_tbpol) | ||
1052 | { | ||
1053 | case cesMultiple: | ||
1054 | viewBar = new QToolBar("View", this, m_tbposition); | ||
1055 | break; | ||
1056 | default: | ||
1057 | qDebug("Incorrect toolbar policy set"); | ||
1058 | case cesSingle: | ||
1059 | case cesMenuTool: | ||
1060 | viewBar = fileBar; | ||
1061 | break; | ||
1062 | } | ||
1063 | } | ||
1064 | return viewBar; | ||
1065 | } | ||
1066 | QToolBar* QTReaderApp::navbar() | ||
1067 | { | ||
1068 | if (navBar == NULL) | ||
1069 | { | ||
1070 | switch (m_tbpol) | ||
1071 | { | ||
1072 | case cesMultiple: | ||
1073 | // qDebug("Creating new nav bar"); | ||
1074 | navBar = new QToolBar("Navigation", this, m_tbposition); | ||
1075 | break; | ||
1076 | default: | ||
1077 | qDebug("Incorrect toolbar policy set"); | ||
1078 | case cesSingle: | ||
1079 | case cesMenuTool: | ||
1080 | navBar = fileBar; | ||
1081 | // qDebug("Setting navbar to filebar"); | ||
1082 | break; | ||
1083 | } | ||
1084 | } | ||
1085 | return navBar; | ||
1086 | } | ||
1087 | QToolBar* QTReaderApp::markbar() | ||
1088 | { | ||
1089 | if (markBar == NULL) | ||
1090 | { | ||
1091 | switch (m_tbpol) | ||
1092 | { | ||
1093 | case cesMultiple: | ||
1094 | markBar = new QToolBar("Marks", this, m_tbposition); | ||
1095 | break; | ||
1096 | default: | ||
1097 | qDebug("Incorrect toolbar policy set"); | ||
1098 | case cesSingle: | ||
1099 | case cesMenuTool: | ||
1100 | markBar = fileBar; | ||
1101 | break; | ||
1102 | } | ||
1103 | } | ||
1104 | return markBar; | ||
1105 | } | ||
1106 | |||
1107 | void QTReaderApp::addfilebar(Config* _config, const QString& key, QAction* a) | ||
1108 | { | ||
1109 | if (_config->readBoolEntry(key, false)) a->addTo( filebar() ); | ||
1110 | } | ||
1111 | void QTReaderApp::addnavbar(Config* _config, const QString& key, QAction* a) | ||
1112 | { | ||
1113 | if (_config->readBoolEntry(key, false)) a->addTo( navbar() ); | ||
1114 | } | ||
1115 | void QTReaderApp::addmarkbar(Config* _config, const QString& key, QAction* a) | ||
1116 | { | ||
1117 | if (_config->readBoolEntry(key, false)) a->addTo( markbar() ); | ||
1118 | } | ||
1119 | void QTReaderApp::addviewbar(Config* _config, const QString& key, QAction* a) | ||
1120 | { | ||
1121 | if (_config->readBoolEntry(key, false)) a->addTo( viewbar() ); | ||
747 | } | 1122 | } |
748 | 1123 | ||
749 | void QTReaderApp::suspend() { reader->suspend(); } | 1124 | void QTReaderApp::suspend() { reader->suspend(); } |
750 | 1125 | ||
1126 | #ifdef USEMSGS | ||
751 | void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | 1127 | void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) |
752 | { | 1128 | { |
753 | QString msg = QString::fromUtf8(_msg); | 1129 | QString msg = QString::fromUtf8(_msg); |
754 | 1130 | ||
755 | // qDebug("Received:%s", (const char*)msg); | 1131 | //// qDebug("Received:%s", (const char*)msg); |
756 | 1132 | ||
757 | QDataStream stream( _data, IO_ReadOnly ); | 1133 | QDataStream stream( _data, IO_ReadOnly ); |
@@ -762,4 +1138,18 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
762 | QMessageBox::information(this, PROGNAME, info); | 1138 | QMessageBox::information(this, PROGNAME, info); |
763 | } | 1139 | } |
1140 | else if ( msg == "Update(int)" ) | ||
1141 | { | ||
1142 | int info; | ||
1143 | stream >> info; | ||
1144 | if (info) | ||
1145 | { | ||
1146 | reader->bDoUpdates = true; | ||
1147 | reader->refresh(); | ||
1148 | } | ||
1149 | else | ||
1150 | { | ||
1151 | reader->bDoUpdates = false; | ||
1152 | } | ||
1153 | } | ||
764 | else if ( msg == "warn(QString)" ) | 1154 | else if ( msg == "warn(QString)" ) |
765 | { | 1155 | { |
@@ -768,6 +1158,4 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
768 | QMessageBox::warning(this, PROGNAME, info); | 1158 | QMessageBox::warning(this, PROGNAME, info); |
769 | } | 1159 | } |
770 | |||
771 | |||
772 | else if ( msg == "exit()" ) | 1160 | else if ( msg == "exit()" ) |
773 | { | 1161 | { |
@@ -795,4 +1183,16 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
795 | showEditTools(); | 1183 | showEditTools(); |
796 | } | 1184 | } |
1185 | else if ( msg == "home()" ) | ||
1186 | { | ||
1187 | reader->goHome(); | ||
1188 | } | ||
1189 | else if ( msg == "back()" ) | ||
1190 | { | ||
1191 | reader->goBack(); | ||
1192 | } | ||
1193 | else if ( msg == "forward()" ) | ||
1194 | { | ||
1195 | reader->goForward(); | ||
1196 | } | ||
797 | else if ( msg == "File/Open(QString)" ) | 1197 | else if ( msg == "File/Open(QString)" ) |
798 | { | 1198 | { |
@@ -805,13 +1205,11 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
805 | showinfo(); | 1205 | showinfo(); |
806 | } | 1206 | } |
807 | else if ( msg == "File/Start Block()" ) | 1207 | else if ( msg == "File/Action(QString)" ) |
808 | { | ||
809 | editMark(); | ||
810 | } | ||
811 | else if ( msg == "File/Copy Block()" ) | ||
812 | { | 1208 | { |
813 | editCopy(); | 1209 | QString info; |
1210 | stream >> info; | ||
1211 | m_spaceTarget = ActNameToInt(info); | ||
814 | } | 1212 | } |
815 | else if ( msg == "File/Scroll(int)" ) | 1213 | else if ( msg == "Navigation/Scroll(int)" ) |
816 | { | 1214 | { |
817 | int info; | 1215 | int info; |
@@ -819,5 +1217,14 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
819 | autoScroll(info); | 1217 | autoScroll(info); |
820 | } | 1218 | } |
821 | else if ( msg == "File/Jump(int)" ) | 1219 | |
1220 | else if ( msg == "Navigation/GotoStart()" ) | ||
1221 | { | ||
1222 | gotoStart(); | ||
1223 | } | ||
1224 | else if ( msg == "Navigation/GotoEnd()" ) | ||
1225 | { | ||
1226 | gotoEnd(); | ||
1227 | } | ||
1228 | else if ( msg == "Navigation/Jump(int)" ) | ||
822 | { | 1229 | { |
823 | int info; | 1230 | int info; |
@@ -825,5 +1232,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
825 | reader->locate(info); | 1232 | reader->locate(info); |
826 | } | 1233 | } |
827 | else if ( msg == "File/Page/Line Scroll(int)" ) | 1234 | else if ( msg == "Navigation/Page/LineScroll(int)" ) |
828 | { | 1235 | { |
829 | int info; | 1236 | int info; |
@@ -831,5 +1238,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
831 | pagemode(info); | 1238 | pagemode(info); |
832 | } | 1239 | } |
833 | else if ( msg == "File/Set Overlap(int)" ) | 1240 | else if ( msg == "Navigation/SetOverlap(int)" ) |
834 | { | 1241 | { |
835 | int info; | 1242 | int info; |
@@ -837,5 +1244,11 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
837 | reader->m_overlap = info; | 1244 | reader->m_overlap = info; |
838 | } | 1245 | } |
839 | else if ( msg == "File/Set Dictionary(QString)" ) | 1246 | else if ( msg == "Navigation/SetMargin(int)" ) |
1247 | { | ||
1248 | int info; | ||
1249 | stream >> info; | ||
1250 | do_margin(info); | ||
1251 | } | ||
1252 | else if ( msg == "File/SetDictionary(QString)" ) | ||
840 | { | 1253 | { |
841 | QString info; | 1254 | QString info; |
@@ -843,5 +1256,13 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
843 | do_settarget(info); | 1256 | do_settarget(info); |
844 | } | 1257 | } |
845 | else if ( msg == "File/Two/One Touch(int)" ) | 1258 | #ifdef _SCROLLPIPE |
1259 | else if ( msg == "File/SetScrollTarget(QString)" ) | ||
1260 | { | ||
1261 | QString info; | ||
1262 | stream >> info; | ||
1263 | reader->m_pipetarget = info; | ||
1264 | } | ||
1265 | #endif | ||
1266 | else if ( msg == "File/Two/OneTouch(int)" ) | ||
846 | { | 1267 | { |
847 | int info; | 1268 | int info; |
@@ -875,9 +1296,9 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
875 | size_t start = pos; | 1296 | size_t start = pos; |
876 | CDrawBuffer test(&(reader->m_fontControl)); | 1297 | CDrawBuffer test(&(reader->m_fontControl)); |
877 | reader->buffdoc.getline(&test,reader->width()); | 1298 | reader->getline(&test); |
878 | while (arg.match(toQString(test.data())) == -1) | 1299 | while (arg.match(toQString(test.data())) == -1) |
879 | { | 1300 | { |
880 | pos = reader->locate(); | 1301 | pos = reader->locate(); |
881 | if (!reader->buffdoc.getline(&test,reader->width())) | 1302 | if (!reader->getline(&test)) |
882 | { | 1303 | { |
883 | QMessageBox::information(this, PROGNAME, QString("Can't find\n")+info); | 1304 | QMessageBox::information(this, PROGNAME, QString("Can't find\n")+info); |
@@ -888,54 +1309,82 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
888 | reader->locate(pos); | 1309 | reader->locate(pos); |
889 | } | 1310 | } |
890 | else if ( msg == "Layout/Strip CR(int)" ) | 1311 | else if ( msg == "File/Fullscreen(int)" ) |
891 | { | 1312 | { |
892 | int info; | 1313 | int info; |
893 | stream >> info; | 1314 | stream >> info; |
894 | stripcr(info); | 1315 | setfullscreen(info); |
895 | } | 1316 | } |
896 | else if ( msg == "Layout/Single Space" ) | 1317 | else if ( msg == "File/Continuous(int)" ) |
897 | { | 1318 | { |
898 | int info; | 1319 | int info; |
899 | stream >> info; | 1320 | stream >> info; |
900 | onespace(info); | 1321 | setcontinuous(info); |
901 | } | 1322 | } |
902 | #ifdef REPALM | 1323 | else if ( msg == "Markup(QString)" ) |
903 | else if ( msg == "Layout/Repalm(int)" ) | 1324 | { |
1325 | QString info; | ||
1326 | stream >> info; | ||
1327 | if (info == "Auto") | ||
1328 | { | ||
1329 | autofmt(true); | ||
1330 | } | ||
1331 | if (info == "None") | ||
1332 | { | ||
1333 | autofmt(false); | ||
1334 | textfmt(false); | ||
1335 | striphtml(false); | ||
1336 | peanut(false); | ||
1337 | } | ||
1338 | if (info == "Text") | ||
1339 | { | ||
1340 | textfmt(true); | ||
1341 | } | ||
1342 | if (info == "HTML") | ||
1343 | { | ||
1344 | striphtml(true); | ||
1345 | } | ||
1346 | if (info == "Peanut/PML") | ||
1347 | { | ||
1348 | peanut(true); | ||
1349 | } | ||
1350 | } | ||
1351 | else if ( msg == "Layout/StripCR(int)" ) | ||
904 | { | 1352 | { |
905 | int info; | 1353 | int info; |
906 | stream >> info; | 1354 | stream >> info; |
907 | repalm(info); | 1355 | stripcr(info); |
908 | } | 1356 | } |
909 | #endif | 1357 | else if ( msg == "Layout/Dehyphen(int)" ) |
910 | else if ( msg == "Markup/Auto(int)" ) | ||
911 | { | 1358 | { |
912 | int info; | 1359 | int info; |
913 | stream >> info; | 1360 | stream >> info; |
914 | autofmt(info); | 1361 | dehyphen(info); |
915 | } | 1362 | } |
916 | else if ( msg == "Markup/Text(int)" ) | 1363 | else if ( msg == "Layout/Depluck(int)" ) |
917 | { | 1364 | { |
918 | int info; | 1365 | int info; |
919 | stream >> info; | 1366 | stream >> info; |
920 | textfmt(info); | 1367 | depluck(info); |
921 | } | 1368 | } |
922 | else if ( msg == "Markup/HTML(int)" ) | 1369 | else if ( msg == "Layout/Dejpluck(int)" ) |
923 | { | 1370 | { |
924 | int info; | 1371 | int info; |
925 | stream >> info; | 1372 | stream >> info; |
926 | striphtml(info); | 1373 | dejpluck(info); |
927 | } | 1374 | } |
928 | else if ( msg == "Markup/Peanut(int)" ) | 1375 | else if ( msg == "Layout/SingleSpace(int)" ) |
929 | { | 1376 | { |
930 | int info; | 1377 | int info; |
931 | stream >> info; | 1378 | stream >> info; |
932 | peanut(info); | 1379 | onespace(info); |
933 | } | 1380 | } |
934 | else if ( msg == "Layout/Dehyphen(int)" ) | 1381 | #ifdef REPALM |
1382 | else if ( msg == "Layout/Repalm(int)" ) | ||
935 | { | 1383 | { |
936 | int info; | 1384 | int info; |
937 | stream >> info; | 1385 | stream >> info; |
938 | dehyphen(info); | 1386 | repalm(info); |
939 | } | 1387 | } |
1388 | #endif | ||
940 | else if ( msg == "Layout/Unindent(int)" ) | 1389 | else if ( msg == "Layout/Unindent(int)" ) |
941 | { | 1390 | { |
@@ -950,5 +1399,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
950 | repara(info); | 1399 | repara(info); |
951 | } | 1400 | } |
952 | else if ( msg == "Layout/Double Space(int)" ) | 1401 | else if ( msg == "Layout/DoubleSpace(int)" ) |
953 | { | 1402 | { |
954 | int info; | 1403 | int info; |
@@ -981,5 +1430,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
981 | monospace(info); | 1430 | monospace(info); |
982 | } | 1431 | } |
983 | else if ( msg == "Format/Set width(int)" ) | 1432 | else if ( msg == "Format/SetWidth(int)" ) |
984 | { | 1433 | { |
985 | int info; | 1434 | int info; |
@@ -989,11 +1438,5 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
989 | reader->refresh(); | 1438 | reader->refresh(); |
990 | } | 1439 | } |
991 | else if ( msg == "Format/Encoding(QString)" ) | 1440 | else if ( msg == "Format/SetFont(QString,int)" ) |
992 | { | ||
993 | QString info; | ||
994 | stream >> info; | ||
995 | reader->setencoding(EncNameToInt(info)); | ||
996 | } | ||
997 | else if ( msg == "Format/Set Font(QString,int)" ) | ||
998 | { | 1441 | { |
999 | QString fontname; | 1442 | QString fontname; |
@@ -1009,6 +1452,14 @@ void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | |||
1009 | do_autogen(info); | 1452 | do_autogen(info); |
1010 | } | 1453 | } |
1454 | else if ( msg == "File/StartBlock()" ) | ||
1455 | { | ||
1456 | editMark(); | ||
1457 | } | ||
1458 | else if ( msg == "File/CopyBlock()" ) | ||
1459 | { | ||
1460 | editCopy(); | ||
1461 | } | ||
1011 | } | 1462 | } |
1012 | 1463 | #endif | |
1013 | ActionTypes QTReaderApp::ActNameToInt(const QString& _enc) | 1464 | ActionTypes QTReaderApp::ActNameToInt(const QString& _enc) |
1014 | { | 1465 | { |
@@ -1025,39 +1476,12 @@ void QTReaderApp::setfullscreen(bool sfs) | |||
1025 | m_fullscreen = sfs; | 1476 | m_fullscreen = sfs; |
1026 | showEditTools(); | 1477 | showEditTools(); |
1027 | qApp->processEvents(); | 1478 | // qApp->processEvents(); |
1028 | reader->bDoUpdates = true; | 1479 | reader->bDoUpdates = true; |
1029 | reader->update(); | 1480 | reader->update(); |
1030 | } | 1481 | } |
1031 | 1482 | ||
1032 | void QTReaderApp::setcontinuous(bool sfs) | ||
1033 | { | ||
1034 | reader->setContinuous(sfs); | ||
1035 | reader->refresh(); | ||
1036 | } | ||
1037 | |||
1038 | int QTReaderApp::EncNameToInt(const QString& _enc) | ||
1039 | { | ||
1040 | for (int i = 0; i < MAX_ENCODING; i++) | ||
1041 | { | ||
1042 | if (m_EncodingAction[i]->text() == _enc) return i; | ||
1043 | } | ||
1044 | return 0; | ||
1045 | /* | ||
1046 | if (_enc == "Ascii") return 0; | ||
1047 | if (_enc == "UTF-8") return 1; | ||
1048 | if (_enc == "UCS-2(BE)") return 2; | ||
1049 | if (_enc == "USC-2(LE)") return 3; | ||
1050 | */ | ||
1051 | } | ||
1052 | |||
1053 | void QTReaderApp::encodingSelected(QAction* _a) | ||
1054 | { | ||
1055 | // qDebug("es:%x : %s", _a, (const char *)(_a->text())); | ||
1056 | reader->setencoding(EncNameToInt(_a->text())); | ||
1057 | } | ||
1058 | |||
1059 | void QTReaderApp::buttonActionSelected(QAction* _a) | 1483 | void QTReaderApp::buttonActionSelected(QAction* _a) |
1060 | { | 1484 | { |
1061 | // qDebug("es:%x : %s (%u)", _a, (const char *)(_a->text()), ActNameToInt(_a->text())); | 1485 | //// qDebug("es:%x : %s (%u)", _a, (const char *)(_a->text()), ActNameToInt(_a->text())); |
1062 | m_spaceTarget = ActNameToInt(_a->text()); | 1486 | m_spaceTarget = ActNameToInt(_a->text()); |
1063 | } | 1487 | } |
@@ -1092,35 +1516,54 @@ void QTReaderApp::clearBkmkList() | |||
1092 | void QTReaderApp::fileClose() | 1516 | void QTReaderApp::fileClose() |
1093 | { | 1517 | { |
1094 | if (pOpenlist != NULL) | 1518 | CCloseDialog* cd = new CCloseDialog(reader->m_string, false, this); |
1519 | if (cd->exec()) | ||
1095 | { | 1520 | { |
1096 | int ind = 0; | 1521 | if (pOpenlist != NULL) |
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 | { | 1522 | { |
1105 | case 0: | 1523 | int ind = 0; |
1106 | default: | 1524 | Bkmk* p = (*pOpenlist)[ind]; |
1107 | break; | 1525 | while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) |
1108 | case 2: | 1526 | { |
1527 | p = (*pOpenlist)[++ind]; | ||
1528 | } | ||
1529 | if (p != NULL) pOpenlist->erase(ind); | ||
1530 | if (cd->delFile()) | ||
1531 | { | ||
1109 | unlink((const char*)reader->m_lastfile); | 1532 | unlink((const char*)reader->m_lastfile); |
1110 | case 1: | 1533 | } |
1111 | unlink((const char *)Global::applicationFileName(APPDIR, reader->m_string)); | 1534 | if (cd->delMarks()) |
1535 | { | ||
1536 | #ifndef USEQPE | ||
1537 | QDir d = QDir::home(); // "/" | ||
1538 | d.cd(APPDIR); | ||
1539 | d.remove(reader->m_string); | ||
1540 | #else /* USEQPE */ | ||
1541 | unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string)); | ||
1542 | #endif /* USEQPE */ | ||
1543 | } | ||
1544 | if (cd->delConfig()) | ||
1545 | { | ||
1546 | #ifndef USEQPE | ||
1547 | QDir d = QDir::home(); // "/" | ||
1548 | d.cd(APPDIR "/configs"); | ||
1549 | d.remove(reader->m_string); | ||
1550 | #else /* USEQPE */ | ||
1551 | unlink((const char *)Global::applicationFileName(APPDIR "/configs",reader->m_string)); | ||
1552 | #endif /* USEQPE */ | ||
1553 | } | ||
1112 | } | 1554 | } |
1113 | } | ||
1114 | 1555 | ||
1115 | fileOpen2(); | 1556 | fileOpen2(); |
1557 | } | ||
1558 | delete cd; | ||
1116 | } | 1559 | } |
1117 | 1560 | ||
1118 | void QTReaderApp::updatefileinfo() | 1561 | void QTReaderApp::updatefileinfo() |
1119 | { | 1562 | { |
1120 | if (reader->m_string.isNull()) return; | 1563 | if (reader->m_string.isEmpty()) return; |
1121 | if (reader->m_lastfile.isNull()) return; | 1564 | if (reader->m_lastfile.isEmpty()) return; |
1122 | tchar* nm = fromQString(reader->m_string); | 1565 | tchar* nm = fromQString(reader->m_string); |
1123 | tchar* fl = fromQString(reader->m_lastfile); | 1566 | tchar* fl = fromQString(reader->m_lastfile); |
1124 | qDebug("Lastfile:%x", fl); | 1567 | // qDebug("Lastfile:%x", fl); |
1125 | bool notadded = true; | 1568 | bool notadded = true; |
1126 | if (pOpenlist == NULL) pOpenlist = new CList<Bkmk>; | 1569 | if (pOpenlist == NULL) pOpenlist = new CList<Bkmk>; |
@@ -1136,5 +1579,5 @@ void QTReaderApp::updatefileinfo() | |||
1136 | CFiledata fd(iter->anno()); | 1579 | CFiledata fd(iter->anno()); |
1137 | reader->setSaveData(data, dlen, fd.content(), fd.length()); | 1580 | reader->setSaveData(data, dlen, fd.content(), fd.length()); |
1138 | qDebug("Filedata(1):%u, %u", fd.length(), dlen); | 1581 | // qDebug("Filedata(1):%u, %u", fd.length(), dlen); |
1139 | // getstate(data, dlen); | 1582 | // getstate(data, dlen); |
1140 | iter->setAnno(data, dlen); | 1583 | iter->setAnno(data, dlen); |
@@ -1145,5 +1588,5 @@ void QTReaderApp::updatefileinfo() | |||
1145 | } | 1588 | } |
1146 | } | 1589 | } |
1147 | qDebug("Added?:%x", notadded); | 1590 | // qDebug("Added?:%x", notadded); |
1148 | if (notadded) | 1591 | if (notadded) |
1149 | { | 1592 | { |
@@ -1155,5 +1598,5 @@ void QTReaderApp::updatefileinfo() | |||
1155 | reader->setSaveData(data, dlen, fd.content(), fd.length()); | 1598 | reader->setSaveData(data, dlen, fd.content(), fd.length()); |
1156 | pOpenlist->push_front(Bkmk(nm, data, dlen, reader->pagelocate())); | 1599 | pOpenlist->push_front(Bkmk(nm, data, dlen, reader->pagelocate())); |
1157 | qDebug("Filedata(2):%u, %u", fd.length(), dlen); | 1600 | //qDebug("Filedata(2):%u, %u", fd.length(), dlen); |
1158 | delete [] data; | 1601 | delete [] data; |
1159 | } | 1602 | } |
@@ -1166,9 +1609,9 @@ void QTReaderApp::fileOpen() | |||
1166 | /* | 1609 | /* |
1167 | menu->hide(); | 1610 | menu->hide(); |
1168 | editBar->hide(); | 1611 | fileBar->hide(); |
1169 | if (regVisible) regBar->hide(); | 1612 | if (regVisible) regBar->hide(); |
1170 | if (searchVisible) searchBar->hide(); | 1613 | if (searchVisible) searchBar->hide(); |
1171 | */ | 1614 | */ |
1172 | qDebug("fileOpen"); | 1615 | // qDebug("fileOpen"); |
1173 | // if (!reader->m_lastfile.isEmpty()) | 1616 | // if (!reader->m_lastfile.isEmpty()) |
1174 | updatefileinfo(); | 1617 | updatefileinfo(); |
@@ -1194,12 +1637,14 @@ void QTReaderApp::fileOpen2() | |||
1194 | fileSelector->reread(); | 1637 | fileSelector->reread(); |
1195 | */ | 1638 | */ |
1639 | bool usebrowser = true; | ||
1196 | if (pOpenlist != NULL) | 1640 | if (pOpenlist != NULL) |
1197 | { | 1641 | { |
1198 | m_nRegAction = cOpenFile; | 1642 | m_nBkmkAction = cOpenFile; |
1199 | listbkmk(pOpenlist, "Browse"); | 1643 | if (listbkmk(pOpenlist, "Browse")) usebrowser = false; |
1200 | } | 1644 | } |
1201 | else | 1645 | if (usebrowser) |
1202 | { | 1646 | { |
1203 | QString fn = usefilebrowser(); | 1647 | QString fn = usefilebrowser(); |
1648 | //qApp->processEvents(); | ||
1204 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) | 1649 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) |
1205 | { | 1650 | { |
@@ -1208,9 +1653,15 @@ void QTReaderApp::fileOpen2() | |||
1208 | reader->setFocus(); | 1653 | reader->setFocus(); |
1209 | } | 1654 | } |
1655 | // reader->refresh(); | ||
1656 | // qDebug("HEIGHT:%d", reader->m_lastheight); | ||
1210 | } | 1657 | } |
1211 | 1658 | ||
1212 | QString QTReaderApp::usefilebrowser() | 1659 | QString QTReaderApp::usefilebrowser() |
1213 | { | 1660 | { |
1214 | fileBrowser* fb = new fileBrowser(this,"QTReader",TRUE, | 1661 | #ifndef USEQPE |
1662 | QString s( QFileDialog::getOpenFileName( reader->m_lastfile, QString::null, this ) ); | ||
1663 | return s; | ||
1664 | #else | ||
1665 | fileBrowser* fb = new fileBrowser(false, this,"OpieReader",!m_bFloatingDialog, | ||
1215 | 0, | 1666 | 0, |
1216 | // WStyle_Customize | WStyle_NoBorderEx, | 1667 | // WStyle_Customize | WStyle_NoBorderEx, |
@@ -1221,18 +1672,250 @@ QString QTReaderApp::usefilebrowser() | |||
1221 | if (fb->exec()) | 1672 | if (fb->exec()) |
1222 | { | 1673 | { |
1223 | fn = fb->fileList[0]; | 1674 | fn = fb->getCurrentFile(); |
1224 | } | 1675 | } |
1225 | qDebug("Selected %s", (const char*)fn); | 1676 | // qDebug("Selected %s", (const char*)fn); |
1226 | delete fb; | 1677 | delete fb; |
1678 | showEditTools(); | ||
1227 | return fn; | 1679 | return fn; |
1680 | #endif | ||
1228 | } | 1681 | } |
1229 | 1682 | ||
1230 | void QTReaderApp::showgraphic(QPixmap& pm) | 1683 | void QTReaderApp::showgraphic(QImage& pm) |
1231 | { | 1684 | { |
1232 | m_graphicwin->setPixmap(pm); | 1685 | QPixmap pc; |
1686 | pc.convertFromImage(pm); | ||
1687 | m_graphicwin->setPixmap(pc); | ||
1233 | editorStack->raiseWidget( m_graphicwin ); | 1688 | editorStack->raiseWidget( m_graphicwin ); |
1234 | m_graphicwin->setFocus(); | 1689 | m_graphicwin->setFocus(); |
1235 | } | 1690 | } |
1236 | 1691 | ||
1692 | |||
1693 | void QTReaderApp::showprefs() | ||
1694 | { | ||
1695 | CPrefs* prefwin = new CPrefs(!m_bFloatingDialog, this); | ||
1696 | |||
1697 | prefwin->twotouch(m_twoTouch); | ||
1698 | prefwin->propfontchange(m_propogatefontchange); | ||
1699 | prefwin->StripCR(reader->bstripcr); | ||
1700 | prefwin->Dehyphen(reader->bdehyphen); | ||
1701 | prefwin->SingleSpace(reader->bonespace); | ||
1702 | prefwin->Unindent(reader->bunindent); | ||
1703 | prefwin->Reparagraph(reader->brepara); | ||
1704 | prefwin->DoubleSpace(reader->bdblspce); | ||
1705 | prefwin->Remap(reader->bremap); | ||
1706 | prefwin->Embolden(reader->bmakebold); | ||
1707 | prefwin->FullJustify(reader->bfulljust); | ||
1708 | prefwin->ParaLead(reader->getextraspace()); | ||
1709 | prefwin->LineLead(reader->getlead()); | ||
1710 | prefwin->Margin(reader->m_border); | ||
1711 | prefwin->Indent(reader->bindenter); | ||
1712 | if (reader->bautofmt) | ||
1713 | { | ||
1714 | prefwin->Markup(0); | ||
1715 | } | ||
1716 | else if (reader->btextfmt) | ||
1717 | { | ||
1718 | prefwin->Markup(2); | ||
1719 | } | ||
1720 | else if (reader->bstriphtml) | ||
1721 | { | ||
1722 | prefwin->Markup(3); | ||
1723 | } | ||
1724 | else if (reader->bpeanut) | ||
1725 | { | ||
1726 | prefwin->Markup(4); | ||
1727 | } | ||
1728 | else | ||
1729 | { | ||
1730 | prefwin->Markup(1); | ||
1731 | } | ||
1732 | prefwin->Depluck(reader->bdepluck); | ||
1733 | prefwin->Dejpluck(reader->bdejpluck); | ||
1734 | prefwin->Continuous(reader->m_continuousDocument); | ||
1735 | |||
1736 | prefwin->dictApplication(m_targetapp); | ||
1737 | prefwin->dictMessage(m_targetmsg); | ||
1738 | |||
1739 | prefwin->spaceAction(m_spaceTarget); | ||
1740 | prefwin->escapeAction(m_escapeTarget); | ||
1741 | prefwin->returnAction(m_returnTarget); | ||
1742 | prefwin->leftAction(m_leftTarget); | ||
1743 | prefwin->rightAction(m_rightTarget); | ||
1744 | prefwin->upAction(m_upTarget); | ||
1745 | prefwin->downAction(m_downTarget); | ||
1746 | |||
1747 | prefwin->leftScroll(m_leftScroll); | ||
1748 | prefwin->rightScroll(m_rightScroll); | ||
1749 | prefwin->upScroll(m_upScroll); | ||
1750 | prefwin->downScroll(m_downScroll); | ||
1751 | |||
1752 | prefwin->miscannotation(m_doAnnotation); | ||
1753 | prefwin->miscdictionary(m_doDictionary); | ||
1754 | prefwin->miscclipboard(m_doClipboard); | ||
1755 | |||
1756 | prefwin->SwapMouse(reader->m_swapmouse); | ||
1757 | |||
1758 | prefwin->Font(reader->m_fontname); | ||
1759 | |||
1760 | prefwin->gfxsize(reader->getBaseSize()); | ||
1761 | |||
1762 | prefwin->pageoverlap(reader->m_overlap); | ||
1763 | |||
1764 | prefwin->ideogram(reader->m_bMonoSpaced); | ||
1765 | |||
1766 | prefwin->encoding(reader->m_encd); | ||
1767 | |||
1768 | prefwin->ideogramwidth(reader->m_charpc); | ||
1769 | |||
1770 | if (prefwin->exec()) | ||
1771 | { | ||
1772 | m_twoTouch = prefwin->twotouch(); | ||
1773 | reader->setTwoTouch(m_twoTouch); | ||
1774 | m_touch_action->setOn(m_twoTouch); | ||
1775 | |||
1776 | reader->bstripcr = prefwin->StripCR(); | ||
1777 | reader->bdehyphen = prefwin->Dehyphen(); | ||
1778 | reader->bonespace = prefwin->SingleSpace(); | ||
1779 | reader->bunindent = prefwin->Unindent(); | ||
1780 | reader->brepara = prefwin->Reparagraph(); | ||
1781 | reader->bdblspce = prefwin->DoubleSpace(); | ||
1782 | reader->bremap = prefwin->Remap(); | ||
1783 | reader->bmakebold = prefwin->Embolden(); | ||
1784 | reader->bfulljust = prefwin->FullJustify(); | ||
1785 | reader->setextraspace(prefwin->ParaLead()); | ||
1786 | reader->setlead(prefwin->LineLead()); | ||
1787 | reader->m_border = prefwin->Margin(); | ||
1788 | reader->bindenter = prefwin->Indent(); | ||
1789 | reader->bautofmt = reader->btextfmt = reader->bstriphtml = reader->bpeanut = false; | ||
1790 | switch (prefwin->Markup()) | ||
1791 | { | ||
1792 | case 0: | ||
1793 | reader->bautofmt = true; | ||
1794 | break; | ||
1795 | case 1: | ||
1796 | break; | ||
1797 | case 2: | ||
1798 | reader->btextfmt = true; | ||
1799 | break; | ||
1800 | case 3: | ||
1801 | reader->bstriphtml = true; | ||
1802 | break; | ||
1803 | case 4: | ||
1804 | reader->bpeanut = true; | ||
1805 | break; | ||
1806 | default: | ||
1807 | qDebug("Format out of range"); | ||
1808 | } | ||
1809 | reader->bdepluck = prefwin->Depluck(); | ||
1810 | reader->bdejpluck = prefwin->Dejpluck(); | ||
1811 | reader->setContinuous(prefwin->Continuous()); | ||
1812 | |||
1813 | m_spaceTarget = (ActionTypes)prefwin->spaceAction(); | ||
1814 | m_escapeTarget = (ActionTypes)prefwin->escapeAction(); | ||
1815 | m_returnTarget = (ActionTypes)prefwin->returnAction(); | ||
1816 | m_leftTarget = (ActionTypes)prefwin->leftAction(); | ||
1817 | m_rightTarget = (ActionTypes)prefwin->rightAction(); | ||
1818 | m_upTarget = (ActionTypes)prefwin->upAction(); | ||
1819 | m_downTarget = (ActionTypes)prefwin->downAction(); | ||
1820 | m_leftScroll = prefwin->leftScroll(); | ||
1821 | m_rightScroll = prefwin->rightScroll(); | ||
1822 | m_upScroll = prefwin->upScroll(); | ||
1823 | m_downScroll = prefwin->downScroll(); | ||
1824 | |||
1825 | m_targetapp = prefwin->dictApplication(); | ||
1826 | m_targetmsg = prefwin->dictMessage(); | ||
1827 | |||
1828 | m_doAnnotation = prefwin->miscannotation(); | ||
1829 | m_doDictionary = prefwin->miscdictionary(); | ||
1830 | m_doClipboard = prefwin->miscclipboard(); | ||
1831 | reader->m_swapmouse = prefwin->SwapMouse(); | ||
1832 | reader->setBaseSize(prefwin->gfxsize()); | ||
1833 | reader->m_overlap = prefwin->pageoverlap(); | ||
1834 | reader->m_bMonoSpaced = prefwin->ideogram(); | ||
1835 | m_setmono_action->setOn(reader->m_bMonoSpaced); | ||
1836 | reader->m_encd = prefwin->encoding(); | ||
1837 | reader->m_charpc = prefwin->ideogramwidth(); | ||
1838 | |||
1839 | if ( | ||
1840 | reader->m_fontname != prefwin->Font() | ||
1841 | || | ||
1842 | m_propogatefontchange != prefwin->propfontchange()) | ||
1843 | { | ||
1844 | m_propogatefontchange = prefwin->propfontchange(); | ||
1845 | setfontHelper(prefwin->Font()); | ||
1846 | } | ||
1847 | delete prefwin; | ||
1848 | reader->setfilter(reader->getfilter()); | ||
1849 | reader->refresh(); | ||
1850 | |||
1851 | } | ||
1852 | else | ||
1853 | { | ||
1854 | delete prefwin; | ||
1855 | } | ||
1856 | } | ||
1857 | |||
1858 | void QTReaderApp::showtoolbarprefs() | ||
1859 | { | ||
1860 | #ifdef USEQPE | ||
1861 | CBarPrefs* prefwin = new CBarPrefs(APPDIR, !m_bFloatingDialog, this); | ||
1862 | #else | ||
1863 | QFileInfo fi; | ||
1864 | QDir d = QDir::home(); // "/" | ||
1865 | if ( !d.cd(APPDIR) ) | ||
1866 | { // "/tmp" | ||
1867 | qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); | ||
1868 | d = QDir::home(); | ||
1869 | d.mkdir(APPDIR); | ||
1870 | d.cd(APPDIR); | ||
1871 | } | ||
1872 | fi.setFile(d, INIFILE); | ||
1873 | CBarPrefs* prefwin = new CBarPrefs(fi.absFilePath(), !m_bFloatingDialog, this); | ||
1874 | #endif | ||
1875 | prefwin->tbpolicy(m_tbpolsave); | ||
1876 | prefwin->tbposition(m_tbposition-2); | ||
1877 | prefwin->tbmovable(m_tbmovesave); | ||
1878 | prefwin->floating(m_bFloatingDialog); | ||
1879 | if (prefwin->exec()) | ||
1880 | { | ||
1881 | m_bFloatingDialog = prefwin->floating(); | ||
1882 | if ( | ||
1883 | m_tbpolsave != (ToolbarPolicy)prefwin->tbpolicy() | ||
1884 | || | ||
1885 | m_tbposition != (ToolBarDock)(prefwin->tbposition()+2) | ||
1886 | || | ||
1887 | m_tbmovesave != prefwin->tbmovable() | ||
1888 | ) | ||
1889 | { | ||
1890 | QMessageBox::warning(this, PROGNAME, "Some changes won't take effect\nuntil the next time the\napplication is started"); | ||
1891 | } | ||
1892 | m_tbpolsave = (ToolbarPolicy)prefwin->tbpolicy(); | ||
1893 | m_tbposition = (ToolBarDock)(prefwin->tbposition()+2); | ||
1894 | m_tbmovesave = prefwin->tbmovable(); | ||
1895 | bool isChanged = prefwin->isChanged(); | ||
1896 | delete prefwin; | ||
1897 | #ifdef USEQPE | ||
1898 | Config config( APPDIR ); | ||
1899 | #else | ||
1900 | QFileInfo fi; | ||
1901 | QDir d = QDir::home(); // "/" | ||
1902 | if ( !d.cd(APPDIR) ) | ||
1903 | { // "/tmp" | ||
1904 | qWarning( "Cannot find the \"~/%s\" directory", APPDIR ); | ||
1905 | d = QDir::home(); | ||
1906 | d.mkdir(APPDIR); | ||
1907 | d.cd(APPDIR); | ||
1908 | } | ||
1909 | fi.setFile(d, INIFILE); | ||
1910 | Config config( fi.absFilePath() ); | ||
1911 | #endif | ||
1912 | if (isChanged) addtoolbars(&config); | ||
1913 | } | ||
1914 | else | ||
1915 | { | ||
1916 | delete prefwin; | ||
1917 | } | ||
1918 | } | ||
1919 | |||
1237 | void QTReaderApp::showinfo() | 1920 | void QTReaderApp::showinfo() |
1238 | { | 1921 | { |
@@ -1353,5 +2036,7 @@ void QTReaderApp::addanno() | |||
1353 | m_annoIsEditing = true; | 2036 | m_annoIsEditing = true; |
1354 | editorStack->raiseWidget( m_annoWin ); | 2037 | editorStack->raiseWidget( m_annoWin ); |
2038 | #ifdef USEQPE | ||
1355 | Global::showInputMethod(); | 2039 | Global::showInputMethod(); |
2040 | #endif | ||
1356 | m_annoWin->setFocus(); | 2041 | m_annoWin->setFocus(); |
1357 | } | 2042 | } |
@@ -1389,4 +2074,8 @@ void QTReaderApp::editCopy() | |||
1389 | unsigned long currentpos = reader->pagelocate(); | 2074 | unsigned long currentpos = reader->pagelocate(); |
1390 | unsigned long endpos = reader->locate(); | 2075 | unsigned long endpos = reader->locate(); |
2076 | if (m_savedpos == 0xffffffff) | ||
2077 | { | ||
2078 | m_savedpos = currentpos; | ||
2079 | } | ||
1391 | reader->jumpto(m_savedpos); | 2080 | reader->jumpto(m_savedpos); |
1392 | while (reader->explocate() < endpos && (ch = reader->getch()) != UEOF) | 2081 | while (reader->explocate() < endpos && (ch = reader->getch()) != UEOF) |
@@ -1396,83 +2085,33 @@ void QTReaderApp::editCopy() | |||
1396 | cb->setText(text); | 2085 | cb->setText(text); |
1397 | reader->locate(currentpos); | 2086 | reader->locate(currentpos); |
2087 | m_savedpos = 0xffffffff; | ||
1398 | } | 2088 | } |
1399 | 2089 | ||
1400 | void QTReaderApp::pageup() | 2090 | void QTReaderApp::gotoStart() |
1401 | { | 2091 | { |
1402 | reader->NavUp(); | 2092 | reader->locate(reader->buffdoc.startSection()); |
1403 | } | 2093 | } |
1404 | 2094 | ||
1405 | void QTReaderApp::pagedn() | 2095 | void QTReaderApp::gotoEnd() |
1406 | { | 2096 | { |
1407 | reader->NavDown(); | 2097 | reader->dopageup(reader->buffdoc.endSection()); |
1408 | } | 2098 | } |
1409 | 2099 | ||
1410 | void QTReaderApp::stripcr(bool _b) | 2100 | void QTReaderApp::pageup() |
1411 | { | ||
1412 | reader->setstripcr(_b); | ||
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 | ||
1424 | void QTReaderApp::remap(bool _b) | ||
1425 | { | ||
1426 | reader->setremap(_b); | ||
1427 | } | ||
1428 | void QTReaderApp::peanut(bool _b) | ||
1429 | { | ||
1430 | reader->setpeanut(_b); | ||
1431 | } | ||
1432 | void QTReaderApp::embolden(bool _b) | ||
1433 | { | ||
1434 | reader->setmakebold(_b); | ||
1435 | } | ||
1436 | void QTReaderApp::autofmt(bool _b) | ||
1437 | { | ||
1438 | reader->setautofmt(_b); | ||
1439 | } | ||
1440 | void QTReaderApp::textfmt(bool _b) | ||
1441 | { | ||
1442 | reader->settextfmt(_b); | ||
1443 | } | ||
1444 | void QTReaderApp::striphtml(bool _b) | ||
1445 | { | ||
1446 | reader->setstriphtml(_b); | ||
1447 | } | ||
1448 | void QTReaderApp::dehyphen(bool _b) | ||
1449 | { | ||
1450 | reader->setdehyphen(_b); | ||
1451 | } | ||
1452 | void QTReaderApp::unindent(bool _b) | ||
1453 | { | ||
1454 | reader->setunindent(_b); | ||
1455 | } | ||
1456 | void QTReaderApp::repara(bool _b) | ||
1457 | { | 2101 | { |
1458 | reader->setrepara(_b); | 2102 | reader->NavUp(); |
1459 | } | 2103 | } |
1460 | void QTReaderApp::dblspce(bool _b) | 2104 | |
2105 | void QTReaderApp::pagedn() | ||
1461 | { | 2106 | { |
1462 | reader->setdblspce(_b); | 2107 | reader->NavDown(); |
1463 | } | 2108 | } |
2109 | |||
1464 | void QTReaderApp::pagemode(bool _b) | 2110 | void QTReaderApp::pagemode(bool _b) |
1465 | { | 2111 | { |
1466 | reader->setpagemode(_b); | 2112 | reader->setpagemode(_b); |
1467 | } | 2113 | } |
1468 | void QTReaderApp::navkeys(bool _b) | ||
1469 | { | ||
1470 | reader->m_navkeys = _b; | ||
1471 | } | ||
1472 | void QTReaderApp::monospace(bool _b) | ||
1473 | { | ||
1474 | reader->setmono(_b); | ||
1475 | } | ||
1476 | 2114 | ||
2115 | /* | ||
1477 | void QTReaderApp::setspacing() | 2116 | void QTReaderApp::setspacing() |
1478 | { | 2117 | { |
@@ -1483,14 +2122,5 @@ void QTReaderApp::setspacing() | |||
1483 | do_regedit(); | 2122 | do_regedit(); |
1484 | } | 2123 | } |
1485 | 2124 | */ | |
1486 | void QTReaderApp::setoverlap() | ||
1487 | { | ||
1488 | m_nRegAction = cOverlap; | ||
1489 | char lcn[20]; | ||
1490 | sprintf(lcn, "%lu", reader->m_overlap); | ||
1491 | regEdit->setText(lcn); | ||
1492 | do_regedit(); | ||
1493 | } | ||
1494 | |||
1495 | void QTReaderApp::settarget() | 2125 | void QTReaderApp::settarget() |
1496 | { | 2126 | { |
@@ -1503,16 +2133,5 @@ void QTReaderApp::settarget() | |||
1503 | } | 2133 | } |
1504 | 2134 | ||
1505 | void QTReaderApp::do_overlap(const QString& lcn) | 2135 | /* |
1506 | { | ||
1507 | bool ok; | ||
1508 | unsigned long ulcn = lcn.toULong(&ok); | ||
1509 | if (ok) | ||
1510 | { | ||
1511 | reader->m_overlap = ulcn; | ||
1512 | } | ||
1513 | else | ||
1514 | QMessageBox::information(this, PROGNAME, "Must be a number"); | ||
1515 | } | ||
1516 | |||
1517 | void QTReaderApp::do_mono(const QString& lcn) | 2136 | void QTReaderApp::do_mono(const QString& lcn) |
1518 | { | 2137 | { |
@@ -1529,5 +2148,5 @@ void QTReaderApp::do_mono(const QString& lcn) | |||
1529 | QMessageBox::information(this, PROGNAME, "Must be a number"); | 2148 | QMessageBox::information(this, PROGNAME, "Must be a number"); |
1530 | } | 2149 | } |
1531 | 2150 | */ | |
1532 | /* | 2151 | /* |
1533 | void QTReaderApp::editPaste() | 2152 | void QTReaderApp::editPaste() |
@@ -1545,5 +2164,7 @@ void QTReaderApp::editFind() | |||
1545 | searchStack = new QStack<searchrecord>; | 2164 | searchStack = new QStack<searchrecord>; |
1546 | #endif | 2165 | #endif |
2166 | #ifdef USEQPE | ||
1547 | Global::showInputMethod(); | 2167 | Global::showInputMethod(); |
2168 | #endif | ||
1548 | searchBar->show(); | 2169 | searchBar->show(); |
1549 | searchVisible = TRUE; | 2170 | searchVisible = TRUE; |
@@ -1556,5 +2177,5 @@ void QTReaderApp::editFind() | |||
1556 | void QTReaderApp::findNext() | 2177 | void QTReaderApp::findNext() |
1557 | { | 2178 | { |
1558 | // qDebug("findNext called\n"); | 2179 | // // qDebug("findNext called\n"); |
1559 | #ifdef __ISEARCH | 2180 | #ifdef __ISEARCH |
1560 | QString arg = searchEdit->text(); | 2181 | QString arg = searchEdit->text(); |
@@ -1565,5 +2186,5 @@ void QTReaderApp::findNext() | |||
1565 | size_t start = reader->pagelocate(); | 2186 | size_t start = reader->pagelocate(); |
1566 | reader->jumpto(start); | 2187 | reader->jumpto(start); |
1567 | reader->buffdoc.getline(&test,reader->width()); | 2188 | reader->getline(&test); |
1568 | dosearch(start, test, arg); | 2189 | dosearch(start, test, arg); |
1569 | } | 2190 | } |
@@ -1573,5 +2194,7 @@ void QTReaderApp::findClose() | |||
1573 | searchVisible = FALSE; | 2194 | searchVisible = FALSE; |
1574 | searchEdit->setText(""); | 2195 | searchEdit->setText(""); |
2196 | #ifdef USEQPE | ||
1575 | Global::hideInputMethod(); | 2197 | Global::hideInputMethod(); |
2198 | #endif | ||
1576 | searchBar->hide(); | 2199 | searchBar->hide(); |
1577 | #ifdef __ISEARCH | 2200 | #ifdef __ISEARCH |
@@ -1591,5 +2214,7 @@ void QTReaderApp::regClose() | |||
1591 | regEdit->setText(""); | 2214 | regEdit->setText(""); |
1592 | regBar->hide(); | 2215 | regBar->hide(); |
2216 | #ifdef USEQPE | ||
1593 | Global::hideInputMethod(); | 2217 | Global::hideInputMethod(); |
2218 | #endif | ||
1594 | reader->setFocus(); | 2219 | reader->setFocus(); |
1595 | } | 2220 | } |
@@ -1605,46 +2230,64 @@ bool QTReaderApp::dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg) | |||
1605 | reader->sizes(fs,ts); | 2230 | reader->sizes(fs,ts); |
1606 | size_t pos = reader->locate(); | 2231 | size_t pos = reader->locate(); |
1607 | reader->buffdoc.getline(&test,reader->width()); | 2232 | pbar->setGeometry(searchBar->x(),searchBar->y(),searchBar->width(), searchBar->height()); |
1608 | pbar->show(); | 2233 | pbar->show(); |
1609 | pbar->resize(width(), editBar->height()); | 2234 | pbar->raise(); |
1610 | pbar->reset(); | 2235 | pbar->reset(); |
2236 | int offset; | ||
1611 | int lastpc = (100*pos)/ts; | 2237 | int lastpc = (100*pos)/ts; |
1612 | pbar->setProgress(lastpc); | 2238 | pbar->setProgress(lastpc); |
1613 | qApp->processEvents(); | 2239 | // qApp->processEvents(); |
1614 | reader->setFocus(); | 2240 | if (reader->buffdoc.getpara(test) >= 0) |
2241 | { | ||
2242 | reader->setFocus(); | ||
1615 | #ifdef __ISEARCH | 2243 | #ifdef __ISEARCH |
1616 | while (strstr(test.data(),(const tchar*)arg) == NULL) | 2244 | while (strstr(test.data(),(const tchar*)arg) == NULL) |
1617 | #else | 2245 | #else |
1618 | #ifdef _UNICODE | 2246 | #ifdef _UNICODE |
1619 | while (arg.match(toQString(test.data())) == -1) | 2247 | while ((offset = arg.match(toQString(test.data()))) == -1) |
1620 | #else | 2248 | #else |
1621 | while (arg.match(test.data()) == -1) | 2249 | while (arg.match(test.data()) == -1) |
1622 | #endif | 2250 | #endif |
1623 | #endif | 2251 | #endif |
1624 | { | ||
1625 | pos = reader->locate(); | ||
1626 | unsigned int lcn = reader->locate(); | ||
1627 | int pc = (100*pos)/ts; | ||
1628 | if (pc != lastpc) | ||
1629 | { | 2252 | { |
1630 | pbar->setProgress(pc); | 2253 | pos = reader->locate(); |
1631 | qApp->processEvents(); | 2254 | int pc = (100*pos)/ts; |
1632 | reader->setFocus(); | 2255 | if (pc != lastpc) |
1633 | lastpc = pc; | 2256 | { |
2257 | pbar->setProgress(pc); | ||
2258 | qApp->processEvents(); | ||
2259 | reader->setFocus(); | ||
2260 | lastpc = pc; | ||
2261 | } | ||
2262 | |||
2263 | if (reader->buffdoc.getpara(test) < 0) | ||
2264 | { | ||
2265 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) | ||
2266 | pos = searchStart; | ||
2267 | else | ||
2268 | pos = start; | ||
2269 | findClose(); | ||
2270 | pbar->hide(); | ||
2271 | reader->locate(pos); | ||
2272 | return false; | ||
2273 | } | ||
1634 | } | 2274 | } |
1635 | 2275 | // qDebug("Found it at %u:%u", pos, offset); | |
1636 | if (!reader->buffdoc.getline(&test,reader->width())) | 2276 | pbar->hide(); |
1637 | { | 2277 | // qDebug("Hid"); |
1638 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) | 2278 | reader->locate(pos+offset); |
1639 | pos = searchStart; | 2279 | // qDebug("Loacted"); |
1640 | else | 2280 | // qDebug("page up"); |
1641 | pos = start; | 2281 | ret = true; |
1642 | ret = false; | 2282 | } |
1643 | findClose(); | 2283 | else |
1644 | break; | 2284 | { |
1645 | } | 2285 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) |
1646 | } | 2286 | pos = searchStart; |
1647 | pbar->hide(); | 2287 | else |
1648 | reader->locate(pos); | 2288 | pos = start; |
2289 | ret = false; | ||
2290 | findClose(); | ||
2291 | } | ||
1649 | return ret; | 2292 | return ret; |
1650 | } | 2293 | } |
@@ -1692,5 +2335,5 @@ void QTReaderApp::search() | |||
1692 | void QTReaderApp::openFile( const QString &f ) | 2335 | void QTReaderApp::openFile( const QString &f ) |
1693 | { | 2336 | { |
1694 | qDebug("File:%s", (const char*)f); | 2337 | // qDebug("File:%s", (const char*)f); |
1695 | // openFile(DocLnk(f)); | 2338 | // openFile(DocLnk(f)); |
1696 | //} | 2339 | //} |
@@ -1703,5 +2346,5 @@ void QTReaderApp::openFile( const QString &f ) | |||
1703 | { | 2346 | { |
1704 | // QMessageBox::information(0, "Progress", "Calling fileNew()"); | 2347 | // QMessageBox::information(0, "Progress", "Calling fileNew()"); |
1705 | 2348 | #ifdef USEQPE | |
1706 | if (fm.extension( FALSE ) == "desktop") | 2349 | if (fm.extension( FALSE ) == "desktop") |
1707 | { | 2350 | { |
@@ -1711,14 +2354,17 @@ void QTReaderApp::openFile( const QString &f ) | |||
1711 | if (!fm.exists()) return; | 2354 | if (!fm.exists()) return; |
1712 | } | 2355 | } |
1713 | 2356 | #endif | |
1714 | clear(); | 2357 | clear(); |
1715 | 2358 | ||
1716 | reader->setText(fm.baseName(), fm.absFilePath()); | 2359 | reader->setText(fm.baseName(), fm.absFilePath()); |
2360 | m_loadedconfig = readconfig(reader->m_string, false); | ||
1717 | showEditTools(); | 2361 | showEditTools(); |
1718 | readbkmks(); | 2362 | readbkmks(); |
2363 | m_savedpos = 0xffffffff; | ||
1719 | } | 2364 | } |
1720 | else | 2365 | else |
1721 | { | 2366 | { |
1722 | QMessageBox::information(this, PROGNAME, "File does not exist"); | 2367 | QMessageBox::information(this, PROGNAME, "File does not exist"); |
2368 | reader->m_lastfile = QString::null; | ||
1723 | } | 2369 | } |
1724 | 2370 | ||
@@ -1734,34 +2380,107 @@ void QTReaderApp::resizeEvent(QResizeEvent* e) | |||
1734 | } | 2380 | } |
1735 | */ | 2381 | */ |
1736 | void QTReaderApp::keyPressEvent(QKeyEvent* e) | 2382 | void QTReaderApp::handlekey(QKeyEvent* e) |
1737 | { | 2383 | { |
1738 | if (m_fullscreen) | 2384 | // qDebug("Keypress event"); |
2385 | timeb now; | ||
2386 | ftime(&now); | ||
2387 | unsigned long etime = (1000*(now.time - m_lastkeytime.time) + now.millitm)-m_lastkeytime.millitm; | ||
2388 | if (etime < m_debounce) | ||
1739 | { | 2389 | { |
1740 | switch(e->key()) | 2390 | return; |
1741 | { | 2391 | } |
1742 | case Key_Escape: | 2392 | m_lastkeytime = now; |
1743 | m_actFullscreen->setOn(false); | 2393 | switch(e->key()) |
2394 | { | ||
2395 | case Key_Escape: | ||
2396 | // qDebug("escape event"); | ||
2397 | if (m_disableesckey) | ||
2398 | { | ||
2399 | m_disableesckey = false; | ||
2400 | } | ||
2401 | else | ||
2402 | { | ||
2403 | m_bcloseDisabled = true; | ||
1744 | if (m_fullscreen) | 2404 | if (m_fullscreen) |
1745 | { | 2405 | { |
1746 | qDebug("Fullscreen already set - remove this!"); | 2406 | m_actFullscreen->setOn(false); |
2407 | e->accept(); | ||
1747 | } | 2408 | } |
1748 | else | 2409 | else |
1749 | { | 2410 | { |
1750 | m_fullscreen = false; | 2411 | // qDebug("escape action"); |
1751 | reader->bDoUpdates = false; | 2412 | doAction(m_escapeTarget, e); |
1752 | showEditTools(); | ||
1753 | qApp->processEvents(); | ||
1754 | reader->bDoUpdates = true; | ||
1755 | reader->update(); | ||
1756 | } | 2413 | } |
1757 | e->accept(); | 2414 | } |
1758 | break; | 2415 | break; |
1759 | default: | 2416 | case Key_Space: |
1760 | e->ignore(); | 2417 | { |
2418 | doAction(m_spaceTarget, e); | ||
1761 | } | 2419 | } |
1762 | } | 2420 | break; |
1763 | else | 2421 | case Key_Return: |
1764 | { | 2422 | { |
1765 | e->ignore(); | 2423 | doAction(m_returnTarget, e); |
2424 | } | ||
2425 | break; | ||
2426 | case Key_Left: | ||
2427 | { | ||
2428 | if (reader->m_autoScroll && m_leftScroll) | ||
2429 | { | ||
2430 | reader->reduceScroll(); | ||
2431 | } | ||
2432 | else | ||
2433 | { | ||
2434 | doAction(m_leftTarget, e); | ||
2435 | } | ||
2436 | } | ||
2437 | break; | ||
2438 | case Key_Right: | ||
2439 | { | ||
2440 | if (reader->m_autoScroll && m_rightScroll) | ||
2441 | { | ||
2442 | reader->increaseScroll(); | ||
2443 | } | ||
2444 | else | ||
2445 | { | ||
2446 | doAction(m_rightTarget, e); | ||
2447 | } | ||
2448 | } | ||
2449 | break; | ||
2450 | case Key_Up: | ||
2451 | { | ||
2452 | if (reader->m_autoScroll && m_upScroll) | ||
2453 | { | ||
2454 | reader->increaseScroll(); | ||
2455 | } | ||
2456 | else | ||
2457 | { | ||
2458 | doAction(m_upTarget, e); | ||
2459 | } | ||
2460 | } | ||
2461 | break; | ||
2462 | case Key_Down: | ||
2463 | { | ||
2464 | if (reader->m_autoScroll && m_downScroll) | ||
2465 | { | ||
2466 | reader->reduceScroll(); | ||
2467 | } | ||
2468 | else | ||
2469 | { | ||
2470 | doAction(m_downTarget, e); | ||
2471 | } | ||
2472 | } | ||
2473 | break; | ||
2474 | default: | ||
2475 | { | ||
2476 | e->ignore(); | ||
2477 | } | ||
2478 | |||
2479 | /* | ||
2480 | QString msg("Key press was:"); | ||
2481 | QString key; | ||
2482 | msg += key.setNum(e->key()); | ||
2483 | QMessageBox::information(this, PROGNAME, msg); | ||
2484 | */ | ||
1766 | } | 2485 | } |
1767 | } | 2486 | } |
@@ -1773,8 +2492,14 @@ void QTReaderApp::showEditTools() | |||
1773 | if (m_fullscreen) | 2492 | if (m_fullscreen) |
1774 | { | 2493 | { |
1775 | editBar->hide(); | 2494 | if (menubar != NULL) menubar->hide(); |
2495 | if (fileBar != NULL) fileBar->hide(); | ||
2496 | if (viewBar != NULL) viewBar->hide(); | ||
2497 | if (navBar != NULL) navBar->hide(); | ||
2498 | if (markBar != NULL) markBar->hide(); | ||
1776 | searchBar->hide(); | 2499 | searchBar->hide(); |
1777 | regBar->hide(); | 2500 | regBar->hide(); |
2501 | #ifdef USEQPE | ||
1778 | Global::hideInputMethod(); | 2502 | Global::hideInputMethod(); |
2503 | #endif | ||
1779 | m_fontBar->hide(); | 2504 | m_fontBar->hide(); |
1780 | //showNormal(); | 2505 | //showNormal(); |
@@ -1783,32 +2508,46 @@ void QTReaderApp::showEditTools() | |||
1783 | else | 2508 | else |
1784 | { | 2509 | { |
1785 | qDebug("him"); | 2510 | //qDebug("him"); |
2511 | #ifdef USEQPE | ||
1786 | Global::hideInputMethod(); | 2512 | Global::hideInputMethod(); |
1787 | qDebug("eb"); | 2513 | #endif |
1788 | editBar->show(); | 2514 | //qDebug("eb"); |
2515 | menubar->show(); | ||
2516 | if (fileBar != NULL) fileBar->show(); | ||
2517 | if (viewBar != NULL) viewBar->show(); | ||
2518 | if (navBar != NULL) navBar->show(); | ||
2519 | if (markBar != NULL) markBar->show(); | ||
2520 | mb->show(); | ||
1789 | if ( searchVisible ) | 2521 | if ( searchVisible ) |
1790 | { | 2522 | { |
2523 | #ifdef USEQPE | ||
1791 | Global::showInputMethod(); | 2524 | Global::showInputMethod(); |
1792 | searchBar->show(); | 2525 | #endif |
2526 | searchBar->show(); | ||
1793 | } | 2527 | } |
1794 | if ( regVisible ) | 2528 | if ( regVisible ) |
1795 | { | 2529 | { |
2530 | #ifdef USEQPE | ||
1796 | Global::showInputMethod(); | 2531 | Global::showInputMethod(); |
1797 | regBar->show(); | 2532 | #endif |
2533 | regBar->show(); | ||
1798 | } | 2534 | } |
1799 | if (m_fontVisible) m_fontBar->show(); | 2535 | if (m_fontVisible) m_fontBar->show(); |
1800 | qDebug("sn"); | 2536 | //qDebug("sn"); |
1801 | showNormal(); | 2537 | showNormal(); |
1802 | qDebug("sm"); | 2538 | //qDebug("sm"); |
2539 | #ifdef USEQPE | ||
1803 | showMaximized(); | 2540 | showMaximized(); |
2541 | #endif | ||
1804 | //setCentralWidget(reader); | 2542 | //setCentralWidget(reader); |
1805 | } | 2543 | } |
1806 | 2544 | ||
1807 | qDebug("uc"); | 2545 | // qDebug("uc"); |
1808 | updateCaption(); | 2546 | updateCaption(); |
1809 | qDebug("rw"); | 2547 | // qDebug("rw"); |
1810 | editorStack->raiseWidget( reader ); | 2548 | editorStack->raiseWidget( reader ); |
1811 | qDebug("sf"); | 2549 | // qDebug("sf"); |
1812 | reader->setFocus(); | 2550 | reader->setFocus(); |
2551 | reader->refresh(); | ||
1813 | } | 2552 | } |
1814 | /* | 2553 | /* |
@@ -1877,4 +2616,5 @@ void QTReaderApp::setDocument(const QString& fileref) | |||
1877 | void QTReaderApp::closeEvent( QCloseEvent *e ) | 2616 | void QTReaderApp::closeEvent( QCloseEvent *e ) |
1878 | { | 2617 | { |
2618 | // qDebug("Close event"); | ||
1879 | if (m_fullscreen) | 2619 | if (m_fullscreen) |
1880 | { | 2620 | { |
@@ -1891,39 +2631,53 @@ void QTReaderApp::closeEvent( QCloseEvent *e ) | |||
1891 | if (editorStack->visibleWidget() == reader) | 2631 | if (editorStack->visibleWidget() == reader) |
1892 | { | 2632 | { |
1893 | if (m_fontVisible) | 2633 | if ((m_escapeTarget != cesNone) && m_bcloseDisabled) |
1894 | { | ||
1895 | m_fontBar->hide(); | ||
1896 | m_fontVisible = false; | ||
1897 | } | ||
1898 | if (regVisible) | ||
1899 | { | ||
1900 | regBar->hide(); | ||
1901 | Global::hideInputMethod(); | ||
1902 | regVisible = false; | ||
1903 | return; | ||
1904 | } | ||
1905 | if (searchVisible) | ||
1906 | { | 2634 | { |
1907 | searchBar->hide(); | 2635 | //qDebug("Close disabled"); |
1908 | Global::hideInputMethod(); | 2636 | m_bcloseDisabled = false; |
1909 | searchVisible = false; | 2637 | e->ignore(); |
1910 | return; | ||
1911 | } | 2638 | } |
1912 | if (m_fBkmksChanged && pBkmklist != NULL) | 2639 | else |
1913 | { | 2640 | { |
1914 | if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) | 2641 | if (m_fontVisible) |
1915 | savebkmks(); | 2642 | { |
1916 | delete pBkmklist; | 2643 | m_fontBar->hide(); |
1917 | pBkmklist = NULL; | 2644 | m_fontVisible = false; |
1918 | m_fBkmksChanged = false; | 2645 | } |
2646 | if (regVisible) | ||
2647 | { | ||
2648 | regBar->hide(); | ||
2649 | #ifdef USEQPE | ||
2650 | Global::hideInputMethod(); | ||
2651 | #endif | ||
2652 | regVisible = false; | ||
2653 | return; | ||
2654 | } | ||
2655 | if (searchVisible) | ||
2656 | { | ||
2657 | searchBar->hide(); | ||
2658 | #ifdef USEQPE | ||
2659 | Global::hideInputMethod(); | ||
2660 | #endif | ||
2661 | searchVisible = false; | ||
2662 | return; | ||
2663 | } | ||
2664 | if (m_fBkmksChanged && pBkmklist != NULL) | ||
2665 | { | ||
2666 | if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) | ||
2667 | savebkmks(); | ||
2668 | delete pBkmklist; | ||
2669 | pBkmklist = NULL; | ||
2670 | m_fBkmksChanged = false; | ||
2671 | } | ||
2672 | bFromDocView = FALSE; | ||
2673 | updatefileinfo(); | ||
2674 | saveprefs(); | ||
2675 | e->accept(); | ||
1919 | } | 2676 | } |
1920 | bFromDocView = FALSE; | ||
1921 | updatefileinfo(); | ||
1922 | saveprefs(); | ||
1923 | e->accept(); | ||
1924 | } | 2677 | } |
1925 | else | 2678 | else |
1926 | { | 2679 | { |
1927 | showEditTools(); | 2680 | showEditTools(); |
2681 | m_disableesckey = true; | ||
1928 | } | 2682 | } |
1929 | } | 2683 | } |
@@ -1932,18 +2686,20 @@ void QTReaderApp::closeEvent( QCloseEvent *e ) | |||
1932 | void QTReaderApp::do_gotomark() | 2686 | void QTReaderApp::do_gotomark() |
1933 | { | 2687 | { |
1934 | m_nRegAction = cGotoBkmk; | 2688 | m_nBkmkAction = cGotoBkmk; |
1935 | listbkmk(pBkmklist); | 2689 | if (!listbkmk(pBkmklist)) |
2690 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); | ||
1936 | } | 2691 | } |
1937 | 2692 | ||
1938 | void QTReaderApp::do_delmark() | 2693 | void QTReaderApp::do_delmark() |
1939 | { | 2694 | { |
1940 | m_nRegAction = cDelBkmk; | 2695 | m_nBkmkAction = cDelBkmk; |
1941 | listbkmk(pBkmklist); | 2696 | if (!listbkmk(pBkmklist)) |
2697 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); | ||
1942 | } | 2698 | } |
1943 | 2699 | ||
1944 | void QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab) | 2700 | bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab) |
1945 | { | 2701 | { |
1946 | bkmkselector->clear(); | 2702 | bkmkselector->clear(); |
1947 | if (_lab.isNull()) | 2703 | if (_lab.isEmpty()) |
1948 | bkmkselector->setText("Cancel"); | 2704 | bkmkselector->setText("Cancel"); |
1949 | else | 2705 | else |
@@ -1955,5 +2711,5 @@ void QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab) | |||
1955 | { | 2711 | { |
1956 | #ifdef _UNICODE | 2712 | #ifdef _UNICODE |
1957 | qDebug("Item:%s", (const char*)toQString(i->name())); | 2713 | // qDebug("Item:%s", (const char*)toQString(i->name())); |
1958 | bkmkselector->insertItem(toQString(i->name())); | 2714 | bkmkselector->insertItem(toQString(i->name())); |
1959 | #else | 2715 | #else |
@@ -1965,21 +2721,10 @@ void QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab) | |||
1965 | if (cnt > 0) | 2721 | if (cnt > 0) |
1966 | { | 2722 | { |
1967 | //tjw menu->hide(); | 2723 | hidetoolbars(); |
1968 | editBar->hide(); | ||
1969 | if (m_fontVisible) m_fontBar->hide(); | ||
1970 | if (regVisible) | ||
1971 | { | ||
1972 | Global::hideInputMethod(); | ||
1973 | regBar->hide(); | ||
1974 | } | ||
1975 | if (searchVisible) | ||
1976 | { | ||
1977 | Global::hideInputMethod(); | ||
1978 | searchBar->hide(); | ||
1979 | } | ||
1980 | editorStack->raiseWidget( bkmkselector ); | 2724 | editorStack->raiseWidget( bkmkselector ); |
2725 | return true; | ||
1981 | } | 2726 | } |
1982 | else | 2727 | else |
1983 | QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); | 2728 | return false; |
1984 | } | 2729 | } |
1985 | 2730 | ||
@@ -1993,13 +2738,15 @@ void QTReaderApp::do_autogen() | |||
1993 | void QTReaderApp::do_regedit() | 2738 | void QTReaderApp::do_regedit() |
1994 | { | 2739 | { |
1995 | // editBar->hide(); | 2740 | // fileBar->hide(); |
1996 | reader->bDoUpdates = false; | 2741 | reader->bDoUpdates = false; |
1997 | qDebug("Showing regbar"); | 2742 | // qDebug("Showing regbar"); |
1998 | regBar->show(); | 2743 | regBar->show(); |
1999 | qDebug("Showing kbd"); | 2744 | // qDebug("Showing kbd"); |
2745 | #ifdef USEQPE | ||
2000 | Global::showInputMethod(); | 2746 | Global::showInputMethod(); |
2747 | #endif | ||
2001 | regVisible = true; | 2748 | regVisible = true; |
2002 | regEdit->setFocus(); | 2749 | regEdit->setFocus(); |
2003 | qApp->processEvents(); | 2750 | // qApp->processEvents(); |
2004 | reader->bDoUpdates = true; | 2751 | reader->bDoUpdates = true; |
2005 | reader->update(); | 2752 | reader->update(); |
@@ -2011,8 +2758,8 @@ bool QTReaderApp::openfrombkmk(Bkmk* bk) | |||
2011 | CFiledata(bk->anno()).name() | 2758 | CFiledata(bk->anno()).name() |
2012 | ); | 2759 | ); |
2013 | qDebug("fileinfo"); | 2760 | //qDebug("fileinfo"); |
2014 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) | 2761 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) |
2015 | { | 2762 | { |
2016 | qDebug("Opening"); | 2763 | //qDebug("Opening"); |
2017 | openFile(fn); | 2764 | openFile(fn); |
2018 | struct stat fnstat; | 2765 | struct stat fnstat; |
@@ -2036,5 +2783,6 @@ bool QTReaderApp::openfrombkmk(Bkmk* bk) | |||
2036 | QMessageBox::warning(this, PROGNAME, "Not all file data used\nNew version?"); | 2783 | QMessageBox::warning(this, PROGNAME, "Not all file data used\nNew version?"); |
2037 | } | 2784 | } |
2038 | qDebug("updating"); | 2785 | // qDebug("updating"); |
2786 | // showEditTools(); | ||
2039 | reader->locate(bk->value()); | 2787 | reader->locate(bk->value()); |
2040 | } | 2788 | } |
@@ -2049,8 +2797,10 @@ bool QTReaderApp::openfrombkmk(Bkmk* bk) | |||
2049 | void QTReaderApp::gotobkmk(int ind) | 2797 | void QTReaderApp::gotobkmk(int ind) |
2050 | { | 2798 | { |
2051 | switch (m_nRegAction) | 2799 | showEditTools(); |
2800 | switch (m_nBkmkAction) | ||
2052 | { | 2801 | { |
2053 | case cOpenFile: | 2802 | case cOpenFile: |
2054 | { | 2803 | { |
2804 | // qApp->processEvents(); | ||
2055 | if (!openfrombkmk((*pOpenlist)[ind])) | 2805 | if (!openfrombkmk((*pOpenlist)[ind])) |
2056 | { | 2806 | { |
@@ -2064,5 +2814,5 @@ void QTReaderApp::gotobkmk(int ind) | |||
2064 | break; | 2814 | break; |
2065 | case cDelBkmk: | 2815 | case cDelBkmk: |
2066 | // qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name()); | 2816 | //// qDebug("Deleting:%s\n",(*pBkmklist)[ind]->name()); |
2067 | pBkmklist->erase(ind); | 2817 | pBkmklist->erase(ind); |
2068 | m_fBkmksChanged = true; | 2818 | m_fBkmksChanged = true; |
@@ -2070,13 +2820,136 @@ void QTReaderApp::gotobkmk(int ind) | |||
2070 | break; | 2820 | break; |
2071 | case cRmBkmkFile: | 2821 | case cRmBkmkFile: |
2072 | unlink((const char *)Global::applicationFileName(APPDIR,bkmkselector->text(ind))); | 2822 | { |
2823 | #ifndef USEQPE | ||
2824 | QDir d = QDir::home(); // "/" | ||
2825 | d.cd(APPDIR); | ||
2826 | d.remove(bkmkselector->text(ind)); | ||
2827 | #else /* USEQPE */ | ||
2828 | unlink((const char *)Global::applicationFileName(APPDIR,bkmkselector->text(ind))); | ||
2829 | #endif /* USEQPE */ | ||
2830 | } | ||
2831 | break; | ||
2832 | case cLdConfig: | ||
2833 | readconfig(bkmkselector->text(ind), false); | ||
2834 | break; | ||
2835 | case cRmConfig: | ||
2836 | { | ||
2837 | #ifndef USEQPE | ||
2838 | QDir d = QDir::home(); // "/" | ||
2839 | d.cd(APPDIR "/configs"); | ||
2840 | d.remove(bkmkselector->text(ind)); | ||
2841 | #else /* USEQPE */ | ||
2842 | unlink((const char *)Global::applicationFileName(APPDIR "/configs",bkmkselector->text(ind))); | ||
2843 | #endif /* USEQPE */ | ||
2844 | } | ||
2073 | break; | 2845 | break; |
2846 | case cExportLinks: | ||
2847 | { | ||
2848 | #ifndef USEQPE | ||
2849 | QDir d = QDir::home(); // "/" | ||
2850 | d.cd(APPDIR "/urls"); | ||
2851 | QFileInfo fi(d, bkmkselector->text(ind)); | ||
2852 | if (fi.exists()) | ||
2853 | { | ||
2854 | QString outfile( QFileDialog::getSaveFileName( QString::null, QString::null, this ) ); | ||
2855 | if (!outfile.isEmpty()) | ||
2856 | { | ||
2857 | FILE* fout = fopen((const char *)outfile, "w"); | ||
2858 | if (fout != NULL) | ||
2859 | { | ||
2860 | FILE* fin = fopen((const char *)fi.absFilePath(), "r"); | ||
2861 | if (fin != NULL) | ||
2862 | { | ||
2863 | fprintf(fout, "<html><body>\n"); | ||
2864 | int ch = 0; | ||
2865 | while ((ch = fgetc(fin)) != EOF) | ||
2866 | { | ||
2867 | fputc(ch, fout); | ||
2868 | } | ||
2869 | fclose(fin); | ||
2870 | fprintf(fout, "</html></body>\n"); | ||
2871 | d.remove(bkmkselector->text(ind)); | ||
2872 | } | ||
2873 | fclose(fout); | ||
2874 | } | ||
2875 | else | ||
2876 | QMessageBox::information(this, PROGNAME, "Couldn't open output"); | ||
2877 | } | ||
2878 | } | ||
2879 | #else /* USEQPE */ | ||
2880 | FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); | ||
2881 | if (fin != NULL) | ||
2882 | { | ||
2883 | bool allok = false; | ||
2884 | fileBrowser* fb = new fileBrowser(true, this,"OpieReader",!m_bFloatingDialog, 0, "*", QString::null); | ||
2885 | if (fb->exec()) | ||
2886 | { | ||
2887 | QString outfile = fb->getCurrentFile(); | ||
2888 | FILE* fout = fopen((const char *)outfile, "w"); | ||
2889 | if (fout != NULL) | ||
2890 | { | ||
2891 | fprintf(fout, "<html><body>\n"); | ||
2892 | int ch = 0; | ||
2893 | while ((ch = fgetc(fin)) != EOF) | ||
2894 | { | ||
2895 | fputc(ch, fout); | ||
2896 | } | ||
2897 | fprintf(fout, "</html></body>\n"); | ||
2898 | fclose(fout); | ||
2899 | allok = true; | ||
2900 | } | ||
2901 | else | ||
2902 | QMessageBox::information(this, PROGNAME, "Couldn't open output"); | ||
2903 | } | ||
2904 | delete fb; | ||
2905 | fclose(fin); | ||
2906 | if (allok) unlink((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind))); | ||
2907 | } | ||
2908 | else | ||
2909 | { | ||
2910 | QMessageBox::information(this, PROGNAME, "Couldn't open input"); | ||
2911 | } | ||
2912 | |||
2913 | /* | ||
2914 | CFileSelector *f = new CFileSelector("text/html", this, NULL, !m_bFloatingDialog, TRUE, TRUE ); | ||
2915 | int ret = f->exec(); | ||
2916 | qDebug("Return:%d", ret); | ||
2917 | DocLnk* doc = f->getDoc(); | ||
2918 | if (doc != NULL) | ||
2919 | { | ||
2920 | FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); | ||
2921 | QString rt; | ||
2922 | rt = "<html><body>\n"; | ||
2923 | int ch = 0; | ||
2924 | while ((ch = fgetc(fin)) != EOF) | ||
2925 | { | ||
2926 | rt += (char)ch; | ||
2927 | } | ||
2928 | fclose(fin); | ||
2929 | rt += "</html></body>\n"; | ||
2930 | if ( doc->name().isEmpty() ) | ||
2931 | { | ||
2932 | doc->setName(bkmkselector->text(ind)); | ||
2933 | } | ||
2934 | FileManager fm; | ||
2935 | fm.saveFile( *doc, rt ); | ||
2936 | qDebug("YES"); | ||
2937 | } | ||
2938 | else | ||
2939 | { | ||
2940 | qDebug("NO"); | ||
2941 | } | ||
2942 | delete f; | ||
2943 | */ | ||
2944 | |||
2945 | #endif /* USEQPE */ | ||
2946 | } | ||
2947 | break; | ||
2074 | } | 2948 | } |
2075 | showEditTools(); | ||
2076 | } | 2949 | } |
2077 | 2950 | ||
2078 | void QTReaderApp::cancelbkmk() | 2951 | void QTReaderApp::cancelbkmk() |
2079 | { | 2952 | { |
2080 | if (m_nRegAction == cOpenFile) | 2953 | if (m_nBkmkAction == cOpenFile) |
2081 | { | 2954 | { |
2082 | QString fn = usefilebrowser(); | 2955 | QString fn = usefilebrowser(); |
@@ -2109,5 +2982,7 @@ void QTReaderApp::do_regaction() | |||
2109 | reader->bDoUpdates = false; | 2982 | reader->bDoUpdates = false; |
2110 | regBar->hide(); | 2983 | regBar->hide(); |
2984 | #ifdef USEQPE | ||
2111 | Global::hideInputMethod(); | 2985 | Global::hideInputMethod(); |
2986 | #endif | ||
2112 | regVisible = false; | 2987 | regVisible = false; |
2113 | switch(m_nRegAction) | 2988 | switch(m_nRegAction) |
@@ -2122,18 +2997,26 @@ void QTReaderApp::do_regaction() | |||
2122 | do_jump(regEdit->text()); | 2997 | do_jump(regEdit->text()); |
2123 | break; | 2998 | break; |
2999 | /* | ||
2124 | case cMonoSpace: | 3000 | case cMonoSpace: |
2125 | do_mono(regEdit->text()); | 3001 | do_mono(regEdit->text()); |
2126 | break; | 3002 | break; |
2127 | case cOverlap: | 3003 | */ |
2128 | do_overlap(regEdit->text()); | ||
2129 | break; | ||
2130 | case cSetTarget: | 3004 | case cSetTarget: |
2131 | do_settarget(regEdit->text()); | 3005 | do_settarget(regEdit->text()); |
2132 | break; | 3006 | break; |
3007 | #ifdef _SCROLLPIPE | ||
3008 | case cSetPipeTarget: | ||
3009 | do_setpipetarget(regEdit->text()); | ||
3010 | break; | ||
3011 | #endif | ||
3012 | case cSetConfigName: | ||
3013 | // qDebug("Saving config"); | ||
3014 | do_saveconfig(regEdit->text(), false); | ||
3015 | break; | ||
2133 | } | 3016 | } |
2134 | reader->restore(); | 3017 | // reader->restore(); |
2135 | // editBar->show(); | 3018 | // fileBar->show(); |
2136 | reader->setFocus(); | 3019 | reader->setFocus(); |
2137 | qApp->processEvents(); | 3020 | // qApp->processEvents(); |
2138 | reader->bDoUpdates = true; | 3021 | reader->bDoUpdates = true; |
2139 | reader->update(); | 3022 | reader->update(); |
@@ -2156,6 +3039,35 @@ void QTReaderApp::do_settarget(const QString& _txt) | |||
2156 | } | 3039 | } |
2157 | 3040 | ||
3041 | void QTReaderApp::chooseencoding() | ||
3042 | { | ||
3043 | m_fontSelector->clear(); | ||
3044 | m_fontSelector->insertItem("Ascii"); | ||
3045 | m_fontSelector->insertItem("UTF-8"); | ||
3046 | m_fontSelector->insertItem("UCS-2(BE)"); | ||
3047 | m_fontSelector->insertItem("USC-2(LE)"); | ||
3048 | m_fontSelector->insertItem("Palm"); | ||
3049 | for (unicodetable::iterator iter = unicodetable::begin(); iter != unicodetable::end(); iter++) | ||
3050 | { | ||
3051 | m_fontSelector->insertItem(iter->mime); | ||
3052 | } // delete the FontDatabase!!! | ||
3053 | m_fontSelector->setCurrentItem (reader->m_encd); | ||
3054 | m_fontAction = cChooseEncoding; | ||
3055 | m_fontBar->show(); | ||
3056 | m_fontVisible = true; | ||
3057 | } | ||
3058 | |||
2158 | void QTReaderApp::setfont() | 3059 | void QTReaderApp::setfont() |
2159 | { | 3060 | { |
3061 | m_fontSelector->clear(); | ||
3062 | { | ||
3063 | #ifdef USEQPE | ||
3064 | FontDatabase f; | ||
3065 | #else | ||
3066 | QFontDatabase f; | ||
3067 | #endif | ||
3068 | QStringList flist = f.families(); | ||
3069 | m_fontSelector->insertStringList(flist); | ||
3070 | } // delete the FontDatabase!!! | ||
3071 | |||
2160 | for (int i = 1; i <= m_fontSelector->count(); i++) | 3072 | for (int i = 1; i <= m_fontSelector->count(); i++) |
2161 | { | 3073 | { |
@@ -2166,4 +3078,5 @@ void QTReaderApp::setfont() | |||
2166 | } | 3078 | } |
2167 | } | 3079 | } |
3080 | m_fontAction = cChooseFont; | ||
2168 | m_fontBar->show(); | 3081 | m_fontBar->show(); |
2169 | m_fontVisible = true; | 3082 | m_fontVisible = true; |
@@ -2173,32 +3086,47 @@ void QTReaderApp::setfontHelper(const QString& lcn, int size) | |||
2173 | { | 3086 | { |
2174 | if (size == 0) size = reader->m_fontControl.currentsize(); | 3087 | if (size == 0) size = reader->m_fontControl.currentsize(); |
2175 | QFont f(lcn, 10 /*, QFont::Bold*/); | 3088 | if (m_propogatefontchange) |
2176 | qDebug("bs"); | 3089 | { |
2177 | bkmkselector->setFont( f ); | 3090 | QFont f(lcn, 10); |
2178 | qDebug("re"); | 3091 | bkmkselector->setFont( f ); |
2179 | regEdit->setFont( f ); | 3092 | regEdit->setFont( f ); |
2180 | qDebug("se"); | 3093 | searchEdit->setFont( f ); |
2181 | searchEdit->setFont( f ); | 3094 | m_annoWin->setFont( f ); |
2182 | qDebug("aw"); | 3095 | } |
2183 | m_annoWin->setFont( f ); | ||
2184 | reader->m_fontname = lcn; | 3096 | reader->m_fontname = lcn; |
2185 | qDebug("cf1"); | ||
2186 | if (!reader->ChangeFont(size)) | 3097 | if (!reader->ChangeFont(size)) |
2187 | { | 3098 | { |
2188 | qDebug("cf2"); | ||
2189 | reader->ChangeFont(size); | 3099 | reader->ChangeFont(size); |
2190 | } | 3100 | } |
2191 | qDebug("ref"); | 3101 | } |
3102 | |||
3103 | void QTReaderApp::do_setencoding(int i) | ||
3104 | { | ||
3105 | // qDebug("setencoding:%d", i); | ||
3106 | if (m_fontAction == cChooseEncoding) | ||
3107 | { | ||
3108 | reader->setencoding(i); | ||
3109 | } | ||
2192 | reader->refresh(); | 3110 | reader->refresh(); |
2193 | m_fontBar->hide(); | 3111 | m_fontBar->hide(); |
2194 | m_fontVisible = false; | 3112 | m_fontVisible = false; |
2195 | qDebug("showedit"); | 3113 | // qDebug("showedit"); |
2196 | if (reader->isVisible()) showEditTools(); | 3114 | if (reader->isVisible()) showEditTools(); |
2197 | qDebug("showeditdone"); | 3115 | // qDebug("showeditdone"); |
2198 | } | 3116 | } |
2199 | 3117 | ||
2200 | void QTReaderApp::do_setfont(const QString& lcn) | 3118 | void QTReaderApp::do_setfont(const QString& lcn) |
2201 | { | 3119 | { |
2202 | setfontHelper(lcn); | 3120 | if (m_fontAction == cChooseFont) |
3121 | { | ||
3122 | setfontHelper(lcn); | ||
3123 | } | ||
3124 | reader->refresh(); | ||
3125 | m_fontBar->hide(); | ||
3126 | m_fontVisible = false; | ||
3127 | // qDebug("showedit"); | ||
3128 | //if (reader->isVisible()) | ||
3129 | showEditTools(); | ||
3130 | // qDebug("showeditdone"); | ||
2203 | } | 3131 | } |
2204 | 3132 | ||
@@ -2207,5 +3135,5 @@ void QTReaderApp::do_autogen(const QString& regText) | |||
2207 | unsigned long fs, ts; | 3135 | unsigned long fs, ts; |
2208 | reader->sizes(fs,ts); | 3136 | reader->sizes(fs,ts); |
2209 | // qDebug("Reg:%s\n", (const tchar*)(regEdit->text())); | 3137 | // // qDebug("Reg:%s\n", (const tchar*)(regEdit->text())); |
2210 | m_autogenstr = regText; | 3138 | m_autogenstr = regText; |
2211 | QRegExp re(regText); | 3139 | QRegExp re(regText); |
@@ -2214,7 +3142,10 @@ void QTReaderApp::do_autogen(const QString& regText) | |||
2214 | pBkmklist = new CList<Bkmk>; | 3142 | pBkmklist = new CList<Bkmk>; |
2215 | m_fBkmksChanged = true; | 3143 | m_fBkmksChanged = true; |
3144 | |||
3145 | pbar->setGeometry(regBar->x(),regBar->y(),regBar->width(), regBar->height()); | ||
2216 | pbar->show(); | 3146 | pbar->show(); |
2217 | pbar->resize(width(), editBar->height()); | 3147 | pbar->raise(); |
2218 | pbar->reset(); | 3148 | pbar->reset(); |
3149 | reader->update(); | ||
2219 | qApp->processEvents(); | 3150 | qApp->processEvents(); |
2220 | reader->setFocus(); | 3151 | reader->setFocus(); |
@@ -2246,9 +3177,15 @@ pbar->resize(width(), editBar->height()); | |||
2246 | qApp->processEvents(); | 3177 | qApp->processEvents(); |
2247 | pbar->hide(); | 3178 | pbar->hide(); |
3179 | reader->refresh(); | ||
2248 | } | 3180 | } |
2249 | 3181 | ||
2250 | void QTReaderApp::saveprefs() | 3182 | void QTReaderApp::saveprefs() |
2251 | { | 3183 | { |
3184 | // qDebug("saveprefs"); | ||
2252 | // reader->saveprefs("uqtreader"); | 3185 | // reader->saveprefs("uqtreader"); |
3186 | // if (!m_loadedconfig) | ||
3187 | do_saveconfig( APPDIR, true ); | ||
3188 | |||
3189 | /* | ||
2253 | Config config( APPDIR ); | 3190 | Config config( APPDIR ); |
2254 | config.setGroup( "View" ); | 3191 | config.setGroup( "View" ); |
@@ -2256,4 +3193,5 @@ void QTReaderApp::saveprefs() | |||
2256 | reader->m_lastposn = reader->pagelocate(); | 3193 | reader->m_lastposn = reader->pagelocate(); |
2257 | 3194 | ||
3195 | config.writeEntry("FloatDialogs", m_bFloatingDialog); | ||
2258 | config.writeEntry( "StripCr", reader->bstripcr ); | 3196 | config.writeEntry( "StripCr", reader->bstripcr ); |
2259 | config.writeEntry( "AutoFmt", reader->bautofmt ); | 3197 | config.writeEntry( "AutoFmt", reader->bautofmt ); |
@@ -2261,4 +3199,6 @@ void QTReaderApp::saveprefs() | |||
2261 | config.writeEntry( "StripHtml", reader->bstriphtml ); | 3199 | config.writeEntry( "StripHtml", reader->bstriphtml ); |
2262 | config.writeEntry( "Dehyphen", reader->bdehyphen ); | 3200 | config.writeEntry( "Dehyphen", reader->bdehyphen ); |
3201 | config.writeEntry( "Depluck", reader->bdepluck ); | ||
3202 | config.writeEntry( "Dejpluck", reader->bdejpluck ); | ||
2263 | config.writeEntry( "OneSpace", reader->bonespace ); | 3203 | config.writeEntry( "OneSpace", reader->bonespace ); |
2264 | config.writeEntry( "Unindent", reader->bunindent ); | 3204 | config.writeEntry( "Unindent", reader->bunindent ); |
@@ -2271,12 +3211,17 @@ void QTReaderApp::saveprefs() | |||
2271 | config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); | 3211 | config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); |
2272 | config.writeEntry( "PageMode", reader->m_bpagemode ); | 3212 | config.writeEntry( "PageMode", reader->m_bpagemode ); |
2273 | config.writeEntry( "CursorNavigation", reader->m_navkeys ); | ||
2274 | config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); | 3213 | config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); |
3214 | config.writeEntry( "SwapMouse", reader->m_swapmouse); | ||
2275 | config.writeEntry( "Fontname", reader->m_fontname ); | 3215 | config.writeEntry( "Fontname", reader->m_fontname ); |
2276 | config.writeEntry( "Encoding", reader->m_encd ); | 3216 | config.writeEntry( "Encoding", reader->m_encd ); |
2277 | config.writeEntry( "CharSpacing", reader->m_charpc ); | 3217 | config.writeEntry( "CharSpacing", reader->m_charpc ); |
2278 | config.writeEntry( "Overlap", (int)(reader->m_overlap) ); | 3218 | config.writeEntry( "Overlap", (int)(reader->m_overlap) ); |
3219 | config.writeEntry( "Margin", (int)reader->m_border ); | ||
2279 | config.writeEntry( "TargetApp", m_targetapp ); | 3220 | config.writeEntry( "TargetApp", m_targetapp ); |
2280 | config.writeEntry( "TargetMsg", m_targetmsg ); | 3221 | config.writeEntry( "TargetMsg", m_targetmsg ); |
3222 | #ifdef _SCROLLPIPE | ||
3223 | config.writeEntry( "PipeTarget", reader->m_pipetarget ); | ||
3224 | config.writeEntry( "PauseAfterPara", reader->m_pauseAfterEachPara ); | ||
3225 | #endif | ||
2281 | config.writeEntry( "TwoTouch", m_twoTouch ); | 3226 | config.writeEntry( "TwoTouch", m_twoTouch ); |
2282 | config.writeEntry( "Annotation", m_doAnnotation); | 3227 | config.writeEntry( "Annotation", m_doAnnotation); |
@@ -2284,4 +3229,14 @@ void QTReaderApp::saveprefs() | |||
2284 | config.writeEntry( "Clipboard", m_doClipboard); | 3229 | config.writeEntry( "Clipboard", m_doClipboard); |
2285 | config.writeEntry( "SpaceTarget", m_spaceTarget); | 3230 | config.writeEntry( "SpaceTarget", m_spaceTarget); |
3231 | config.writeEntry( "EscapeTarget", m_escapeTarget); | ||
3232 | config.writeEntry( "ReturnTarget", m_returnTarget); | ||
3233 | config.writeEntry( "LeftTarget", m_leftTarget); | ||
3234 | config.writeEntry( "RightTarget", m_rightTarget); | ||
3235 | config.writeEntry( "UpTarget", m_upTarget); | ||
3236 | config.writeEntry( "DownTarget", m_downTarget); | ||
3237 | config.writeEntry("LeftScroll", m_leftScroll); | ||
3238 | config.writeEntry("RightScroll", m_rightScroll); | ||
3239 | config.writeEntry("UpScroll", m_upScroll); | ||
3240 | config.writeEntry("DownScroll", m_downScroll); | ||
2286 | #ifdef REPALM | 3241 | #ifdef REPALM |
2287 | config.writeEntry( "Repalm", reader->brepalm ); | 3242 | config.writeEntry( "Repalm", reader->brepalm ); |
@@ -2291,26 +3246,26 @@ void QTReaderApp::saveprefs() | |||
2291 | config.writeEntry( "MakeBold", reader->bmakebold ); | 3246 | config.writeEntry( "MakeBold", reader->bmakebold ); |
2292 | config.writeEntry( "Continuous", reader->m_continuousDocument ); | 3247 | config.writeEntry( "Continuous", reader->m_continuousDocument ); |
2293 | 3248 | config.writeEntry( "FullJust", reader->bfulljust ); | |
3249 | config.writeEntry( "ExtraSpace", reader->getextraspace() ); | ||
3250 | config.writeEntry( "ExtraLead", reader->getlead() ); | ||
3251 | config.writeEntry( "Basesize", (int)reader->getBaseSize()); | ||
3252 | config.writeEntry( "RequestorFontChange", m_propogatefontchange); | ||
3253 | |||
3254 | config.setGroup( "Toolbar" ); | ||
3255 | config.writeEntry("Movable", m_tbmovesave); | ||
3256 | config.writeEntry("Policy", m_tbpolsave); | ||
3257 | config.writeEntry("Position", m_tbposition); | ||
3258 | */ | ||
2294 | savefilelist(); | 3259 | savefilelist(); |
2295 | } | 3260 | } |
2296 | 3261 | ||
2297 | void QTReaderApp::indentplus() | ||
2298 | { | ||
2299 | reader->indentplus(); | ||
2300 | } | ||
2301 | |||
2302 | void QTReaderApp::indentminus() | ||
2303 | { | ||
2304 | reader->indentminus(); | ||
2305 | } | ||
2306 | |||
2307 | /* | 3262 | /* |
2308 | void QTReaderApp::oldFile() | 3263 | void QTReaderApp::oldFile() |
2309 | { | 3264 | { |
2310 | qDebug("oldFile called"); | 3265 | // qDebug("oldFile called"); |
2311 | reader->setText(true); | 3266 | reader->setText(true); |
2312 | qDebug("settext called"); | 3267 | // qDebug("settext called"); |
2313 | showEditTools(); | 3268 | showEditTools(); |
2314 | qDebug("showedit called"); | 3269 | // qDebug("showedit called"); |
2315 | } | 3270 | } |
2316 | */ | 3271 | */ |
@@ -2365,5 +3320,12 @@ void QTReaderApp::savebkmks() | |||
2365 | if (pBkmklist != NULL) | 3320 | if (pBkmklist != NULL) |
2366 | { | 3321 | { |
2367 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR, reader->m_string), true); | 3322 | #ifndef USEQPE |
3323 | QDir d = QDir::home(); // "/" | ||
3324 | d.cd(APPDIR); | ||
3325 | QFileInfo fi(d, reader->m_string); | ||
3326 | BkmkFile bf((const char *)fi.absFilePath(), true); | ||
3327 | #else /* USEQPE */ | ||
3328 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string), true); | ||
3329 | #endif /* USEQPE */ | ||
2368 | bf.write(*pBkmklist); | 3330 | bf.write(*pBkmklist); |
2369 | } | 3331 | } |
@@ -2373,9 +3335,16 @@ void QTReaderApp::savebkmks() | |||
2373 | void QTReaderApp::readfilelist() | 3335 | void QTReaderApp::readfilelist() |
2374 | { | 3336 | { |
2375 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR, ".openfiles")); | 3337 | #ifndef USEQPE |
2376 | qDebug("Reading open files"); | 3338 | QDir d = QDir::home(); // "/" |
3339 | d.cd(APPDIR); | ||
3340 | QFileInfo fi(d, ".openfiles"); | ||
3341 | BkmkFile bf((const char *)fi.absFilePath()); | ||
3342 | #else /* USEQPE */ | ||
3343 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles")); | ||
3344 | #endif /* USEQPE */ | ||
3345 | // qDebug("Reading open files"); | ||
2377 | pOpenlist = bf.readall(); | 3346 | pOpenlist = bf.readall(); |
2378 | if (pOpenlist != NULL) qDebug("...with success"); | 3347 | // if (pOpenlist != NULL) qDebug("...with success"); |
2379 | else qDebug("...without success!"); | 3348 | // else qDebug("...without success!"); |
2380 | } | 3349 | } |
2381 | 3350 | ||
@@ -2384,6 +3353,13 @@ void QTReaderApp::savefilelist() | |||
2384 | if (pOpenlist != NULL) | 3353 | if (pOpenlist != NULL) |
2385 | { | 3354 | { |
2386 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR, ".openfiles"), true); | 3355 | #ifndef USEQPE |
2387 | qDebug("Writing open files"); | 3356 | QDir d = QDir::home(); // "/" |
3357 | d.cd(APPDIR); | ||
3358 | QFileInfo fi(d, ".openfiles"); | ||
3359 | BkmkFile bf((const char *)fi.absFilePath(), true); | ||
3360 | #else /* USEQPE */ | ||
3361 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,".openfiles"), true); | ||
3362 | #endif /* USEQPE */ | ||
3363 | //qDebug("Writing open files"); | ||
2388 | bf.write(*pOpenlist); | 3364 | bf.write(*pOpenlist); |
2389 | } | 3365 | } |
@@ -2398,17 +3374,34 @@ void QTReaderApp::readbkmks() | |||
2398 | struct stat fnstat; | 3374 | struct stat fnstat; |
2399 | struct stat bkstat; | 3375 | struct stat bkstat; |
3376 | #ifndef USEQPE | ||
3377 | QDir d = QDir::home(); // "/" | ||
3378 | d.cd(APPDIR); | ||
3379 | QFileInfo fi(d, reader->m_string); | ||
3380 | #endif /* ! USEQPE */ | ||
2400 | if ( | 3381 | if ( |
2401 | stat((const char *)reader->m_lastfile, &fnstat) == 0 | 3382 | stat((const char *)reader->m_lastfile, &fnstat) == 0 |
2402 | && | 3383 | && |
2403 | stat((const char *)Global::applicationFileName(APPDIR, reader->m_string), &bkstat) == 0 | 3384 | #ifndef USEQPE |
3385 | stat((const char *)fi.absFilePath(), &bkstat) == 0 | ||
3386 | #else /* USEQPE */ | ||
3387 | stat((const char *)Global::applicationFileName(APPDIR,reader->m_string), &bkstat) == 0 | ||
3388 | #endif /* USEQPE */ | ||
2404 | ) | 3389 | ) |
2405 | { | 3390 | { |
2406 | if (bkstat.st_mtime < fnstat.st_mtime) | 3391 | if (bkstat.st_mtime < fnstat.st_mtime) |
2407 | { | 3392 | { |
2408 | unlink((const char *)Global::applicationFileName(APPDIR, reader->m_string)); | 3393 | #ifndef USEQPE |
3394 | unlink((const char *)fi.absFilePath()); | ||
3395 | #else /* USEQPE */ | ||
3396 | unlink((const char *)Global::applicationFileName(APPDIR,reader->m_string)); | ||
3397 | #endif /* USEQPE */ | ||
2409 | } | 3398 | } |
2410 | } | 3399 | } |
2411 | 3400 | ||
2412 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR, reader->m_string)); | 3401 | #ifndef USEQPE |
3402 | BkmkFile bf((const char *)fi.absFilePath()); | ||
3403 | #else /* USEQPE */ | ||
3404 | BkmkFile bf((const char *)Global::applicationFileName(APPDIR,reader->m_string)); | ||
3405 | #endif /* USEQPE */ | ||
2413 | 3406 | ||
2414 | pBkmklist = bf.readall(); | 3407 | pBkmklist = bf.readall(); |
@@ -2457,5 +3450,5 @@ void QTReaderApp::do_addbkmk(const QString& text) | |||
2457 | void QTReaderApp::OnRedraw() | 3450 | void QTReaderApp::OnRedraw() |
2458 | { | 3451 | { |
2459 | if (pBkmklist != NULL) | 3452 | if ((pBkmklist != NULL) && (m_bkmkAvail != NULL)) |
2460 | { | 3453 | { |
2461 | bool found = findNextBookmark(reader->pagelocate()); | 3454 | bool found = findNextBookmark(reader->pagelocate()); |
@@ -2469,5 +3462,7 @@ void QTReaderApp::showAnnotation() | |||
2469 | m_annoWin->setAnno(toQString(m_anno->anno())); | 3462 | m_annoWin->setAnno(toQString(m_anno->anno())); |
2470 | m_annoIsEditing = false; | 3463 | m_annoIsEditing = false; |
3464 | #ifdef USEQPE | ||
2471 | Global::showInputMethod(); | 3465 | Global::showInputMethod(); |
3466 | #endif | ||
2472 | editorStack->raiseWidget( m_annoWin ); | 3467 | editorStack->raiseWidget( m_annoWin ); |
2473 | m_annoWin->setFocus(); | 3468 | m_annoWin->setFocus(); |
@@ -2476,5 +3471,5 @@ void QTReaderApp::showAnnotation() | |||
2476 | void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString& line) | 3471 | void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString& line) |
2477 | { | 3472 | { |
2478 | // qDebug("OnWordSelected(%u):%s", posn, (const char*)wrd); | 3473 | //// qDebug("OnWordSelected(%u):%s", posn, (const char*)wrd); |
2479 | 3474 | ||
2480 | if (m_doClipboard) | 3475 | if (m_doClipboard) |
@@ -2482,4 +3477,5 @@ void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString& | |||
2482 | QClipboard* cb = QApplication::clipboard(); | 3477 | QClipboard* cb = QApplication::clipboard(); |
2483 | cb->setText(wrd); | 3478 | cb->setText(wrd); |
3479 | #ifdef USEQPE | ||
2484 | if (wrd.length() > 10) | 3480 | if (wrd.length() > 10) |
2485 | { | 3481 | { |
@@ -2490,4 +3486,5 @@ void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString& | |||
2490 | Global::statusMessage(wrd); | 3486 | Global::statusMessage(wrd); |
2491 | } | 3487 | } |
3488 | #endif | ||
2492 | } | 3489 | } |
2493 | if (m_doAnnotation) | 3490 | if (m_doAnnotation) |
@@ -2498,7 +3495,10 @@ void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString& | |||
2498 | m_annoWin->setPosn(posn); | 3495 | m_annoWin->setPosn(posn); |
2499 | m_annoIsEditing = true; | 3496 | m_annoIsEditing = true; |
3497 | #ifdef USEQPE | ||
2500 | Global::showInputMethod(); | 3498 | Global::showInputMethod(); |
3499 | #endif | ||
2501 | editorStack->raiseWidget( m_annoWin ); | 3500 | editorStack->raiseWidget( m_annoWin ); |
2502 | } | 3501 | } |
3502 | #ifdef USEQPE | ||
2503 | if (m_doDictionary) | 3503 | if (m_doDictionary) |
2504 | { | 3504 | { |
@@ -2509,42 +3509,235 @@ void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, const QString& | |||
2509 | } | 3509 | } |
2510 | } | 3510 | } |
3511 | #endif | ||
2511 | } | 3512 | } |
2512 | 3513 | ||
2513 | void QTReaderApp::OnActionPressed() | 3514 | void QTReaderApp::doAction(ActionTypes a, QKeyEvent* e) |
2514 | { | 3515 | { |
2515 | switch (m_spaceTarget) | 3516 | if (a == 0) |
2516 | { | 3517 | { |
2517 | case cesOpenFile: | 3518 | e->ignore(); |
2518 | { | 3519 | } |
2519 | fileOpen(); | 3520 | else |
2520 | } | 3521 | { |
2521 | break; | 3522 | e->accept(); |
2522 | case cesAutoScroll: | 3523 | //qDebug("Accepted"); |
2523 | { | 3524 | switch (a) |
2524 | reader->setautoscroll(!reader->m_autoScroll); | ||
2525 | setScrollState(reader->m_autoScroll); | ||
2526 | } | ||
2527 | break; | ||
2528 | case cesActionMark: | ||
2529 | { | 3525 | { |
2530 | addbkmk(); | 3526 | case cesOpenFile: |
3527 | { | ||
3528 | fileOpen(); | ||
3529 | } | ||
3530 | break; | ||
3531 | case cesAutoScroll: | ||
3532 | { | ||
3533 | reader->setautoscroll(!reader->m_autoScroll); | ||
3534 | setScrollState(reader->m_autoScroll); | ||
3535 | } | ||
3536 | break; | ||
3537 | case cesActionMark: | ||
3538 | { | ||
3539 | addbkmk(); | ||
3540 | } | ||
3541 | break; | ||
3542 | case cesFullScreen: | ||
3543 | { | ||
3544 | m_actFullscreen->setOn(!m_fullscreen); | ||
3545 | } | ||
3546 | break; | ||
3547 | case cesActionAnno: | ||
3548 | { | ||
3549 | addanno(); | ||
3550 | } | ||
3551 | break; | ||
3552 | case cesZoomIn: | ||
3553 | zoomin(); | ||
3554 | break; | ||
3555 | case cesZoomOut: | ||
3556 | zoomout(); | ||
3557 | break; | ||
3558 | case cesBack: | ||
3559 | reader->goBack(); | ||
3560 | break; | ||
3561 | case cesForward: | ||
3562 | reader->goForward(); | ||
3563 | break; | ||
3564 | case cesHome: | ||
3565 | reader->goHome(); | ||
3566 | break; | ||
3567 | case cesPageUp: | ||
3568 | reader->dopageup(); | ||
3569 | break; | ||
3570 | case cesPageDown: | ||
3571 | reader->dopagedn(); | ||
3572 | break; | ||
3573 | case cesLineUp: | ||
3574 | reader->lineUp(); | ||
3575 | break; | ||
3576 | case cesLineDown: | ||
3577 | reader->lineDown(); | ||
3578 | break; | ||
3579 | case cesStartDoc: | ||
3580 | gotoStart(); | ||
3581 | break; | ||
3582 | case cesEndDoc: | ||
3583 | gotoEnd(); | ||
3584 | break; | ||
3585 | default: | ||
3586 | qDebug("Unknown ActionType:%u", a); | ||
3587 | break; | ||
2531 | } | 3588 | } |
2532 | break; | 3589 | } |
2533 | case cesFullScreen: | 3590 | } |
3591 | |||
3592 | void QTReaderApp::setTwoTouch(bool _b) { reader->setTwoTouch(_b); } | ||
3593 | void QTReaderApp::restoreFocus() { reader->setFocus(); } | ||
3594 | |||
3595 | void QTReaderApp::SaveConfig() | ||
3596 | { | ||
3597 | m_nRegAction = cSetConfigName; | ||
3598 | regEdit->setText(reader->m_string); | ||
3599 | do_regedit(); | ||
3600 | } | ||
3601 | |||
3602 | void QTReaderApp::do_saveconfig(const QString& _txt, bool full) | ||
3603 | { | ||
3604 | // qDebug("do_saveconfig:%s", (const char*)_txt); | ||
3605 | #ifdef USEQPE | ||
3606 | QString configname; | ||
3607 | Config::Domain dom; | ||
3608 | |||
3609 | if (full) | ||
3610 | { | ||
3611 | configname = _txt; | ||
3612 | dom = Config::User; | ||
3613 | } | ||
3614 | else | ||
3615 | { | ||
3616 | configname = Global::applicationFileName(APPDIR "/configs", _txt); | ||
3617 | dom = Config::File; | ||
3618 | } | ||
3619 | |||
3620 | Config config(configname, dom); | ||
3621 | config.setGroup( "View" ); | ||
3622 | |||
3623 | #else | ||
3624 | QFileInfo fi; | ||
3625 | if (full) | ||
2534 | { | 3626 | { |
2535 | m_actFullscreen->setOn(true); | 3627 | // qDebug("full:%s", (const char*)_txt); |
3628 | QDir d = QDir::home(); // "/" | ||
3629 | if ( !d.cd(_txt) ) | ||
3630 | { // "/tmp" | ||
3631 | qWarning( "Cannot find the \"~/%s\" directory", (const char*)_txt ); | ||
3632 | d = QDir::home(); | ||
3633 | d.mkdir(_txt); | ||
3634 | d.cd(_txt); | ||
3635 | } | ||
3636 | fi.setFile(d, INIFILE); | ||
2536 | } | 3637 | } |
2537 | break; | 3638 | else |
2538 | default: | ||
2539 | { | 3639 | { |
2540 | qDebug("Unknown ActionType:%u", m_spaceTarget); | 3640 | QDir d = QDir::home(); // "/" |
3641 | if ( !d.cd(APPDIR) ) | ||
3642 | { // "/tmp" | ||
3643 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | ||
3644 | d = QDir::home(); | ||
3645 | d.mkdir(APPDIR); | ||
3646 | d.cd(APPDIR); | ||
3647 | } | ||
3648 | if ( !d.cd("configs") ) | ||
3649 | { // "/tmp" | ||
3650 | qWarning( "Cannot find the \"~/" APPDIR "/configs\" directory" ); | ||
3651 | d = QDir::home(); | ||
3652 | d.cd(APPDIR); | ||
3653 | d.mkdir("configs"); | ||
3654 | d.cd("configs"); | ||
3655 | } | ||
3656 | fi.setFile(d, _txt); | ||
2541 | } | 3657 | } |
2542 | break; | 3658 | //qDebug("Path:%s", (const char*)fi.absFilePath()); |
3659 | Config config(fi.absFilePath()); | ||
3660 | #endif | ||
3661 | |||
3662 | |||
3663 | config.writeEntry( "StripCr", reader->bstripcr ); | ||
3664 | config.writeEntry( "AutoFmt", reader->bautofmt ); | ||
3665 | config.writeEntry( "TextFmt", reader->btextfmt ); | ||
3666 | config.writeEntry( "StripHtml", reader->bstriphtml ); | ||
3667 | config.writeEntry( "Dehyphen", reader->bdehyphen ); | ||
3668 | config.writeEntry( "Depluck", reader->bdepluck ); | ||
3669 | config.writeEntry( "Dejpluck", reader->bdejpluck ); | ||
3670 | config.writeEntry( "OneSpace", reader->bonespace ); | ||
3671 | config.writeEntry( "Unindent", reader->bunindent ); | ||
3672 | config.writeEntry( "Repara", reader->brepara ); | ||
3673 | config.writeEntry( "DoubleSpace", reader->bdblspce ); | ||
3674 | config.writeEntry( "Indent", reader->bindenter ); | ||
3675 | config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) ); | ||
3676 | config.writeEntry( "ScrollDelay", reader->m_delay); | ||
3677 | if (full) | ||
3678 | { | ||
3679 | config.writeEntry("Debounce", m_debounce); | ||
3680 | config.writeEntry("FloatDialogs", m_bFloatingDialog); | ||
3681 | reader->m_lastposn = reader->pagelocate(); | ||
3682 | config.writeEntry( "LastFile", reader->m_lastfile ); | ||
3683 | config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); | ||
3684 | } | ||
3685 | config.writeEntry( "PageMode", reader->m_bpagemode ); | ||
3686 | config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); | ||
3687 | config.writeEntry( "SwapMouse", reader->m_swapmouse); | ||
3688 | config.writeEntry( "Fontname", reader->m_fontname ); | ||
3689 | config.writeEntry( "Encoding", reader->m_encd ); | ||
3690 | config.writeEntry( "CharSpacing", reader->m_charpc ); | ||
3691 | config.writeEntry( "Overlap", (int)(reader->m_overlap) ); | ||
3692 | config.writeEntry( "Margin", (int)reader->m_border ); | ||
3693 | config.writeEntry( "TargetApp", m_targetapp ); | ||
3694 | config.writeEntry( "TargetMsg", m_targetmsg ); | ||
3695 | #ifdef _SCROLLPIPE | ||
3696 | config.writeEntry( "PipeTarget", reader->m_pipetarget ); | ||
3697 | config.writeEntry( "PauseAfterPara", reader->m_pauseAfterEachPara ); | ||
3698 | #endif | ||
3699 | config.writeEntry( "TwoTouch", m_twoTouch ); | ||
3700 | config.writeEntry( "Annotation", m_doAnnotation); | ||
3701 | config.writeEntry( "Dictionary", m_doDictionary); | ||
3702 | config.writeEntry( "Clipboard", m_doClipboard); | ||
3703 | config.writeEntry( "SpaceTarget", m_spaceTarget); | ||
3704 | config.writeEntry( "EscapeTarget", m_escapeTarget); | ||
3705 | config.writeEntry( "ReturnTarget", m_returnTarget); | ||
3706 | config.writeEntry( "LeftTarget", m_leftTarget); | ||
3707 | config.writeEntry( "RightTarget", m_rightTarget); | ||
3708 | config.writeEntry( "UpTarget", m_upTarget); | ||
3709 | config.writeEntry( "DownTarget", m_downTarget); | ||
3710 | config.writeEntry("LeftScroll", m_leftScroll); | ||
3711 | config.writeEntry("RightScroll", m_rightScroll); | ||
3712 | config.writeEntry("UpScroll", m_upScroll); | ||
3713 | config.writeEntry("DownScroll", m_downScroll); | ||
3714 | #ifdef REPALM | ||
3715 | config.writeEntry( "Repalm", reader->brepalm ); | ||
3716 | #endif | ||
3717 | config.writeEntry( "Remap", reader->bremap ); | ||
3718 | config.writeEntry( "Peanut", reader->bpeanut ); | ||
3719 | config.writeEntry( "MakeBold", reader->bmakebold ); | ||
3720 | config.writeEntry( "Continuous", reader->m_continuousDocument ); | ||
3721 | config.writeEntry( "FullJust", reader->bfulljust ); | ||
3722 | config.writeEntry( "ExtraSpace", reader->getextraspace() ); | ||
3723 | config.writeEntry( "ExtraLead", reader->getlead() ); | ||
3724 | config.writeEntry( "Basesize", (int)reader->getBaseSize()); | ||
3725 | config.writeEntry( "RequestorFontChange", m_propogatefontchange); | ||
3726 | if (full) | ||
3727 | { | ||
3728 | config.setGroup( "Toolbar" ); | ||
3729 | config.writeEntry("Movable", m_tbmovesave); | ||
3730 | config.writeEntry("Policy", m_tbpolsave); | ||
3731 | config.writeEntry("Position", m_tbposition); | ||
3732 | #ifndef USEQPE | ||
3733 | config.setGroup( "Geometry" ); | ||
3734 | config.writeEntry( "x", x() ); | ||
3735 | config.writeEntry( "y", y() ); | ||
3736 | config.writeEntry( "width", width() ); | ||
3737 | config.writeEntry( "height", height() ); | ||
3738 | #endif | ||
2543 | } | 3739 | } |
2544 | } | 3740 | } |
2545 | 3741 | ||
2546 | void QTReaderApp::setTwoTouch(bool _b) { reader->setTwoTouch(_b); } | ||
2547 | void QTReaderApp::restoreFocus() { reader->setFocus(); } | ||
2548 | |||
2549 | /* | 3742 | /* |
2550 | void QTReaderApp::setstate(unsigned char* _sd, unsigned short _sdlen) | 3743 | void QTReaderApp::setstate(unsigned char* _sd, unsigned short _sdlen) |
@@ -2585,4 +3778,6 @@ void QTReaderApp::getstate(unsigned char*& data, unsigned short& len) | |||
2585 | sd->bpeanut = reader->bpeanut; | 3778 | sd->bpeanut = reader->bpeanut; |
2586 | sd->bdehyphen = reader->bdehyphen; | 3779 | sd->bdehyphen = reader->bdehyphen; |
3780 | sd->bdepluck = reader->bdepluck; | ||
3781 | sd->bdejpluck = reader->bdejpluck; | ||
2587 | sd->bonespace = reader->bonespace; | 3782 | sd->bonespace = reader->bonespace; |
2588 | sd->bunindent = reader->bunindent; | 3783 | sd->bunindent = reader->bunindent; |
@@ -2590,5 +3785,4 @@ void QTReaderApp::getstate(unsigned char*& data, unsigned short& len) | |||
2590 | sd->bdblspce = reader->bdblspce; | 3785 | sd->bdblspce = reader->bdblspce; |
2591 | sd->m_bpagemode = reader->m_bpagemode; | 3786 | sd->m_bpagemode = reader->m_bpagemode; |
2592 | sd->m_navkeys = reader->m_navkeys; | ||
2593 | sd->m_bMonoSpaced = reader->m_bMonoSpaced; | 3787 | sd->m_bMonoSpaced = reader->m_bMonoSpaced; |
2594 | sd->bremap = reader->bremap; | 3788 | sd->bremap = reader->bremap; |
@@ -2605,2 +3799,424 @@ void QTReaderApp::getstate(unsigned char*& data, unsigned short& len) | |||
2605 | } | 3799 | } |
2606 | */ | 3800 | */ |
3801 | #ifdef _SCRIPT | ||
3802 | void QTReaderApp::RunScript() | ||
3803 | { | ||
3804 | fileBrowser* fb = new fileBrowser(this,"OpieReader",!m_bFloatingDialog, | ||
3805 | 0, | ||
3806 | // WStyle_Customize | WStyle_NoBorderEx, | ||
3807 | "*", Global::applicationFileName(APPDIR "/scripts", "")); | ||
3808 | |||
3809 | QString fn; | ||
3810 | if (fb->exec()) | ||
3811 | { | ||
3812 | fn = fb->fileList[0]; | ||
3813 | } | ||
3814 | delete fb; | ||
3815 | if ( !fn.isEmpty() && fork() == 0 ) | ||
3816 | { | ||
3817 | execlp((const char *)fn,(const char *)fn,NULL); | ||
3818 | } | ||
3819 | } | ||
3820 | |||
3821 | void QTReaderApp::SaveScript(const char* sname) | ||
3822 | { | ||
3823 | FILE* f = fopen(sname,"w"); | ||
3824 | if (f != NULL) | ||
3825 | { | ||
3826 | #ifdef OPIE | ||
3827 | fprintf(f, "#!/bin/sh\nmsg() {\n\tqcop QPE/Application/reader \"$1\" \"$2\" \"$3\"\n}\n"); | ||
3828 | #else | ||
3829 | fprintf(f, "#!/bin/bash\nmsg() {\n\tqcop QPE/Application/uqtreader \"$1\" \"$2\" \"$3\"\n}\n"); | ||
3830 | #endif | ||
3831 | fprintf(f, "msg \"Update(int)\" 0\n"); | ||
3832 | fprintf(f, "msg \"Layout/StripCR(int)\" %d\n", (reader->bstripcr) ? 1:0); | ||
3833 | if (reader->btextfmt) fprintf(f, "msg \"Markup(QString)\" \"Text\"\n"); | ||
3834 | else if (reader->bautofmt) fprintf(f, "msg \"Markup(QString)\" \"Auto\"\n"); | ||
3835 | else if (reader->bstriphtml) fprintf(f, "msg \"Markup(QString)\" \"HTML\"\n"); | ||
3836 | else if (reader->bpeanut) fprintf(f, "msg \"Markup(QString)\" \"Peanut/PML\"\n"); | ||
3837 | else fprintf(f, "msg \"Markup(QString)\" \"None\"\n"); | ||
3838 | fprintf(f, "msg \"Layout/Dehyphen(int)\" %d\n", (reader->bdehyphen) ? 1:0); | ||
3839 | fprintf(f, "msg \"Layout/Depluck(int)\" %d\n", (reader->bdepluck) ? 1:0); | ||
3840 | fprintf(f, "msg \"Layout/Dejpluck(int)\" %d\n", (reader->bdejpluck) ? 1:0); | ||
3841 | fprintf(f, "msg \"Layout/SingleSpace(int)\" %d\n", (reader->bonespace) ? 1:0); | ||
3842 | fprintf(f, "msg \"Layout/Unindent(int)\" %d\n", (reader->bunindent) ? 1:0); | ||
3843 | fprintf(f, "msg \"Layout/Re-paragraph(int)\" %d\n", (reader->brepara) ? 1:0); | ||
3844 | fprintf(f, "msg \"Layout/DoubleSpace(int)\" %d\n", (reader->bdblspce) ? 1:0); | ||
3845 | fprintf(f, "msg \"Layout/Indent(int)\" %d\n", reader->bindenter); | ||
3846 | fprintf(f, "msg \"Format/SetFont(QString,int)\" \"%s\" %d\n", (const char*)reader->m_fontname, reader->m_textsize); | ||
3847 | fprintf(f, "msg \"Navigation/Page/LineScroll(int)\" %d\n", (reader->m_bpagemode) ? 1:0); | ||
3848 | fprintf(f, "msg \"Format/Ideogram/Word(int)\" %d\n", (reader->m_bMonoSpaced) ? 1:0); | ||
3849 | fprintf(f, "msg \"Format/Encoding(QString)\" \"%s\"\n", (const char*)m_EncodingAction[reader->m_encd]->text()); | ||
3850 | fprintf(f, "msg \"Format/SetWidth(int)\" %d\n", reader->m_charpc); | ||
3851 | fprintf(f, "msg \"Navigation/SetOverlap(int)\" %d\n", reader->m_overlap); | ||
3852 | fprintf(f, "msg \"Layout/Remap(int)\" %d\n", (reader->bremap) ? 1:0); | ||
3853 | fprintf(f, "msg \"Layout/Embolden(int)\" %d\n", (reader->bmakebold) ? 1:0); | ||
3854 | fprintf(f, "msg \"File/Continuous(int)\" %d\n", (reader->m_continuousDocument) ? 1:0); | ||
3855 | fprintf(f, "msg \"File/SetDictionary(QString)\" \"%s/%s\"\n", (const char *)m_targetapp, (const char *)m_targetmsg); | ||
3856 | #ifdef _SCROLLPIPE | ||
3857 | fprintf(f, "msg \"File/SetScrollTarget(QString)\" \"%s\"\n", (const char *)reader->m_pipetarget); | ||
3858 | #endif | ||
3859 | fprintf(f, "msg \"File/Two/OneTouch(int)\" %d\n", (m_twoTouch) ? 1:0); | ||
3860 | fprintf(f, "msg \"Target/Annotation(int)\" %d\n", (m_doAnnotation) ? 1:0); | ||
3861 | fprintf(f, "msg \"Target/Dictionary(int)\" %d\n", (m_doDictionary) ? 1:0); | ||
3862 | fprintf(f, "msg \"Target/Clipboard(int)\" %d\n", (m_doClipboard) ? 1:0); | ||
3863 | fprintf(f, "msg \"File/Action(QString)\" \"%s\"\n", (const char *)m_buttonAction[m_spaceTarget]->text()); | ||
3864 | fprintf(f, "msg \"Update(int)\" 1\n"); | ||
3865 | fprintf(f, "msg \"info(QString)\" \"All Done\"\n"); | ||
3866 | fclose(f); | ||
3867 | chmod(sname, S_IXUSR | S_IXGRP | S_IXOTH); | ||
3868 | } | ||
3869 | } | ||
3870 | |||
3871 | void QTReaderApp::SaveConfig() | ||
3872 | { | ||
3873 | m_nRegAction = cSetConfigName; | ||
3874 | regEdit->setText(""); | ||
3875 | do_regedit(); | ||
3876 | } | ||
3877 | |||
3878 | void QTReaderApp::do_saveconfig(const QString& _txt) | ||
3879 | { | ||
3880 | SaveScript(Global::applicationFileName(APPDIR "/scripts", _txt)); | ||
3881 | } | ||
3882 | #endif | ||
3883 | |||
3884 | #ifdef _SCROLLPIPE | ||
3885 | void QTReaderApp::setpipetarget() | ||
3886 | { | ||
3887 | m_nRegAction = cSetPipeTarget; | ||
3888 | QString text = (reader->m_pipetarget.isEmpty()) ? QString("") : reader->m_pipetarget; | ||
3889 | regEdit->setText(text); | ||
3890 | do_regedit(); | ||
3891 | } | ||
3892 | |||
3893 | void QTReaderApp::do_setpipetarget(const QString& _txt) | ||
3894 | { | ||
3895 | reader->m_pipetarget = _txt; | ||
3896 | } | ||
3897 | |||
3898 | void QTReaderApp::setpause(bool sfs) | ||
3899 | { | ||
3900 | reader->m_pauseAfterEachPara = sfs; | ||
3901 | } | ||
3902 | #endif | ||
3903 | |||
3904 | void QTReaderApp::monospace(bool _b) | ||
3905 | { | ||
3906 | reader->setmono(_b); | ||
3907 | } | ||
3908 | |||
3909 | bool QTReaderApp::readconfig(const QString& _txt, bool full=false) | ||
3910 | { | ||
3911 | #ifdef USEQPE | ||
3912 | QString configname; | ||
3913 | Config::Domain dom; | ||
3914 | |||
3915 | if (full) | ||
3916 | { | ||
3917 | configname = _txt; | ||
3918 | dom = Config::User; | ||
3919 | } | ||
3920 | else | ||
3921 | { | ||
3922 | configname = Global::applicationFileName(APPDIR "/configs", _txt); | ||
3923 | QFileInfo fm(configname); | ||
3924 | if ( !fm.exists() ) return false; | ||
3925 | dom = Config::File; | ||
3926 | } | ||
3927 | |||
3928 | Config config(configname, dom); | ||
3929 | config.setGroup( "View" ); | ||
3930 | |||
3931 | #else | ||
3932 | QFileInfo fi; | ||
3933 | if (full) | ||
3934 | { | ||
3935 | QDir d = QDir::home(); // "/" | ||
3936 | if ( !d.cd(_txt) ) | ||
3937 | { // "/tmp" | ||
3938 | qWarning( "Cannot find the \"~/%s\" directory", (const char*)_txt ); | ||
3939 | d = QDir::home(); | ||
3940 | d.mkdir(_txt); | ||
3941 | d.cd(_txt); | ||
3942 | } | ||
3943 | fi.setFile(d, INIFILE); | ||
3944 | } | ||
3945 | else | ||
3946 | { | ||
3947 | QDir d = QDir::home(); // "/" | ||
3948 | if ( !d.cd(APPDIR) ) | ||
3949 | { // "/tmp" | ||
3950 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | ||
3951 | d = QDir::home(); | ||
3952 | d.mkdir(APPDIR); | ||
3953 | d.cd(APPDIR); | ||
3954 | } | ||
3955 | if ( !d.cd("configs") ) | ||
3956 | { // "/tmp" | ||
3957 | qWarning( "Cannot find the \"~/" APPDIR "/configs\" directory" ); | ||
3958 | d = QDir::home(); | ||
3959 | d.mkdir("configs"); | ||
3960 | d.cd("configs"); | ||
3961 | } | ||
3962 | fi.setFile(d, _txt); | ||
3963 | } | ||
3964 | #ifdef _WINDOWS | ||
3965 | struct stat fnstat; | ||
3966 | if (stat((const char *)reader->m_lastfile, &fnstat) == 0) return false; // get round fileinfo bug on windows | ||
3967 | #else | ||
3968 | if (!fi.exists()) return false; | ||
3969 | #endif | ||
3970 | Config config(fi.absFilePath()); | ||
3971 | #endif | ||
3972 | if (full) | ||
3973 | { | ||
3974 | config.setGroup("Toolbar"); | ||
3975 | m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false); | ||
3976 | m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1); | ||
3977 | m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2); | ||
3978 | } | ||
3979 | config.setGroup( "View" ); | ||
3980 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false); | ||
3981 | reader->bstripcr = config.readBoolEntry( "StripCr", true ); | ||
3982 | reader->bfulljust = config.readBoolEntry( "FullJust", false ); | ||
3983 | reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 )); | ||
3984 | reader->setlead(config.readNumEntry( "ExtraLead", 0 )); | ||
3985 | reader->btextfmt = config.readBoolEntry( "TextFmt", false ); | ||
3986 | reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); | ||
3987 | reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); | ||
3988 | reader->bpeanut = config.readBoolEntry( "Peanut", false ); | ||
3989 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); | ||
3990 | reader->bdepluck = config.readBoolEntry( "Depluck", false ); | ||
3991 | reader->bdejpluck = config.readBoolEntry( "Dejpluck", false ); | ||
3992 | reader->bonespace = config.readBoolEntry( "OneSpace", false ); | ||
3993 | reader->bunindent = config.readBoolEntry( "Unindent", false ); | ||
3994 | reader->brepara = config.readBoolEntry( "Repara", false ); | ||
3995 | reader->bdblspce = config.readBoolEntry( "DoubleSpace", false ); | ||
3996 | reader->bindenter = config.readNumEntry( "Indent", 0 ); | ||
3997 | reader->m_textsize = config.readNumEntry( "FontSize", 12 ); | ||
3998 | reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); | ||
3999 | if (full) | ||
4000 | { | ||
4001 | reader->m_lastfile = config.readEntry( "LastFile", QString::null ); | ||
4002 | reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); | ||
4003 | } | ||
4004 | reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); | ||
4005 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); | ||
4006 | reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false); | ||
4007 | reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); | ||
4008 | reader->m_encd = config.readNumEntry( "Encoding", 0 ); | ||
4009 | reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); | ||
4010 | reader->m_overlap = config.readNumEntry( "Overlap", 0 ); | ||
4011 | reader->m_border = config.readNumEntry( "Margin", 6 ); | ||
4012 | #ifdef REPALM | ||
4013 | reader->brepalm = config.readBoolEntry( "Repalm", true ); | ||
4014 | #endif | ||
4015 | reader->bremap = config.readBoolEntry( "Remap", true ); | ||
4016 | reader->bmakebold = config.readBoolEntry( "MakeBold", false ); | ||
4017 | reader->setContinuous(config.readBoolEntry( "Continuous", true )); | ||
4018 | m_targetapp = config.readEntry( "TargetApp", QString::null ); | ||
4019 | m_targetmsg = config.readEntry( "TargetMsg", QString::null ); | ||
4020 | #ifdef _SCROLLPIPE | ||
4021 | reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null ); | ||
4022 | reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true ); | ||
4023 | #endif | ||
4024 | m_twoTouch = config.readBoolEntry( "TwoTouch", false); | ||
4025 | m_doAnnotation = config.readBoolEntry( "Annotation", false); | ||
4026 | m_doDictionary = config.readBoolEntry( "Dictionary", false); | ||
4027 | m_doClipboard = config.readBoolEntry( "Clipboard", false); | ||
4028 | m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll); | ||
4029 | m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone); | ||
4030 | m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen); | ||
4031 | m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut); | ||
4032 | m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn); | ||
4033 | m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp); | ||
4034 | m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown); | ||
4035 | |||
4036 | m_leftScroll = config.readBoolEntry("LeftScroll", false); | ||
4037 | m_rightScroll = config.readBoolEntry("RightScroll", false); | ||
4038 | m_upScroll = config.readBoolEntry("UpScroll", true); | ||
4039 | m_downScroll = config.readBoolEntry("DownScroll", true); | ||
4040 | m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false); | ||
4041 | reader->setBaseSize(config.readNumEntry( "Basesize", 10 )); | ||
4042 | reader->setTwoTouch(m_twoTouch); | ||
4043 | |||
4044 | m_touch_action->setOn(m_twoTouch); | ||
4045 | m_setmono_action->setOn(reader->m_bMonoSpaced); | ||
4046 | setfontHelper(reader->m_fontname); | ||
4047 | if (full) | ||
4048 | { | ||
4049 | addtoolbars(&config); | ||
4050 | } | ||
4051 | reader->setfilter(reader->getfilter()); | ||
4052 | reader->refresh(); | ||
4053 | return true; | ||
4054 | } | ||
4055 | |||
4056 | bool QTReaderApp::PopulateConfig(const char* tgtdir) | ||
4057 | { | ||
4058 | bkmkselector->clear(); | ||
4059 | bkmkselector->setText("Cancel"); | ||
4060 | #ifndef USEQPE | ||
4061 | int cnt = 0; | ||
4062 | |||
4063 | QDir d = QDir::home(); // "/" | ||
4064 | if ( !d.cd(APPDIR) ) { // "/tmp" | ||
4065 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | ||
4066 | d = QDir::home(); | ||
4067 | d.mkdir(APPDIR); | ||
4068 | d.cd(APPDIR); | ||
4069 | } | ||
4070 | if ( !d.cd(tgtdir) ) { // "/tmp" | ||
4071 | qWarning( "Cannot find the \"~/" APPDIR "/%s\" directory", tgtdir ); | ||
4072 | d = QDir::home(); | ||
4073 | d.mkdir(tgtdir); | ||
4074 | d.cd(tgtdir); | ||
4075 | } | ||
4076 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | ||
4077 | // d.setSorting( QDir::Size | QDir::Reversed ); | ||
4078 | |||
4079 | const QFileInfoList *list = d.entryInfoList(); | ||
4080 | QFileInfoListIterator it( *list ); // create list iterator | ||
4081 | QFileInfo *fi; // pointer for traversing | ||
4082 | |||
4083 | while ( (fi=it.current()) ) { // for each file... | ||
4084 | |||
4085 | bkmkselector->insertItem(fi->fileName()); | ||
4086 | cnt++; | ||
4087 | |||
4088 | //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); | ||
4089 | ++it; // goto next list element | ||
4090 | } | ||
4091 | |||
4092 | #else /* USEQPE */ | ||
4093 | int cnt = 0; | ||
4094 | DIR *d; | ||
4095 | char* finaldir; | ||
4096 | finaldir = new char[strlen(APPDIR)+1+strlen(tgtdir)+1]; | ||
4097 | strcpy(finaldir, APPDIR); | ||
4098 | strcat(finaldir, "/"); | ||
4099 | strcat(finaldir, tgtdir); | ||
4100 | d = opendir((const char *)Global::applicationFileName(finaldir,"")); | ||
4101 | |||
4102 | while(1) | ||
4103 | { | ||
4104 | struct dirent* de; | ||
4105 | struct stat buf; | ||
4106 | de = readdir(d); | ||
4107 | if (de == NULL) break; | ||
4108 | |||
4109 | if (lstat((const char *)Global::applicationFileName(finaldir,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) | ||
4110 | { | ||
4111 | bkmkselector->insertItem(de->d_name); | ||
4112 | cnt++; | ||
4113 | } | ||
4114 | } | ||
4115 | delete [] finaldir; | ||
4116 | closedir(d); | ||
4117 | #endif | ||
4118 | return (cnt > 0); | ||
4119 | } | ||
4120 | |||
4121 | void QTReaderApp::LoadConfig() | ||
4122 | { | ||
4123 | if (PopulateConfig("configs")) | ||
4124 | { | ||
4125 | editorStack->raiseWidget( bkmkselector ); | ||
4126 | hidetoolbars(); | ||
4127 | m_nBkmkAction = cLdConfig; | ||
4128 | } | ||
4129 | else | ||
4130 | QMessageBox::information(this, PROGNAME, "No config files"); | ||
4131 | } | ||
4132 | |||
4133 | void QTReaderApp::TidyConfig() | ||
4134 | { | ||
4135 | if (PopulateConfig("configs")) | ||
4136 | { | ||
4137 | editorStack->raiseWidget( bkmkselector ); | ||
4138 | hidetoolbars(); | ||
4139 | m_nBkmkAction = cRmConfig; | ||
4140 | } | ||
4141 | else | ||
4142 | QMessageBox::information(this, PROGNAME, "No config files"); | ||
4143 | } | ||
4144 | |||
4145 | void QTReaderApp::ExportLinks() | ||
4146 | { | ||
4147 | if (PopulateConfig("urls")) | ||
4148 | { | ||
4149 | editorStack->raiseWidget( bkmkselector ); | ||
4150 | hidetoolbars(); | ||
4151 | m_nBkmkAction = cExportLinks; | ||
4152 | } | ||
4153 | else | ||
4154 | QMessageBox::information(this, PROGNAME, "No url files"); | ||
4155 | } | ||
4156 | |||
4157 | void QTReaderApp::OnURLSelected(const QString& href) | ||
4158 | { | ||
4159 | CURLDialog* urld = new CURLDialog(href, false, this); | ||
4160 | urld->clipboard(m_url_clipboard); | ||
4161 | urld->localfile(m_url_localfile); | ||
4162 | urld->globalfile(m_url_globalfile); | ||
4163 | if (urld->exec()) | ||
4164 | { | ||
4165 | m_url_clipboard = urld->clipboard(); | ||
4166 | m_url_localfile = urld->localfile(); | ||
4167 | m_url_globalfile = urld->globalfile(); | ||
4168 | if (m_url_clipboard) | ||
4169 | { | ||
4170 | QClipboard* cb = QApplication::clipboard(); | ||
4171 | cb->setText(href); | ||
4172 | qDebug("<a href=\"%s\">%s</a>", (const char*)href, (const char*)href); | ||
4173 | } | ||
4174 | if (m_url_localfile) | ||
4175 | { | ||
4176 | writeUrl(reader->m_string, href); | ||
4177 | } | ||
4178 | if (m_url_globalfile) | ||
4179 | { | ||
4180 | writeUrl("GlobalURLFile", href); | ||
4181 | } | ||
4182 | } | ||
4183 | delete urld; | ||
4184 | } | ||
4185 | |||
4186 | void QTReaderApp::writeUrl(const QString& file, const QString& href) | ||
4187 | { | ||
4188 | QString filename; | ||
4189 | #ifdef USEQPE | ||
4190 | filename = Global::applicationFileName(APPDIR "/urls", file); | ||
4191 | #else | ||
4192 | QFileInfo fi; | ||
4193 | QDir d = QDir::home(); // "/" | ||
4194 | if ( !d.cd(APPDIR) ) | ||
4195 | { // "/tmp" | ||
4196 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | ||
4197 | d = QDir::home(); | ||
4198 | d.mkdir(APPDIR); | ||
4199 | d.cd(APPDIR); | ||
4200 | } | ||
4201 | if ( !d.cd("urls") ) | ||
4202 | { // "/tmp" | ||
4203 | qWarning( "Cannot find the \"~/" APPDIR "/urls\" directory" ); | ||
4204 | d = QDir::home(); | ||
4205 | d.cd(APPDIR); | ||
4206 | d.mkdir("urls"); | ||
4207 | d.cd("urls"); | ||
4208 | } | ||
4209 | fi.setFile(d, file); | ||
4210 | filename = fi.absFilePath(); | ||
4211 | #endif | ||
4212 | FILE* fout = fopen(filename, "a"); | ||
4213 | if (fout != NULL) | ||
4214 | { | ||
4215 | fprintf(fout, "<p><a href=\"%s\">%s</a>\n", (const char*)href, (const char*)href); | ||
4216 | fclose(fout); | ||
4217 | } | ||
4218 | else | ||
4219 | { | ||
4220 | QMessageBox::warning(this, PROGNAME, "Problem with writing URL"); | ||
4221 | } | ||
4222 | } | ||