Diffstat (limited to 'noncore/apps/opie-reader/QTReaderApp.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/QTReaderApp.h | 259 |
1 files changed, 205 insertions, 54 deletions
diff --git a/noncore/apps/opie-reader/QTReaderApp.h b/noncore/apps/opie-reader/QTReaderApp.h index cb33e4a..2765d47 100644 --- a/noncore/apps/opie-reader/QTReaderApp.h +++ b/noncore/apps/opie-reader/QTReaderApp.h | |||
@@ -21,13 +21,17 @@ | |||
21 | #define __QTREADERAPP_H | 21 | #define __QTREADERAPP_H |
22 | 22 | ||
23 | //#define _SCROLLPIPE | ||
23 | //#define __ISEARCH | 24 | //#define __ISEARCH |
24 | 25 | ||
25 | #define MAX_ENCODING 6 | 26 | //#define MAX_ENCODING 6 |
26 | #define MAX_ACTIONS 4 | 27 | #define MAX_ACTIONS 5 |
27 | 28 | ||
29 | #include "useqpe.h" | ||
30 | #include <sys/timeb.h> | ||
28 | #include <qmainwindow.h> | 31 | #include <qmainwindow.h> |
29 | #include "CExpander.h" | 32 | #include "CExpander.h" |
33 | #include "CEncoding.h" | ||
30 | #include <qlist.h> | 34 | #include <qlist.h> |
31 | #include <qpe/filemanager.h> | 35 | //#include <qpe/filemanager.h> |
32 | #include <qmap.h> | 36 | #include <qmap.h> |
33 | #include <qlineedit.h> | 37 | #include <qlineedit.h> |
@@ -40,5 +44,8 @@ class QToolButton; | |||
40 | class QPopupMenu; | 44 | class QPopupMenu; |
41 | class QToolBar; | 45 | class QToolBar; |
42 | //class QPEToolBar; | 46 | #ifdef USEQPE |
47 | class QPEToolBar; | ||
48 | class QPEMenuBar; | ||
49 | #endif | ||
43 | class CBkmkSelector; | 50 | class CBkmkSelector; |
44 | class QProgressBar; | 51 | class QProgressBar; |
@@ -48,12 +55,72 @@ class QFloatBar; | |||
48 | class CDrawBuffer; | 55 | class CDrawBuffer; |
49 | class QTReader; | 56 | class QTReader; |
50 | class QPixmap; | 57 | class QImage; |
58 | class Config; | ||
51 | 59 | ||
52 | enum ActionTypes | 60 | enum ActionTypes |
53 | { | 61 | { |
54 | cesOpenFile = 0, | 62 | cesNone = 0, |
63 | cesOpenFile, | ||
55 | cesAutoScroll, | 64 | cesAutoScroll, |
56 | cesActionMark, | 65 | cesActionMark, |
57 | cesFullScreen | 66 | cesActionAnno, |
67 | cesFullScreen, | ||
68 | cesZoomIn, | ||
69 | cesZoomOut, | ||
70 | cesBack, | ||
71 | cesForward, | ||
72 | cesHome, | ||
73 | cesPageUp, | ||
74 | cesPageDown, | ||
75 | cesLineUp, | ||
76 | cesLineDown, | ||
77 | cesStartDoc, | ||
78 | cesEndDoc | ||
79 | }; | ||
80 | /* | ||
81 | *m_preferences_action, *m_close_action *m_info_action, *m_touch_action, | ||
82 | *m_find_action, *m_jump_action, *m_setfont_action *m_goto_action, | ||
83 | *m_delete_action; *m_autogen_action, *m_clear_action, *m_save_action; | ||
84 | *m_tidy_action, *m_startBlock_action, *m_endBlock_action; | ||
85 | *m_setenc_action, *m_setmono_action; | ||
86 | */ | ||
87 | enum ToolbarPolicy | ||
88 | { | ||
89 | cesSingle = 0, | ||
90 | cesMenuTool, | ||
91 | cesMultiple | ||
92 | }; | ||
93 | |||
94 | enum regedit_type | ||
95 | { | ||
96 | cAutoGen, | ||
97 | cAddBkmk, | ||
98 | cJump, | ||
99 | cMonoSpace, | ||
100 | cSetTarget, | ||
101 | #ifdef _SCROLLPIPE | ||
102 | cSetPipeTarget, | ||
103 | #endif | ||
104 | cSetConfigName, | ||
105 | cMargin, | ||
106 | cExtraSpace, | ||
107 | cExtraLead | ||
108 | }; | ||
109 | |||
110 | enum bkmk_action | ||
111 | { | ||
112 | cOpenFile, | ||
113 | cGotoBkmk, | ||
114 | cDelBkmk, | ||
115 | cRmBkmkFile, | ||
116 | cLdConfig, | ||
117 | cRmConfig, | ||
118 | cExportLinks | ||
119 | }; | ||
120 | |||
121 | enum fontselector_action | ||
122 | { | ||
123 | cChooseFont, | ||
124 | cChooseEncoding | ||
58 | }; | 125 | }; |
59 | 126 | ||
@@ -75,9 +142,22 @@ class QTReaderApp : public QMainWindow | |||
75 | 142 | ||
76 | unsigned long m_savedpos; | 143 | unsigned long m_savedpos; |
144 | int m_debounce; | ||
145 | timeb m_lastkeytime; | ||
77 | bool m_annoIsEditing; | 146 | bool m_annoIsEditing; |
147 | bool m_propogatefontchange, m_bFloatingDialog; | ||
148 | bool m_url_clipboard, m_url_localfile, m_url_globalfile; | ||
149 | fontselector_action m_fontAction; | ||
150 | void doAction(ActionTypes a, QKeyEvent* e); | ||
78 | 151 | ||
79 | public: | 152 | public: |
80 | QTReaderApp( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | 153 | QTReaderApp( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
81 | ~QTReaderApp(); | 154 | ~QTReaderApp(); |
155 | |||
156 | void handlekey(QKeyEvent* e); | ||
157 | void hideEvent(QHideEvent*) | ||
158 | { | ||
159 | suspend(); | ||
160 | } | ||
161 | |||
82 | void suspend(); | 162 | void suspend(); |
83 | void openFile( const QString & ); | 163 | void openFile( const QString & ); |
@@ -91,12 +171,15 @@ class QTReaderApp : public QMainWindow | |||
91 | Bkmk* m_anno; | 171 | Bkmk* m_anno; |
92 | // void resizeEvent(QResizeEvent* e); | 172 | // void resizeEvent(QResizeEvent* e); |
93 | void keyPressEvent(QKeyEvent* e); | ||
94 | void closeEvent( QCloseEvent *e ); | 173 | void closeEvent( QCloseEvent *e ); |
95 | void readbkmks(); | 174 | void readbkmks(); |
96 | void do_mono(const QString&); | 175 | void do_mono(const QString&); |
97 | void do_jump(const QString&); | 176 | void do_jump(const QString&); |
98 | void do_overlap(const QString&); | ||
99 | void do_settarget(const QString&); | 177 | void do_settarget(const QString&); |
100 | int EncNameToInt(const QString&); | 178 | #ifdef _SCROLLPIPE |
179 | //void do_setpipetarget(const QString&); | ||
180 | #endif | ||
181 | void do_saveconfig(const QString&, bool); | ||
182 | bool readconfig(const QString&, bool); | ||
183 | bool PopulateConfig(const char*); | ||
101 | ActionTypes ActNameToInt(const QString&); | 184 | ActionTypes ActNameToInt(const QString&); |
102 | bool m_doAnnotation; | 185 | bool m_doAnnotation; |
@@ -104,12 +187,22 @@ class QTReaderApp : public QMainWindow | |||
104 | bool m_doClipboard; | 187 | bool m_doClipboard; |
105 | bool m_fullscreen; | 188 | bool m_fullscreen; |
106 | 189 | bool m_loadedconfig; | |
107 | public: | 190 | public: |
108 | void saveprefs(); | 191 | void saveprefs(); |
192 | public slots: | ||
193 | void setDocument(const QString&); | ||
109 | private slots: | 194 | private slots: |
195 | #ifdef _SCRIPT | ||
196 | // void RunScript(); | ||
197 | #endif | ||
198 | void SaveConfig(); | ||
199 | void LoadConfig(); | ||
200 | void TidyConfig(); | ||
201 | void ExportLinks(); | ||
110 | void zoomin(); | 202 | void zoomin(); |
111 | void zoomout(); | 203 | void zoomout(); |
204 | void chooseencoding(); | ||
112 | void setfullscreen(bool sfs); | 205 | void setfullscreen(bool sfs); |
113 | void setcontinuous(bool sfs); | 206 | // void setcontinuous(bool sfs); |
114 | void setTwoTouch(bool _b); | 207 | void setTwoTouch(bool _b); |
115 | void restoreFocus(); | 208 | void restoreFocus(); |
@@ -127,18 +220,22 @@ private slots: | |||
127 | } | 220 | } |
128 | void OnWordSelected(const QString&, size_t, const QString&); | 221 | void OnWordSelected(const QString&, size_t, const QString&); |
129 | void showgraphic(QPixmap&); | 222 | void OnURLSelected(const QString& href); |
223 | void showgraphic(QImage&); | ||
130 | void addAnno(const QString&, const QString&, size_t); | 224 | void addAnno(const QString&, const QString&, size_t); |
131 | void addAnno(const QString&, const QString&); | 225 | void addAnno(const QString&, const QString&); |
132 | void addanno(); | 226 | void addanno(); |
133 | void showAnnotation(); | 227 | void showAnnotation(); |
228 | void do_setencoding(int i); | ||
134 | void do_setfont(const QString&); | 229 | void do_setfont(const QString&); |
135 | void encodingSelected(QAction*); | ||
136 | void buttonActionSelected(QAction*); | 230 | void buttonActionSelected(QAction*); |
137 | void msgHandler(const QCString&, const QByteArray&); | 231 | //void msgHandler(const QCString&, const QByteArray&); |
138 | void monospace(bool); | 232 | void monospace(bool); |
139 | void jump(); | 233 | void jump(); |
140 | void setoverlap(); | ||
141 | void settarget(); | 234 | void settarget(); |
142 | void setspacing(); | 235 | #ifdef _SCROLLPIPE |
236 | //void setpipetarget(); | ||
237 | //void setpause(bool); | ||
238 | #endif | ||
239 | //void setspacing(); | ||
143 | void setfont(); | 240 | void setfont(); |
144 | void clearBkmkList(); | 241 | void clearBkmkList(); |
@@ -149,11 +246,12 @@ private slots: | |||
149 | void savebkmks(); | 246 | void savebkmks(); |
150 | //void importFiles(); | 247 | //void importFiles(); |
248 | void showprefs(); | ||
249 | void showtoolbarprefs(); | ||
151 | void infoClose(); | 250 | void infoClose(); |
152 | // void oldFile(); | 251 | // void oldFile(); |
153 | void showinfo(); | 252 | void showinfo(); |
154 | void setDocument(const QString&); | ||
155 | 253 | ||
156 | void indentplus(); | 254 | // void indentplus(); |
157 | void indentminus(); | 255 | // void indentminus(); |
158 | 256 | ||
159 | void fileOpen(); | 257 | void fileOpen(); |
@@ -163,4 +261,7 @@ private slots: | |||
163 | void editFind(); | 261 | void editFind(); |
164 | 262 | ||
263 | void gotoStart(); | ||
264 | void gotoEnd(); | ||
265 | |||
165 | void pageup(); | 266 | void pageup(); |
166 | void pagedn(); | 267 | void pagedn(); |
@@ -179,21 +280,23 @@ private slots: | |||
179 | void showEditTools(); | 280 | void showEditTools(); |
180 | 281 | ||
181 | void stripcr(bool); | 282 | // void stripcr(bool); |
182 | void onespace(bool); | 283 | // void setfulljust(bool); |
284 | // void onespace(bool); | ||
183 | #ifdef REPALM | 285 | #ifdef REPALM |
184 | // void repalm(bool); | 286 | // void repalm(bool); |
185 | #endif | 287 | #endif |
186 | void peanut(bool _b); | 288 | // void peanut(bool _b); |
187 | void remap(bool); | 289 | // void remap(bool); |
188 | void embolden(bool); | 290 | // void embolden(bool); |
189 | void autofmt(bool); | 291 | // void autofmt(bool); |
190 | void textfmt(bool); | 292 | // void textfmt(bool); |
191 | void striphtml(bool); | 293 | // void striphtml(bool); |
192 | void dehyphen(bool); | 294 | // void dehyphen(bool); |
193 | void unindent(bool); | 295 | // void depluck(bool); |
194 | void repara(bool); | 296 | // void dejpluck(bool); |
195 | void dblspce(bool); | 297 | // void unindent(bool); |
298 | // void repara(bool); | ||
299 | // void dblspce(bool); | ||
196 | void pagemode(bool); | 300 | void pagemode(bool); |
197 | void navkeys(bool); | ||
198 | // void gotobkmk(const QString& bm); | 301 | // void gotobkmk(const QString& bm); |
199 | void gotobkmk(int); | 302 | void gotobkmk(int); |
@@ -204,7 +307,36 @@ private slots: | |||
204 | void do_regaction(); | 307 | void do_regaction(); |
205 | void OnRedraw(); | 308 | void OnRedraw(); |
206 | void OnActionPressed(); | ||
207 | 309 | ||
208 | private: | 310 | private: |
311 | void writeUrl(const QString& file, const QString& href); | ||
312 | QAction *m_preferences_action, *m_open_action, *m_close_action; | ||
313 | QAction *m_info_action, *m_touch_action, *m_find_action, *m_start_action; | ||
314 | QAction *m_end_action, *m_jump_action, *m_pageline_action; | ||
315 | QAction *m_pageup_action, *m_pagedn_action, *m_back_action; | ||
316 | QAction *m_home_action, *m_forward_action, *m_zoomin_action; | ||
317 | QAction *m_zoomout_action, *m_setfont_action, *m_mark_action; | ||
318 | QAction *m_annotate_action, *m_goto_action, *m_delete_action; | ||
319 | QAction *m_autogen_action, *m_clear_action, *m_save_action; | ||
320 | QAction *m_tidy_action, *m_startBlock_action, *m_endBlock_action; | ||
321 | QAction *m_setenc_action, *m_setmono_action, *m_saveconfig_action; | ||
322 | QAction *m_loadconfig_action, *m_toolbarprefs_action, *m_tidyconfig_action; | ||
323 | QAction *m_exportlinks_action; | ||
324 | void addtoolbars(Config* config); | ||
325 | ToolbarPolicy m_tbpol, m_tbpolsave; | ||
326 | ToolBarDock m_tbposition; | ||
327 | bool m_tbmove, m_tbmovesave; | ||
328 | QToolBar* filebar(); | ||
329 | QToolBar* viewbar(); | ||
330 | QToolBar* navbar(); | ||
331 | QToolBar* markbar(); | ||
332 | void hidetoolbars(); | ||
333 | void addfilebar(Config* _config, const QString& key, QAction* a); | ||
334 | void addviewbar(Config* _config, const QString& key, QAction* a); | ||
335 | void addnavbar(Config* _config, const QString& key, QAction* a); | ||
336 | void addmarkbar(Config* _config, const QString& key, QAction* a); | ||
337 | bool checkbar(Config* _config, const QString& key); | ||
338 | #ifdef _SCRIPT | ||
339 | void SaveScript(const char* sname); | ||
340 | #endif | ||
209 | /* | 341 | /* |
210 | void setstate(unsigned char* _sd, unsigned short _sdlen); | 342 | void setstate(unsigned char* _sd, unsigned short _sdlen); |
@@ -217,5 +349,5 @@ private slots: | |||
217 | bool openfrombkmk(Bkmk*); | 349 | bool openfrombkmk(Bkmk*); |
218 | QString m_targetapp, m_targetmsg; | 350 | QString m_targetapp, m_targetmsg; |
219 | void listbkmk(CList<Bkmk>*, const QString& _lab = QString::null); | 351 | bool listbkmk(CList<Bkmk>*, const QString& _lab = QString::null); |
220 | QString usefilebrowser(); | 352 | QString usefilebrowser(); |
221 | void do_regedit(); | 353 | void do_regedit(); |
@@ -231,11 +363,12 @@ private slots: | |||
231 | QAction* m_scrollButton; | 363 | QAction* m_scrollButton; |
232 | 364 | ||
233 | QAction* m_EncodingAction[MAX_ENCODING]; | ||
234 | |||
235 | QAction* m_buttonAction[MAX_ACTIONS]; | 365 | QAction* m_buttonAction[MAX_ACTIONS]; |
236 | 366 | ||
237 | CBkmkSelector* bkmkselector; | 367 | CBkmkSelector* bkmkselector; |
238 | 368 | ||
239 | ActionTypes m_spaceTarget; | 369 | ActionTypes m_spaceTarget, m_escapeTarget, m_returnTarget, m_leftTarget, m_rightTarget, |
370 | m_upTarget, m_downTarget; | ||
371 | bool m_leftScroll, m_rightScroll, m_upScroll, m_downScroll; | ||
372 | bool m_bcloseDisabled, m_disableesckey; | ||
240 | size_t searchStart; | 373 | size_t searchStart; |
241 | #ifdef __ISEARCH | 374 | #ifdef __ISEARCH |
@@ -248,6 +381,11 @@ private slots: | |||
248 | QTReader* reader; | 381 | QTReader* reader; |
249 | QComboBox* m_fontSelector; | 382 | QComboBox* m_fontSelector; |
250 | // QPEToolBar /* *menu,*/ *editBar; | 383 | // QPEToolBar /* *menu,*/ *fileBar; |
251 | QToolBar /* *menu,*/ *editBar; | 384 | QToolBar *menubar, *fileBar, *navBar, *viewBar, *markBar; |
385 | #ifdef USEQPE | ||
386 | QPEMenuBar *mb; | ||
387 | #else | ||
388 | QMenuBar *mb; | ||
389 | #endif | ||
252 | QFloatBar *searchBar, *regBar/*, *m_fontBar*/; | 390 | QFloatBar *searchBar, *regBar/*, *m_fontBar*/; |
253 | QToolBar /* *searchBar, *regBar,*/ *m_fontBar; | 391 | QToolBar /* *searchBar, *regBar,*/ *m_fontBar; |
@@ -262,6 +400,6 @@ private slots: | |||
262 | void resizeEvent( QResizeEvent * r) | 400 | void resizeEvent( QResizeEvent * r) |
263 | { | 401 | { |
264 | qDebug("resize:(%u,%u)", r->oldSize().width(), r->oldSize().height()); | 402 | // qDebug("resize:(%u,%u)", r->oldSize().width(), r->oldSize().height()); |
265 | qDebug("resize:(%u,%u)", r->size().width(), r->size().height()); | 403 | // qDebug("resize:(%u,%u)", r->size().width(), r->size().height()); |
266 | // bgroup->move( width()-bgroup->width(), 0 ); | 404 | // bgroup->move( width()-bgroup->width(), 0 ); |
267 | } | 405 | } |
@@ -273,19 +411,32 @@ private slots: | |||
273 | QProgressBar* pbar; | 411 | QProgressBar* pbar; |
274 | bool m_fBkmksChanged; | 412 | bool m_fBkmksChanged; |
275 | int m_nRegAction; | 413 | // int m_nRegAction; |
414 | regedit_type m_nRegAction; | ||
415 | bkmk_action m_nBkmkAction; | ||
276 | QString m_autogenstr; | 416 | QString m_autogenstr; |
277 | bool m_dontSave; | 417 | bool m_dontSave; |
278 | }; | 418 | }; |
279 | 419 | ||
280 | const int cAutoGen = 0; | 420 | //const int cAutoGen = 0; |
281 | const int cAddBkmk = 1; | 421 | //const int cAddBkmk = 1; |
282 | const int cDelBkmk = 2; | 422 | //const int cDelBkmk = 2; |
283 | const int cGotoBkmk = 3; | 423 | //const int cGotoBkmk = 3; |
284 | const int cRmBkmkFile = 4; | 424 | //const int cRmBkmkFile = 4; |
285 | const int cJump = 5; | 425 | //const int cJump = 5; |
286 | const int cMonoSpace = 6; | 426 | //const int cMonoSpace = 6; |
287 | const int cOverlap = 7; | 427 | //const int cOverlap = 7; |
288 | const int cSetTarget = 8; | 428 | //const int cSetTarget = 8; |
289 | const int cOpenFile = 9; | 429 | //const int cOpenFile = 9; |
430 | //const int cSetPipeTarget = 10; | ||
431 | //const int cSetConfigName = 11; | ||
432 | //const int cMargin = 12; | ||
433 | //const int cExtraSpace = 14; | ||
434 | //const int cExtraLead = 15; | ||
435 | //const int cGfxSize = 16; | ||
436 | //const int cChooseFont = 2; | ||
437 | //const int cChooseEncoding = 1; | ||
290 | 438 | ||
291 | #endif | 439 | #endif |
440 | |||
441 | |||
442 | |||