summaryrefslogtreecommitdiff
path: root/noncore/unsupported/qpdf
Side-by-side diff
Diffstat (limited to 'noncore/unsupported/qpdf') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/qpdf/qbusybar.cpp2
-rw-r--r--noncore/unsupported/qpdf/qpdf.cpp30
2 files changed, 16 insertions, 16 deletions
diff --git a/noncore/unsupported/qpdf/qbusybar.cpp b/noncore/unsupported/qpdf/qbusybar.cpp
index ce7ab8e..e942f06 100644
--- a/noncore/unsupported/qpdf/qbusybar.cpp
+++ b/noncore/unsupported/qpdf/qbusybar.cpp
@@ -1,116 +1,116 @@
#include <qapplication.h>
#include <qtimer.h>
#include <qpainter.h>
#include "qbusybar.h"
QBusyBar::QBusyBar ( QWidget *parent, const char *name, int flags ) : QWidget ( parent, name, flags | WRepaintNoErase )
{
m_busy = 0;
m_div = 0;
m_pos = 0;
m_fade = 0;
m_fadecols = 0;
m_speed = 500;
m_timer = new QTimer ( this );
- connect ( m_timer, SIGNAL( timeout ( )), this, SLOT( slotTimeout ( )));
+ connect ( m_timer, SIGNAL( timeout()), this, SLOT( slotTimeout()));
setParameters ( 12, 8, 200 );
}
void QBusyBar::setParameters ( int d, int s, int v )
{
bool running = m_timer-> isActive ( );
if ( running )
m_timer-> stop ( );
m_div = d;
m_speed = v;
delete [] m_fadecols;
m_fade = s;
m_fadecols = new QColor [m_fade];
int rt, gt, bt;
int rf, gf, bf;
colorGroup ( ). color ( QColorGroup::Highlight ). rgb ( &rf, &gf, &bf );
colorGroup ( ). color ( QColorGroup::Background ). rgb ( &rt, &gt, &bt );
for ( int i = 0; i < s; i++ )
m_fadecols [i]. setRgb ( rf + ( rt - rf ) * i / s, gf + ( gt - gf ) * i / s, bf + ( bt - bf ) * i / s );
if ( running ) {
m_pos = 0;
m_timer-> start ( m_speed );
}
}
QBusyBar::~QBusyBar ( )
{
delete [] m_fadecols;
}
bool QBusyBar::isBusy ( ) const
{
return m_busy;
}
void QBusyBar::beginBusy ( )
{
setBusy ( true );
}
void QBusyBar::endBusy ( )
{
setBusy ( false );
}
void QBusyBar::setBusy ( bool b )
{
int busy = m_busy + ( b ? 1 : -1 );
if ( busy < 0 )
busy = 0;
if (( m_busy == 0 ) && ( busy > 0 )) { // Changed state to on
m_pos = 0;
m_timer-> start ( m_speed );
update ( );
}
else if (( m_busy > 0 ) && ( busy == 0 )) { // Changed state to off
m_timer-> stop ( );
update ( );
}
m_busy = busy;
}
void QBusyBar::slotTimeout ( )
{
m_pos++;
m_pos %= ( 2 * ( m_fade + m_div ));
update ( );
}
void QBusyBar::paintEvent ( QPaintEvent *e )
{
QPainter p ( this );
QRect clip = e-> rect ( );
int x = 0;
int dx = width ( ) / m_div;
int y = clip. top ( );
int dy = clip. height ( );
if ( m_busy ) {
int dir = ( m_pos < ( m_fade + m_div )) ? 1 : -1;
int pos = ( dir > 0 ) ? m_pos : ( 2 * ( m_div + m_fade )) - m_pos - m_fade - 1;
diff --git a/noncore/unsupported/qpdf/qpdf.cpp b/noncore/unsupported/qpdf/qpdf.cpp
index 5cdcccf..75e86d0 100644
--- a/noncore/unsupported/qpdf/qpdf.cpp
+++ b/noncore/unsupported/qpdf/qpdf.cpp
@@ -1,242 +1,242 @@
//========================================================================
//
// qpdf.cc
//
// Copyright 2001 Robert Griebl
//
//========================================================================
#include "aconf.h"
#include "GString.h"
#include "PDFDoc.h"
#include "TextOutputDev.h"
#include "QPEOutputDev.h"
#include <qpe/qpeapplication.h>
#include <qpe/resource.h>
#include <qpe/applnk.h>
#include <qpe/qcopenvelope_qws.h>
#include <qclipboard.h>
#include <qpe/qpetoolbar.h>
#include <qtoolbutton.h>
#include <qmenubar.h>
#include <qpopupmenu.h>
#include <qwidgetstack.h>
#include <qtimer.h>
#include <qfileinfo.h>
#include <qstring.h>
#include <qlineedit.h>
#include <qspinbox.h>
#include <qlayout.h>
#include <qdialog.h>
#include <qlabel.h>
#include <qmessagebox.h>
#include "qpdf.h"
#ifdef QPDF_QPE_ONLY
#include <qpe/fileselector.h>
#else
#include <opie/ofileselector.h>
#endif
int main ( int argc, char **argv )
{
QPEApplication app ( argc, argv );
// read config file
globalParams = new GlobalParams ( "" );
globalParams-> setErrQuiet ( true );
QPdfDlg *dlg = new QPdfDlg ( );
app. showMainDocumentWidget ( dlg );
if (( app. argc ( ) == 3 ) && ( app. argv ( ) [1] == QCString ( "-f" )))
dlg-> openFile ( app. argv ( ) [2] );
return app. exec ( );
}
QPdfDlg::QPdfDlg ( ) : QMainWindow ( )
{
setCaption ( tr( "QPdf" ));
setIcon ( Resource::loadPixmap ( "qpdf_icon" ));
m_busy = false;
m_doc = 0;
m_pages = 0;
m_zoom = 72;
m_currentpage = 0;
m_fullscreen = false;
m_renderok = false;
setToolBarsMovable ( false );
m_stack = new QWidgetStack ( this );
m_stack-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding ));
setCentralWidget ( m_stack );
m_outdev = new QPEOutputDev ( m_stack );
- connect ( m_outdev, SIGNAL( selectionChanged ( const QRect & )), this, SLOT( copyToClipboard ( const QRect & )));
+ connect ( m_outdev, SIGNAL( selectionChanged(const QRect&)), this, SLOT( copyToClipboard(const QRect&)));
#ifdef QPDF_QPE_ONLY
m_filesel = new FileSelector ( "application/pdf", m_stack, "fs", false, true );
#else
m_filesel = new OFileSelector ( "application/pdf", m_stack, "fs", false, true );
#endif
- connect ( m_filesel, SIGNAL( closeMe ( )), this, SLOT( closeFileSelector ( )));
- connect ( m_filesel, SIGNAL( fileSelected ( const DocLnk & )), this, SLOT( openFile ( const DocLnk & )));
+ connect ( m_filesel, SIGNAL( closeMe()), this, SLOT( closeFileSelector()));
+ connect ( m_filesel, SIGNAL( fileSelected(const DocLnk&)), this, SLOT( openFile(const DocLnk&)));
m_tb_menu = new QToolBar ( this );
m_tb_menu-> setHorizontalStretchable ( true );
QMenuBar *mb = new QMenuBar ( m_tb_menu );
m_pm_zoom = new QPopupMenu ( mb );
m_pm_zoom-> setCheckable ( true );
mb-> insertItem ( tr( "Zoom" ), m_pm_zoom );
m_pm_zoom-> insertItem ( tr( "Fit to width" ), 1 );
m_pm_zoom-> insertItem ( tr( "Fit to page" ), 2 );
m_pm_zoom-> insertSeparator ( );
m_pm_zoom-> insertItem ( tr( "50%" ), 50 );
m_pm_zoom-> insertItem ( tr( "75%" ), 75 );
m_pm_zoom-> insertItem ( tr( "100%" ), 100 );
m_pm_zoom-> insertItem ( tr( "125%" ), 125 );
m_pm_zoom-> insertItem ( tr( "150%" ), 150 );
m_pm_zoom-> insertItem ( tr( "200%" ), 200 );
- connect ( m_pm_zoom, SIGNAL( activated ( int )), this, SLOT( setZoom ( int )));
+ connect ( m_pm_zoom, SIGNAL( activated(int)), this, SLOT( setZoom(int)));
m_tb_tool = new QToolBar ( this );
- new QToolButton ( Resource::loadIconSet ( "fileopen" ), tr( "Open..." ), QString::null, this, SLOT( openFile ( )), m_tb_tool, "open" );
+ new QToolButton ( Resource::loadIconSet ( "fileopen" ), tr( "Open..." ), QString::null, this, SLOT( openFile()), m_tb_tool, "open" );
m_tb_tool-> addSeparator ( );
- m_to_find = new QToolButton ( Resource::loadIconSet ( "find" ), tr( "Find..." ), QString::null, this, SLOT( toggleFindBar ( )), m_tb_tool, "find" );
+ m_to_find = new QToolButton ( Resource::loadIconSet ( "find" ), tr( "Find..." ), QString::null, this, SLOT( toggleFindBar()), m_tb_tool, "find" );
m_to_find-> setToggleButton ( true );
m_tb_tool-> addSeparator ( );
- m_to_full = new QToolButton ( Resource::loadIconSet ( "fullscreen" ), tr( "Fullscreen" ), QString::null, this, SLOT( toggleFullscreen ( )), m_tb_tool, "fullscreen" );
+ m_to_full = new QToolButton ( Resource::loadIconSet ( "fullscreen" ), tr( "Fullscreen" ), QString::null, this, SLOT( toggleFullscreen()), m_tb_tool, "fullscreen" );
m_to_full-> setToggleButton ( true );
m_tb_tool-> addSeparator ( );
- new QToolButton ( Resource::loadIconSet ( "fastback" ), tr( "First page" ), QString::null, this, SLOT( firstPage ( )), m_tb_tool, "first" );
- new QToolButton ( Resource::loadIconSet ( "back" ), tr( "Previous page" ), QString::null, this, SLOT( prevPage ( )), m_tb_tool, "prev" );
- new QToolButton ( Resource::loadIconSet ( "down" ), tr( "Goto page..." ), QString::null, this, SLOT( gotoPageDialog ( )), m_tb_tool, "goto" );
- new QToolButton ( Resource::loadIconSet ( "forward" ), tr( "Next page" ), QString::null, this, SLOT( nextPage ( )), m_tb_tool, "next" );
- new QToolButton ( Resource::loadIconSet ( "fastforward" ), tr( "Last page" ), QString::null, this, SLOT( lastPage ( )), m_tb_tool, "last" );
+ new QToolButton ( Resource::loadIconSet ( "fastback" ), tr( "First page" ), QString::null, this, SLOT( firstPage()), m_tb_tool, "first" );
+ new QToolButton ( Resource::loadIconSet ( "back" ), tr( "Previous page" ), QString::null, this, SLOT( prevPage()), m_tb_tool, "prev" );
+ new QToolButton ( Resource::loadIconSet ( "down" ), tr( "Goto page..." ), QString::null, this, SLOT( gotoPageDialog()), m_tb_tool, "goto" );
+ new QToolButton ( Resource::loadIconSet ( "forward" ), tr( "Next page" ), QString::null, this, SLOT( nextPage()), m_tb_tool, "next" );
+ new QToolButton ( Resource::loadIconSet ( "fastforward" ), tr( "Last page" ), QString::null, this, SLOT( lastPage()), m_tb_tool, "last" );
m_tb_find = new QToolBar ( this );
addToolBar ( m_tb_find, "Search", QMainWindow::Top, true );
m_tb_find-> setHorizontalStretchable ( true );
m_tb_find-> hide ( );
m_findedit = new QLineEdit ( m_tb_find, "findedit" );
m_tb_find-> setStretchableWidget ( m_findedit );
- connect ( m_findedit, SIGNAL( textChanged ( const QString & )), this, SLOT( findText ( const QString & )));
+ connect ( m_findedit, SIGNAL( textChanged(const QString&)), this, SLOT( findText(const QString&)));
- new QToolButton ( Resource::loadIconSet ( "next" ), tr( "Next" ), QString::null, this, SLOT( findText ( )), m_tb_find, "findnext" );
+ new QToolButton ( Resource::loadIconSet ( "next" ), tr( "Next" ), QString::null, this, SLOT( findText()), m_tb_find, "findnext" );
openFile ( );
}
QPdfDlg::~QPdfDlg ( )
{
delete m_doc;
}
// vv Fullscreen handling (for broken QT-lib) [David Hedbor, www.eongames.com]
void QPdfDlg::resizeEvent ( QResizeEvent * )
{
if ( m_fullscreen && ( size ( ) != qApp-> desktop ( )-> size ( )))
setFullscreen ( true );
}
void QPdfDlg::focusInEvent ( QFocusEvent * )
{
if ( m_fullscreen )
setFullscreen ( true );
}
void QPdfDlg::toggleFullscreen ( )
{
if ( m_to_full-> isOn ( ) == m_fullscreen )
m_to_full-> setOn ( !m_fullscreen );
m_fullscreen = !m_fullscreen;
setFullscreen ( m_fullscreen );
}
void QPdfDlg::setFullscreen ( bool b )
{
static QSize normalsize;
if ( b ) {
if ( !normalsize. isValid ( ))
normalsize = size ( );
setFixedSize ( qApp-> desktop ( )-> size ( ));
showNormal ( );
reparent ( 0, WStyle_Customize | WStyle_NoBorder, QPoint ( 0, 0 ));
showFullScreen ( );
}
else {
showNormal ( );
reparent ( 0, 0, QPoint ( 0, 0 ));
resize ( normalsize );
showMaximized ( );
normalsize = QSize ( );
}
}
// ^^ Fullscreen handling (for broken QT-lib)
void QPdfDlg::setBusy ( bool b )
{
if ( b != m_busy ) {
m_busy = b;
m_outdev-> setBusy ( m_busy );
setEnabled ( !m_busy );
}
}
bool QPdfDlg::busy ( ) const
{
return m_busy;
}
void QPdfDlg::updateCaption ( )
{
QString cap = "";
if ( !m_currentdoc. isEmpty ( ))
cap = QString ( "%1 - " ). arg ( m_currentdoc );
cap += "QPdf";
setCaption ( cap );
}
void QPdfDlg::setZoom ( int id )
{
int dpi = 0;
switch ( id ) {
case 1:
if ( m_doc && m_doc-> isOk ( ))
dpi = m_outdev-> visibleWidth ( ) * 72 / m_doc-> getPageWidth ( m_currentpage );
break;
case 2:
if ( m_doc && m_doc-> isOk ( ))
@@ -402,139 +402,139 @@ void QPdfDlg::copyToClipboard ( const QRect &r )
qApp-> clipboard ( )-> setText ( m_outdev-> getText ( r ));
}
void QPdfDlg::firstPage ( )
{
gotoPage ( 1 );
}
void QPdfDlg::prevPage ( )
{
gotoPage ( m_currentpage - 1 );
}
void QPdfDlg::nextPage ( )
{
gotoPage ( m_currentpage + 1 );
}
void QPdfDlg::lastPage ( )
{
gotoPage ( m_pages );
}
void QPdfDlg::gotoPage ( int n )
{
if ( n < 1 )
n = 1;
if ( n > m_pages )
n = m_pages;
if ( n != m_currentpage ) {
m_currentpage = n;
renderPage ( );
}
}
void QPdfDlg::renderPage ( )
{
if ( m_renderok && m_doc && m_doc-> isOk ( )) {
m_renderok = false;
setBusy ( true );
m_doc-> displayPage ( m_outdev, m_currentpage, m_zoom, 0, true );
setBusy ( false );
m_outdev-> setPageCount ( m_currentpage, m_pages );
m_renderok = true;
}
}
void QPdfDlg::closeFileSelector ( )
{
m_tb_menu-> show ( );
m_tb_tool-> show ( );
m_stack-> raiseWidget ( m_outdev );
}
void QPdfDlg::openFile ( )
{
m_tb_menu-> hide ( );
m_tb_tool-> hide ( );
m_tb_find-> hide ( );
m_stack-> raiseWidget ( m_filesel );
}
void QPdfDlg::openFile ( const QString &f )
{
DocLnk nf;
nf. setType ( "application/pdf" );
nf. setFile ( f );
QFileInfo fi ( f );
nf. setName ( fi. baseName ( ));
openFile ( nf );
}
void QPdfDlg::openFile ( const DocLnk &f )
{
QString fn = f. file ( );
QFileInfo fi ( fn );
if ( fi. exists ( )) {
delete m_doc;
m_doc = new PDFDoc ( new GString ( fn. local8Bit ( )), 0, 0 );
if ( m_doc-> isOk ( )) {
m_currentdoc = f. name ( );
int sep = m_currentdoc. findRev ( '/' );
if ( sep > 0 )
m_currentdoc = m_currentdoc. mid ( sep + 1 );
m_pages = m_doc-> getNumPages ( );
m_currentpage = 0;
- QTimer::singleShot ( 0, this, SLOT( delayedInit ( )));
+ QTimer::singleShot ( 0, this, SLOT( delayedInit()));
}
else {
delete m_doc;
m_doc = 0;
m_currentdoc = QString::null;
}
updateCaption ( );
}
else
QMessageBox::warning ( this, tr( "Error" ), tr( "File does not exist!" ));
}
void QPdfDlg::setDocument ( const QString &f )
{
if ( f. find ( ".desktop", 0, true ) == -1 )
openFile ( f );
else
openFile ( DocLnk ( f ));
closeFileSelector ( );
}
void QPdfDlg::delayedInit ( )
{
closeFileSelector ( );
m_currentpage = 0;
m_zoom = 0;
m_renderok = false;
setZoom ( 100 );
gotoPage ( 1 );
m_renderok = true;
renderPage ( );
m_outdev-> setFocus ( );
}