kscan.cpp
/* This file is part of the KDE libraries
Copyright (C) 2001 Carsten Pfeiffer <pfeiffer@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <qfile.h>
#include <klocale.h>
#include <ktrader.h>
#include "kscan.h"
// static factory method
KScanDialog * KScanDialog::getScanDialog( QWidget *parent, const char *name,
bool modal )
{
KTrader::OfferList offers = KTrader::self()->query("KScan/KScanDialog");
if ( offers.isEmpty() )
return 0L;
KService::Ptr ptr = *(offers.begin());
KLibFactory *factory = KLibLoader::self()->factory( QFile::encodeName(ptr->library()) );
if ( !factory )
return 0;
QStringList args;
args << QString::number( (int)modal );
QObject *res = factory->create( parent, name, "KScanDialog", args );
return dynamic_cast<KScanDialog *>( res );
}
KScanDialog::KScanDialog( int dialogFace, int buttonMask,
QWidget *parent, const char *name, bool modal )
: KDialogBase( dialogFace, i18n("Acquire Image"), buttonMask, Close,
parent, name, modal, true ),
m_currentId( 1 )
{
}
KScanDialog::~KScanDialog()
{
}
bool KScanDialog::setup()
{
return true;
}
// static factory method
KOCRDialog * KOCRDialog::getOCRDialog( QWidget *parent, const char *name,
bool modal )
{
KTrader::OfferList offers = KTrader::self()->query("KScan/KOCRDialog");
if ( offers.isEmpty() )
return 0L;
KService::Ptr ptr = *(offers.begin());
KLibFactory *factory = KLibLoader::self()->factory( QFile::encodeName(ptr->library()) );
if ( !factory )
return 0;
QStringList args;
args << QString::number( (int)modal );
QObject *res = factory->create( parent, name, "KOCRDialog", args );
return dynamic_cast<KOCRDialog *>( res );
}
KOCRDialog::KOCRDialog( int dialogFace, int buttonMask,
QWidget *parent, const char *name, bool modal )
: KDialogBase( dialogFace, i18n("OCR Image"), buttonMask, Close,
parent, name, modal, true ),
m_currentId( 1 )
{
}
KOCRDialog::~KOCRDialog()
{
}
KScanDialogFactory::KScanDialogFactory( QObject *parent, const char *name )
: KLibFactory( parent, name ),
m_instance( 0L )
{
}
KScanDialogFactory::~KScanDialogFactory()
{
delete m_instance;
}
QObject *KScanDialogFactory::createObject( QObject *parent, const char *name,
const char *classname,
const QStringList &args )
{
if ( strcmp( classname, "KScanDialog" ) != 0 )
return 0;
if ( parent && !parent->isWidgetType() )
return 0;
bool modal = false;
if ( args.count() == 1 )
modal = (bool)args[ 0 ].toInt();
return createDialog( static_cast<QWidget *>( parent ), name, modal );
}
KOCRDialogFactory::KOCRDialogFactory( QObject *parent, const char *name )
: KLibFactory( parent, name ),
m_instance( 0L )
{
}
KOCRDialogFactory::~KOCRDialogFactory()
{
delete m_instance;
}
QObject *KOCRDialogFactory::createObject( QObject *parent, const char *name,
const char *classname,
const QStringList &args )
{
if ( strcmp( classname, "KOCRDialog" ) != 0 )
return 0;
if ( parent && !parent->isWidgetType() )
return 0;
bool modal = false;
if ( args.count() == 1 )
modal = (bool)args[ 0 ].toInt();
return createDialog( static_cast<QWidget *>( parent ), name, modal );
}
void KScanDialog::virtual_hook( int id, void* data )
{ KDialogBase::virtual_hook( id, data ); }
void KScanDialogFactory::virtual_hook( int id, void* data )
{ KLibFactory::virtual_hook( id, data ); }
void KOCRDialog::virtual_hook( int id, void* data )
{ KDialogBase::virtual_hook( id, data ); }
void KOCRDialogFactory::virtual_hook( int id, void* data )
{ KLibFactory::virtual_hook( id, data ); }
#include "kscan.moc"
KScanDialog::KScanDialog
KScanDialog(int dialogFace=Tabbed, int buttonMask=Close|Help, QWidget *parent=0L, const char *name=0, bool modal=false)
Constructs the scan dialog.
Definition: kscan.cpp:50
KOCRDialog::getOCRDialog
static KOCRDialog * getOCRDialog(QWidget *parent=0L, const char *name=0, bool modal=false)
Creates the user's preferred OCR dialog and returns it, or 0L if no OCR-support is available...
Definition: kscan.cpp:71
KOCRDialogFactory::createDialog
virtual KOCRDialog * createDialog(QWidget *parent=0, const char *name=0, bool modal=false)=0
Your library should reimplement this method to return your KOCRDialog derived dialog.
KTrader::query
virtual OfferList query(const QString &servicetype, const QString &constraint=QString::null, const QString &preferences=QString::null) const
The main function in the KTrader class.
Definition: ktrader.cpp:106
KScanDialog::getScanDialog
static KScanDialog * getScanDialog(QWidget *parent=0L, const char *name=0, bool modal=false)
Creates the user's preferred scanning dialog and returns it, or 0L if no scan-support is available...
Definition: kscan.cpp:28
KScanDialogFactory::createDialog
virtual KScanDialog * createDialog(QWidget *parent=0, const char *name=0, bool modal=false)=0
Your library should reimplement this method to return your KScanDialog derived dialog.
KOCRDialog
Base class for OCR Dialogs.
Definition: kscan.h:236
KScanDialog
This is a base class for scanning dialogs.
Definition: kscan.h:63
KOCRDialog::KOCRDialog
KOCRDialog(int dialogFace=Tabbed, int buttonMask=Close|Help, QWidget *parent=0L, const char *name=0, bool modal=false)
Constructs the OCR dialog.
Definition: kscan.cpp:93
KScanDialog::setup
virtual bool setup()
Reimplement this if you need to set up some things, before showing the dialog, e.g.
Definition: kscan.cpp:62
KOCRDialogFactory::KOCRDialogFactory
KOCRDialogFactory(QObject *parent=0, const char *name=0)
Creates a new KScanDialogFactory.
Definition: kscan.cpp:143
KTrader::OfferList
QValueList< KService::Ptr > OfferList
A list of services.
Definition: ktrader.h:92
KTrader::self
static KTrader * self()
This is a static pointer to a KTrader instance.
Definition: ktrader.cpp:90
KScanDialog::~KScanDialog
~KScanDialog()
Destructs the scan dialog.
Definition: kscan.cpp:58
KScanDialogFactory::KScanDialogFactory
KScanDialogFactory(QObject *parent=0, const char *name=0)
Creates a new KScanDialogFactory.
Definition: kscan.cpp:110

KDE Home | KDE Accessibility Home | Description of Access Keys