Correct the implementation of Quit link action

Add the implementation of close link action
That two actions only work within inside kpdf as in konqueror they would be quite shocking
Reverse the order link actions are added to m_rects because there are some pdf that have a rect with a link and inside of that another link with a snall rect, and with this order we match acrobat behaviour

svn path=/trunk/KDE/kdegraphics/kpdf/; revision=435350
remotes/origin/kpdf
Albert Astals Cid 21 years ago
parent af4ffd7258
commit bdc00ae3f3
  1. 5
      core/document.cpp
  2. 2
      core/document.h
  3. 4
      core/generator_pdf/gp_outputdev.cpp
  4. 2
      core/link.h
  5. 24
      part.cpp
  6. 5
      part.h
  7. 1
      shell/shell.cpp
  8. 5
      shell/shell.h
  9. 5
      ui/pageview.cpp

@ -1025,7 +1025,7 @@ void KPDFDocument::processLink( const KPDFLink * link )
setNextViewport();
break;
case KPDFLinkAction::Quit:
kapp->quit();
emit quit();
break;
case KPDFLinkAction::Find:
emit linkFind();
@ -1033,6 +1033,9 @@ void KPDFDocument::processLink( const KPDFLink * link )
case KPDFLinkAction::GoToPage:
emit linkGoToPage();
break;
case KPDFLinkAction::Close:
emit close();
break;
}
} break;

@ -102,6 +102,8 @@ class KPDFDocument : public QObject
void requestDone( PixmapRequest * request );
signals:
void close();
void quit();
void linkFind();
void linkGoToPage();
void openURL(const KURL &url);

@ -174,7 +174,7 @@ void KPDFOutputDev::drawLink( Link * link, Catalog * catalog )
// create the rect using normalized coords and attach the KPDFLink to it
ObjectRect * rect = new ObjectRect( nl, nt, nr, nb, ObjectRect::Link, l );
// add the ObjectRect to the vector container
m_rects.push_back( rect );
m_rects.push_front( rect );
}
}
SplashOutputDev::drawLink( link, catalog );
@ -325,6 +325,8 @@ KPDFLink * KPDFOutputDev::generateLink( LinkAction * a )
link = new KPDFLinkAction( KPDFLinkAction::GoToPage );
else if ( !strcmp( name, "Find" ) )
link = new KPDFLinkAction( KPDFLinkAction::Find );
else if ( !strcmp( name, "Close" ) )
link = new KPDFLinkAction( KPDFLinkAction::Close );
else
kdDebug() << "Unknown named action: '" << name << "'" << endl;
}

@ -88,7 +88,7 @@ class KPDFLinkAction : public KPDFLink
{
public:
// define types of actions
enum ActionType { PageFirst, PagePrev, PageNext, PageLast, HistoryBack, HistoryForward, Quit, Find, GoToPage };
enum ActionType { PageFirst, PagePrev, PageNext, PageLast, HistoryBack, HistoryForward, Quit, Find, GoToPage, Close };
// query for action type
ActionType actionType() const { return m_type; }

@ -106,6 +106,12 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
connect( m_document, SIGNAL( linkFind() ), this, SLOT( slotFind() ) );
connect( m_document, SIGNAL( linkGoToPage() ), this, SLOT( slotGoToPage() ) );
connect( m_document, SIGNAL( openURL(const KURL &) ), this, SLOT( openURL(const KURL &) ) );
connect( m_document, SIGNAL( close() ), this, SLOT( close() ) );
if (parent && parent->metaObject()->slotNames(true).contains("slotQuit()"))
connect( m_document, SIGNAL( quit() ), parent, SLOT( slotQuit() ) );
else
connect( m_document, SIGNAL( quit() ), this, SLOT( cannotQuit() ) );
// widgets: ^searchbar (toolbar containing label and SearchWidget)
// m_searchToolBar = new KToolBar( parentWidget, "searchBar" );
@ -431,10 +437,12 @@ bool Part::closeURL()
m_printPreview->setEnabled( false );
m_showProperties->setEnabled( false );
m_showPresentation->setEnabled( false );
updateViewActions();
emit setWindowCaption("");
emit enablePrintAction(false);
m_searchStarted = false;
if (!m_file.isEmpty()) m_watcher->removeFile(m_file);
m_document->closeDocument();
updateViewActions();
m_searchWidget->clearText();
return KParts::ReadOnlyPart::closeURL();
}
@ -483,6 +491,15 @@ void Part::slotDoFileDirty()
}
}
void Part::close()
{
if (parent() && strcmp(parent()->name(), "KPDF::Shell") == 0)
{
closeURL();
}
else KMessageBox::information(widget(), i18n("This link points to a close document action that does not work when using the embedded viewer."), QString::null, "warnNoCloseIfNotInKPDF");
}
void Part::updateViewActions()
{
bool opened = m_document->pages() > 0;
@ -521,6 +538,11 @@ void Part::psTransformEnded()
openFile();
}
void Part::cannotQuit()
{
KMessageBox::information(widget(), i18n("This link points to a quit application action that does not work when using the embedded viewer."), QString::null, "warnNoQuitIfNotInKPDF");
}
//BEGIN go to page dialog
class KPDFGotoPageDialog : public KDialogBase
{

@ -78,6 +78,9 @@ public:
uint currentPage();
KURL currentDocument();
signals:
void enablePrintAction(bool enable);
protected:
// reimplemented from KParts::ReadOnlyPart
bool openFile();
@ -103,10 +106,12 @@ protected slots:
void slotShowProperties();
void slotShowLeftPanel();
void slotShowPresentation();
void close();
// can be connected to widget elements
void updateViewActions();
void enableTOC(bool enable);
void psTransformEnded();
void cannotQuit();
public slots:
// connected to Shell action (and browserExtension), not local one

@ -88,6 +88,7 @@ void Shell::init()
}
connect( this, SIGNAL( restoreDocument(const KURL &, int) ),m_part, SLOT( restoreDocument(const KURL &, int)));
connect( this, SIGNAL( saveDocumentRestoreInfo(KConfig*) ), m_part, SLOT( saveDocumentRestoreInfo(KConfig*)));
connect( m_part, SIGNAL( enablePrintAction(bool) ), m_printAction, SLOT( setEnabled(bool)));
readSettings();
if (!KGlobal::config()->hasGroup("MainWindow"))

@ -70,11 +70,12 @@ namespace KPDF
void writeSettings();
void setFullScreen( bool );
public slots:
void slotQuit();
private slots:
void fileOpen();
void slotQuit();
void optionsConfigureToolbars();
void applyNewToolbarConfig();
void slotUpdateFullScreen();

@ -272,7 +272,12 @@ void PageView::notifySetup( const QValueVector< KPDFPage * > & pageSet, bool doc
// so pages are never relayouted
slotRelayoutPages();
else
{
// update the mouse cursor when closing because we may have close through a link and
// want the cursor to come back to the normal cursor
updateCursor( viewportToContents( mapFromGlobal( QCursor::pos() ) ) );
resizeContents( 0, 0 );
}
// OSD to display pages
if ( documentChanged && pageSet.count() > 0 && Settings::showOSD() )

Loading…
Cancel
Save