Diffstat (limited to 'noncore/apps/opie-reader/QTReaderApp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/QTReaderApp.cpp | 246 |
1 files changed, 176 insertions, 70 deletions
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp index 876b65a..6753698 100644 --- a/noncore/apps/opie-reader/QTReaderApp.cpp +++ b/noncore/apps/opie-reader/QTReaderApp.cpp @@ -4,32 +4,33 @@ ** This file is part of Qt Palmtop Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ + #include <qregexp.h> #include <qclipboard.h> #include <qwidgetstack.h> #ifdef USEQPE #include <qpe/qpemenubar.h> #include <qpe/qpetoolbar.h> #endif #include <qmenubar.h> #include <qtoolbar.h> #ifdef USEQPE #include <qpe/menubutton.h> #endif #include <qcombobox.h> #include <qpopupmenu.h> #include <qaction.h> #include <qapplication.h> @@ -53,55 +54,60 @@ #ifdef USEQPE #include <qpe/qcopenvelope_qws.h> #endif #include "QTReader.h" #include "GraphicWin.h" #include "Bkmks.h" #include "cbkmkselector.h" #include "infowin.h" #include "ToolbarPrefs.h" #include "Prefs.h" #include "CAnnoEdit.h" #include "QFloatBar.h" #include "FixedFont.h" #include "URLDialog.h" #include "util.h" #include <qfontdatabase.h> + #ifdef USEQPE #include <qpe/resource.h> #ifdef OPIE -//#include <qpe/applnk.h> +#if defined(OPIEFILEDIALOG) +#include <qpe/applnk.h> #include <opie2/ofiledialog.h> using namespace Opie::Ui; #else #include "fileBrowser.h" #endif #else +#include "fileBrowser.h" +#endif +#else #include "qfiledialog.h" #endif #include "QTReaderApp.h" #include "CDrawBuffer.h" #include "Filedata.h" #include "names.h" #include "CEncoding_tables.h" #include "CloseDialog.h" #include "ButtonPrefs.h" -bool CheckVersion(int&, int&, char&); +bool CheckVersion(int&, int&, char&, QWidget*); #ifdef _WINDOWS #define PICDIR "c:\\uqtreader\\pics\\" #else #ifdef USEQPE #define USEMSGS #define PICDIR "opie-reader/" #else //#define PICDIR "/home/tim/uqtreader/pics/" QString picdir() { QString hd(getenv("READERDIR")); return hd + "/pics"; } #define PICDIR picdir() #endif @@ -140,82 +146,79 @@ void QTReaderApp::listBkmkFiles() if ( !d.cd(APPDIR) ) { // "/tmp" qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); d = QDir::home(); d.mkdir(APPDIR); d.cd(APPDIR); } d.setFilter( QDir::Files | QDir::NoSymLinks ); // d.setSorting( QDir::Size | QDir::Reversed ); const QFileInfoList *list = d.entryInfoList(); QFileInfoListIterator it( *list ); // create list iterator QFileInfo *fi; // pointer for traversing - while ( (fi=it.current()) ) { // for each file... - bkmkselector->insertItem(fi->fileName()); - cnt++; + bkmkselector->insertItem(fi->fileName(), cnt++); //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); ++it; // goto next list element } #else /* USEQPE */ int cnt = 0; DIR *d; d = opendir((const char *)Global::applicationFileName(APPDIR,"")); while(1) { struct dirent* de; struct stat buf; de = readdir(d); if (de == NULL) break; if (lstat((const char *)Global::applicationFileName(APPDIR,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) { - bkmkselector->insertItem(de->d_name); - cnt++; + bkmkselector->insertItem(de->d_name, cnt++); } } closedir(d); #endif if (cnt > 0) { //tjw menu->hide(); editorStack->raiseWidget( bkmkselector ); hidetoolbars(); m_nBkmkAction = cRmBkmkFile; } else QMessageBox::information(this, PROGNAME, "No bookmark files"); } void QTReaderApp::hidetoolbars() { if (m_scrollbar != NULL) m_scrollbar->hide(); if (m_prog != NULL) m_prog->hide(); -#ifdef USEQPE +#if defined(USEQPE) menubar->hide(); #endif if (m_scrollbar != NULL) m_scrollbar->hide(); if (fileBar != NULL) fileBar->hide(); if (viewBar != NULL) viewBar->hide(); if (navBar != NULL) navBar->hide(); if (markBar != NULL) markBar->hide(); if (m_fontVisible) m_fontBar->hide(); if (regVisible) { #ifdef USEQPE Global::hideInputMethod(); #endif regBar->hide(); @@ -320,40 +323,40 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) QFileInfo fi(d, INIFILE); // qDebug("Path:%s", (const char*)fi.absFilePath()); Config config(fi.absFilePath()); #endif config.setGroup("Toolbar"); m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false); m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1); m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2); m_qtscroll = config.readNumEntry("QTScrollBar", false); m_localscroll = config.readNumEntry("LocalScrollBar", false); // fileBar = new QToolBar("File", this); // QToolBar* viewBar = new QToolBar("File", this); // QToolBar* navBar = new QToolBar("File", this); // QToolBar* markBar = new QToolBar("File", this); -#ifdef USEQPE +#if defined(USEQPE) menubar = new QToolBar("Menus", this, m_tbposition); mb = new QPEMenuBar( menubar ); #else mb = new QMenuBar( this ); #endif -#ifdef USEQPE +#if defined(USEQPE) QPopupMenu* tmp = new QPopupMenu(mb); mb->insertItem( geticon( "AppsIcon" ), tmp ); #else QMenuBar* tmp = mb; #endif QPopupMenu *file = new QPopupMenu( mb ); tmp->insertItem( tr( "File" ), file ); QPopupMenu *navigation = new QPopupMenu(mb); tmp->insertItem( tr( "Navigation" ), navigation ); QPopupMenu *view = new QPopupMenu( mb ); tmp->insertItem( tr( "View" ), view ); QPopupMenu *marks = new QPopupMenu( this ); @@ -423,112 +426,122 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) importSelector->setCloseVisible( FALSE ); */ // qDebug("Reading file list"); readfilelist(); reader = new QTReader( editorStack ); reader->setDoUpdates(false); #ifdef USEQPE ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold); #endif // qDebug("Reading config"); // Config config( APPDIR ); config.setGroup( "View" ); +#if defined(USEQPE) && defined(USENEWFULLSCREEN) + m_usenewfullscreen = config.readBoolEntry("NewFullScreen", false); +#endif m_debounce = config.readNumEntry("Debounce", 0); m_buttonprefs->Debounce(m_debounce); #ifdef USEQPE m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false); #else m_bFloatingDialog = config.readBoolEntry("FloatDialogs", true); #endif reader->setStripCR(config.readBoolEntry( "StripCr", true )); reader->bfulljust = config.readBoolEntry( "FullJust", false ); /* bool btmp = config.readBoolEntry("Negative", false); if (btmp) reader->setNegative(); */ reader->bInverse = config.readBoolEntry("Inverse", false); reader->m_fontControl.FixGraphics(config.readBoolEntry( "FixGraphics", false )); reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 )); reader->setlead(config.readNumEntry( "ExtraLead", 0 )); reader->btextfmt = config.readBoolEntry( "TextFmt", false ); reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); + reader->bNoInlineTables = config.readBoolEntry( "NoInlineTables", false ); reader->bpeanut = config.readBoolEntry( "Peanut", false ); reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); reader->bdepluck = config.readBoolEntry( "Depluck", false ); reader->bdejpluck = config.readBoolEntry( "Dejpluck", false ); reader->bonespace = config.readBoolEntry( "OneSpace", false ); reader->bunindent = config.readBoolEntry( "Unindent", false ); reader->brepara = config.readBoolEntry( "Repara", false ); reader->m_reparastring = config.readEntry( "ReparaString", "\\n{[\\n \\t]}"); m_bgtype = (bground)config.readNumEntry( "BackgroundType" , 0 ); m_themename = config.readEntry("Theme", QString::null ); reader->bdblspce = config.readBoolEntry( "DoubleSpace", false ); reader->bindenter = config.readNumEntry( "Indent", 0 ); reader->m_textsize = config.readNumEntry( "FontSize", 12 ); reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); reader->m_scrollstep = config.readNumEntry( "ScrollStep", 1); + reader->m_outputName = config.readEntry( "OutputCodec", ""); + reader->m_lastfile = config.readEntry( "LastFile", QString::null ); reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); reader->m_rotated = config.readBoolEntry( "IsRotated", false ); reader->m_scrolltype = config.readNumEntry( "ScrollType", 0 ); m_statusstring = config.readEntry("StatusContent", "%P%% Doc:%d/%D %p%% %z%%"); m_statusishidden = config.readBoolEntry("StatusHidden", false); m_background = config.readNumEntry( "Background", 0 ); reader->setBackground(getcolour(m_background)); m_foreground = config.readNumEntry( "Foreground", 1 ); reader->setForeground(getcolour(m_foreground)); m_scrollcolor = config.readNumEntry( "ScrollColour", 5 ); setscrollcolour(); m_scrollbarcolor = config.readNumEntry( "ScrollBarColour", 5 ); setscrollbarcolour(); reader->hyphenate = config.readBoolEntry( "Hyphenate", false ); reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false); reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); reader->m_encd = config.readNumEntry( "Encoding", 0 ); reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); reader->m_overlap = config.readNumEntry( "Overlap", 0 ); reader->m_abstopmargin = config.readNumEntry( "Top Margin", 100 ); reader->m_absbottommargin = config.readNumEntry( "Bottom Margin", 100 ); reader->m_absleft_border = config.readNumEntry( "Left Margin", 100 ); reader->m_absright_border = config.readNumEntry( "Right Margin", 100 ); m_scrollishidden = config.readBoolEntry( "HideScrollBar", false ); + m_hidebars = config.readBoolEntry( "HideToolBar", false ); reader->brepalm = config.readBoolEntry( "Repalm", false ); + reader->bunderlineLink = config.readBoolEntry( "UnderlineLink", true ); reader->bkern = config.readBoolEntry( "Kern", false ); reader->bremap = config.readBoolEntry( "Remap", true ); reader->bmakebold = config.readBoolEntry( "MakeBold", false ); reader->setContinuous(config.readBoolEntry( "Continuous", true )); + reader->setDoubleBuffer(config.readBoolEntry("DoubleBuffer", true)); m_targetapp = config.readEntry( "TargetApp", QString::null ); m_targetmsg = config.readEntry( "TargetMsg", QString::null ); #ifdef _SCROLLPIPE reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null ); reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true ); #endif m_twoTouch = config.readBoolEntry( "TwoTouch", false); m_doAnnotation = config.readBoolEntry( "Annotation", false); m_doDictionary = config.readBoolEntry( "Dictionary", false); m_doClipboard = config.readBoolEntry( "Clipboard", false); + m_doOutput = config.readBoolEntry( "OutputTgt", false); /* m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll); m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone); m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen); m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut); m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn); m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp); m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown); m_leftScroll = config.readBoolEntry("LeftScroll", false); m_rightScroll = config.readBoolEntry("RightScroll", false); m_upScroll = config.readBoolEntry("UpScroll", true); m_downScroll = config.readBoolEntry("DownScroll", true); */ m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false); reader->setBaseSize(config.readNumEntry( "Basesize", 10 )); @@ -829,32 +842,44 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) m_tidy_action->addTo( marks ); m_startBlock_action = new QAction( tr( "Start Block" ), geticon( "new" ), QString::null, 0, this, NULL); connect( m_startBlock_action, SIGNAL( activated() ), this, SLOT( editMark() ) ); marks->insertSeparator(); m_startBlock_action->addTo( marks ); m_endBlock_action = new QAction( tr( "Copy Block" ), geticon( "copy" ), QString::null, 0, this, NULL); connect( m_endBlock_action, SIGNAL( activated() ), this, SLOT( editCopy() ) ); m_endBlock_action->addTo( marks ); m_bkmkAvail = NULL; setToolBarsMovable(m_tbmove); addtoolbars(&config); + if (m_hidebars) + { +#if defined(USEQPE) + menubar->hide(); +#endif + if (fileBar != NULL) fileBar->hide(); + if (viewBar != NULL) viewBar->hide(); + if (navBar != NULL) navBar->hide(); + if (markBar != NULL) markBar->hide(); + mb->hide(); + } + pbar = new QProgressBar(this); pbar->hide(); searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE ); searchBar->setHorizontalStretchable( TRUE ); connect(searchBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); searchEdit = new QLineEdit( searchBar, "searchEdit" ); // QFont f("unifont", 16 /*, QFont::Bold*/); // searchEdit->setFont( f ); searchBar->setStretchableWidget( searchEdit ); @@ -959,32 +984,33 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) else { m_scrollbar = NULL; } setBackgroundBitmap(); m_inverse_action->setOn(reader->bInverse); reader->init(); // qDebug("Inited"); // m_buttonAction[m_spaceTarget]->setOn(true); // qDebug("fonting"); do_setfont(reader->m_fontname); // qDebug("fonted"); QFont progfont(reader->m_fontname, reader->m_fontControl.getsize(0)); m_prog->setFont( progfont ); if (m_statusishidden) m_prog->hide(); + showEditTools(); if (!reader->m_lastfile.isEmpty()) { // qDebug("doclnk"); // doc = new DocLnk(reader->m_lastfile); // qDebug("doclnk done"); if (pOpenlist != NULL) { /* int ind = 0; Bkmk* p = (*pOpenlist)[ind]; while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) { p = (*pOpenlist)[++ind]; } */ @@ -1019,94 +1045,94 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) } } } else { showEditTools(); } // qApp->processEvents(); if (m_scrollbar == NULL || m_scrollbar->isHidden()) { reader->m_scrollpos = m_localscroll; } else { reader->m_scrollpos = (m_qtscroll == 0) ? m_localscroll : 0; } - reader->bDoUpdates = true; - reader->update(); + // reader->bDoUpdates = true; + // reader->update(); config.setGroup("Version"); int major = config.readNumEntry("Major", 0); int bkmktype = config.readNumEntry("BkmkType", 0); char minor = config.readNumEntry("Minor", 0); - if (CheckVersion(major, bkmktype, minor)) + if (CheckVersion(major, bkmktype, minor, this)) { config.writeEntry("Major", major); config.writeEntry("BkmkType", bkmktype); config.writeEntry("Minor", (int)minor); } // qDebug("finished update"); if (kmap.isEmpty()) { QMessageBox::warning(this, PROGNAME, "You haven't mapped any keys yet!\n\nYou will be taken to the key\nmapping dialog.\nA few defaults are provided\nbut you can change then to\nsuit yourself.\n\nYou can change the key\nmapping at any time by\nselecting the Settings/Button\noption on the menu."); m_buttonprefs->mapkey(Qt::NoButton, Key_Up, cesPageUp); m_buttonprefs->mapkey(Qt::NoButton, Key_Down, cesPageDown); m_buttonprefs->mapkey(Qt::NoButton, Key_Right, cesZoomIn); m_buttonprefs->mapkey(Qt::NoButton, Key_Left, cesZoomOut); showbuttonprefs(); } } void QTReaderApp::addtoolbars(Config* config) { config->setGroup("Toolbar"); if (fileBar != NULL) { -#ifdef USEQPE +#if defined(USEQPE) if (fileBar != menubar) { fileBar->clear(); } else { m_preferences_action->removeFrom( filebar() ); m_open_action->removeFrom( filebar() ); m_close_action->removeFrom( filebar() ); m_info_action->removeFrom( filebar() ); m_touch_action->removeFrom( filebar() ); m_find_action->removeFrom( filebar() ); } #else fileBar->clear(); #endif } m_preferences_action->addTo( filebar() ); addfilebar(config, "Open", m_open_action); addfilebar(config, "Close", m_close_action); addfilebar(config, "Info", m_info_action); addfilebar(config, "Two/One Touch", m_touch_action); addfilebar(config, "Find", m_find_action); if (navBar != NULL) { -#ifdef USEQPE +#if defined(USEQPE) if ((navBar == fileBar) && (fileBar == menubar)) #else if (navBar == fileBar) #endif { m_scrollButton->removeFrom( navbar() ); m_start_action->removeFrom( navbar() ); m_end_action->removeFrom( navbar() ); m_jump_action->removeFrom( navbar() ); m_pageline_action->removeFrom( navbar() ); m_pageup_action->removeFrom( navbar() ); m_pagedn_action->removeFrom( navbar() ); m_back_action->removeFrom( navbar() ); m_home_action->removeFrom( navbar() ); m_forward_action->removeFrom( navbar() ); } @@ -1119,65 +1145,65 @@ void QTReaderApp::addtoolbars(Config* config) addnavbar(config, "Scroll", m_scrollButton); addnavbar(config, "Goto Start", m_start_action); addnavbar(config, "Goto End", m_end_action); addnavbar(config, "Jump", m_jump_action); addnavbar(config, "Page/Line Scroll", m_pageline_action); addnavbar(config, "Page Up", m_pageup_action); addnavbar(config, "Page Down", m_pagedn_action); addnavbar(config, "Back", m_back_action); addnavbar(config, "Home", m_home_action); addnavbar(config, "Forward", m_forward_action); if (viewBar != NULL) { -#ifdef USEQPE +#if defined(USEQPE) if ((viewBar == fileBar) && (fileBar == menubar)) #else if (viewBar == fileBar) #endif { m_actFullscreen->removeFrom( filebar() ); m_rotate_action->removeFrom( viewbar() ); m_inverse_action->removeFrom( viewbar() ); m_zoomin_action->removeFrom( viewbar() ); m_zoomout_action->removeFrom( viewbar() ); m_setfont_action->removeFrom( viewbar() ); m_setenc_action->removeFrom( viewbar() ); m_setmono_action->removeFrom( viewbar() ); } else if (viewBar != fileBar) { viewBar->clear(); } } addviewbar(config, "Fullscreen", m_actFullscreen); addviewbar(config, "Rotate", m_rotate_action); addviewbar(config, "Invert Action", m_inverse_action); addviewbar(config, "Zoom In", m_zoomin_action); addviewbar(config, "Zoom Out", m_zoomout_action); addviewbar(config, "Set Font", m_setfont_action); addviewbar(config, "Encoding Select", m_setenc_action); addviewbar(config, "Ideogram Mode", m_setmono_action); if (markBar != NULL) { -#ifdef USEQPE +#if defined(USEQPE) if ((markBar == fileBar) && (fileBar == menubar)) #else if (markBar == fileBar) #endif { m_mark_action->removeFrom( markbar() ); m_annotate_action->removeFrom( markbar()); m_goto_action->removeFrom( markbar() ); m_delete_action->removeFrom( markbar() ); m_autogen_action->removeFrom( markbar() ); m_clear_action->removeFrom( markbar() ); m_save_action->removeFrom( markbar() ); m_tidy_action->removeFrom( markbar() ); m_startBlock_action->removeFrom( markbar() ); m_endBlock_action->removeFrom( markbar() ); } @@ -1220,33 +1246,33 @@ void QTReaderApp::addtoolbars(Config* config) } } } bool QTReaderApp::checkbar(Config* _config, const QString& key) { return _config->readBoolEntry(key, false); } QToolBar* QTReaderApp::filebar() { if (fileBar == NULL) { switch (m_tbpol) { -#ifdef USEQPE +#if defined(USEQPE) case cesSingle: // qDebug("Setting filebar to menubar"); fileBar = menubar; break; #endif default: qDebug("Incorrect toolbar policy set"); case cesMenuTool: case cesMultiple: // qDebug("Creating new file bar"); fileBar = new QToolBar("File", this, m_tbposition); break; } // fileBar->setHorizontalStretchable( true ); } return fileBar; @@ -1704,51 +1730,49 @@ void QTReaderApp::setrotated(bool sfs) { reader->setrotated(sfs); if (sfs) { m_layout->setDirection( (m_qtscroll == 2) ? QBoxLayout::BottomToTop : QBoxLayout::TopToBottom ); if (m_scrollbar != NULL) { scrollbar->disconnect(); m_scrollbar->setOrientation(Qt::Horizontal); connect(scrollbar, SIGNAL(nextLine()), reader, SLOT(lineUp()) ); connect(scrollbar, SIGNAL(prevLine()), reader, SLOT(lineDown()) ); connect(scrollbar, SIGNAL(nextPage()), reader, SLOT(dopageup()) ); connect(scrollbar, SIGNAL(prevPage()), reader, SLOT(dopagedn()) ); connect(scrollbar, SIGNAL(sliderMoved(int)), this, SLOT(actionscroll(int)) ); } // reader->repaint(0, reader->m_left_border, reader->width(), reader->height()-2*reader->m_border); - reader->repaint(); } else { m_layout->setDirection( (m_qtscroll == 2) ? QBoxLayout::RightToLeft : QBoxLayout::LeftToRight ); if (m_scrollbar != NULL) { scrollbar->disconnect(); m_scrollbar->setOrientation(Qt::Vertical); connect(scrollbar, SIGNAL(nextLine()), reader, SLOT(lineDown()) ); connect(scrollbar, SIGNAL(prevLine()), reader, SLOT(lineUp()) ); connect(scrollbar, SIGNAL(nextPage()), reader, SLOT(dopagedn()) ); connect(scrollbar, SIGNAL(prevPage()), reader, SLOT(dopageup()) ); connect(scrollbar, SIGNAL(sliderMoved(int)), this, SLOT(actionscroll(int)) ); } // reader->repaint(reader->m_border, 0, reader->width()-2*reader->m_border, reader->height()); - reader->repaint(); } - // reader->update(); + reader->refresh(); } void QTReaderApp::setgrab(bool sfs) { #ifdef USEQPE m_grabkeyboard = sfs; if (m_grabkeyboard) { ((QPEApplication*)qApp)->grabKeyboard(); } else { ((QPEApplication*)qApp)->ungrabKeyboard(); } #endif } @@ -1915,56 +1939,56 @@ void QTReaderApp::fileOpen2() if (QMessageBox::warning(this, PROGNAME, "Save bookmarks?", "Save", "Don't bother") == 0) savebkmks(); } delete pBkmklist; reader->pBkmklist = pBkmklist = NULL; m_fBkmksChanged = false; } reader->disableAutoscroll(); /* editorStack->raiseWidget( fileSelector ); fileSelector->reread(); */ bool usebrowser = true; if (pOpenlist != NULL) { m_nBkmkAction = cOpenFile; - if (listbkmk(pOpenlist, "Browse")) usebrowser = false; + if (listbkmk(pOpenlist, "Browse", true)) usebrowser = false; } if (usebrowser) { QString fn = usefilebrowser(); // qApp->processEvents(); if (!fn.isEmpty() && QFileInfo(fn).isFile()) { openFile(fn); } reader->setFocus(); } // reader->refresh(); // qDebug("HEIGHT:%d", reader->m_lastheight); } QString QTReaderApp::usefilebrowser() { #ifndef USEQPE QString s( QFileDialog::getOpenFileName( reader->m_lastfile, QString::null, this ) ); return s; #else QString fn; -#ifdef OPIE +#if defined(OPIE) && defined(OPIEFILEDIALOG) QMap<QString, QStringList> mimeTypes; QStringList etypes; etypes << "etext/*"; mimeTypes.insert( tr("eText"), etypes ); QStringList types; types << "text/*"; mimeTypes.insert( tr("Text"), types ); mimeTypes.insert( tr("All"), "*/*" ); fn = OFileDialog::getOpenFileName(OFileSelector::EXTENDED_ALL, QFileInfo(reader->m_lastfile).dirPath(true), QString::null, mimeTypes, 0, "OpieReader"); #else fileBrowser* fb = new fileBrowser(false, this,"OpieReader",!m_bFloatingDialog, 0, // WStyle_Customize | WStyle_NoBorderEx, "*", QFileInfo(reader->m_lastfile).dirPath(true)); @@ -1990,44 +2014,46 @@ void QTReaderApp::showgraphic(QImage& pm) void QTReaderApp::showbuttonprefs() { editorStack->raiseWidget( m_buttonprefs ); hidetoolbars(); m_buttonprefs->setFocus(); m_kmapchanged = true; } void QTReaderApp::showprefs() { CPrefs* prefwin = new CPrefs(reader->width(), !m_bFloatingDialog, this); // prefwin->Debounce(m_debounce); prefwin->bgtype(m_bgtype); prefwin->repalm(reader->brepalm); + prefwin->UnderlineLink(reader->bunderlineLink); prefwin->kern(reader->bkern); prefwin->hyphenate(reader->hyphenate); // prefwin->customhyphen(reader->buffdoc.getCustomHyphen()); prefwin->scrolltype(reader->m_scrolltype); prefwin->scrollstep(reader->m_scrollstep); prefwin->scrollcolor(m_scrollcolor); prefwin->minibarcol(m_scrollbarcolor); prefwin->foreground(m_foreground); prefwin->background(m_background); prefwin->twotouch(m_twoTouch); prefwin->propfontchange(m_propogatefontchange); prefwin->StripCR(reader->bstripcr); + prefwin->InlineTables(!reader->bNoInlineTables); prefwin->Dehyphen(reader->bdehyphen); prefwin->SingleSpace(reader->bonespace); prefwin->Unindent(reader->bunindent); prefwin->Reparagraph(reader->brepara); prefwin->DoubleSpace(reader->bdblspce); prefwin->Remap(reader->bremap); prefwin->Embolden(reader->bmakebold); prefwin->FullJustify(reader->bfulljust); // prefwin->Inverse(reader->bInverse); // prefwin->Negative(reader->bNegative); prefwin->FixGraphics(reader->m_fontControl.FixGraphics()); prefwin->ParaLead(reader->getextraspace()); prefwin->LineLead(reader->getlead()); prefwin->TopMargin(reader->m_abstopmargin); prefwin->BottomMargin(reader->m_absbottommargin); prefwin->LeftMargin(reader->m_absleft_border); @@ -2043,83 +2069,90 @@ void QTReaderApp::showprefs() } else if (reader->bstriphtml) { prefwin->Markup(3); } else if (reader->bpeanut) { prefwin->Markup(4); } else { prefwin->Markup(1); } prefwin->Depluck(reader->bdepluck); prefwin->Dejpluck(reader->bdejpluck); prefwin->Continuous(reader->m_continuousDocument); + prefwin->DoubleBuffer(reader->m_doubleBuffered); prefwin->dictApplication(m_targetapp); prefwin->dictMessage(m_targetmsg); /* prefwin->leftScroll(m_leftScroll); prefwin->rightScroll(m_rightScroll); prefwin->upScroll(m_upScroll); prefwin->downScroll(m_downScroll); */ prefwin->miscannotation(m_doAnnotation); prefwin->miscdictionary(m_doDictionary); prefwin->miscclipboard(m_doClipboard); + prefwin->miscoutput(m_doOutput); prefwin->SwapMouse(reader->m_swapmouse); prefwin->Font(reader->m_fontname); prefwin->gfxsize(reader->getBaseSize()); prefwin->pageoverlap(reader->m_overlap); prefwin->ideogram(reader->m_bMonoSpaced); prefwin->encoding(reader->m_encd); prefwin->ideogramwidth(reader->m_charpc); + prefwin->outcodec(reader->m_outputName); + if (prefwin->exec()) { // m_debounce = prefwin->Debounce(); reader->brepalm = prefwin->repalm(); + reader->bunderlineLink = prefwin->UnderlineLink(); + reader->bkern = prefwin->kern(); reader->hyphenate = prefwin->hyphenate(); // reader->buffdoc.setCustomHyphen(prefwin->customhyphen()); reader->m_scrolltype = prefwin->scrolltype(); reader->m_scrollstep = prefwin->scrollstep(); m_scrollcolor = prefwin->scrollcolor(); setscrollcolour(); m_scrollbarcolor = prefwin->minibarcol(); setscrollbarcolour(); m_foreground = prefwin->foreground(); reader->setForeground(getcolour(m_foreground)); m_background = prefwin->background(); reader->setBackground(getcolour(m_background)); m_twoTouch = prefwin->twotouch(); reader->setTwoTouch(m_twoTouch); m_touch_action->setOn(m_twoTouch); reader->bstripcr = prefwin->StripCR(); + reader->bNoInlineTables = !prefwin->InlineTables(); reader->bdehyphen = prefwin->Dehyphen(); reader->bonespace = prefwin->SingleSpace(); reader->bunindent = prefwin->Unindent(); reader->brepara = prefwin->Reparagraph(); reader->bdblspce = prefwin->DoubleSpace(); reader->bremap = prefwin->Remap(); reader->bmakebold = prefwin->Embolden(); reader->bfulljust = prefwin->FullJustify(); // if (reader->bInverse != prefwin->Inverse()) reader->setInverse(prefwin->Inverse()); // if (reader->bNegative != prefwin->Negative()) reader->setNegative(); reader->m_fontControl.FixGraphics(prefwin->FixGraphics()); reader->setextraspace(prefwin->ParaLead()); reader->setlead(prefwin->LineLead()); reader->m_abstopmargin = prefwin->TopMargin(); reader->m_absbottommargin = prefwin->BottomMargin(); @@ -2136,66 +2169,77 @@ void QTReaderApp::showprefs() break; case 2: reader->btextfmt = true; break; case 3: reader->bstriphtml = true; break; case 4: reader->bpeanut = true; break; default: qDebug("Format out of range"); } reader->bdepluck = prefwin->Depluck(); reader->bdejpluck = prefwin->Dejpluck(); reader->setContinuous(prefwin->Continuous()); + reader->setDoubleBuffer(prefwin->DoubleBuffer()); /* m_leftScroll = prefwin->leftScroll(); m_rightScroll = prefwin->rightScroll(); m_upScroll = prefwin->upScroll(); m_downScroll = prefwin->downScroll(); */ m_targetapp = prefwin->dictApplication(); m_targetmsg = prefwin->dictMessage(); m_doAnnotation = prefwin->miscannotation(); m_doDictionary = prefwin->miscdictionary(); m_doClipboard = prefwin->miscclipboard(); + m_doOutput = prefwin->miscoutput(); reader->m_swapmouse = prefwin->SwapMouse(); reader->setBaseSize(prefwin->gfxsize()); reader->m_overlap = prefwin->pageoverlap(); reader->m_bMonoSpaced = prefwin->ideogram(); m_setmono_action->setOn(reader->m_bMonoSpaced); reader->m_encd = prefwin->encoding(); reader->m_charpc = prefwin->ideogramwidth(); if ( reader->m_fontname != prefwin->Font() || m_propogatefontchange != prefwin->propfontchange()) { m_propogatefontchange = prefwin->propfontchange(); setfontHelper(prefwin->Font()); } if (m_bgtype != (bground)prefwin->bgtype()) { m_bgtype = (bground)prefwin->bgtype(); setBackgroundBitmap(); } + qDebug("OutCodec:%s", (const char*)prefwin->outcodec()); + if (reader->m_outputName != prefwin->outcodec()) + { + if (reader->m_output != NULL) + { + QMessageBox::warning(this, PROGNAME, "Change of output codec\nrequires a restart"); + } + reader->m_outputName = prefwin->outcodec(); + } delete prefwin; reader->setfilter(reader->getfilter()); reader->refresh(); } else { delete prefwin; } } void QTReaderApp::showtoolbarprefs() { #ifdef USEQPE CBarPrefs* prefwin = new CBarPrefs(APPDIR, !m_bFloatingDialog, this); #else QFileInfo fi; @@ -2277,38 +2321,62 @@ void QTReaderApp::showtoolbarprefs() void QTReaderApp::showinfo() { unsigned long ds, fs, ts, pl, dl; if (reader->empty()) { QMessageBox::information(this, PROGNAME, "No file loaded", 1); } else { reader->sizes(fs,ts); ds = reader->buffdoc.endSection() - reader->buffdoc.startSection(); pl = reader->pagelocate(); dl = pl - reader->buffdoc.startSection(); m_infoWin->setFileSize(fs); m_infoWin->setTextSize(ts); - m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts); + if (fs > UINT_MAX/100) + { + unsigned long t1 = (ts+50)/100; + m_infoWin->setRatio(100-(fs + (t1 >> 1))/t1); + } + else + { + m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts); + } m_infoWin->setLocation(pl); - m_infoWin->setRead((100*pl + (ts >> 1))/ts); + if (pl > UINT_MAX/100) + { + unsigned long t1 = (ts+50)/100; + m_infoWin->setRead((pl + (t1 >> 1))/t1); + } + else + { + m_infoWin->setRead((100*pl + (ts >> 1))/ts); + } m_infoWin->setDocSize(ds); m_infoWin->setDocLocation(dl); - m_infoWin->setDocRead((100*dl + (ds >> 1))/ds); + if (dl > UINT_MAX/100) + { + unsigned long d1 = (ds+50)/100; + m_infoWin->setDocRead((dl + (d1 >> 1))/d1); + } + else + { + m_infoWin->setDocRead((100*dl + (ds >> 1))/ds); + } m_infoWin->setZoom(reader->m_fontControl.currentsize()*10); m_infoWin->setAbout(QString("\nApplication (c) Tim Wentford\n")+reader->about()); editorStack->raiseWidget( m_infoWin ); hidetoolbars(); m_infoWin->setFocus(); } } void QTReaderApp::addAnno(const QString& name, const QString& text, size_t posn, size_t posn2) { if (pBkmklist == NULL) reader->pBkmklist = pBkmklist = new CList<Bkmk>; #ifdef _UNICODE CBuffer buff(name.length()+1); int i; for (i = 0; i < name.length(); i++) { @@ -2729,56 +2797,56 @@ void QTReaderApp::search(const QString & arg) */ else { start = reader->pagelocate(); reader->jumpto(start); searchStack->push(new searchrecord(arg,start)); } dosearch(start, test, arg); } #else void QTReaderApp::search() { findNext(); } #endif -void QTReaderApp::openFile( const QString &f ) +void QTReaderApp::openFile( const QString &f, unsigned int loc ) { // qDebug("File:%s", (const char*)f); // openFile(DocLnk(f)); //} // //void QTReaderApp::openFile( const DocLnk &f ) //{ clear(); QFileInfo fm(f); if ( fm.exists() ) { // QMessageBox::information(0, "Progress", "Calling fileNew()"); #ifdef USEQPE if (fm.extension( FALSE ) == "desktop") { DocLnk d(f); QFileInfo fnew(d.file()); fm = fnew; if (!fm.exists()) return; } #endif clear(); - reader->setText(fm.baseName(), fm.absFilePath()); + reader->setText(fm.baseName(), fm.absFilePath(), loc); m_loadedconfig = readconfig(APPDIR "/configs", reader->m_string, false); qDebug("Showing tools"); showEditTools(); qDebug("Shown tools"); readbkmks(); qDebug("read markss"); m_savedpos = 0xffffffff; } else { QString msg = f; msg += "\nFile does not exist"; QMessageBox::information(this, PROGNAME, msg); reader->m_lastfile = QString::null; } @@ -2793,33 +2861,33 @@ void QTReaderApp::resizeEvent(QResizeEvent* e) } } */ void QTReaderApp::handlekey(QKeyEvent* e) { // qDebug("Keypress event"); timeb now; ftime(&now); unsigned long etime = (1000*(now.time - m_lastkeytime.time) + now.millitm)-m_lastkeytime.millitm; if (etime < m_debounce) { return; } switch(e->key()) { case Key_Escape: -// qDebug("escape event"); + qDebug("escape event"); if (m_disableesckey) { m_disableesckey = false; } else { m_bcloseDisabled = true; if (m_fullscreen) { m_actFullscreen->setOn(false); e->accept(); } else { // qDebug("escape action"); doAction(e); @@ -2878,112 +2946,109 @@ void QTReaderApp::handlekey(QKeyEvent* e) */ default: { doAction(e); } /* QString msg("Key press was:"); QString key; msg += key.setNum(e->key()); QMessageBox::information(this, PROGNAME, msg); */ } ftime(&m_lastkeytime); } -#ifdef NEWFULLSCREEN -void QTReaderApp::enableFullscreen() -{ - setFixedSize(qApp->desktop()->size()); - showNormal(); - reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0)); - showFullScreen(); -} - -void QTReaderApp::resizeEvent(QResizeEvent *) +#if defined(USEQPE) && defined(USENEWFULLSCREEN) +void QTReaderApp::focusInEvent(QFocusEvent *) { - if (m_fullscreen && (size() != qApp->desktop()->size())) + if (m_usenewfullscreen && m_fullscreen && (editorStack->visibleWidget() == reader)) { - enableFullscreen(); + m_usenewfullscreen = false; + reader->bDoUpdates = false; + showEditTools(); + reader->bDoUpdates = true; + reader->update(); + m_usenewfullscreen = true; } } -void QTReaderApp::focusInEvent(QFocusEvent*) +void QTReaderApp::resizeEvent(QResizeEvent *) { - if (m_fullscreen) + if (m_usenewfullscreen && m_fullscreen && (editorStack->visibleWidget() == reader)) { - enableFullscreen(); - raise(); + m_usenewfullscreen = false; + reader->bDoUpdates = false; + showEditTools(); + reader->bDoUpdates = true; + reader->update(); + m_usenewfullscreen = true; } } #endif void QTReaderApp::showEditTools() { // if ( !doc ) // close(); if (m_fullscreen) { -#ifdef USEQPE +#if defined(USEQPE) if (menubar != NULL) menubar->hide(); #endif if (fileBar != NULL) fileBar->hide(); if (viewBar != NULL) viewBar->hide(); if (navBar != NULL) navBar->hide(); if (markBar != NULL) markBar->hide(); if (m_prog != NULL) { // qDebug("Hiding status"); m_prog->hide(); } searchBar->hide(); regBar->hide(); #ifdef USEQPE Global::hideInputMethod(); #endif if (m_scrollbar != NULL) m_scrollbar->hide(); m_fontBar->hide(); // showNormal(); -#ifdef NEWFULLSCREEN - enableFullscreen(); -#else showFullScreen(); -#endif - } + } else { // qDebug("him"); #ifdef USEQPE Global::hideInputMethod(); #endif // qDebug("eb"); if (m_scrollbar != NULL) { if (m_scrollishidden) { m_scrollbar->hide(); } else { m_scrollbar->show(); } } if (!m_hidebars) { -#ifdef USEQPE +#if defined(USEQPE) menubar->show(); #endif if (fileBar != NULL) fileBar->show(); if (viewBar != NULL) viewBar->show(); if (navBar != NULL) navBar->show(); if (markBar != NULL) markBar->show(); if (m_prog != NULL && !m_statusishidden) { // qDebug("Showing status"); m_prog->show(); // qDebug("Shown status"); } // qDebug("Showing mb"); mb->show(); } if ( searchVisible ) @@ -2991,46 +3056,46 @@ void QTReaderApp::showEditTools() #ifdef USEQPE Global::showInputMethod(); #endif searchBar->show(); } if ( regVisible ) { #ifdef USEQPE Global::showInputMethod(); #endif regBar->show(); } if (m_fontVisible) m_fontBar->show(); // qDebug("sn"); showNormal(); // qDebug("sm"); -#ifdef USEQPE +#if defined(USEQPE) && !defined(SIMPAD) showMaximized(); #endif // setCentralWidget(reader); } // qDebug("uc"); updateCaption(); // qDebug("rw"); editorStack->raiseWidget( reader ); // qDebug("sf"); reader->setFocus(); // qDebug("ref"); - reader->refresh(true); + //reader->refresh(true); // qDebug("done"); } /* void QTReaderApp::save() { if ( !doc ) return; if ( !editor->edited() ) return; QString rt = editor->text(); QString pt = rt; if ( doc->name().isEmpty() ) { unsigned ispace = pt.find( ' ' ); unsigned ienter = pt.find( '\n' ); @@ -3161,57 +3226,67 @@ void QTReaderApp::closeEvent( QCloseEvent *e ) } void QTReaderApp::do_gotomark() { m_nBkmkAction = cGotoBkmk; if (!listbkmk(pBkmklist)) QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); } void QTReaderApp::do_delmark() { m_nBkmkAction = cDelBkmk; if (!listbkmk(pBkmklist)) QMessageBox::information(this, PROGNAME, "No bookmarks in memory"); } -bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab) +bool QTReaderApp::listbkmk(CList<Bkmk>* plist, const QString& _lab, bool presel) { bkmkselector->clear(); if (_lab.isEmpty()) bkmkselector->setText("Cancel"); else bkmkselector->setText(_lab); int cnt = 0; + int slt = -1; if (plist != NULL) { for (CList<Bkmk>::iterator i = plist->begin(); i != plist->end(); i++) { + if (presel) + { + Bkmk* p = i.pContent(); + if (toQString(CFiledata(p->anno()).name()) == reader->m_lastfile) + { + slt = cnt; + } + } #ifdef _UNICODE // qDebug("Item:%s", (const char*)toQString(i->name())); - bkmkselector->insertItem(toQString(i->name())); + bkmkselector->insertItem(toQString(i->name()), cnt++); #else - bkmkselector->insertItem(i->name()); + bkmkselector->insertItem(i->name(), cnt++); #endif - cnt++; + } } if (cnt > 0) { hidetoolbars(); editorStack->raiseWidget( bkmkselector ); + if (slt != -1) bkmkselector->setCurrentItem(slt); return true; } else return false; } void QTReaderApp::do_autogen() { m_nRegAction = cAutoGen; regEdit->setText(m_autogenstr); do_regedit(); } void QTReaderApp::do_regedit() { // fileBar->hide(); @@ -3225,56 +3300,57 @@ void QTReaderApp::do_regedit() regVisible = true; regEdit->setFocus(); // qApp->processEvents(); reader->bDoUpdates = true; reader->update(); } bool QTReaderApp::openfrombkmk(Bkmk* bk) { QString fn = toQString( CFiledata(bk->anno()).name() ); // qDebug("fileinfo"); if (!fn.isEmpty() && QFileInfo(fn).isFile()) { // qDebug("Opening"); - openFile(fn); struct stat fnstat; - stat((const char *)reader->m_lastfile, &fnstat); + stat((const char *)fn, &fnstat); if (CFiledata(bk->anno()).date() != fnstat.st_mtime) { CFiledata fd(bk->anno()); fd.setdate(fnstat.st_mtime); bk->value(0); + reader->m_lastposn = 0; + openFile(fn); } else { unsigned short svlen = bk->filedatalen(); unsigned char* svdata = bk->filedata(); + openFile(fn, bk->value()); reader->putSaveData(svdata, svlen); // setstate(svdata, svlen); if (svlen != 0) { QMessageBox::warning(this, PROGNAME, "Not all file data used\nNew version?"); } // qDebug("updating"); // showEditTools(); - reader->locate(bk->value()); } return true; } else { return false; } } void QTReaderApp::gotobkmk(int ind) { qDebug("gbkmk"); showEditTools(); switch (m_nBkmkAction) { case cOpenFile: @@ -3353,33 +3429,33 @@ void QTReaderApp::gotobkmk(int ind) } fclose(fin); fprintf(fout, "</html></body>\n"); d.remove(bkmkselector->text(ind)); } fclose(fout); } else QMessageBox::information(this, PROGNAME, "Couldn't open output"); } } #else /* USEQPE */ FILE* fin = fopen((const char *)Global::applicationFileName(APPDIR "/urls",bkmkselector->text(ind)), "r"); if (fin != NULL) { bool allok = false; -#ifdef OPIE +#if defined(OPIE) && defined(OPIEFILEDIALOG) QString outfile = OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL, QString::null, QString::null, MimeTypes(), 0, "OpieReader"); if (!outfile.isEmpty()) { FILE* fout = fopen((const char *)outfile, "w"); if (fout != NULL) { fprintf(fout, "<html><body>\n"); int ch = 0; while ((ch = fgetc(fin)) != EOF) { fputc(ch, fout); } fprintf(fout, "</html></body>\n"); fclose(fout); allok = true; } @@ -3690,51 +3766,60 @@ void QTReaderApp::do_autogen(const QString& regText) QRegExp re(regText); CBuffer buff; if (pBkmklist != NULL) delete pBkmklist; reader->pBkmklist = pBkmklist = new CList<Bkmk>; m_fBkmksChanged = true; pbar->setGeometry(regBar->x(),regBar->y(),regBar->width(), regBar->height()); pbar->show(); pbar->raise(); pbar->reset(); reader->update(); qApp->processEvents(); reader->setFocus(); reader->jumpto(0); int lastpc = 0; int i = 0; + unsigned int llcn = reader->locate(); while (i >= 0) { - unsigned int lcn = reader->locate(); + unsigned int lcn = llcn; int pc = (100*lcn)/ts; if (pc != lastpc) { pbar->setProgress(pc); qApp->processEvents(); if (reader->locate() != lcn) reader->jumpto(lcn); reader->setFocus(); lastpc = pc; } i = reader->buffdoc.getpara(buff); #ifdef _UNICODE if (re.match(toQString(buff.data())) != -1) #else if (re.match(buff.data()) != -1) #endif pBkmklist->push_back(Bkmk(buff.data(), NULL, lcn)); + /* + llcn = reader->locate(); + if ((i == 0) && (llcn+1 < ts)) + { + reader->jumpto(++llcn); + i = 1; + } + */ } pBkmklist->sort(); pbar->setProgress(100); qApp->processEvents(); pbar->hide(); reader->refresh(); } void QTReaderApp::saveprefs() { do_saveconfig( APPDIR, true ); savefilelist(); } /* void QTReaderApp::oldFile() @@ -4019,32 +4104,36 @@ void QTReaderApp::showAnnotation() m_annoWin->setName(toQString(m_anno->name())); m_annoWin->setAnno(toQString(m_anno->anno())); m_annoWin->setColor(QColor(m_anno->red(), m_anno->green(), m_anno->blue())); m_annoIsEditing = false; #ifdef USEQPE Global::showInputMethod(); #endif editorStack->raiseWidget( m_annoWin ); hidetoolbars(); m_annoWin->setFocus(); } void QTReaderApp::OnWordSelected(const QString& wrd, size_t posn, size_t posn2, const QString& line) { //// qDebug("OnWordSelected(%u):%s", posn, (const char*)wrd); + if (m_doOutput && reader->checkoutput()) + { + reader->doOutput(wrd); + } if (m_doClipboard) { QClipboard* cb = QApplication::clipboard(); cb->setText(wrd); #ifdef USEQPE if (wrd.length() > 10) { Global::statusMessage(wrd.left(8) + ".."); } else { Global::statusMessage(wrd); } #endif } if (m_doAnnotation) @@ -4103,44 +4192,44 @@ void QTReaderApp::doAction(QKeyEvent* e) { reader->gotoLink(); } break; case cesNextLink: { reader->getNextLink(); } break; case cesInvertColours: m_inverse_action->setOn(!reader->bInverse); break; case cesToggleBars: m_hidebars = !m_hidebars; if (m_hidebars) { -#ifdef USEQPE +#if defined(USEQPE) menubar->hide(); #endif if (fileBar != NULL) fileBar->hide(); if (viewBar != NULL) viewBar->hide(); if (navBar != NULL) navBar->hide(); if (markBar != NULL) markBar->hide(); mb->hide(); } else { -#ifdef USEQPE +#if defined(USEQPE) menubar->show(); #endif if (fileBar != NULL) fileBar->show(); if (viewBar != NULL) viewBar->show(); if (navBar != NULL) navBar->show(); if (markBar != NULL) markBar->show(); mb->show(); } break; case cesToggleScrollBar: if (m_scrollbar != NULL) { if (m_scrollbar->isHidden()) { m_scrollishidden = false; m_scrollbar->show(); @@ -4327,108 +4416,114 @@ void QTReaderApp::do_saveconfig(const QString& _txt, bool full) if ( !d.cd("configs") ) { // "/tmp" qWarning( "Cannot find the \"~/" APPDIR "/configs\" directory" ); d = QDir::home(); d.cd(APPDIR); d.mkdir("configs"); d.cd("configs"); } fi.setFile(d, _txt); } // qDebug("Path:%s", (const char*)fi.absFilePath()); Config config(fi.absFilePath()); #endif config.writeEntry( "StripCr", reader->bstripcr ); + config.writeEntry( "NoInlineTables", reader->bNoInlineTables ); config.writeEntry( "AutoFmt", reader->bautofmt ); config.writeEntry( "TextFmt", reader->btextfmt ); config.writeEntry( "StripHtml", reader->bstriphtml ); config.writeEntry( "Dehyphen", reader->bdehyphen ); config.writeEntry( "Depluck", reader->bdepluck ); config.writeEntry( "Dejpluck", reader->bdejpluck ); config.writeEntry( "OneSpace", reader->bonespace ); config.writeEntry( "Unindent", reader->bunindent ); config.writeEntry( "Repara", reader->brepara ); config.writeEntry( "ReparaString", reader->m_reparastring); config.writeEntry( "BackgroundType" , (int)m_bgtype ); config.writeEntry( "Theme", m_themename ); config.writeEntry( "DoubleSpace", reader->bdblspce ); config.writeEntry( "Indent", reader->bindenter ); config.writeEntry( "FontSize", (int)(reader->m_fontControl.currentsize()) ); config.writeEntry( "ScrollDelay", reader->m_delay); config.writeEntry( "ScrollStep", reader->m_scrollstep); config.writeEntry( "ScrollType", reader->m_scrolltype ); if (full) { config.writeEntry("Debounce", m_debounce); config.writeEntry("FloatDialogs", m_bFloatingDialog); reader->m_lastposn = reader->pagelocate(); config.writeEntry( "LastFile", reader->m_lastfile ); config.writeEntry( "LastPosn", (int)(reader->pagelocate()) ); + config.writeEntry( "OutputCodec", reader->m_outputName); } config.writeEntry( "PageMode", reader->m_bpagemode ); config.writeEntry( "MonoSpaced", reader->m_bMonoSpaced ); config.writeEntry( "SwapMouse", reader->m_swapmouse); config.writeEntry( "IsRotated", reader->m_rotated ); config.writeEntry("StatusContent", m_statusstring); config.writeEntry("StatusHidden", m_statusishidden); config.writeEntry( "Background", m_background ); config.writeEntry( "Foreground", m_foreground ); config.writeEntry( "ScrollColour", m_scrollcolor ); config.writeEntry( "ScrollBarColour", m_scrollbarcolor ); config.writeEntry( "Hyphenate", reader->hyphenate ); // config.writeEntry( "CustomHyphen", reader->buffdoc.getCustomHyphen() ); config.writeEntry( "Fontname", reader->m_fontname ); config.writeEntry( "Encoding", reader->m_encd ); config.writeEntry( "CharSpacing", reader->m_charpc ); config.writeEntry( "Overlap", (int)(reader->m_overlap) ); config.writeEntry( "Top Margin", (int)reader->m_abstopmargin ); config.writeEntry( "Bottom Margin", (int)reader->m_absbottommargin ); config.writeEntry( "Left Margin", (int)reader->m_absleft_border ); config.writeEntry( "Right Margin", (int)reader->m_absright_border ); config.writeEntry( "TargetApp", m_targetapp ); config.writeEntry( "TargetMsg", m_targetmsg ); #ifdef _SCROLLPIPE config.writeEntry( "PipeTarget", reader->m_pipetarget ); config.writeEntry( "PauseAfterPara", reader->m_pauseAfterEachPara ); #endif config.writeEntry( "TwoTouch", m_twoTouch ); config.writeEntry( "Annotation", m_doAnnotation); config.writeEntry( "Dictionary", m_doDictionary); config.writeEntry( "Clipboard", m_doClipboard); + config.writeEntry( "OutputTgt", m_doOutput); /* config.writeEntry( "SpaceTarget", m_spaceTarget); config.writeEntry( "EscapeTarget", m_escapeTarget); config.writeEntry( "ReturnTarget", m_returnTarget); config.writeEntry( "LeftTarget", m_leftTarget); config.writeEntry( "RightTarget", m_rightTarget); config.writeEntry( "UpTarget", m_upTarget); config.writeEntry( "DownTarget", m_downTarget); config.writeEntry("LeftScroll", m_leftScroll); config.writeEntry("RightScroll", m_rightScroll); config.writeEntry("UpScroll", m_upScroll); config.writeEntry("DownScroll", m_downScroll); */ config.writeEntry( "Repalm", reader->brepalm ); + config.writeEntry( "UnderlineLink", reader->bunderlineLink ); config.writeEntry( "HideScrollBar", m_scrollishidden ); + config.writeEntry( "HideToolBar", m_hidebars ); config.writeEntry( "Kern", reader->bkern ); config.writeEntry( "Remap", reader->bremap ); config.writeEntry( "Peanut", reader->bpeanut ); config.writeEntry( "MakeBold", reader->bmakebold ); config.writeEntry( "Continuous", reader->m_continuousDocument ); + config.writeEntry( "DoubleBuffer", reader->m_doubleBuffered); config.writeEntry( "FullJust", reader->bfulljust ); // config.writeEntry( "Negative", reader->bNegative ); config.writeEntry( "Inverse", reader->bInverse ); config.writeEntry( "FixGraphics", reader->m_fontControl.FixGraphics()); config.writeEntry( "ExtraSpace", reader->getextraspace() ); config.writeEntry( "ExtraLead", reader->getlead() ); config.writeEntry( "Basesize", (int)reader->getBaseSize()); config.writeEntry( "RequestorFontChange", m_propogatefontchange); #ifdef USEQPE config.writeEntry( "GrabKeyboard", m_grabkeyboard ); #endif if (full) { config.setGroup( "Toolbar" ); config.writeEntry("QTScrollBar", m_qtscroll); config.writeEntry("LocalScrollBar", m_localscroll); @@ -4506,32 +4601,33 @@ bool QTReaderApp::readconfig(const QString& dirname, const QString& _txt, bool f fullname = QDir::homeDirPath() + "/" + dirname + "/" + _txt; } if (!QFile::exists(fullname)) return false; Config config(fullname); #endif if (full) { config.setGroup("Toolbar"); m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", m_tbmovesave); m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", m_tbpolsave); m_tbposition = (ToolBarDock)config.readNumEntry("Position", m_tbposition); } config.setGroup( "View" ); m_bFloatingDialog = config.readBoolEntry("FloatDialogs", m_bFloatingDialog); reader->bstripcr = config.readBoolEntry( "StripCr", reader->bstripcr ); + reader->bNoInlineTables = config.readBoolEntry( "NoInlineTables", reader->bNoInlineTables ); reader->bfulljust = config.readBoolEntry( "FullJust", reader->bfulljust ); reader->bInverse = config.readBoolEntry( "Inverse", reader->bInverse ); // reader->bNegative = config.readBoolEntry( "Negative", false ); reader->m_fontControl.FixGraphics(config.readBoolEntry( "FixGraphics", reader->m_fontControl.FixGraphics() )); reader->setextraspace(config.readNumEntry( "ExtraSpace", reader->getextraspace() )); reader->setlead(config.readNumEntry( "ExtraLead", reader->getlead() )); reader->btextfmt = config.readBoolEntry( "TextFmt", reader->btextfmt ); reader->bautofmt = config.readBoolEntry( "AutoFmt", reader->bautofmt ); reader->bstriphtml = config.readBoolEntry( "StripHtml", reader->bstriphtml ); reader->bpeanut = config.readBoolEntry( "Peanut", reader->bpeanut ); reader->bdehyphen = config.readBoolEntry( "Dehyphen", reader->bdehyphen ); reader->bdepluck = config.readBoolEntry( "Depluck", reader->bdepluck ); reader->bdejpluck = config.readBoolEntry( "Dejpluck", reader->bdejpluck ); reader->bonespace = config.readBoolEntry( "OneSpace", reader->bonespace ); reader->bunindent = config.readBoolEntry( "Unindent", reader->bunindent ); reader->brepara = config.readBoolEntry( "Repara", reader->brepara ); @@ -4561,53 +4657,59 @@ bool QTReaderApp::readconfig(const QString& dirname, const QString& _txt, bool f m_scrollcolor = config.readNumEntry( "ScrollColour", m_scrollcolor); setscrollcolour(); m_scrollbarcolor = config.readNumEntry( "ScrollBarColour", m_scrollbarcolor); setscrollbarcolour(); reader->hyphenate = config.readBoolEntry( "Hyphenate", reader->hyphenate ); // reader->buffdoc.setCustomHyphen(config.readBoolEntry( "CustomHyphen", false )); reader->m_swapmouse = config.readBoolEntry( "SwapMouse", reader->m_swapmouse); reader->m_fontname = config.readEntry( "Fontname", reader->m_fontname ); reader->m_encd = config.readNumEntry( "Encoding", reader->m_encd ); reader->m_charpc = config.readNumEntry( "CharSpacing", reader->m_charpc ); reader->m_overlap = config.readNumEntry( "Overlap", reader->m_overlap ); reader->m_abstopmargin = config.readNumEntry( "Top Margin", reader->m_abstopmargin ); reader->m_absbottommargin = config.readNumEntry( "Bottom Margin", reader->m_absbottommargin ); reader->m_absleft_border = config.readNumEntry( "Left Margin", reader->m_absleft_border ); reader->m_absright_border = config.readNumEntry( "Right Margin", reader->m_absright_border ); m_scrollishidden = config.readBoolEntry( "HideScrollBar", m_scrollishidden ); + m_hidebars = config.readBoolEntry( "HideToolBar", m_hidebars ); reader->brepalm = config.readBoolEntry( "Repalm", reader->brepalm ); + reader->bunderlineLink = config.readBoolEntry( "UnderlineLink", reader->bunderlineLink ); reader->bkern = config.readBoolEntry( "Kern", reader->bkern ); reader->bremap = config.readBoolEntry( "Remap", reader->bremap ); reader->bmakebold = config.readBoolEntry( "MakeBold", reader->bmakebold ); reader->setContinuous(config.readBoolEntry( "Continuous", reader->m_continuousDocument )); + reader->setDoubleBuffer(config.readBoolEntry("DoubleBuffer", reader->m_doubleBuffered)); m_targetapp = config.readEntry( "TargetApp", m_targetapp ); m_targetmsg = config.readEntry( "TargetMsg", m_targetmsg ); #ifdef _SCROLLPIPE reader->m_pipetarget = config.readEntry( "PipeTarget", reader->m_pipetarget ); reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", reader->m_pauseAfterEachPara ); #endif m_twoTouch = config.readBoolEntry( "TwoTouch", m_twoTouch); m_doAnnotation = config.readBoolEntry( "Annotation", m_doAnnotation); m_doDictionary = config.readBoolEntry( "Dictionary", m_doDictionary); m_doClipboard = config.readBoolEntry( "Clipboard", m_doClipboard); + m_doOutput = config.readBoolEntry( "OutputTgt", m_doOutput); #ifdef USEQPE m_grabkeyboard = config.readBoolEntry( "GrabKeyboard", m_grabkeyboard); #endif m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", m_propogatefontchange); reader->setBaseSize(config.readNumEntry( "Basesize", reader->getBaseSize() )); reader->setTwoTouch(m_twoTouch); + + reader->m_outputName = config.readEntry( "OutputCodec", reader->m_outputName); m_touch_action->setOn(m_twoTouch); m_setmono_action->setOn(reader->m_bMonoSpaced); setfontHelper(reader->m_fontname); if (full) { addtoolbars(&config); } reader->setfilter(reader->getfilter()); reader->refresh(); return true; } bool QTReaderApp::PopulateConfig(const char* tgtdir, bool usedirs) { bkmkselector->clear(); @@ -4624,60 +4726,58 @@ bool QTReaderApp::PopulateConfig(const char* tgtdir, bool usedirs) } if ( !d.cd(tgtdir) ) { // "/tmp" qWarning( "Cannot find the \"~/" APPDIR "/%s\" directory", tgtdir ); d = QDir::home(); d.mkdir(tgtdir); d.cd(tgtdir); } d.setFilter( ((usedirs) ? QDir::Dirs : QDir::Files) | QDir::NoSymLinks ); // d.setSorting( QDir::Size | QDir::Reversed ); const QFileInfoList *list = d.entryInfoList(); QFileInfoListIterator it( *list ); // create list iterator QFileInfo *fi; // pointer for traversing while ( (fi=it.current()) ) { // for each file... - bkmkselector->insertItem(fi->fileName()); - cnt++; + bkmkselector->insertItem(fi->fileName(), cnt++); //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); ++it; // goto next list element } #else /* USEQPE */ int cnt = 0; DIR *d; char* finaldir; finaldir = new char[strlen(APPDIR)+1+strlen(tgtdir)+1]; strcpy(finaldir, APPDIR); strcat(finaldir, "/"); strcat(finaldir, tgtdir); d = opendir((const char *)Global::applicationFileName(finaldir,"")); while(1) { struct dirent* de; struct stat buf; de = readdir(d); if (de == NULL) break; if (lstat((const char *)Global::applicationFileName(finaldir,de->d_name),&buf) == 0 && ((usedirs && S_ISDIR(buf.st_mode)) || (!usedirs && S_ISREG(buf.st_mode)))) { - bkmkselector->insertItem(de->d_name); - cnt++; + bkmkselector->insertItem(de->d_name, cnt++); } } delete [] finaldir; closedir(d); #endif return (cnt > 0); } void QTReaderApp::LoadTheme() { if (PopulateConfig("Themes", true)) { editorStack->raiseWidget( bkmkselector ); hidetoolbars(); m_nBkmkAction = cLdTheme; } @@ -4722,32 +4822,34 @@ void QTReaderApp::ExportLinks() } void QTReaderApp::OnURLSelected(const QString& href, const size_t tgt) { #ifndef USEQPE qDebug("URL:%s", (const char*)href); int col = href.find(':'); if (col > 0) { QString type = href.left(col); qDebug("Type:%s", (const char*)type); } else { qDebug("No type"); } + QString msg = "External URL\n" + href; + QMessageBox::information(this, PROGNAME, msg); #else if (href.isEmpty()) { QMessageBox::information(this, PROGNAME, "No URL information supplied"); } else { CURLDialog* urld = new CURLDialog(href, false, this); urld->clipboard(m_url_clipboard); urld->localfile(m_url_localfile); urld->globalfile(m_url_globalfile); if (urld->exec()) { m_url_clipboard = urld->clipboard(); m_url_localfile = urld->localfile(); m_url_globalfile = urld->globalfile(); @@ -4888,49 +4990,53 @@ void QTReaderApp::setscrollbarcolour() /* QColor xc = getcolour(m_scrollcolor); int r,g,b; xc.rgb(&r,&g,&b); reader->m_scrollcolor.setRgb(255^r, 255^g, 255^b); */ reader->m_scrollbarcolor = getcolour(m_scrollbarcolor); } void QTReaderApp::forceopen(const QString& filename) { /* QFileInfo fi(reader->m_lastfile); fi = QFileInfo(filename); QString flnm = fi.absFilePath(); */ - if (!filename.isEmpty()) + if (!filename.isEmpty() && QFileInfo(filename).exists()) { updatefileinfo(); if (pBkmklist != NULL) { if (m_fBkmksChanged) { savebkmks(); } delete pBkmklist; pBkmklist = NULL; m_fBkmksChanged = false; } reader->disableAutoscroll(); openFile(filename); reader->setFocus(); } + else + { + OnURLSelected(filename, 0); + } } void QTReaderApp::actionscroll(int v) { if (reader->m_rotated) { reader->dopageup(reader->buffdoc.startSection()+reader->buffdoc.endSection()-v); } else { /* if (reader->pagelocate() < v) { while (reader->pagelocate() < v) reader->lineDown(); } else |