summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/qprocess.cpp6
-rw-r--r--libopie2/opiecore/device/odevice.cpp6
-rw-r--r--libopie2/opiecore/oconfig.h2
-rw-r--r--libopie2/opiecore/odebug.h6
-rw-r--r--libopie2/opiecore/okeyconfigmanager.cpp2
-rw-r--r--libopie2/opiecore/okeyfilter.h8
-rw-r--r--libopie2/opiecore/opluginloader.cpp5
-rw-r--r--libopie2/opiecore/oprocess.h8
-rw-r--r--libopie2/opieui/oimageeffect.h6
-rw-r--r--libopie2/opieui/opixmapeffect.h11
-rw-r--r--libopie2/qt3/opieui/ocombobox.h4
-rw-r--r--libopie2/qt3/opieui/olineedit.h6
12 files changed, 33 insertions, 37 deletions
diff --git a/core/launcher/qprocess.cpp b/core/launcher/qprocess.cpp
index 3fe1238..aef7967 100644
--- a/core/launcher/qprocess.cpp
+++ b/core/launcher/qprocess.cpp
@@ -1,630 +1,630 @@
/**********************************************************************
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
** This file is part of the Qtopia 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 <stdio.h>
#include <stdlib.h>
#include "qprocess.h"
#ifndef QT_NO_PROCESS
#include "qapplication.h"
//#define QT_QPROCESS_DEBUG
/*!
\class QProcess qprocess.h
\brief The QProcess class is used to start external programs and to
communicate with them.
This is a temporary class. This will be replaced by Qt 3's QProcess class.
\ingroup qtopiaemb
*/
/*!
\enum QProcess::Communication
This enum type defines the communication channels connected to the
process.
\value Stdin Data can be written to the process's standard input.
\value Stdout Data can be read from the process's standard output.
\value Stderr Data can be read from the process's standard error.
\value DupStderr Duplicates standard error to standard output for new
processes; i.e. everything that the process writes to standard error, is
reported by QProcess on standard output instead. This is especially useful if
your application requires that the output on standard output and standard
error is read in the same order as the process output it. Please note that
this is a binary flag, so if you want to activate this together with standard
input, output and error redirection (the default), you have to specify
- \c{Stdin|Stdout|Stderr|DupStderr} for the setCommunication() call.
+ \c {Stdin|Stdout|Stderr|DupStderr} for the setCommunication() call.
\sa setCommunication() communication()
*/
/*!
Constructs a QProcess object. The \a parent and \a name parameters are passed
to the QObject constructor.
\sa setArguments() addArgument() start()
*/
QProcess::QProcess( QObject *parent, const char *name )
: QObject( parent, name ), ioRedirection( FALSE ), notifyOnExit( FALSE ),
wroteToStdinConnected( FALSE ),
readStdoutCalled( FALSE ), readStderrCalled( FALSE ),
comms( Stdin|Stdout|Stderr )
{
init();
}
/*!
Constructs a QProcess with \a arg0 as the command to be executed. The
\a parent and \a name parameters are passed to the QObject constructor.
The process is not started. You must call start() or launch()
to start the process.
\sa setArguments() addArgument() start()
*/
QProcess::QProcess( const QString& arg0, QObject *parent, const char *name )
: QObject( parent, name ), ioRedirection( FALSE ), notifyOnExit( FALSE ),
wroteToStdinConnected( FALSE ),
readStdoutCalled( FALSE ), readStderrCalled( FALSE ),
comms( Stdin|Stdout|Stderr )
{
init();
addArgument( arg0 );
}
/*!
Constructs a QProcess with \a args as the arguments of the process. The first
element in the list is the command to be executed. The other elements in the
list are the arguments to this command. The \a parent and \a name
parameters are passed to the QObject constructor.
The process is not started. You must call start() or launch()
to start the process.
\sa setArguments() addArgument() start()
*/
QProcess::QProcess( const QStringList& args, QObject *parent, const char *name )
: QObject( parent, name ), ioRedirection( FALSE ), notifyOnExit( FALSE ),
wroteToStdinConnected( FALSE ),
readStdoutCalled( FALSE ), readStderrCalled( FALSE ),
comms( Stdin|Stdout|Stderr )
{
init();
setArguments( args );
}
/*!
Returns the list of arguments that are set for the process. Arguments can be
specified with the constructor or with the functions setArguments() and
addArgument().
\sa setArguments() addArgument()
*/
QStringList QProcess::arguments() const
{
return _arguments;
}
/*!
Clears the list of arguments that are set for the process.
\sa setArguments() addArgument()
*/
void QProcess::clearArguments()
{
_arguments.clear();
}
/*!
Sets \a args as the arguments for the process. The first element in the list
is the command to be executed. The other elements in the list are the
arguments to the command. Any previous arguments are deleted.
\sa arguments() addArgument()
*/
void QProcess::setArguments( const QStringList& args )
{
_arguments = args;
}
/*!
Adds \a arg to the end of the list of arguments.
The first element in the list of arguments is the command to be
executed; the following elements are the arguments to the command.
\sa arguments() setArguments()
*/
void QProcess::addArgument( const QString& arg )
{
_arguments.append( arg );
}
#ifndef QT_NO_DIR
/*!
Returns the working directory that was set with
setWorkingDirectory(), or the current directory if none has been
set.
\sa setWorkingDirectory() QDir::current()
*/
QDir QProcess::workingDirectory() const
{
return workingDir;
}
/*!
Sets \a dir as the working directory for a process. This does not affect
running processes; only processes that are started afterwards are affected.
Setting the working directory is especially useful for processes that try to
access files with relative filenames.
\sa workingDirectory() start()
*/
void QProcess::setWorkingDirectory( const QDir& dir )
{
workingDir = dir;
}
#endif //QT_NO_DIR
/*!
Returns the communication required with the process.
\sa setCommunication()
*/
int QProcess::communication() const
{
return comms;
}
/*!
Sets \a commFlags as the communication required with the process.
\a commFlags is a bitwise OR between the flags defined in \c Communication.
- The default is \c{Stdin|Stdout|Stderr}.
+ The default is \c {Stdin|Stdout|Stderr}.
\sa communication()
*/
void QProcess::setCommunication( int commFlags )
{
comms = commFlags;
}
/*!
Returns TRUE if the process has exited normally; otherwise returns
FALSE. This implies that this function returns FALSE if the process
is still running.
\sa isRunning() exitStatus() processExited()
*/
bool QProcess::normalExit() const
{
// isRunning() has the side effect that it determines the exit status!
if ( isRunning() )
return FALSE;
else
return exitNormal;
}
/*!
Returns the exit status of the process or 0 if the process is still
running. This function returns immediately and does not wait until
the process is finished.
If normalExit() is FALSE (e.g. if the program was killed or
crashed), this function returns 0, so you should check the return
value of normalExit() before relying on this value.
\sa normalExit() processExited()
*/
int QProcess::exitStatus() const
{
// isRunning() has the side effect that it determines the exit status!
if ( isRunning() )
return 0;
else
return exitStat;
}
/*!
Reads the data that the process has written to standard output. When
new data is written to standard output, the class emits the signal
readyReadStdout().
If there is no data to read, this function returns a QByteArray of
size 0: it does not wait until there is something to read.
\sa readyReadStdout() readLineStdout() readStderr() writeToStdin()
*/
QByteArray QProcess::readStdout()
{
if ( readStdoutCalled ) {
return QByteArray();
}
readStdoutCalled = TRUE;
QByteArray buf = bufStdout()->copy();
consumeBufStdout( -1 ); // consume everything
readStdoutCalled = FALSE;
return buf;
}
/*!
Reads the data that the process has written to standard error. When
new data is written to standard error, the class emits the signal
readyReadStderr().
If there is no data to read, this function returns a QByteArray of
size 0: it does not wait until there is something to read.
\sa readyReadStderr() readLineStderr() readStdout() writeToStdin()
*/
QByteArray QProcess::readStderr()
{
if ( readStderrCalled ) {
return QByteArray();
}
readStderrCalled = TRUE;
QByteArray buf = bufStderr()->copy();
consumeBufStderr( -1 ); // consume everything
readStderrCalled = FALSE;
return buf;
}
/*!
Returns TRUE if it's possible to read an entire line of text from
standard output at this time; otherwise returns FALSE.
\sa readLineStdout() canReadLineStderr()
*/
bool QProcess::canReadLineStdout() const
{
QProcess *that = (QProcess*)this;
return that->scanNewline( TRUE, 0 );
}
/*!
Returns TRUE if it's possible to read an entire line of text from
standard error at this time; otherwise returns FALSE.
\sa readLineStderr() canReadLineStdout()
*/
bool QProcess::canReadLineStderr() const
{
QProcess *that = (QProcess*)this;
return that->scanNewline( FALSE, 0 );
}
/*!
Reads a line of text from standard output, excluding any trailing newline or
carriage return characters, and returns it. Returns QString::null if
canReadLineStdout() returns FALSE.
\sa canReadLineStdout() readyReadStdout() readStdout() readLineStderr()
*/
QString QProcess::readLineStdout()
{
QByteArray a;
QString s;
if ( scanNewline( TRUE, &a ) ) {
if ( a.isEmpty() )
s = "";
else
s = QString( a );
}
return s;
}
/*!
Reads a line of text from standard error, excluding any trailing newline or
carriage return characters and returns it. Returns QString::null if
canReadLineStderr() returns FALSE.
\sa canReadLineStderr() readyReadStderr() readStderr() readLineStdout()
*/
QString QProcess::readLineStderr()
{
QByteArray a;
QString s;
if ( scanNewline( FALSE, &a ) ) {
if ( a.isEmpty() )
s = "";
else
s = QString( a );
}
return s;
}
/*!
- This private function scans for any occurrence of \n or \r\n in the
+ This private function scans for any occurrence of \\n or \\r\\n in the
buffer \e buf. It stores the text in the byte array \a store if it is
non-null.
*/
bool QProcess::scanNewline( bool stdOut, QByteArray *store )
{
QByteArray *buf;
if ( stdOut )
buf = bufStdout();
else
buf = bufStderr();
uint n = buf->size();
uint i;
for ( i=0; i<n; i++ ) {
if ( buf->at(i) == '\n' ) {
break;
}
}
if ( i >= n )
return FALSE;
if ( store ) {
uint lineLength = i;
if ( lineLength>0 && buf->at(lineLength-1) == '\r' )
lineLength--; // (if there are two \r, let one stay)
store->resize( lineLength );
memcpy( store->data(), buf->data(), lineLength );
if ( stdOut )
consumeBufStdout( i+1 );
else
consumeBufStderr( i+1 );
}
return TRUE;
}
/*!
\fn void QProcess::launchFinished()
This signal is emitted when the process was started with launch().
If the start was successful, this signal is emitted after all the
data has been written to standard input. If the start failed, then
this signal is emitted immediately.
\sa launch() QObject::deleteLater()
*/
/*!
Runs the process and writes the data \a buf to the process's standard input.
If all the data is written to standard input, standard input is
closed. The command is searched for in the path for executable programs;
you can also use an absolute path in the command itself.
If \a env is null, then the process is started with the same environment as
the starting process. If \a env is non-null, then the values in the
stringlist are interpreted as environment setttings of the form \c
{key=value} and the process is started with these environment settings. For
convenience, there is a small exception to this rule under Unix: if \a env
does not contain any settings for the environment variable \c
LD_LIBRARY_PATH, then this variable is inherited from the starting process.
Returns TRUE if the process could be started; otherwise returns FALSE.
Note that you should not use the slots writeToStdin() and closeStdin() on
processes started with launch(), since the result is not well-defined. If you
need these slots, use start() instead.
The process may or may not read the \a buf data sent to its standard
input.
You can call this function even when a process that was started with
this instance is still running. Be aware that if you do this the
standard input of the process that was launched first will be
closed, with any pending data being deleted, and the process will be
left to run out of your control. Similarly, if the process could not
be started the standard input will be closed and the pending data
deleted. (On operating systems that have zombie processes, Qt will
also wait() on the old process.)
The object emits the signal launchFinished() when this function
call is finished. If the start was successful, this signal is
emitted after all the data has been written to standard input. If
the start failed, then this signal is emitted immediately.
\sa start() launchFinished();
*/
bool QProcess::launch( const QByteArray& buf, QStringList *env )
{
if ( start( env ) ) {
if ( !buf.isEmpty() ) {
connect( this, SIGNAL(wroteToStdin()),
this, SLOT(closeStdinLaunch()) );
writeToStdin( buf );
} else {
closeStdin();
emit launchFinished();
}
return TRUE;
} else {
emit launchFinished();
return FALSE;
}
}
/*! \overload
The data \a buf is written to standard input with writeToStdin()
using the QString::local8Bit() representation of the strings.
*/
bool QProcess::launch( const QString& buf, QStringList *env )
{
if ( start( env ) ) {
if ( !buf.isEmpty() ) {
connect( this, SIGNAL(wroteToStdin()),
this, SLOT(closeStdinLaunch()) );
writeToStdin( buf );
} else {
closeStdin();
emit launchFinished();
}
return TRUE;
} else {
emit launchFinished();
return FALSE;
}
}
/*!
This private slot is used by the launch() functions to close standard input.
*/
void QProcess::closeStdinLaunch()
{
disconnect( this, SIGNAL(wroteToStdin()),
this, SLOT(closeStdinLaunch()) );
closeStdin();
emit launchFinished();
}
/*!
\fn void QProcess::readyReadStdout()
This signal is emitted when the process has written data to standard output.
You can read the data with readStdout().
Note that this signal is only emitted when there is new data and not
when there is old, but unread data. In the slot connected to this signal, you
should always read everything that is available at that moment to make sure
that you don't lose any data.
\sa readStdout() readLineStdout() readyReadStderr()
*/
/*!
\fn void QProcess::readyReadStderr()
This signal is emitted when the process has written data to standard error.
You can read the data with readStderr().
Note that this signal is only emitted when there is new data and not
when there is old, but unread data. In the slot connected to this signal, you
should always read everything that is available at that moment to make sure
that you don't lose any data.
\sa readStderr() readLineStderr() readyReadStdout()
*/
/*!
\fn void QProcess::processExited()
This signal is emitted when the process has exited.
\sa isRunning() normalExit() exitStatus() start() launch()
*/
/*!
\fn void QProcess::wroteToStdin()
This signal is emitted if the data sent to standard input (via
writeToStdin()) was actually written to the process. This does not
imply that the process really read the data, since this class only detects
when it was able to write the data to the operating system. But it is now
safe to close standard input without losing pending data.
\sa writeToStdin() closeStdin()
*/
/*! \overload
The string \a buf is handled as text using
the QString::local8Bit() representation.
*/
void QProcess::writeToStdin( const QString& buf )
{
QByteArray tmp = buf.local8Bit();
tmp.resize( buf.length() );
writeToStdin( tmp );
}
/*
* Under Windows the implementation is not so nice: it is not that easy to
* detect when one of the signals should be emitted; therefore there are some
* timers that query the information.
* To keep it a little efficient, use the timers only when they are needed.
* They are needed, if you are interested in the signals. So use
* connectNotify() and disconnectNotify() to keep track of your interest.
*/
/*! \reimp
*/
void QProcess::connectNotify( const char * signal )
{
#if defined(QT_QPROCESS_DEBUG)
odebug << "QProcess::connectNotify(): signal " << signal << " has been connected" << oendl;
#endif
if ( !ioRedirection )
if ( qstrcmp( signal, SIGNAL(readyReadStdout()) )==0 ||
qstrcmp( signal, SIGNAL(readyReadStderr()) )==0
) {
#if defined(QT_QPROCESS_DEBUG)
odebug << "QProcess::connectNotify(): set ioRedirection to TRUE" << oendl;
#endif
setIoRedirection( TRUE );
return;
}
if ( !notifyOnExit && qstrcmp( signal, SIGNAL(processExited()) )==0 ) {
#if defined(QT_QPROCESS_DEBUG)
odebug << "QProcess::connectNotify(): set notifyOnExit to TRUE" << oendl;
#endif
setNotifyOnExit( TRUE );
return;
}
if ( !wroteToStdinConnected && qstrcmp( signal, SIGNAL(wroteToStdin()) )==0 ) {
#if defined(QT_QPROCESS_DEBUG)
odebug << "QProcess::connectNotify(): set wroteToStdinConnected to TRUE" << oendl;
#endif
setWroteStdinConnected( TRUE );
return;
}
}
/*! \reimp
*/
void QProcess::disconnectNotify( const char * )
{
if ( ioRedirection &&
receivers( SIGNAL(readyReadStdout()) ) ==0 &&
receivers( SIGNAL(readyReadStderr()) ) ==0
) {
#if defined(QT_QPROCESS_DEBUG)
odebug << "QProcess::disconnectNotify(): set ioRedirection to FALSE" << oendl;
#endif
setIoRedirection( FALSE );
}
if ( notifyOnExit && receivers( SIGNAL(processExited()) ) == 0 ) {
#if defined(QT_QPROCESS_DEBUG)
odebug << "QProcess::disconnectNotify(): set notifyOnExit to FALSE" << oendl;
#endif
setNotifyOnExit( FALSE );
}
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index b5ae4e5..8b64c41 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -81,518 +81,518 @@ static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo";
}
/* EXPORT */ QCString makeChannel ( const char *str ){
if ( str && !::strchr ( str, '/' ))
return QCString ( "QPE/Application/" ) + str;
else
return str;
}
/* Now the default implementation of ODevice */
struct default_button default_buttons [] = {
{ Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
"devicebuttons/z_calendar",
"datebook", "nextView()",
"today", "raise()" },
{ Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
"devicebuttons/z_contact",
"addressbook", "raise()",
"addressbook", "beamBusinessCard()" },
{ Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
"devicebuttons/z_home",
"QPE/Launcher", "home()",
"buttonsettings", "raise()" },
{ Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
"devicebuttons/z_menu",
"QPE/TaskBar", "toggleMenu()",
"QPE/TaskBar", "toggleStartMenu()" },
{ Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
"devicebuttons/z_mail",
"opiemail", "raise()",
"opiemail", "newMail()" },
};
ODevice *ODevice::inst()
{
static ODevice *dev = 0;
// rewrite this to only use /proc/cpuinfo or so
QString cpu_info;
if ( !dev )
{
QFile f( PATH_PROC_CPUINFO );
if ( f.open( IO_ReadOnly ) )
{
QTextStream s( &f );
while ( !s.atEnd() )
{
QString line;
line = s.readLine();
if ( line.startsWith( "Hardware" ) )
{
qDebug( "ODevice() - found '%s'", (const char*) line );
cpu_info = line;
if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus();
else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ();
else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad();
else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada();
else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses();
else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle();
else qWarning( "ODevice() - unknown hardware - using default." );
break;
}
}
}
else
{
qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO );
}
if ( !dev ) dev = new ODevice();
dev->init(cpu_info);
}
return dev;
}
ODevice::ODevice()
{
d = new ODeviceData;
d->m_modelstr = "Unknown";
d->m_model = Model_Unknown;
d->m_vendorstr = "Unknown";
d->m_vendor = Vendor_Unknown;
d->m_systemstr = "Unknown";
d->m_system = System_Unknown;
d->m_sysverstr = "0.0";
d->m_rotation = Rot0;
d->m_direction = CW;
d->m_holdtime = 1000; // 1000ms
d->m_buttons = 0;
d->m_cpu_frequencies = new QStrList;
/* mixer */
d->m_sound = d->m_vol = d->m_mixer = -1;
// New distribution detection code first checks for legacy distributions,
// identified by /etc/familiar-version or /etc/oz_version.
// Then check for OpenEmbedded and lastly, read /etc/issue
for ( unsigned int i = 0; i < sizeof distributions; ++i )
{
if ( QFile::exists( distributions[i].sysvfile ) )
{
d->m_systemstr = distributions[i].sysstr;
d->m_system = distributions[i].system;
d->m_sysverstr = "<Unknown>";
QFile f( distributions[i].sysvfile );
if ( f.open( IO_ReadOnly ) )
{
QTextStream ts( &f );
d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" );
}
break;
}
}
}
void ODevice::systemMessage( const QCString &msg, const QByteArray & )
{
if ( msg == "deviceButtonMappingChanged()" ) {
reloadButtonMapping();
}
}
void ODevice::init(const QString&)
{
}
/**
* This method initialises the button mapping
*/
void ODevice::initButtons()
{
if ( d->m_buttons )
return;
qDebug ( "init Buttons" );
d->m_buttons = new QValueList <ODeviceButton>;
for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) {
default_button *db = default_buttons + i;
ODeviceButton b;
b. setKeycode ( db->code );
b. setUserText ( QObject::tr ( "Button", db->utext ));
b. setPixmap ( Resource::loadPixmap ( db->pix ));
b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction ));
b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction ));
d->m_buttons->append ( b );
}
reloadButtonMapping();
QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
}
ODevice::~ODevice()
{
// we leak m_devicebuttons and m_cpu_frequency
// but it's a singleton and it is not so importantant
// -zecke
delete d;
}
bool ODevice::setSoftSuspend ( bool /*soft*/ )
{
return false;
}
//#include <linux/apm_bios.h>
#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
/**
* This method will try to suspend the device
* It only works if the user is the QWS Server and the apm application
* is installed.
* It tries to suspend and then waits some time cause some distributions
* do have asynchronus apm implementations.
* This method will either fail and return false or it'll suspend the
* device and return once the device got woken up
*
* @return if the device got suspended
*/
bool ODevice::suspend()
{
if ( !isQWS( ) ) // only qwsserver is allowed to suspend
return false;
if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
return false;
bool res = false;
ODevice::sendSuspendmsg();
struct timeval tvs, tvn;
::gettimeofday ( &tvs, 0 );
::sync(); // flush fs caches
res = ( ::system ( "apm --suspend" ) == 0 );
// This is needed because the iPAQ apm implementation is asynchronous and we
// can not be sure when exactly the device is really suspended
// This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
if ( res ) {
do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
::usleep ( 200 * 1000 );
::gettimeofday ( &tvn, 0 );
} while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
}
return res;
}
//#include <linux/fb.h> better not rely on kernel headers in userspace ...
#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
/* VESA Blanking Levels */
#define VESA_NO_BLANKING 0
#define VESA_VSYNC_SUSPEND 1
#define VESA_HSYNC_SUSPEND 2
#define VESA_POWERDOWN 3
/**
* This sets the display on or off
*/
bool ODevice::setDisplayStatus ( bool on )
{
qDebug("ODevice::setDisplayStatus(%d)", on);
if ( d->m_model == Model_Unknown )
return false;
bool res = false;
int fd;
#ifdef QT_QWS_DEVFS
if (( fd = ::open ( "/dev/fb/0", O_RDWR )) >= 0 ) {
#else
if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
#endif
res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
::close ( fd );
}
return res;
}
/**
* This sets the display brightness
*
-* @param p The brightness to be set on a scale from 0 to 255
+* @param b The brightness to be set on a scale from 0 to 255
* @return success or failure
*/
-bool ODevice::setDisplayBrightness ( int p)
+bool ODevice::setDisplayBrightness ( int b)
{
- Q_UNUSED( p )
+ Q_UNUSED( b )
return false;
}
/**
*
* @return Returns the number of steppings on the brightness slider
* in the Light-'n-Power settings. Values smaller zero and bigger
* than 255 do not make sense.
*
* \sa QSlider::setLineStep
* \sa QSlider::setPageStep
*/
int ODevice::displayBrightnessResolution() const
{
return 16;
}
/**
* This sets the display contrast
* @param p The contrast to be set on a scale from 0 to 255
* @return success or failure
*/
bool ODevice::setDisplayContrast ( int p)
{
Q_UNUSED( p )
return false;
}
/**
* @return return the max value for the brightness settings slider
* or 0 if the device doesn't support setting of a contrast
*/
int ODevice::displayContrastResolution() const
{
return 0;
}
/**
* This returns the vendor as string
* @return Vendor as QString
*/
QString ODevice::vendorString() const
{
return d->m_vendorstr;
}
/**
* This returns the vendor as one of the values of OVendor
* @return OVendor
*/
OVendor ODevice::vendor() const
{
return d->m_vendor;
}
/**
* This returns the model as a string
* @return A string representing the model
*/
QString ODevice::modelString() const
{
return d->m_modelstr;
}
/**
* This does return the OModel used
*/
OModel ODevice::model() const
{
return d->m_model;
}
/**
* This does return the systen name
*/
QString ODevice::systemString() const
{
return d->m_systemstr;
}
/**
* Return System as OSystem value
*/
OSystem ODevice::system() const
{
return d->m_system;
}
/**
* @return the version string of the base system
*/
QString ODevice::systemVersionString() const
{
return d->m_sysverstr;
}
/**
* @return the current Transformation
*/
Transformation ODevice::rotation() const
{
return d->m_rotation;
}
/**
* @return the current rotation direction
*/
ODirection ODevice::direction() const
{
return d->m_direction;
}
/**
* This plays an alarm sound
*/
void ODevice::playAlarmSound()
{
#ifndef QT_NO_SOUND
static Sound snd ( "alarm" );
if ( snd. isFinished())
snd. play();
#endif
}
/**
* This plays a key sound
*/
void ODevice::playKeySound()
{
#ifndef QT_NO_SOUND
static Sound snd ( "keysound" );
if ( snd. isFinished())
snd. play();
#endif
}
/**
* This plays a touch sound
*/
void ODevice::playTouchSound()
{
#ifndef QT_NO_SOUND
static Sound snd ( "touchsound" );
if ( snd. isFinished())
snd. play();
#endif
}
/**
* This method will return a list of leds
* available on this device
* @return a list of LEDs.
*/
QValueList <OLed> ODevice::ledList() const
{
return QValueList <OLed>();
}
/**
* This does return the state of the LEDs
*/
QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
{
return QValueList <OLedState>();
}
/**
* @return the state for a given OLed
*/
OLedState ODevice::ledState ( OLed /*which*/ ) const
{
return Led_Off;
}
/**
* Set the state for a LED
* @param which Which OLed to use
* @param st The state to set
* @return success or failure
*/
bool ODevice::setLedState ( OLed which, OLedState st )
{
Q_UNUSED( which )
Q_UNUSED( st )
return false;
}
/**
* @return if the device has a light sensor
*/
bool ODevice::hasLightSensor() const
{
return false;
}
/**
* @return a value from the light sensor
*/
int ODevice::readLightSensor()
{
return -1;
}
/**
* @return the light sensor resolution
*/
int ODevice::lightSensorResolution() const
{
return 0;
}
/**
* @return if the device has a hinge sensor
*/
bool ODevice::hasHingeSensor() const
{
return false;
}
/**
* @return a value from the hinge sensor
*/
OHingeStatus ODevice::readHingeSensor()
{
return CASE_UNKNOWN;
}
/**
* @return a list with CPU frequencies supported by the hardware
*/
const QStrList &ODevice::allowedCpuFrequencies() const
{
return *d->m_cpu_frequencies;
}
/**
* Set desired CPU frequency
*
* @param index index into d->m_cpu_frequencies of the frequency to be set
*/
bool ODevice::setCurrentCpuFrequency(uint index)
{
if (index >= d->m_cpu_frequencies->count())
return false;
char *freq = d->m_cpu_frequencies->at(index);
qWarning("set freq to %s", freq);
int fd;
if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) {
char writeCommand[50];
diff --git a/libopie2/opiecore/oconfig.h b/libopie2/opiecore/oconfig.h
index ab95dc3..05a1a25 100644
--- a/libopie2/opiecore/oconfig.h
+++ b/libopie2/opiecore/oconfig.h
@@ -1,163 +1,163 @@
/*
                This file is part of the Opie Project
(C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
Inspired by the config classes from the KDE Project which are
=. (C) 1997 Matthias Kalle Dalheimer <kalle@kde.org>
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program 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., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OCONFIG_H
#define OCONFIG_H
//FIXME: Implement for X11 or reuse libqpe/Config there also?
//FIXME: Or rather use QSettings also for libqpe?
#include <qpe/config.h>
class QColor;
class QFont;
namespace Opie {
namespace Core {
/**
* A Configuration class based on the Qtopia @ref Config class
* featuring additional handling of color and font entries
*/
class OConfig : public Config
{
public:
/**
* Constructs a OConfig object with a @a name.
*/
OConfig( const QString &name, Domain domain = User );
/**
* Destructs the OConfig object.
*
* Writes back any dirty configuration entries, and destroys
* dynamically created objects.
*/
virtual ~OConfig();
/**
* @returns the name of the current group.
* The current group is used for searching keys and accessing entries.
* @todo make const
*/
const QString& group()const { return git.key(); };
/**
* @returns a @ref QColor entry or a @a default value if the key is not found.
*/
QColor readColorEntry( const QString& key, const QColor* pDefault ) const;
/**
* @returns a @ref QFont value or a @a default value if the key is not found.
*/
QFont readFontEntry( const QString& key, const QFont* pDefault ) const;
private:
class Private;
Private *d;
};
/**
* @brief Helper class for easier use of OConfig groups.
*
* Careful programmers always set the group of a
* @ref OConfig object to the group they want to read from
* and set it back to the old one of afterwards. This is usually
* written as:
* <pre>
*
* QString oldgroup config()->group();
* config()->setGroup( "TheGroupThatIWant" );
* ...
* config()->writeEntry( "Blah", "Blubb" );
*
* config()->setGroup( oldgroup );
* </pre>
*
* In order to facilitate this task, you can use
* OConfigGroupSaver. Simply construct such an object ON THE STACK
* when you want to switch to a new group. Then, when the object goes
* out of scope, the group will automatically be restored. If you
* want to use several different groups within a function or method,
* you can still use OConfigGroupSaver: Simply enclose all work with
* one group (including the creation of the OConfigGroupSaver object)
* in one block.
*
* \code
* OConfigGroupSaver saver(cfg,"TheGroupThatInWhat");
* \endcode
*
* Note that OConfigGroupSaver (cfg,"TheGroupThatInWhat"); would get imediately
* destructed after created and that you would save in the old group which
* is unwished.
*
* @author Matthias Kalle Dalheimer <Kalle@kde.org>
* @version $Id$
* @see OConfig
*/
class OConfigGroupSaver
{
public:
/**
* Constructor.
- * Create the object giving a @config object and a @a group to become
+ * Create the object giving a OConfig object and a @a group to become
* the current group.
*/
OConfigGroupSaver( OConfig* config, QString group ) :_config(config), _oldgroup(config->group() )
{ _config->setGroup( group ); }
OConfigGroupSaver( OConfig* config, const char *group ) :_config(config), _oldgroup(config->group())
{ _config->setGroup( group ); }
OConfigGroupSaver( OConfig* config, const QCString &group ) : _config(config), _oldgroup(config->group())
{ _config->setGroup( group ); }
/**
* Destructor.
* Restores the last current group.
* @todo make it not inline for bc reasons. See KDE BC guide
*/
~OConfigGroupSaver() { _config->setGroup( _oldgroup ); }
OConfig* config() { return _config; };
private:
OConfig* _config;
QString _oldgroup;
OConfigGroupSaver( const OConfigGroupSaver& );
OConfigGroupSaver& operator=( const OConfigGroupSaver& );
class Private;
Private *d;
};
}
}
#endif // OCONFIG_H
diff --git a/libopie2/opiecore/odebug.h b/libopie2/opiecore/odebug.h
index 21a6c26..18dc09e 100644
--- a/libopie2/opiecore/odebug.h
+++ b/libopie2/opiecore/odebug.h
@@ -163,329 +163,329 @@ class odbgstream
* Flushes the output.
*/
virtual void flush();
/**
* Prints the given value.
* @param string the string to print
* @return this stream
*/
odbgstream &operator<<(const QString& string);
/**
* Prints the given value.
* @param string the string to print
* @return this stream
*/
odbgstream &operator<<(const char *string);
/**
* Prints the given value.
* @param string the string to print
* @return this stream
*/
odbgstream &operator<<(const QCString& string);
/**
* Prints the given value.
* @param p a pointer to print (in number form)
* @return this stream
*/
odbgstream& operator<<(const void * p);
/**
* Prints the given value.
* @param d the double to print
* @return this stream
*/
odbgstream& operator<<(double d);
/**
* Prints the string @p format which can contain
* printf-style formatted values.
* @param format the printf-style format
* @return this stream
*/
odbgstream &form(const char *format, ...);
/** Operator to print out basic information about a QWidget.
* Output of class names only works if the class is moc'ified.
* @param widget the widget to print
* @return this stream
*/
odbgstream& operator<< (QWidget* widget);
/**
* Prints the given value.
* @param dateTime the datetime to print
* @return this stream
*/
odbgstream& operator<< ( const QDateTime& dateTime );
/**
* Prints the given value.
* @param date the date to print
* @return this stream
*/
odbgstream& operator<< ( const QDate& date );
/**
* Prints the given value.
* @param time the time to print
* @return this stream
*/
odbgstream& operator<< ( const QTime& time );
/**
* Prints the given value.
* @param point the point to print
* @return this stream
*/
odbgstream& operator<< ( const QPoint& point );
/**
* Prints the given value.
* @param size the QSize to print
* @return this stream
*/
odbgstream& operator<< ( const QSize& size );
/**
* Prints the given value.
* @param rect the QRect to print
* @return this stream
*/
odbgstream& operator<< ( const QRect& rect);
/**
* Prints the given value.
* @param region the QRegion to print
* @return this stream
*/
odbgstream& operator<< ( const QRegion& region);
/**
* Prints the given value.
* @param list the stringlist to print
* @return this stream
*/
odbgstream& operator<< ( const QStringList& list);
/**
* Prints the given value.
* @param color the color to print
* @return this stream
*/
odbgstream& operator<< ( const QColor& color);
/**
* Prints the given value.
* @param brush the brush to print
* @return this stream
*/
odbgstream& operator<< ( const QBrush& brush );
private:
QString output;
unsigned int area, level;
bool print;
odbgstreamprivate* d;
};
/**
* Prints an "\n".
* @param s the debug stream to write to
* @return the debug stream (@p s)
*/
inline odbgstream& endl( odbgstream &s) { s << "\n"; return s; }
/**
* Flushes the stream.
* @param s the debug stream to write to
* @return the debug stream (@p s)
*/
inline odbgstream& flush( odbgstream &s) { s.flush(); return s; }
odbgstream &perror( odbgstream &s);
/**
* ondbgstream is a dummy variant of @ref odbgstream. All functions do
* nothing.
* @see ondDebug()
*/
class ondbgstream {
public:
/// Empty constructor.
ondbgstream() {}
~ondbgstream() {}
/**
* Does nothing.
* @return this stream
*/
ondbgstream &operator<<(short int ) { return *this; }
/**
* Does nothing.
* @return this stream
*/
ondbgstream &operator<<(unsigned short int ) { return *this; }
/**
* Does nothing.
* @return this stream
*/
ondbgstream &operator<<(char ) { return *this; }
/**
* Does nothing.
* @return this stream
*/
ondbgstream &operator<<(unsigned char ) { return *this; }
/**
* Does nothing.
* @return this stream
*/
ondbgstream &operator<<(int ) { return *this; }
/**
* Does nothing.
* @return this stream
*/
ondbgstream &operator<<(unsigned int ) { return *this; }
/**
* Does nothing.
*/
void flush() {}
/**
* Does nothing.
* @return this stream
*/
ondbgstream &operator<<(const QString& ) { return *this; }
/**
* Does nothing.
* @return this stream
*/
ondbgstream &operator<<(const QCString& ) { return *this; }
/**
* Does nothing.
* @return this stream
*/
ondbgstream &operator<<(const char *) { return *this; }
/**
* Does nothing.
* @return this stream
*/
ondbgstream& operator<<(const void *) { return *this; }
/**
* Does nothing.
* @return this stream
*/
ondbgstream& operator<<(void *) { return *this; }
/**
* Does nothing.
* @return this stream
*/
ondbgstream& operator<<(double) { return *this; }
/**
* Does nothing.
* @return this stream
*/
ondbgstream& operator<<(long) { return *this; }
/**
* Does nothing.
* @return this stream
*/
ondbgstream& operator<<(unsigned long) { return *this; }
/**
* Does nothing.
* @return this stream
*/
ondbgstream& operator << (QWidget*) { return *this; }
/**
* Does nothing.
* @return this stream
*/
ondbgstream &form(const char *, ...) { return *this; }
ondbgstream& operator<<( const QDateTime& ) { return *this; }
ondbgstream& operator<<( const QDate& ) { return *this; }
ondbgstream& operator<<( const QTime& ) { return *this; }
ondbgstream& operator<<( const QPoint & ) { return *this; }
ondbgstream& operator<<( const QSize & ) { return *this; }
ondbgstream& operator<<( const QRect & ) { return *this; }
ondbgstream& operator<<( const QRegion & ) { return *this; }
ondbgstream& operator<<( const QStringList & ) { return *this; }
ondbgstream& operator<<( const QColor & ) { return *this; }
ondbgstream& operator<<( const QBrush & ) { return *this; }
private:
class Private;
Private *d;
};
/*======================================================================================
* related functions
*======================================================================================*/
/**
* Does nothing.
- * @param a stream
+ * @param s stream
* @return the given @p s
*/
inline ondbgstream& endl( ondbgstream & s) { return s; }
/**
* Does nothing.
- * @param a stream
+ * @param s stream
* @return the given @p s
*/
inline ondbgstream& flush( ondbgstream & s) { return s; }
inline ondbgstream& perror( ondbgstream & s) { return s; }
/**
* Returns a debug stream. You can use it to print debug
* information.
* @param area an id to identify the output, 0 for default
*/
odbgstream odDebug(int area = 0);
odbgstream odDebug(bool cond, int area = 0);
/**
* Returns a backtrace.
* @param levels the number of levels (-1 for unlimited) of the backtrace
* @return a backtrace
*/
QString odBacktrace(int levels = -1);
/**
* Returns a dummy debug stream. The stream does not print anything.
* @param area an id to identify the output, 0 for default
* @see odDebug()
*/
-inline ondbgstream ondDebug(int = 0) { return ondbgstream(); }
+inline ondbgstream ondDebug(int area = 0) { return ondbgstream(); }
inline ondbgstream ondDebug(bool , int = 0) { return ondbgstream(); }
inline QString ondBacktrace() { return QString::null; }
inline QString ondBacktrace(int) { return QString::null; }
/**
* Returns a warning stream. You can use it to print warning
* information.
* @param area an id to identify the output, 0 for default
*/
odbgstream odWarning(int area = 0);
odbgstream odWarning(bool cond, int area = 0);
/**
* Returns an error stream. You can use it to print error
* information.
* @param area an id to identify the output, 0 for default
*/
odbgstream odError(int area = 0);
odbgstream odError(bool cond, int area = 0);
/**
* Returns a fatal error stream. You can use it to print fatal error
* information.
* @param area an id to identify the output, 0 for default
*/
odbgstream odFatal(int area = 0);
odbgstream odFatal(bool cond, int area = 0);
/**
* Deletes the odebugrc cache and therefore forces KDebug to reread the
* config file
*/
void odClearDebugConfig();
#ifdef OPIE_NO_DEBUG
#define odDebug ondDebug
#define odBacktrace ondBacktrace
#endif
}
}
#endif
diff --git a/libopie2/opiecore/okeyconfigmanager.cpp b/libopie2/opiecore/okeyconfigmanager.cpp
index 891cda7..48546bd 100644
--- a/libopie2/opiecore/okeyconfigmanager.cpp
+++ b/libopie2/opiecore/okeyconfigmanager.cpp
@@ -1,356 +1,356 @@
#include "okeyconfigmanager.h"
#include "okeyconfigmanager_p.h"
namespace Opie {
namespace Core {
namespace Internal {
/*
* the virtual and hardware key events have both issues...
*/
void fixupKeys( int& key, int &mod, QKeyEvent* e ) {
key = e->key();
mod = e->state();
/*
* virtual keyboard
* else change the button mod only
*/
if ( key == 0 ) {
key = e->ascii();
if ( key > 96 && key < 123)
key -= 32;
}else{
int new_mod = 0;
if ( mod & 256 )
new_mod |= Qt::ShiftButton;
else if ( mod & 512 )
new_mod |= Qt::ControlButton;
else if ( mod & 1024 )
new_mod |= Qt::AltButton;
mod = new_mod == 0? mod : new_mod;
}
}
}
/**
* The default Constructor of a OKeyPair.
* A Key and a Modifier ( Alt/Shift/Ctrl )
* needs to be supplied.
* Use Qt::Key for the information.
* The default arguments create an Empty OKeyPair. If you
* want to get an empty OKeyPair use the static method for getting
* the emptyKey()
*
* @see OKeyPair OKeyPair::emptyKey()
*/
OKeyPair::OKeyPair( int key, int mod )
: m_key( key ), m_mod( mod )
{}
/**
* The destructor
*/
OKeyPair::~OKeyPair() {}
/**
* Is this OKeyPair empty/valid?
*/
bool OKeyPair::isEmpty()const {
return ( ( m_key == -1 )&& ( m_mod == -1 ) );
}
/**
* get the keycode for this OKeyPair. The Key relates to Qt::Key.
*
* @see Qt::Key
* @see setKey
*/
int OKeyPair::keycode()const {
return m_key;
}
/**
* get the modifier key for this OKeyPair. The Modifier State relates
* to the Qt::ButtonState
*
* @see Qt::ButtonState
* @see setModifier
*/
int OKeyPair::modifier()const {
return m_mod;
}
/**
* Set the keycode
* @param key The Keycode to set
*
* @see keycode()
* @see Qt::Key
*/
void OKeyPair::setKeycode( int key ) {
m_key = key;
}
/**
* Set the modifier key
*
- * @param the Modifier key
+ * @param mod the Modifier key
* @see Qt::ButtonState
* @see modifier()
*/
void OKeyPair::setModifier( int mod ) {
m_mod = mod;
}
/**
* Return an OKeyPair for the Return Key without any modifier.
*/
OKeyPair OKeyPair::returnKey() {
return OKeyPair( Qt::Key_Return, 0 );
}
/**
* Return an OKeyPair for the Left Arrow Key
* without any modifier Key
*/
OKeyPair OKeyPair::leftArrowKey() {
return OKeyPair( Qt::Key_Left, 0 );
}
/**
* Return an OKeyPair for the Right Arrow Key
* without any modifier Key
*/
OKeyPair OKeyPair::rightArrowKey() {
return OKeyPair( Qt::Key_Right, 0 );
}
/**
* Return an OKeyPair for the Up Arrow Key
* without any modifier Key
*/
OKeyPair OKeyPair::upArrowKey() {
return OKeyPair( Qt::Key_Up, 0 );
}
/**
* Return an OKeyPair for the Down Arrow Key
* without any modifier Key
*/
OKeyPair OKeyPair::downArrowKey() {
return OKeyPair( Qt::Key_Down, 0 );
}
/**
* Return an Empty OKeyPair
*/
OKeyPair OKeyPair::emptyKey() {
return OKeyPair();
}
/**
* This functions uses the Opie::Core::ODevice::buttons
* for OKeyPairList
*
* @see Opie::Core::ODevice
* @see Opie::Core::ODeviceButton
* @see Opie::Core::ODevice::button
*/
OKeyPair::List OKeyPair::hardwareKeys() {
const QValueList<Opie::Core::ODeviceButton> but = Opie::Core::ODevice::inst()->buttons();
OKeyPair::List lst;
for ( QValueList<Opie::Core::ODeviceButton>::ConstIterator it = but.begin();
it != but.end(); ++it )
lst.append( OKeyPair( (*it).keycode(), 0 ) );
return lst;
}
/**
* Equals operator. Check if two OKeyPairs have the same key and modifier
* @see operator!=
*/
bool OKeyPair::operator==( const OKeyPair& pair)const {
if ( m_key != pair.m_key ) return false;
if ( m_mod != pair.m_mod ) return false;
return true;
}
/**
* Not equal operator. calls the equal operator internally
*/
bool OKeyPair::operator!=( const OKeyPair& pair)const {
return !(*this == pair);
}
/**
* The normal Constructor to create a OKeyConfigItem
*
* You can set the the key paramater of this item but if
* you use this item with the OKeyConfigManager your setting
* will be overwritten.
* You can also specify a QObject and slot which sould get called
* once this item is activated. This slot only works if you
* use the OKeyConfigManager.
* The actual Key is read by load()
*
* \code
* void MySlot::create(){
* OKeyConfigItem item(tr("Delete"),"delete",Resource::loadPixmap("trash"),
* 123, OKeyPair(Qt::Key_D,Qt::ControlButton),
* this,SLOT(slotDelete(QWidget*,QKeyEvent*)));
* }
* \endcode
*
* @param text The text exposed to the user
* @param config_key The key used in the config
* @param pix A Pixmap associated with this Item
* @param def The OKeyPair used as default
* @param caller The object where the slot exists
* @param slot The slot which should get called
*
*/
OKeyConfigItem::OKeyConfigItem( const QString& text, const QCString& config_key,
const QPixmap& pix, int id, const OKeyPair& def,
QObject *caller,
const char* slot )
: m_text( text ), m_config( config_key ), m_pix( pix ),
m_id( id ), m_def( def ),
m_obj( caller ), m_str( slot ) {}
/**
* A special Constructor for converting from an Opie::Core::ODeviceButton
* delivered by Opie::Core::ODevice::buttons()
* There is no Config Key set and both default key and key are set
* to Opie::Core::ODeviceButton::keycode() and 0 to modifier
*
* @see Opie::Core::ODevice
* @see Opie::Core::ODeviceButton
* @see Opie::Core::ODevice::buttons()
*/
OKeyConfigItem::OKeyConfigItem( const Opie::Core::ODeviceButton& b )
: m_text( b.userText() ), m_pix( b.pixmap() ), m_id( -1 ),
m_key( OKeyPair( b.keycode(), 0 ) ), m_def( OKeyPair( b.keycode(), 0 ) )
{}
/**
* Destructor
*/
OKeyConfigItem::~OKeyConfigItem() {}
/**
* The text exposed to the user
*
* @see setText
*/
QString OKeyConfigItem::text()const {
return m_text;
}
/**
* The pixmap shown to the user for your action/key
*
* @see setPixmap
*/
QPixmap OKeyConfigItem::pixmap()const {
return m_pix;
}
/**
* Return the OKeyPair this OKeyConfigItem is configured for.
*
* @see setKeyPair
*/
OKeyPair OKeyConfigItem::keyPair()const {
return m_key;
}
/**
* Return the default OKeyPair
* @see setDefaultKeyPair
*/
OKeyPair OKeyConfigItem::defaultKeyPair()const {
return m_def;
}
/**
* Return the Id you assigned to this item.
* setting is only possible by the constructor
*/
int OKeyConfigItem::id()const{
return m_id;
}
/**
* reutrn the Config Key. Setting it is only possible
* by the constructor
*/
QCString OKeyConfigItem::configKey()const {
return m_config;
}
/**
* @internal
*/
QObject* OKeyConfigItem::object()const{
return m_obj;
}
/**
* @internal
*/
QCString OKeyConfigItem::slot()const {
return m_str;
}
/**
* Set the text
*
* @param text Set the Text of this Action to text
* @see text()
*/
void OKeyConfigItem::setText( const QString& text ) {
m_text = text;
}
/**
* Set the pixmap of this action
*
* @param pix The Pixmap to set
* @see pixmap()
*/
void OKeyConfigItem::setPixmap( const QPixmap& pix ) {
m_pix = pix;
}
/**
* Set the KeyPair the OKeyConfigItem uses.
* Your set Key could get overwritten if you use
* the manager or GUI to configure the key
*
* @param key Set the OKeyPair used
* @see keyPair()
*/
void OKeyConfigItem::setKeyPair( const OKeyPair& key) {
m_key = key;
}
/**
* Set the default KeyPair.
*
* @param key The default keypair
* @see defaultKeyPair()
*/
void OKeyConfigItem::setDefaultKeyPair( const OKeyPair& key ) {
m_def = key;
}
diff --git a/libopie2/opiecore/okeyfilter.h b/libopie2/opiecore/okeyfilter.h
index d183641..1871247 100644
--- a/libopie2/opiecore/okeyfilter.h
+++ b/libopie2/opiecore/okeyfilter.h
@@ -1,100 +1,100 @@
/*
This file is part of the Opie Project
=. Copyright (C) 2004 Rajko 'Alwin' Albrecht <alwin@handhelds.org>
.=l. Copyright (C) The Opie Team <opie-devel@handhelds.org>
.>+-=
_;:, .> :=|. This program is free software; you can
.> <`_, > . <= redistribute it and/or modify it under
:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
.="- .-=="i, .._ License as published by the Free Software
- . .-<_> .<> Foundation; either version 2 of the License,
._= =} : or (at your option) any later version.
.%`+i> _;_.
.i_,=:_. -<s. This program 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., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/* QT */
#include <qwindowsystem_qws.h>
#include <qvaluelist.h>
namespace Opie {
namespace Core {
class ODevice;
/**
* A singleton which will manage all possible keyboard filters inside opie.
* It makes sure that key handlers of odevice are checked first than the
* keyfilters of software.
* @short a keyfilter proxy
* @see QWSServer::KeyboardFilter
* @author Rajko Albrecht
* @version 1.0
*/
class OKeyFilter
{
friend class Opie::Core::ODevice;
protected:
/**
* Protected constructor - generate class via inst()
* @see inst()
*/
OKeyFilter();
/**
* Protected constructor - generate class via inst()
* @see inst()
*/
OKeyFilter(const OKeyFilter&){};
/**
* Append filter to the primary list.
* This is only allowed for friend classes from odevice
* @param aFilter a filter to append
* @see addHandler
*/
- virtual void addPreHandler(QWSServer::KeyboardFilter*aFilter)=0;
+ virtual void addPreHandler(QWSServer::KeyboardFilter *aFilter)=0;
/**
* Remove the specified filter from list and give back ownership.
* This is only allowed for friend classes from odevice
* @param aFilter a filter to remove
* @see remHandler
*/
- virtual void remPreHandler(QWSServer::KeyboardFilter*aFilter)=0;
+ virtual void remPreHandler(QWSServer::KeyboardFilter *aFilter)=0;
public:
virtual ~OKeyFilter();
/**
* Append filter to the secondary list.
* @param aFilter a filter to append
* @see addPreHandler
*/
- virtual void addHandler(QWSServer::KeyboardFilter*)=0;
+ virtual void addHandler(QWSServer::KeyboardFilter *aFilter)=0;
/**
* Remove the specified filter from list and give back ownership.
* @param aFilter a filter to remove
* @see remPreHandler
*/
- virtual void remHandler(QWSServer::KeyboardFilter*)=0;
+ virtual void remHandler(QWSServer::KeyboardFilter *aFilter)=0;
/**
* Returns a handler to an instance of OKeyFilter
* @return a pointer to a working OKeyFilter
*/
static OKeyFilter*inst();
};
}
}
diff --git a/libopie2/opiecore/opluginloader.cpp b/libopie2/opiecore/opluginloader.cpp
index ec19fa0..2a6e369 100644
--- a/libopie2/opiecore/opluginloader.cpp
+++ b/libopie2/opiecore/opluginloader.cpp
@@ -270,637 +270,636 @@ void OPluginItem::setPosition( int pos ) {
* for(Opie::Core::OPluginItem::List::Iterator it = lst.begin(); it!=lst.end();++it){
* MyIface* iface = static_cast<MyIface*>(loader.load(*it,IID_MyIface));
* }
* ...
* loader.clear();
*
* \endcode
*
* @param name The name of the plugin directory.
* @param isSorted Tell the PluginLoader if your Plugins are sorted
*/
OGenericPluginLoader::OGenericPluginLoader( const QString& name, bool isSorted)
: m_dir( name ), m_autoDelete( false ), m_isSafeMode( false ),
m_isSorted( isSorted )
{
setPluginDir( QPEApplication::qpeDir() + "plugins/"+name );
readConfig();
}
/**
* \brief simple d'tor that cleans up depending on autoDelete
*
* calls clear if autoDelete is true. This will release all interfaces
* and remove the library from this process if the refcount falls to zero
*/
OGenericPluginLoader::~OGenericPluginLoader() {
if ( m_autoDelete )
clear();
}
/**
* \brief Enable or disable autoDelete on destruction
*
* enable autoDelete. This will call clear on the d'tor
*
* @see ~OGenericPluginLoader
* @see clear()
*/
void OGenericPluginLoader::setAutoDelete( bool t ) {
m_autoDelete = t;
}
/**
* \brief See if autoDelete is enabled.
*/
bool OGenericPluginLoader::autoDelete()const{
return m_autoDelete;
}
/**
* \brief unload all loaded Plugins
*
* This will unload all returned QUnknownInterfaces by load. Unload
* will be called.
*/
void OGenericPluginLoader::clear() {
QPtrDictIterator<QLibrary> it( m_library );
for ( ;it.current(); )
unload( static_cast<QUnknownInterface*>( it.currentKey() ) );
}
/**
* \brief unload the Plugin and the accompanied Resources.
*
* This will take the iface from the internal QPtrDict, Release it,
* and deref the libray used.
* The visibility depends on the QPtrDict.
* @see QPtrDict::insert
*/
void OGenericPluginLoader::unload( QUnknownInterface* iface ) {
if ( !iface )
return;
iface->release();
Internal::OPluginLibraryHolder::self()->deref( m_library.take( iface ) );
}
/**
* \brief The name of the plugins.
*
* Return the name/type you specified in the constructor.
* This is at least used by the OPluginManager to find the right config
*/
QString OGenericPluginLoader::name()const {
return m_dir;
}
/**
* \brief See if loading of a plugin segfaulted
* This tells you
* if by previous tries to load, loading crashed your application.
* If isInSafeMode you can use the GUI to configure the plugins prior to loading
*
* @return true if prior loading failed
*/
bool OGenericPluginLoader::isInSafeMode()const {
return m_isSafeMode;
}
/**
* \brief Return all Plugins found in the plugins dirs.
* Return the list of all available plugins. This will go through all plugin
* directories and search for your type of plugins ( by subdir )
*
* @param sorted Tell if you want to have the positions sorted. This only makes sense if you
*/
OPluginItem::List OGenericPluginLoader::allAvailable( bool sorted )const {
OPluginItem::List lst;
for ( QStringList::ConstIterator it = m_plugDirs.begin(); it != m_plugDirs.end(); ++it )
lst += plugins( *it, sorted, false );
if ( sorted )
qHeapSort( lst );
return lst;
}
/**
* \brief Return only the enabled plugins
* Return only activated plugins.
*
* @param sorted If the list should be sorted
*/
OPluginItem::List OGenericPluginLoader::filtered( bool sorted )const {
OPluginItem::List lst;
for ( QStringList::ConstIterator it = m_plugDirs.begin(); it != m_plugDirs.end(); ++it )
lst += plugins( *it, sorted, true );
if ( sorted )
qHeapSort( lst );
return lst;
}
/**
* \brief Load a OPluginItem for the specified interface
* This will open the resource of the OPluginItem::path() and then will query
* if the Interface specified in the uuid is available and then will manage the
* resource and Interface.
*
* @param item The OPluginItem that should be loaded
* @param uuid The Interface to query for
*
* @return Either 0 in case of failure or the Plugin as QUnknownInterface*
*/
QUnknownInterface* OGenericPluginLoader::load( const OPluginItem& item, const QUuid& uuid) {
/*
* Check if there could be a library
*/
QString pa = item.path();
if ( pa.isEmpty() )
return 0l;
/*
* See if we get a library
* return if we've none
*/
setSafeMode( pa, true );
QLibrary *lib = Internal::OPluginLibraryHolder::self()->ref( pa );
if ( !lib ) {
setSafeMode();
return 0l;
}
/**
* try to load the plugin and just in case initialize the pointer to a pointer again
*/
QUnknownInterface* iface=0;
if ( lib->queryInterface( uuid, &iface ) == QS_OK ) {
installTranslators( item.name() );
m_library.insert( iface, lib );
}else
iface = 0;
setSafeMode();
return iface;
}
/**
* @internal and reads in the safe mode
*/
void OGenericPluginLoader::readConfig() {
/* read the config for SafeMode */
OConfig conf( m_dir + "-odpplugins" );
conf.setGroup( "General" );
m_isSafeMode = conf.readBoolEntry( "SafeMode", false );
}
/**
* @internal Enter or leave SafeMode
*/
void OGenericPluginLoader::setSafeMode(const QString& str, bool b) {
OConfig conf( m_dir + "-odpplugins" );
conf.setGroup( "General" );
conf.writeEntry( "SafeMode", b );
conf.writeEntry( "CrashedPlugin", str );
}
/**
* @internal
*
* Set the List of Plugin Dirs to lst. Currently only QPEApplication::qpeDir()+"/plugins/"+mytype
* is used as plugin dir
*/
void OGenericPluginLoader::setPluginDirs( const QStringList& lst ) {
m_plugDirs = lst;
}
/**
*
* @internal
* Set the Plugin Dir to str. Str will be the only element in the list of plugin dirs
*/
void OGenericPluginLoader::setPluginDir( const QString& str) {
m_plugDirs.clear();
m_plugDirs.append( str );
}
/**
* @internal
*/
bool OGenericPluginLoader::isSorted()const{
return m_isSorted;
}
/*
* make libfoo.so.1.0.0 -> foo on UNIX
* make libfoo.dylib -> foo on MAC OS X Unix
* windows is obviously missing
*/
/**
* @internal
*/
QString OGenericPluginLoader::unlibify( const QString& str ) {
QString st = str.mid( str.find( "lib" )+3 );
#ifdef Q_OS_MACX
return st.left( st.findRev( ".dylib" ) );
#else
return st.left( st.findRev( ".so" ) );
#endif
}
/**
* @internal
*
* \brief method to return available plugins. Internal and for reeimplementations
*
*Return a List of Plugins for a dir and add positions and remove disabled.
* If a plugin is on the excluded list assign position -2
*
- * @param dir The dir to look in
+ * @param _dir The dir to look in
* @param sorted Should positions be read?
* @param disabled Remove excluded from the list
*/
OPluginItem::List OGenericPluginLoader::plugins( const QString& _dir, bool sorted, bool disabled )const {
#ifdef Q_OS_MACX
QDir dir( _dir, "lib*.dylib" );
#else
QDir dir( _dir, "lib*.so" );
#endif
OPluginItem::List lst;
/*
* get excluded list and then iterate over them
* Excluded list contains the name
* Position is a list with 'name.pos.name.pos.name.pos'
*
* For the look up we will create two QMap<QString,pos>
*/
QMap<QString, int> positionMap;
QMap<QString, int> excludedMap;
OConfig cfg( m_dir+"-odpplugins" );
cfg.setGroup( _dir );
QStringList excludes = cfg.readListEntry( "Excluded", ',' );
for ( QStringList::Iterator it = excludes.begin(); it != excludes.end(); ++it )
excludedMap.insert( *it, -2 );
if ( sorted ) {
QStringList pos = cfg.readListEntry( "Positions", '.' );
QStringList::Iterator it = pos.begin();
QString tmp; int i;
while ( it != pos.end() ) {
tmp = *it++; i = (*it++).toInt();
positionMap.insert( tmp, i );
}
}
QStringList list = dir.entryList();
for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
QString str = unlibify( *it );
OPluginItem item( str, _dir + "/" + *it );
bool ex = excludedMap.contains( str );
/*
* if disabled but we should show all mark it as disabled
* else continue because we don't want to add the item
* else if sorted we assign the right position
*/
if ( ex && !disabled)
item.setEnabled( false );
else if ( ex && disabled )
continue;
else if ( sorted )
item.setPosition( positionMap[str] );
lst.append( item );
}
return lst;
}
/**
* @internal generate a list of languages from $LANG
*/
QStringList OGenericPluginLoader::languageList() {
if ( m_languages.isEmpty() ) {
/*
* be_BY.CP1251 We will add, be_BY.CP1251,be_BY,be
* to our list of languages.
* Also for de_DE@euro we will add de_DE@eurp, de_DE, de
* to our list of languages
*/
QString str = ::getenv( "LANG" );
m_languages += str;
int pos = str.find( '@' );
if( pos > 0 )
m_languages += str.left( pos );
pos = str.find( '.' );
if ( pos > 0 )
m_languages += str.left( pos );
int n_pos = str.find( '_' );
if ( n_pos > 0 )
m_languages += str.left( n_pos );
}
return m_languages;
}
/**
* @internal
* Tries to install languages using the languageList for the type
*/
void OGenericPluginLoader::installTranslators(const QString& type) {
QStringList lst = languageList();
/*
* for each language and maybe later for each language dir...
* try to load a Translator
*/
for ( QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) {
QTranslator* trans = new QTranslator( qApp );
QString tfn = QPEApplication::qpeDir()+"/i18n/" + *it + "/lib" + type + ".qm" ;
/*
* If loaded then install else clean up and don't leak
*/
if ( trans->load( tfn ) )
qApp->installTranslator( trans );
else
delete trans;
}
}
/**
* \brief Simple c'tor.
*
* Simple C'tor same as the one of the base class. Additional this
* class can cast for you if you nee it.
*
*
* @param name The name of your plugin class
* @param sorted If plugins are sorted
*
* @see OGenericPluginLoader
*/
OPluginLoader::OPluginLoader( const QString& name, bool sorted )
: OGenericPluginLoader( name, sorted )
{
}
/**
* d'tor
* @see OGenericPluginLoader::~OGenericPluginLoader
*/
OPluginLoader::~OPluginLoader() {
}
/**
* \brief C'Tor using a OGenericPluginLoader
* The C'tor. Pass your OGenericPluginLoader to manage
* OGenericPluginLoader::allAvailable plugins.
*
*
* @param loader A Pointer to your OGenericPluginLoader
- * @param name The name
*/
OPluginManager::OPluginManager( OGenericPluginLoader* loader)
: m_loader( loader ), m_isSorted( false )
{
}
/**
* \brief Overloaded c'tor using a List of Plugins and a type name
* Overloaded Constructor to work with a 'Type' of plugins
* and a correspending list of those. In this case calling load
* is a no operation.
*
* @param name The name of your plugin ('today','inputmethods','applets')
* @param lst A List with plugins of your type to manage
* @param isSorted If the List should be treated sorted
*/
OPluginManager::OPluginManager( const QString& name, const OPluginItem::List& lst, bool isSorted)
: m_loader( 0l ), m_cfgName( name ), m_plugins( lst ), m_isSorted( isSorted )
{
}
/**
* \brief A simple d'tor
*/
OPluginManager::~OPluginManager() {
}
/**
* \brief Return the OPluginItem where loading is likely to have crashed on.
* Return the Item that made the OGenericPluginLoader crash
* the returned OPluginItem could be empty if no crash occured
* which should apply most of the time. It could also be empty if the crashed
* plugin is not in the current list of available/managed plugins
*
* @see OPluginItem::isEmpty
* @return OPluginItem that crashed the loader
*/
OPluginItem OPluginManager::crashedPlugin()const {
return m_crashed;
}
/**
* \brief Return a list of plugins that are managed by this OPluginManager
*
* Return the list of managed plugins. This could either result
* from passing a OGenericPluginLoader and calling load or by
* giving name and a list of plugins.
*/
OPluginItem::List OPluginManager::managedPlugins()const {
return m_plugins;
}
/**
* \brief Set the position of the items
*
* Replace the OPluginItem with the name and path and this way
* apply the new position. The search is linear and this way O(n/2)
* You still need to call save() to make your changes effective. After saving
* a call to OGenericPluginLoader::filtered() returns the newly configured order and items
*
* @param item The OPluginItem to be replaced internall
*
*/
void OPluginManager::setPosition( const OPluginItem& item) {
replace( item );
}
/**
* \brief Enable the item specified as argument
*
* This will make sure that OPluginItem::setEnabled is called and then will replace
* the item with one that matches name and path internally.
* @see setPosition
*
- * @param the Item to enable
+ * @param item the Item to enable
*/
void OPluginManager::enable( const OPluginItem& item ) {
setEnabled( item, true );
}
/**
* \brief disable the Item.
*
* Disable the OPluginItem. Same applies as in
* @see setPosition and @see enable
*
* @param item Item to disable
*/
void OPluginManager::disable( const OPluginItem& item) {
setEnabled( item, false );
}
/**
* \brief Enable or disable the OPluginItem.
* Depending on the value of the parameter this will either disable
* or enable the pluginitem.
* Beside that same as in @see disable, @see enable, @see setPosition
* applies.
*
* @param _item The OPluginItem to enable or to disable.
* @param b Enable or disable the plugin.
*
*/
void OPluginManager::setEnabled( const OPluginItem& _item, bool b ) {
OPluginItem item = _item;
item.setEnabled( b );
replace( item );
}
/**
* \brief Load necessary information after constructing the object
* If you speified a OGenericPluginLoader you need to call this method
* so that this manager knows what to manage and have a right value for \sa crashedPlugin
* For the name and the list of plugins this does only try to find out the crashed plugin
*/
void OPluginManager::load() {
OConfig cfg( configName() );
cfg.setGroup( "General" );
QString crashedPath = cfg.readEntry( "CrashedPlugin" );
/* if we've a loader this applies if we were called from the first part */
if ( m_loader )
m_plugins = m_loader->allAvailable( m_loader->isSorted() );
/* fast and normal route if we did not crash... */
if ( crashedPath.isEmpty() )
return;
/* lets try to find the plugin path and this way the associated item */
for ( OPluginItem::List::Iterator it = m_plugins.begin(); it != m_plugins.end(); ++it )
if ( (*it).path() == crashedPath ) {
m_crashed = *it;
break;
}
}
/**
* \brief Save the values and this way make it available.
*
* Save the current set of data. A call to @see OGenericPluginLoader::filtered
* now would return your saved changes.
*/
void OPluginManager::save() {
QMap<QString, QStringList> excluded; // map for path to excluded name
QMap<QString, QStringList> positions; // if positions matter contains splitted up by dirs
bool sorted = m_loader ? m_loader->isSorted() : m_isSorted;
/*
* We will create some maps for the groups to include positions a
*/
for ( OPluginItem::List::Iterator it = m_plugins.begin(); it != m_plugins.end(); ++it ) {
OPluginItem item = *it;
QString path = QFileInfo( item.path() ).dirPath(true);
if ( sorted ) {
positions[path].append( item.name() );
positions[path].append( QString::number( item.position() ) );
}
if ( !item.isEnabled() )
excluded[path].append( item.name() );
if ( !excluded.contains( path ) )
excluded[path] = QString::null;
}
/*
* The code below wouldn't work because we can't delete groups/keys from the config
* ### for ODP make Config right!
*/
// if ( excluded.isEmpty() && positions.isEmpty() ) return;
/*
* Now safe for each path
*/
OConfig cfg( configName() );
/* safe excluded items */
for ( QMap<QString, QStringList>::Iterator it = excluded.begin(); it != excluded.end(); ++it ) {
OConfigGroupSaver saver( &cfg, it.key() );
cfg.writeEntry("Excluded", it.data(), ',' );
}
/* safe positions we could also see if positions.contains(path) and remove/write in the above loop
* ### Write a Test Suite that can profile these runs...
*/
for ( QMap<QString, QStringList>::Iterator it = positions.begin(); it != positions.end(); ++it ) {
OConfigGroupSaver saver( &cfg, it.key() );
cfg.writeEntry("Positions", it.data(), '.' );
}
}
/**
* @internal
*/
QString OPluginManager::configName()const {
QString str = m_loader ? m_loader->name() : m_cfgName;
return str + "-odpplugins";
}
/**
* @internal.. replace in m_plugins by path... this is linear search O(n/2)
*/
void OPluginManager::replace( const OPluginItem& item ) {
OPluginItem _item;
/* for all plugins */
for ( OPluginItem::List::Iterator it=m_plugins.begin();it != m_plugins.end(); ++it ) {
_item = *it;
/* if path and name are the same we will remove, readd and return */
if ( _item.path() == item.path() &&
_item.name() == item.name() ) {
it = m_plugins.remove( it );
m_plugins.append( item );
return;
}
}
}
}
}
diff --git a/libopie2/opiecore/oprocess.h b/libopie2/opiecore/oprocess.h
index be1436c..ac6be98 100644
--- a/libopie2/opiecore/oprocess.h
+++ b/libopie2/opiecore/oprocess.h
@@ -1,761 +1,763 @@
/*
                This file is part of the Opie Project
            Copyright (C) 2003-2004 Holger Freyther <zecke@handhelds.org>
Copyright (C) The Opie Team <opie-devel@handhelds.org>
=. Based on KProcess (C) 1997 Christian Czezatke (e9025461@student.tuwien.ac.at)
.=l.
         .>+-=
_;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
- .   .-<_>     .<> Foundation; either version 2 of the License,
   ._= =}       : or (at your option) any later version.
  .%`+i>       _;_.
  .i_,=:_.      -<s. This program 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., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OPROCESS_H
#define OPROCESS_H
/* QT */
#include <qcstring.h>
#include <qobject.h>
#include <qvaluelist.h>
/* STD */
#include <sys/types.h> // for pid_t
#include <sys/wait.h>
#include <signal.h>
#include <unistd.h>
class QSocketNotifier;
namespace Opie {
namespace Core {
namespace Internal {
class OProcessController;
class OProcessPrivate;
}
/**
* Child process invocation, monitoring and control.
*
- * @sect General usage and features
+ * @par General usage and features
*
*This class allows a KDE and OPIE application to start child processes without having
*to worry about UN*X signal handling issues and zombie process reaping.
*
*@see KProcIO
*
*Basically, this class distinguishes three different ways of running
*child processes:
*
*@li OProcess::DontCare -- The child process is invoked and both the child
*process and the parent process continue concurrently.
*
*Starting a DontCare child process means that the application is
*not interested in any notification to determine whether the
*child process has already exited or not.
*
*@li OProcess::NotifyOnExit -- The child process is invoked and both the
*child and the parent process run concurrently.
*
*When the child process exits, the OProcess instance
*corresponding to it emits the Qt signal @ref processExited().
*
*Since this signal is @em not emitted from within a UN*X
*signal handler, arbitrary function calls can be made.
*
*Be aware: When the OProcess objects gets destructed, the child
*process will be killed if it is still running!
*This means in particular, that you cannot use a OProcess on the stack
*with OProcess::NotifyOnExit.
*
*@li OProcess::Block -- The child process starts and the parent process
*is suspended until the child process exits. (@em Really not recommended
*for programs with a GUI.)
*
*OProcess also provides several functions for determining the exit status
*and the pid of the child process it represents.
*
*Furthermore it is possible to supply command-line arguments to the process
*in a clean fashion (no null -- terminated stringlists and such...)
*
*A small usage example:
*<pre>
*OProcess *proc = new OProcess;
*
**proc << "my_executable";
**proc << "These" << "are" << "the" << "command" << "line" << "args";
*QApplication::connect(proc, SIGNAL(processExited(Opie::Core::OProcess *)),
* pointer_to_my_object, SLOT(my_objects_slot(Opie::Core::OProcess *)));
*proc->start();
*</pre>
*
*This will start "my_executable" with the commandline arguments "These"...
*
*When the child process exits, the respective Qt signal will be emitted.
*
- *@sect Communication with the child process
+ *@par Communication with the child process
*
*OProcess supports communication with the child process through
*stdin/stdout/stderr.
*
*The following functions are provided for getting data from the child
*process or sending data to the child's stdin (For more information,
*have a look at the documentation of each function):
*
*@li bool @ref writeStdin(char *buffer, int buflen);
*@li -- Transmit data to the child process's stdin.
*
*@li bool @ref closeStdin();
*@li -- Closes the child process's stdin (which causes it to see an feof(stdin)).
*Returns false if you try to close stdin for a process that has been started
*without a communication channel to stdin.
*
*@li bool @ref closeStdout();
*@li -- Closes the child process's stdout.
*Returns false if you try to close stdout for a process that has been started
*without a communication channel to stdout.
*
*@li bool @ref closeStderr();
*@li -- Closes the child process's stderr.
*Returns false if you try to close stderr for a process that has been started
*without a communication channel to stderr.
*
*
- *@sect QT signals:
+ *@par QT signals:
*
*@li void @ref receivedStdout(OProcess *proc, char *buffer, int buflen);
*@li void @ref receivedStderr(OProcess *proc, char *buffer, int buflen);
*@li -- Indicates that new data has arrived from either the
*child process's stdout or stderr.
*
*@li void @ref wroteStdin(OProcess *proc);
*@li -- Indicates that all data that has been sent to the child process
*by a prior call to @ref writeStdin() has actually been transmitted to the
*client .
*
*@author Christian Czezakte e9025461@student.tuwien.ac.at
*@author Holger Freyther (Opie Port)
*
**/
class OProcess : public QObject
{
Q_OBJECT
public:
/**
* Modes in which the communication channel can be opened.
*
* If communication for more than one channel is required,
* the values have to be or'ed together, for example to get
* communication with stdout as well as with stdin, you would
* specify @p Stdin @p | @p Stdout
*
* If @p NoRead is specified in conjunction with @p Stdout,
* no data is actually read from @p Stdout but only
* the signal @ref childOutput(int fd) is emitted.
*/
enum Communication { NoCommunication = 0, Stdin = 1, Stdout = 2, Stderr = 4,
AllOutput = 6, All = 7,
NoRead };
/**
* Run-modes for a child process.
*/
enum RunMode {
/**
* The application does not receive notifications from the subprocess when
* it is finished or aborted.
*/
DontCare,
/**
* The application is notified when the subprocess dies.
*/
NotifyOnExit,
/**
* The application is suspended until the started process is finished.
*/
Block };
/**
* Constructor
*/
OProcess( QObject *parent = 0, const char *name = 0 );
/**
* Constructor
*/
OProcess( const QString &arg0, QObject *parent = 0, const char *name = 0 );
/**
* Constructor
*/
OProcess( const QStringList &args, QObject *parent = 0, const char *name = 0 );
/**
*Destructor:
*
* If the process is running when the destructor for this class
* is called, the child process is killed with a SIGKILL, but
* only if the run mode is not of type @p DontCare.
* Processes started as @p DontCare keep running anyway.
*/
virtual ~OProcess();
/**
@deprecated
The use of this function is now deprecated. -- Please use the
"operator<<" instead of "setExecutable".
Sets the executable to be started with this OProcess object.
Returns false if the process is currently running (in that
case the executable remains unchanged.)
@see operator<<
*/
bool setExecutable( const QString& proc );
/**
* Sets the executable and the command line argument list for this process.
*
* For example, doing an "ls -l /usr/local/bin" can be achieved by:
* <pre>
* OProcess p;
* ...
* p << "ls" << "-l" << "/usr/local/bin"
* </pre>
*
**/
OProcess &operator<<( const QString& arg );
/**
* Similar to previous method, takes a char *, supposed to be in locale 8 bit already.
*/
OProcess &operator<<( const char * arg );
/**
* Similar to previous method, takes a QCString, supposed to be in locale 8 bit already.
*/
OProcess &operator<<( const QCString & arg );
/**
* Sets the executable and the command line argument list for this process,
* in a single method call, or add a list of arguments.
**/
OProcess &operator<<( const QStringList& args );
/**
* Clear a command line argument list that has been set by using
* the "operator<<".
*/
void clearArguments();
/**
* Starts the process.
* For a detailed description of the
* various run modes and communication semantics, have a look at the
* general description of the OProcess class.
*
* The following problems could cause this function to
* return false:
*
* @li The process is already running.
* @li The command line argument list is empty.
* @li The starting of the process failed (could not fork).
* @li The executable was not found.
*
* @param comm Specifies which communication links should be
* established to the child process (stdin/stdout/stderr). By default,
* no communication takes place and the respective communication
* signals will never get emitted.
*
* @return true on success, false on error
* (see above for error conditions)
**/
virtual bool start( RunMode runmode = NotifyOnExit,
Communication comm = NoCommunication );
/**
* Stop the process (by sending it a signal).
*
* @param signo The signal to send. The default is SIGTERM.
* @return @p true if the signal was delivered successfully.
*/
virtual bool kill( int signo = SIGTERM );
/**
@return @p true if the process is (still) considered to be running
*/
bool isRunning() const;
/** Returns the process id of the process.
*
* If it is called after
* the process has exited, it returns the process id of the last
* child process that was created by this instance of OProcess.
*
* Calling it before any child process has been started by this
* OProcess instance causes pid() to return 0.
**/
pid_t pid() const;
/**
* Suspend processing of data from stdout of the child process.
*/
void suspend();
/**
* Resume processing of data from stdout of the child process.
*/
void resume();
/**
* @return @p true if the process has already finished and has exited
* "voluntarily", ie: it has not been killed by a signal.
*
* Note that you should check @ref OProcess::exitStatus() to determine
* whether the process completed its task successful or not.
*/
bool normalExit() const;
/**
* Returns the exit status of the process.
*
* Please use
* @ref OProcess::normalExit() to check whether the process has exited
* cleanly (i.e., @ref OProcess::normalExit() returns @p true) before calling
* this function because if the process did not exit normally,
* it does not have a valid exit status.
*/
int exitStatus() const;
/**
* Transmit data to the child process's stdin.
*
* OProcess::writeStdin may return false in the following cases:
*
* @li The process is not currently running.
*
* @li Communication to stdin has not been requested in the @ref start() call.
*
* @li Transmission of data to the child process by a previous call to
* @ref writeStdin() is still in progress.
*
* Please note that the data is sent to the client asynchronously,
* so when this function returns, the data might not have been
* processed by the child process.
*
* If all the data has been sent to the client, the signal
* @ref wroteStdin() will be emitted.
*
* Please note that you must not free "buffer" or call @ref writeStdin()
* again until either a @ref wroteStdin() signal indicates that the
* data has been sent or a @ref processHasExited() signal shows that
* the child process is no longer alive...
**/
bool writeStdin( const char *buffer, int buflen );
void flushStdin();
/**
* This causes the stdin file descriptor of the child process to be
* closed indicating an "EOF" to the child.
*
* @return @p false if no communication to the process's stdin
* had been specified in the call to @ref start().
*/
bool closeStdin();
/**
* This causes the stdout file descriptor of the child process to be
* closed.
*
* @return @p false if no communication to the process's stdout
* had been specified in the call to @ref start().
*/
bool closeStdout();
/**
* This causes the stderr file descriptor of the child process to be
* closed.
*
* @return @p false if no communication to the process's stderr
* had been specified in the call to @ref start().
*/
bool closeStderr();
/**
* Lets you see what your arguments are for debugging.
* \todo make const
*/
const QValueList<QCString> &args()
{
return arguments;
}
/**
* Controls whether the started process should drop any
* setuid/segid privileges or whether it should keep them
*
* The default is @p false : drop privileges
*/
void setRunPrivileged( bool keepPrivileges );
/**
* Returns whether the started process will drop any
* setuid/segid privileges or whether it will keep them
*/
bool runPrivileged() const;
/**
* Modifies the environment of the process to be started.
* This function must be called before starting the process.
*/
void setEnvironment( const QString &name, const QString &value );
/**
* Changes the current working directory (CWD) of the process
* to be started.
* This function must be called before starting the process.
*/
void setWorkingDirectory( const QString &dir );
/**
* Specify whether to start the command via a shell or directly.
* The default is to start the command directly.
* If @p useShell is true @p shell will be used as shell, or
* if shell is empty, the standard shell is used.
* @p quote A flag indicating whether to quote the arguments.
*
* When using a shell, the caller should make sure that all filenames etc.
* are properly quoted when passed as argument.
* @see quote()
*/
void setUseShell( bool useShell, const char *shell = 0 );
/**
* This function can be used to quote an argument string such that
* the shell processes it properly. This is e. g. necessary for
* user-provided file names which may contain spaces or quotes.
* It also prevents expansion of wild cards and environment variables.
*/
static QString quote( const QString &arg );
/**
* Detaches OProcess from child process. All communication is closed.
* No exit notification is emitted any more for the child process.
* Deleting the OProcess will no longer kill the child process.
* Note that the current process remains the parent process of the
* child process.
*/
void detach();
/**
* @return the PID of @a process, or -1 if the process is not running
*/
static int processPID( const QString& process );
signals:
/**
* Emitted after the process has terminated when
* the process was run in the @p NotifyOnExit (==default option to
* @ref start()) or the @ref Block mode.
**/
void processExited( Opie::Core::OProcess *proc );
/**
* Emitted, when output from the child process has
* been received on stdout.
*
* To actually get
* these signals, the respective communication link (stdout/stderr)
* has to be turned on in @ref start().
*
+ * @param proc The process
* @param buffer The data received.
* @param buflen The number of bytes that are available.
*
* You should copy the information contained in @p buffer to your private
* data structures before returning from this slot.
**/
void receivedStdout( Opie::Core::OProcess *proc, char *buffer, int buflen );
/**
* Emitted when output from the child process has
* been received on stdout.
*
* To actually get these signals, the respective communications link
* (stdout/stderr) has to be turned on in @ref start() and the
* @p NoRead flag should have been passed.
*
* You will need to explicitly call resume() after your call to start()
* to begin processing data from the child process's stdout. This is
* to ensure that this signal is not emitted when no one is connected
* to it, otherwise this signal will not be emitted.
*
* The data still has to be read from file descriptor @p fd.
**/
void receivedStdout( int fd, int &len );
/**
* Emitted, when output from the child process has
* been received on stderr.
* To actually get
* these signals, the respective communication link (stdout/stderr)
* has to be turned on in @ref start().
*
+ * @param proc The process
* @param buffer The data received.
* @param buflen The number of bytes that are available.
*
* You should copy the information contained in @p buffer to your private
* data structures before returning from this slot.
*/
void receivedStderr( Opie::Core::OProcess *proc, char *buffer, int buflen );
/**
* Emitted after all the data that has been
* specified by a prior call to @ref writeStdin() has actually been
* written to the child process.
**/
void wroteStdin( Opie::Core::OProcess *proc );
protected slots:
/**
* This slot gets activated when data from the child's stdout arrives.
* It usually calls "childOutput"
*/
void slotChildOutput( int fdno );
/**
* This slot gets activated when data from the child's stderr arrives.
* It usually calls "childError"
*/
void slotChildError( int fdno );
/*
Slot functions for capturing stdout and stderr of the child
*/
/**
* Called when another bulk of data can be sent to the child's
* stdin. If there is no more data to be sent to stdin currently
* available, this function must disable the QSocketNotifier "innot".
*/
void slotSendData( int dummy );
protected:
/**
* Sets up the environment according to the data passed via
* setEnvironment(...)
*/
void setupEnvironment();
/**
* The list of the process' command line arguments. The first entry
* in this list is the executable itself.
*/
QValueList<QCString> arguments;
/**
* How to run the process (Block, NotifyOnExit, DontCare). You should
* not modify this data member directly from derived classes.
*/
RunMode run_mode;
/**
* true if the process is currently running. You should not
* modify this data member directly from derived classes. For
* reading the value of this data member, please use "isRunning()"
* since "runs" will probably be made private in later versions
* of OProcess.
*/
bool runs;
/**
* The PID of the currently running process (see "getPid()").
* You should not modify this data member in derived classes.
* Please use "getPid()" instead of directly accessing this
* member function since it will probably be made private in
* later versions of OProcess.
*/
pid_t pid_;
/**
* The process' exit status as returned by "waitpid". You should not
* modify the value of this data member from derived classes. You should
* rather use @ref exitStatus than accessing this data member directly
* since it will probably be made private in further versions of
* OProcess.
*/
int status;
/**
* See setRunPrivileged()
*/
bool keepPrivs;
/*
Functions for setting up the sockets for communication.
setupCommunication
-- is called from "start" before "fork"ing.
commSetupDoneP
-- completes communication socket setup in the parent
commSetupDoneC
-- completes communication setup in the child process
commClose
-- frees all allocated communication resources in the parent
after the process has exited
*/
/**
* This function is called from "OProcess::start" right before a "fork" takes
* place. According to
* the "comm" parameter this function has to initialize the "in", "out" and
* "err" data member of OProcess.
*
* This function should return 0 if setting the needed communication channels
* was successful.
*
* The default implementation is to create UNIX STREAM sockets for the communication,
* but you could overload this function and establish a TCP/IP communication for
* network communication, for example.
*/
virtual int setupCommunication( Communication comm );
/**
* Called right after a (successful) fork on the parent side. This function
* will usually do some communications cleanup, like closing the reading end
* of the "stdin" communication channel.
*
* Furthermore, it must also create the QSocketNotifiers "innot", "outnot" and
* "errnot" and connect their Qt slots to the respective OProcess member functions.
*
* For a more detailed explanation, it is best to have a look at the default
* implementation of "setupCommunication" in kprocess.cpp.
*/
virtual int commSetupDoneP();
/**
* Called right after a (successful) fork, but before an "exec" on the child
* process' side. It usually just closes the unused communication ends of
* "in", "out" and "err" (like the writing end of the "in" communication
* channel.
*/
virtual int commSetupDoneC();
/**
* Immediately called after a process has exited. This function normally
* calls commClose to close all open communication channels to this
* process and emits the "processExited" signal (if the process was
* not running in the "DontCare" mode).
*/
virtual void processHasExited( int state );
/**
* Should clean up the communication links to the child after it has
* exited. Should be called from "processHasExited".
*/
virtual void commClose();
/**
* the socket descriptors for stdin/stdout/stderr.
*/
int out[ 2 ];
int in[ 2 ];
int err[ 2 ];
/**
* The socket notifiers for the above socket descriptors.
*/
QSocketNotifier *innot;
QSocketNotifier *outnot;
QSocketNotifier *errnot;
/**
* Lists the communication links that are activated for the child
* process. Should not be modified from derived classes.
*/
Communication communication;
/**
* Called by "slotChildOutput" this function copies data arriving from the
* child process's stdout to the respective buffer and emits the signal
* "@ref receivedStderr".
*/
int childOutput( int fdno );
/**
* Called by "slotChildOutput" this function copies data arriving from the
* child process's stdout to the respective buffer and emits the signal
* "@ref receivedStderr"
*/
int childError( int fdno );
// information about the data that has to be sent to the child:
const char *input_data; // the buffer holding the data
int input_sent; // # of bytes already transmitted
int input_total; // total length of input_data
/**
* @ref OProcessController is a friend of OProcess because it has to have
* access to various data members.
*/
friend class Internal::OProcessController;
private:
/**
* Searches for a valid shell.
* Here is the algorithm used for finding an executable shell:
*
* @li Try the executable pointed to by the "SHELL" environment
* variable with white spaces stripped off
*
* @li If your process runs with uid != euid or gid != egid, a shell
* not listed in /etc/shells will not used.
*
* @li If no valid shell could be found, "/bin/sh" is used as a last resort.
*/
QCString searchShell();
/**
* Used by @ref searchShell in order to find out whether the shell found
* is actually executable at all.
*/
bool isExecutable( const QCString &filename );
// Disallow assignment and copy-construction
OProcess( const OProcess& );
OProcess& operator= ( const OProcess& );
private:
void init ( );
Internal::OProcessPrivate *d;
};
}
}
#endif
diff --git a/libopie2/opieui/oimageeffect.h b/libopie2/opieui/oimageeffect.h
index 4f86d5b..4422741 100644
--- a/libopie2/opieui/oimageeffect.h
+++ b/libopie2/opieui/oimageeffect.h
@@ -1,564 +1,564 @@
//FIXME: Revise for Opie - do we really need such fancy stuff on PDA's?
//FIXME: Maybe not on SL5xxx, but surely on C700 :))
//FIXME: I think we don#t need that -zecke
/* This file is part of the KDE libraries
Copyright (C) 1998, 1999, 2001, 2002 Daniel M. Duley <mosfet@interaccess.com>
(C) 1998, 1999 Christian Tibirna <ctibirna@total.net>
(C) 1998, 1999 Dirk A. Mueller <mueller@kde.org>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// $Id$
#ifndef OIMAGEEFFECT_H
#define OIMAGEEFFECT_H
class QImage;
class QSize;
class QColor;
namespace Opie {
namespace Ui {
/**
* This class includes various @ref QImage based graphical effects.
*
* Everything is
* static, so there is no need to create an instance of this class. You can
* just call the static methods. They are encapsulated here merely to provide
* a common namespace.
*/
class OImageEffect
{
public:
enum GradientType { VerticalGradient, HorizontalGradient,
DiagonalGradient, CrossDiagonalGradient,
PyramidGradient, RectangleGradient,
PipeCrossGradient, EllipticGradient };
enum RGBComponent { Red, Green, Blue, Gray, All };
enum Lighting {NorthLite, NWLite, WestLite, SWLite,
SouthLite, SELite, EastLite, NELite};
enum ModulationType { Intensity, Saturation, HueShift, Contrast };
enum NoiseType { UniformNoise=0, GaussianNoise, MultiplicativeGaussianNoise,
ImpulseNoise, LaplacianNoise, PoissonNoise};
enum RotateDirection{ Rotate90, Rotate180, Rotate270 };
/**
* Create a gradient from color a to color b of the specified type.
*
* @param size The desired size of the gradient.
* @param ca Color a
* @param cb Color b
* @param type The type of gradient.
* @param ncols The number of colors to use when not running on a
* truecolor display. The gradient will be dithered to this number of
* colors. Pass 0 to prevent dithering.
*/
static QImage gradient(const QSize &size, const QColor &ca,
const QColor &cb, GradientType type, int ncols=3);
/**
* Create an unbalanced gradient.
* An unbalanced gradient is a gradient where the transition from
* color a to color b is not linear, but in this case, exponential.
*
* @param size The desired size of the gradient.
* @param ca Color a
* @param cb Color b
* @param type The type of gradient.
* @param xfactor The x decay length. Use a value between -200 and 200.
* @param yfactor The y decay length.
* @param ncols The number of colors. See OPixmapEffect:gradient.
*/
static QImage unbalancedGradient(const QSize &size, const QColor &ca,
const QColor &cb, GradientType type, int xfactor = 100,
int yfactor = 100, int ncols = 3);
/**
* Blends a color into the destination image, using an opacity
* value for blending one into another. Very fast direct pixel
* manipulation is used.
*
* @author Karol Szwed (gallium@kde.org)
* @param clr source color to be blended into the destination image.
* @param dst destination image in which the source will be blended into.
* @param opacity opacity (in percent) which determines how much the source
* color will be blended into the destination image.
* @return The destination image (dst) containing the result.
*/
static QImage& blend(const QColor& clr, QImage& dst, float opacity);
/**
* Blend the src image into the destination image, using an opacity
* value for blending one into another. Very fast direct pixel
* manipulation is used.
*
* @author Karol Szwed (gallium@kde.org)
* @param src source image to be blended into the destination image.
* @param dst destination image in which the source will be blended into.
* @param opacity opacity (in percent) which determines how much the source
* image will be blended into the destination image.
* @return The destination image (dst) containing the result.
*/
static QImage& blend(QImage& src, QImage& dst, float opacity);
/**
* Blend the provided image into a background of the indicated color.
*
* @param initial_intensity this parameter takes values from -1 to 1:
* a) if positive: how much to fade the image in its
* less affected spot
* b) if negative: roughly indicates how much of the image
* remains unaffected
* @param bgnd indicates the color of the background to blend in
* @param eff lets you choose what kind of blending you like
* @param anti_dir blend in the opposite direction (makes no much sense
* with concentric blending effects)
* @param image must be 32bpp
*/
static QImage& blend(QImage &image, float initial_intensity,
const QColor &bgnd, GradientType eff,
bool anti_dir=false);
/**
* Blend an image into another one, using a gradient type
* for blending from one to another.
*
* @param image1 source1 and result of blending
* @param image2 source2 of blending
* @param gt gradient type for blending between source1 and source2
* @param xf x decay length for unbalanced gradient tpye
* @param yf y decay length for unbalanced gradient tpye
*/
static QImage& blend(QImage &image1,QImage &image2,
GradientType gt, int xf=100, int yf=100);
/**
* Blend an image into another one, using a color channel of a
* third image for the decision of blending from one to another.
*
* @param image1 Source 1 and result of blending
* @param image2 Source 2 of blending
* @param blendImage If the gray value of of pixel is 0, the result
* for this pixel is that of image1; for a gray value
* of 1, the pixel of image2 is used; for a value
* inbetween, a corresponding blending is used.
* @param channel The RBG channel to use for the blending decision.
*/
static QImage& blend(QImage &image1, QImage &image2,
QImage &blendImage, RGBComponent channel);
/**
* Blend an image into another one, using alpha in the expected way.
* @author Rik Hemsley (rikkus) <rik@kde.org>
*/
static bool blend(const QImage & upper, const QImage & lower, QImage & output);
// Not yet... static bool blend(const QImage & image1, const QImage & image2, QImage & output, const QRect & destRect);
/**
* Blend an image into another one, using alpha in the expected way and
* over coordinates @p x and @p y with respect to the lower image.
* The output is a QImage which is the @p upper image already blended
* with the @p lower one, so its size will be (in general) the same than
* @p upper instead of the same size than @p lower like the method above.
* In fact, the size of @p output is like upper's one only when it can be
* painted on lower, if there has to be some clipping, output's size will
* be the clipped area and x and y will be set to the correct up-left corner
* where the clipped rectangle begins.
*/
static bool blend(int &x, int &y, const QImage & upper, const QImage & lower, QImage & output);
/**
* Blend an image into another one, using alpha in the expected way and
* over coordinates @p x and @p y with respect to the lower image.
* The output is painted in the own @p lower image. This is an optimization
* of the blend method above provided by convenience.
*/
static bool blendOnLower(int x, int y, const QImage & upper, const QImage & lower);
/**
* Modifies the intensity of a pixmap's RGB channel component.
*
* @author Daniel M. Duley (mosfet)
* @param image The QImage to process.
* @param percent Percent value. Use a negative value to dim.
* @param channel Which channel(s) should be modified
* @return The @p image, provided for convenience.
*/
static QImage& channelIntensity(QImage &image, float percent,
RGBComponent channel);
/**
* Fade an image to a certain background color.
*
* The number of colors will not be changed.
*
- * @param image The QImage to process.
+ * @param img The QImage to process.
* @param val The strength of the effect. 0 <= val <= 1.
* @param color The background color.
* @return Returns the @ref image(), provided for convenience.
*/
static QImage& fade(QImage &img, float val, const QColor &color);
/**
* This recolors a pixmap. The most dark color will become color a,
* the most bright one color b, and in between.
*
* @param image A QImage to process.
* @param ca Color a
* @param cb Color b
*/
static QImage& flatten(QImage &image, const QColor &ca,
const QColor &cb, int ncols=0);
/**
* Build a hash on any given @ref QImage
*
* @param image The QImage to process
* @param lite The hash faces the indicated lighting (cardinal poles).
* @param spacing How many unmodified pixels inbetween hashes.
* @return Returns the @ref image(), provided for convenience.
*/
static QImage& hash(QImage &image, Lighting lite=NorthLite,
unsigned int spacing=0);
/**
* Either brighten or dim the image by a specified percent.
* For example, .50 will modify the colors by 50%.
*
* @author Daniel M. Duley (mosfet)
* @param image The QImage to process.
* @param percent The percent value. Use a negative value to dim.
* @return Returns The @ref image(), provided for convenience.
*/
static QImage& intensity(QImage &image, float percent);
/**
* Modulate the image with a color channel of another image.
*
* @param image The QImage to modulate and result.
* @param modImage The QImage to use for modulation.
* @param reverse Invert the meaning of image/modImage; result is image!
* @param type The modulation Type to use.
* @param factor The modulation amplitude; with 0 no effect [-200;200].
* @param channel The RBG channel of image2 to use for modulation.
* @return Returns the @ref image(), provided for convenience.
*/
static QImage& modulate(QImage &image, QImage &modImage, bool reverse,
ModulationType type, int factor, RGBComponent channel);
/**
* Convert an image to grayscale.
*
* @author Daniel M. Duley (mosfet)
* @param image The @ref QImage to process.
* @param fast Set to @p true in order to use a faster but non-photographic
* quality algorithm. Appropriate for things such as toolbar icons.
* @return Returns the @ref image(), provided for convenience.
*/
static QImage& toGray(QImage &image, bool fast = false);
/**
* Desaturate an image evenly.
*
* @param image The QImage to process.
* @param desat A value between 0 and 1 setting the degree of desaturation
* @return Returns the @ref image(), provided for convenience.
*/
static QImage& desaturate(QImage &image, float desat = 0.3);
/**
* Fast, but low quality contrast of an image. Also see contrastHSV.
*
* @author Daniel M. Duley (mosfet)
* @param image The QImage to process.
* @param c A contrast value between -255 to 255.
* @return The @ref image(), provided for convenience.
*/
static QImage& contrast(QImage &image, int c);
/**
* Dither an image using Floyd-Steinberg dithering for low-color
* situations.
*
- * @param image The QImage to process.
+ * @param img The QImage to process.
* @param palette The color palette to use
* @param size The size of the palette
* @return Returns the @ref image(), provided for convenience.
*/
static QImage& dither(QImage &img, const QColor *palette, int size);
/**
* Calculate the image for a selected image, for instance a selected icon
* on the desktop.
* @param img the QImage to select
* @param col the selected color, usually from QColorGroup::highlight().
*/
static QImage& selectedImage( QImage &img, const QColor &col );
/**
* High quality, expensive HSV contrast. You can do a faster one by just
* taking a intensity threshold (ie: 128) and incrementing RGB color
* channels above it and decrementing those below it, but this gives much
* better results.
*
* @author Daniel M. Duley (mosfet)
* @param img The QImage to process.
* @param sharpen If true sharpness is increase, (spiffed). Otherwise
* it is decreased, (dulled).
*/
static void contrastHSV(QImage &img, bool sharpen=true);
/**
* Normalizes the pixel values to span the full range of color values.
* This is a contrast enhancement technique.
* @author Daniel M. Duley (mosfet)
*/
static void normalize(QImage &img);
/**
* Performs histogram equalization on the reference
* image.
* @author Daniel M. Duley (mosfet)
*/
static void equalize(QImage &img);
/**
* Thresholds the reference image. You can also threshold images by using
* ThresholdDither in the various QPixmap/QImage convert methods, but this
* lets you specify a threshold value.
*
* @author Daniel M. Duley (mosfet)
* @param img The QImage to process.
* @param value The threshold value.
*/
static void threshold(QImage &img, unsigned int value=128);
/**
* Produces a 'solarization' effect seen when exposing a photographic
* film to light during the development process.
*
* @author Daniel M. Duley (mosfet)
* @param img The QImage to process.
* @param factor The extent of the solarization (0-99.9)
*/
static void solarize(QImage &img, double factor=50.0);
/**
* Embosses the source image. This involves highlighting the edges
* and applying various other enhancements in order to get a metal
* effect.
*
* @author Daniel M. Duley (mosfet)
* @param src The QImage to process.
* @return The embossed image. The original is not changed.
*/
static QImage emboss(QImage &src);
/**
* Minimizes speckle noise in the source image using the 8 hull
* algorithm.
*
* @author Daniel M. Duley (mosfet)
* @param src The QImage to process.
* @return The despeckled image. The original is not changed.
*/
static QImage despeckle(QImage &src);
/**
* Produces a neat little "charcoal" effect.
*
* @author Daniel M. Duley (mosfet)
* @param src The QImage to process.
* @param factor The factor for detecting lines (0-99.0).
* @return The charcoal image. The original is not changed.
*/
static QImage charcoal(QImage &src, double factor=50.0);
/**
* Rotates the image by the specified amount
*
* @author Daniel M. Duley (mosfet)
* @param src The QImage to process.
* @param r The rotate direction.
* @return The rotated image. The original is not changed.
*/
static QImage rotate(QImage &src, RotateDirection r);
/**
* Scales an image using simple pixel sampling. This does not produce
* nearly as nice a result as QImage::smoothScale(), but has the
* advantage of being much faster - only a few milliseconds.
*
* @author Daniel M. Duley (mosfet)
* @param src The QImage to process.
* @param w The new width.
* @param h The new height.
* @return The scaled image. The original is not changed.
*/
static QImage sample(QImage &src, int w, int h);
/**
* Adds noise to an image.
*
* @author Daniel M. Duley (mosfet)
* @param src The QImage to process.
* @param type The algorithm used to generate the noise.
* @return The image with noise added. The original is not changed.
*/
static QImage addNoise(QImage &src, NoiseType type = GaussianNoise);
/**
* Blurs an image by convolving pixel neighborhoods.
*
* @author Daniel M. Duley (mosfet)
* @param src The QImage to process.
* @param factor The percent weight to give to the center pixel.
* @return The blurred image. The original is not changed.
*/
static QImage blur(QImage &src, double factor=50.0);
/**
* Detects edges in an image using pixel neighborhoods and an edge
* detection mask.
*
* @author Daniel M. Duley (mosfet)
* @param src The QImage to process.
* @param factor The percent weight to give to the center pixel.
* @return The image with edges detected. The original is not changed.
*/
static QImage edge(QImage &src, double factor=50.0);
/**
* Implodes an image by a specified percent.
*
* @author Daniel M. Duley (mosfet)
* @param src The QImage to process.
* @param factor The extent of the implosion.
* @param background An RGBA value to use for the background. After the
* effect some pixels may be "empty". This value is used for those pixels.
* @return The imploded image. The original is not changed.
*/
static QImage implode(QImage &src, double factor=30.0,
unsigned int background = 0xFFFFFFFF);
/**
* Produces an oil painting effect.
*
* @author Daniel M. Duley (mosfet)
* @param src The QImage to process.
* @param radius The radius of the pixel neighborhood used in applying the
* effect.
* @return The new image. The original is not changed.
*/
static QImage oilPaint(QImage &src, int radius=3);
/**
* Sharpens the pixels in the image using pixel neighborhoods.
*
* @author Daniel M. Duley (mosfet)
* @param src The QImage to process.
* @param factor The percent weight to give to the center pixel.
* @return The sharpened image. The original is not changed.
*/
static QImage sharpen(QImage &src, double factor=30.0);
/**
* Randomly displaces pixels.
*
* @author Daniel M. Duley (mosfet)
* @param src The QImage to process.
* @param amount The vicinity for choosing a random pixel to swap.
* @return The image with pixels displaced. The original is not changed.
*/
static QImage spread(QImage &src, unsigned int amount=3);
/**
* Shades the image using a distance light source.
*
* @author Daniel M. Duley (mosfet)
* @param src The QImage to process.
* @param color_shading If true do color shading, otherwise do grayscale.
* @param azimuth Determines the light source and direction.
* @param elevation Determines the light source and direction.
* @return The shaded image. The original is not changed.
*/
static QImage shade(QImage &src, bool color_shading=true, double azimuth=30.0,
double elevation=30.0);
/**
* Swirls the image by a specified amount
*
* @author Daniel M. Duley (mosfet)
* @param src The QImage to process.
* @param degrees The tightness of the swirl.
* @param background An RGBA value to use for the background. After the
* effect some pixels may be "empty". This value is used for those pixels.
* @return The swirled image. The original is not changed.
*/
static QImage swirl(QImage &src, double degrees=50.0, unsigned int background =
0xFFFFFFFF);
/**
* Modifies the pixels along a sine wave.
*
* @author Daniel M. Duley (mosfet)
* @param src The QImage to process.
* @param amplitude The amplitude of the sine wave.
- * @param wavelength The frequency of the sine wave.
+ * @param frequency The frequency of the sine wave.
* @return The new image. The original is not changed.
*/
static QImage wave(QImage &src, double amplitude=25.0, double frequency=150.0,
unsigned int background = 0xFFFFFFFF);
private:
/**
* Helper function to fast calc some altered (lighten, shaded) colors
*
*/
static unsigned int lHash(unsigned int c);
static unsigned int uHash(unsigned int c);
/**
* Helper function to find the nearest color to the RBG triplet
*/
static int nearestColor( int r, int g, int b, const QColor *pal, int size );
static void hull(const int x_offset, const int y_offset, const int polarity,
const int width, const int height,
unsigned int *f, unsigned int *g);
static unsigned int generateNoise(unsigned int pixel, NoiseType type);
static unsigned int interpolateColor(QImage *image, double x, double y,
unsigned int background);
};
}
}
#endif
diff --git a/libopie2/opieui/opixmapeffect.h b/libopie2/opieui/opixmapeffect.h
index b780f9f..85a1e25 100644
--- a/libopie2/opieui/opixmapeffect.h
+++ b/libopie2/opieui/opixmapeffect.h
@@ -1,219 +1,214 @@
/* This file is part of the KDE libraries
Copyright (C) 1998, 1999 Christian Tibirna <ctibirna@total.net>
(C) 1998, 1999 Daniel M. Duley <mosfet@kde.org>
(C) 1998, 1999 Dirk A. Mueller <mueller@kde.org>
*/
// $Id$
#ifndef __OPIXMAP_EFFECT_H
#define __OPIXMAP_EFFECT_H
#include <qsize.h>
typedef QPixmap OPixmap;
class QColor;
namespace Opie {
namespace Ui {
/**
* This class includes various pixmap-based graphical effects.
*
* Everything is
* static, so there is no need to create an instance of this class. You can
* just call the static methods. They are encapsulated here merely to provide
* a common namespace.
*/
class OPixmapEffect
{
public:
enum GradientType { VerticalGradient, HorizontalGradient,
DiagonalGradient, CrossDiagonalGradient,
PyramidGradient, RectangleGradient,
PipeCrossGradient, EllipticGradient };
enum RGBComponent { Red, Green, Blue };
enum Lighting {NorthLite, NWLite, WestLite, SWLite,
SouthLite, SELite, EastLite, NELite};
/**
* Creates a gradient from color a to color b of the specified type.
*
* @param pixmap The pixmap to process.
* @param ca Color a.
* @param cb Color b.
* @param type The type of gradient.
* @param ncols The number of colors to use when not running on a
* truecolor display. The gradient will be dithered to this number of
* colors. Pass 0 to prevent dithering.
* @return Returns the generated pixmap, for convenience.
*/
static OPixmap& gradient(OPixmap& pixmap, const QColor &ca, const QColor &cb,
GradientType type, int ncols=3);
/**
* Creates an unbalanced gradient.
*
* An unbalanced gradient is a gradient where the transition from
* color a to color b is not linear, but in this case, exponential.
*
* @param pixmap The pixmap that should be written.
* @param ca Color a.
* @param cb Color b.
* @param type The type of gradient.
* @param xfactor The x decay length. Use a value between -200 and 200.
* @param yfactor The y decay length.
* @param ncols The number of colors. See #gradient.
* @return The generated pixmap, for convencience.
*/
static OPixmap& unbalancedGradient(OPixmap& pixmap, const QColor &ca,
const QColor &cb, GradientType type, int xfactor = 100,
int yfactor = 100, int ncols=3);
/**
* Creates a pixmap of a given size with the given pixmap.
*
* if the
* given size is bigger than the size of the pixmap, the pixmap is
* tiled.
*
* @param pixmap This is the source pixmap
* @param size The size the new pixmap should have.
* @return The generated, tiled pixmap.
*/
static OPixmap createTiled(const OPixmap& pixmap, QSize size);
/**
* Either brightens or dims a pixmap by a specified ratio.
*
* @param pixmap The pixmap to process.
* @param ratio The ratio to use. Use negative value to dim.
* @return Returns The @ref pixmap(), provided for convenience.
*/
static OPixmap& intensity(OPixmap& pixmap, float ratio);
/**
* Modifies the intensity of a pixmap's RGB channel component.
*
* @param pixmap The pixmap to process.
* @param ratio value. Use negative value to dim.
* @param channel Which channel(s) should be modified
* @return Returns the @ref pixmap(), provided for convenience.
*/
static OPixmap& channelIntensity(OPixmap& pixmap, float ratio,
RGBComponent channel);
/**
* Blends the provided pixmap into a background of the indicated color.
*
* @param pixmap The pixmap to process.
* @param initial_intensity this parameter takes values from -1 to 1:
* @li If positive, it tells how much to fade the image in its
* less affected spot.
* @li If negative, it tells roughly indicates how much of the image
* remains unaffected
* @param bgnd Indicates the color of the background to blend in.
* @param eff Lets you choose what kind of blending you like.
* @param anti_dir Blend in the opposite direction (makes no much sense
* with concentric blending effects).
* @return Returns the @ref pixmap(), provided for convenience.
*/
static OPixmap& blend(OPixmap& pixmap, float initial_intensity,
const QColor &bgnd, GradientType eff,
bool anti_dir=false, int ncols=3);
/**
* Builds a hash on any given pixmap.
*
* @param pixmap The pixmap to process.
* @param lite The hash faces the indicated lighting (cardinal poles)
* @param spacing How many unmodified pixels inbetween hashes.
* @return Returns The @ref pixmap(), provided for convenience.
*/
static OPixmap& hash(OPixmap& pixmap, Lighting lite=NorthLite,
unsigned int spacing=0, int ncols=3);
/**
* Creates a pattern from a pixmap.
*
* The given pixmap is "flattened"
* between color a to color b.
*
* @param pixmap The pixmap to process.
* @param ca Color a.
* @param cb Color b.
* @param ncols The number of colors to use. The image will be
* dithered to this depth. Pass zero to prevent dithering.
* @return The @ref pixmap(), provided for convenience.
*/
static OPixmap pattern(const OPixmap& pixmap, QSize size,
const QColor &ca, const QColor &cb, int ncols=8);
/**
- * Recolors a pixmap.
- *
- * The most dark color will become color a,
- * the most bright one color b, and in between.
+ * Fades a pixmap to a certain color.
*
* @param pixmap The pixmap to process.
- * @param ca Color a.
- * @param cb Color b.
- * @param ncols The number of colors to use. Pass zero to prevent
- * dithering.
+ * @param val The strength of the effect. 0 <= val <= 1.
+ * @param color The color to blend to.
* @return Returns the @ref pixmap(), provided for convenience.
*/
static OPixmap& fade(OPixmap& pixmap, double val, const QColor &color);
/**
* Converts a pixmap to grayscale.
*
* @param pixmap The pixmap to process.
* @param fast Set to @p true in order to use a faster but non-photographic
* quality algorithm. Appropriate for things such as toolbar icons.
* @return Returns the @ref pixmap(), provided for convenience.
*/
static OPixmap& toGray(OPixmap& pixmap, bool fast=false);
/**
* Desaturates a pixmap.
*
* @param pixmap The pixmap to process.
* @param desat A value between 0 and 1 setting the degree of desaturation
* @return Returns The @ref pixmap(), provided for convenience.
*/
static OPixmap& desaturate(OPixmap& pixmap, float desat = 0.3);
/**
* Modifies the contrast of a pixmap.
*
* @param pixmap The pixmap to process.
* @param c A contrast value between -255 and 255.
* @return Returns the @ref pixmap(), provided for convenience.
*/
static OPixmap& contrast(OPixmap& pixmap, int c);
/**
* Dithers a pixmap using Floyd-Steinberg dithering for low-color
* situations.
*
* @param pixmap The pixmap to process.
* @param palette The color palette to use.
* @param size The size of the palette.
* @return Returns the @ref pixmap(), provided for convenience.
*/
static OPixmap& dither(OPixmap &pixmap, const QColor *palette, int size);
/**
* Calculate a 'selected' pixmap, for instance a selected icon
* on the desktop.
* @param pixmap the pixmap to select
* @param col the selected color, usually from QColorGroup::highlight().
*/
static OPixmap selectedPixmap( const OPixmap &pixmap, const QColor &col );
};
}
}
#endif
diff --git a/libopie2/qt3/opieui/ocombobox.h b/libopie2/qt3/opieui/ocombobox.h
index 4e35b61..3f60f54 100644
--- a/libopie2/qt3/opieui/ocombobox.h
+++ b/libopie2/qt3/opieui/ocombobox.h
@@ -1,356 +1,356 @@
/*
This file Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
is part of the Copyright (C) 2000 Carsten Pfeiffer <pfeiffer@kde.org>
Opie Project Copyright (C) 2000 Dawit Alemayehu <adawit@kde.org>
=. Originally part of the KDE projects
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program 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., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OCOMBOBOX_H
#define OCOMBOBOX_H
/* QT */
#include <qcombobox.h>
/* OPIE */
#include <opie2/olineedit.h>
#include <opie2/ocompletion.h>
#include <opie2/ocompletionbase.h>
/* FORWARDS */
class QListBoxItem;
class QPopupMenu;
class OCompletionBox;
typedef QString OURL;
/**
* A combined button, line-edit and a popup list widget.
*
- * @sect Detail
+ * @par Detail
*
* This widget inherits from @ref QComboBox and implements
* the following additional functionalities: a completion
* object that provides both automatic and manual text
* completion as well as text rotation features, configurable
* key-bindings to activate these features, and a popup-menu
* item that can be used to allow the user to set text completion
* modes on the fly based on their preference.
*
* To support these new features OComboBox also emits a few
* more additional signals as well. The main ones are the
* @ref completion( const QString& ) and @ref textRotation( KeyBindingType )
* signals. The completion signal is intended to be connected to a slot
* that will assist the user in filling out the remaining text while
* the rotation signals is intended to be used to traverse through all
* possible matches whenever text completion results in multiple matches.
* The @ref returnPressed() and @ref returnPressed( const QString& )
* signal is emitted when the user presses the Enter/Return key.
*
* This widget by default creates a completion object when you invoke
* the @ref completionObject( bool ) member function for the first time
* or use @ref setCompletionObject( OCompletion*, bool ) to assign your
* own completion object. Additionally, to make this widget more functional,
* OComboBox will by default handle the text rotation and completion
* events internally whenever a completion object is created through either
* one of the methods mentioned above. If you do not need this functionality,
* simply use @ref OCompletionBase::setHandleSignals( bool ) or alternatively
* set the boolean parameter in the above methods to FALSE.
*
* The default key-bindings for completion and rotation is determined
* from the global settings in @ref OStdAccel. These values, however,
* can be overriden locally by invoking @ref OCompletionBase::setKeyBinding().
* The values can easily be reverted back to the default setting, by simply
* calling @ref useGlobalSettings(). An alternate method would be to default
* individual key-bindings by usning @ref setKeyBinding() with the default
* second argument.
*
* Note that if this widget is not editable ( i.e. select-only ), then only
* one completion mode, @p CompletionAuto, will work. All the other modes are
* simply ignored. The @p CompletionAuto mode in this case allows you to
* automatically select an item from the list by trying to match the pressed
* keycode with the first letter of the enteries in the combo box.
*
- * @sect Useage
+ * @par Usage
*
* To enable the basic completion feature:
*
* <pre>
* OComboBox *combo = new OComboBox( true, this, "mywidget" );
* OCompletion *comp = combo->completionObject();
* // Connect to the return pressed signal - optional
* connect(combo,SIGNAL(returnPressed(const QString&)),comp,SLOT(addItem(const QString&));
* </pre>
*
* To use your own completion object:
*
* <pre>
* OComboBox *combo = new OComboBox( this,"mywidget" );
* OURLCompletion *comp = new OURLCompletion();
* combo->setCompletionObject( comp );
* // Connect to the return pressed signal - optional
* connect(combo,SIGNAL(returnPressed(const QString&)),comp,SLOT(addItem(const QString&));
* </pre>
*
* Note that you have to either delete the allocated completion object
* when you don't need it anymore, or call
* setAutoDeleteCompletionObject( true );
*
* Miscellaneous function calls:
*
* <pre>
* // Tell the widget not to handle completion and rotation
* combo->setHandleSignals( false );
* // Set your own completion key for manual completions.
* combo->setKeyBinding( OCompletionBase::TextCompletion, Qt::End );
* // Hide the context (popup) menu
* combo->setContextMenuEnabled( false );
* // Temporarly disable signal emition
* combo->disableSignals();
* // Default the all key-bindings to their system-wide settings.
* combo->useGlobalKeyBindings();
* </pre>
*
* @short An enhanced combo box.
* @author Dawit Alemayehu <adawit@kde.org>
*/
class OComboBox : public QComboBox, public OCompletionBase
{
Q_OBJECT
//Q_PROPERTY( bool autoCompletion READ autoCompletion WRITE setAutoCompletion )
//Q_PROPERTY( bool contextMenuEnabled READ isContextMenuEnabled WRITE setContextMenuEnabled )
//Q_PROPERTY( bool urlDropsEnabled READ isURLDropsEnabled WRITE setURLDropsEnabled )
public:
/**
* Constructs a read-only or rather select-only combo box with a
* parent object and a name.
*
* @param parent The parent object of this widget
* @param name The name of this widget
*/
OComboBox( QWidget *parent=0, const char *name=0 );
/**
* Constructs a "read-write" or "read-only" combo box depending on
* the value of the first argument( @p rw ) with a parent, a
* name.
*
* @param rw When @p true, widget will be editable.
* @param parent The parent object of this widget.
* @param name The name of this widget.
*/
OComboBox( bool rw, QWidget *parent=0, const char *name=0 );
/**
* Destructor.
*/
virtual ~OComboBox();
/**
* Sets @p url into the edit field of the combobox. It uses
* @ref OURL::prettyURL() so that the url is properly decoded for
* displaying.
*/
//void setEditURL( const OURL& url );
/**
* Inserts @p url at position @p index into the combobox. The item will
* be appended if @p index is negative. @ref OURL::prettyURL() is used
* so that the url is properly decoded for displaying.
*/
//void insertURL( const OURL& url, int index = -1 );
/**
* Inserts @p url with the pixmap &p pixmap at position @p index into
* the combobox. The item will be appended if @p index is negative.
* @ref OURL::prettyURL() is used so that the url is properly decoded
* for displaying.
*/
//void insertURL( const QPixmap& pixmap, const OURL& url, int index = -1 );
/**
* Replaces the item at position @p index with @p url.
* @ref OURL::prettyURL() is used so that the url is properly decoded
* for displaying.
*/
//void changeURL( const OURL& url, int index );
/**
* Replaces the item at position @p index with @p url and pixmap @p pixmap.
* @ref OURL::prettyURL() is used so that the url is properly decoded
* for displaying.
*/
//void changeURL( const QPixmap& pixmap, const OURL& url, int index );
/**
* Returns the current cursor position.
*
* This method always returns a -1 if the combo-box is @em not
* editable (read-write).
*
* @return Current cursor position.
*/
int cursorPosition() const { return ( lineEdit() ) ? lineEdit()->cursorPosition() : -1; }
/**
* Re-implemented from @ref QComboBox.
*
* If @p true, the completion mode will be set to automatic.
* Otherwise, it is defaulted to the global setting. This
* method has been replaced by the more comprehensive
* @ref setCompletionMode().
*
* @param autocomplete Flag to enable/disable automatic completion mode.
*/
virtual void setAutoCompletion( bool autocomplete );
/**
* Re-implemented from QComboBox.
*
* Returns @p true if the current completion mode is set
* to automatic. See its more comprehensive replacement
* @ref completionMode().
*
* @return @p true when completion mode is automatic.
*/
bool autoCompletion() const {
return completionMode() == OGlobalSettings::CompletionAuto;
}
/**
* Enables or disable the popup (context) menu.
*
* This method only works if this widget is editable, i.e.
* read-write and allows you to enable/disable the context
* menu. It does nothing if invoked for a none-editable
* combo-box. Note that by default the mode changer item
* is made visiable whenever the context menu is enabled.
* Use @ref hideModechanger() if you want to hide this
* item. Also by default, the context menu is created if
* this widget is editable. Call this function with the
* argument set to false to disable the popup menu.
*
* @param showMenu If @p true, show the context menu.
* @param showMode If @p true, show the mode changer.
*/
virtual void setContextMenuEnabled( bool showMenu );
/**
* Returns @p true when the context menu is enabled.
*/
bool isContextMenuEnabled() const { return m_bEnableMenu; }
/**
* Enables/Disables handling of URL drops. If enabled and the user
* drops an URL, the decoded URL will be inserted. Otherwise the default
* behaviour of QComboBox is used, which inserts the encoded URL.
*
* @param enable If @p true, insert decoded URLs
*/
//void setURLDropsEnabled( bool enable );
/**
* Returns @p true when decoded URL drops are enabled
*/
//bool isURLDropsEnabled() const;
/**
* Convenience method which iterates over all items and checks if
* any of them is equal to @p text.
*
* If @p text is an empty string, @p false
* is returned.
*
* @return @p true if an item with the string @p text is in the combobox.
*/
bool contains( const QString& text ) const;
/**
* By default, OComboBox recognizes Key_Return and Key_Enter
* and emits
* the @ref returnPressed() signals, but it also lets the event pass,
* for example causing a dialog's default-button to be called.
*
* Call this method with @p trap equal to true to make OComboBox
* stop these
* events. The signals will still be emitted of course.
*
* Only affects read-writable comboboxes.
*
* @see setTrapReturnKey()
*/
void setTrapReturnKey( bool trap );
/**
* @return @p true if keyevents of Key_Return or Key_Enter will
* be stopped or if they will be propagated.
*
* @see setTrapReturnKey ()
*/
bool trapReturnKey() const;
/**
* Re-implemented for internal reasons. API not affected.
*
* @reimplemented
*/
virtual bool eventFilter( QObject *, QEvent * );
/**
* @returns the completion-box, that is used in completion mode
* @ref OGlobalSettings::CompletionPopup and @ref OGlobalSettings::CompletionPopupAuto.
* This method will create a completion-box by calling
* @ref OLineEdit::completionBox, if none is there, yet.
*
* @param create Set this to false if you don't want the box to be created
* i.e. to test if it is available.
*/
OCompletionBox * completionBox( bool create = true );
virtual void setLineEdit( OLineEdit * );
signals:
/**
* Emitted when the user presses the Enter key.
*
* Note that this signal is only
* emitted if this widget is editable.
*/
void returnPressed();
/**
* Emitted when the user presses
* the Enter key.
*
* The argument is the current
* text being edited. This signal is just like
* @ref returnPressed() except it contains the
diff --git a/libopie2/qt3/opieui/olineedit.h b/libopie2/qt3/opieui/olineedit.h
index ecfca27..db3d7ef 100644
--- a/libopie2/qt3/opieui/olineedit.h
+++ b/libopie2/qt3/opieui/olineedit.h
@@ -1,384 +1,384 @@
/*
This file Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
is part of the Copyright (C) 2001 Carsten Pfeiffer <pfeiffer@kde.org>, Dawit Alemayehu <adawit@kde.org>
Opie Project Copyright (C) 1999 Preston Brown <pbrown@kde.org>, Patrick Ward <PAT_WARD@HP-USA-om5.om.hp.com>
Copyright (C) 1997 Sven Radej (sven.radej@iname.com)
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program 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., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OLINEEDIT_H
#define OLINEEDIT_H
/* QT */
#include <qlineedit.h>
/* OPIE */
#include <opie2/ocompletion.h>
#include <opie2/ocompletionbase.h>
class QPopupMenu;
class OCompletionBox;
typedef QString KURL; //class KURL;
/**
* An enhanced QLineEdit widget for inputting text.
*
- * @sect Detail
+ * @par Detail
*
* This widget inherits from @ref QLineEdit and implements the following
* additional functionalities: q completion object that provides both
* automatic and manual text completion as well as multiple match iteration
* features, configurable key-bindings to activate these features and a
* popup-menu item that can be used to allow the user to set text completion
* modes on the fly based on their preference.
*
* To support these new features OLineEdit also emits a few more
* additional signals. These are: @ref completion( const QString& ),
* textRotation( KeyBindingType ), and @ref returnPressed( const QString& ).
* The completion signal can be connected to a slot that will assist the
* user in filling out the remaining text. The text rotation signal is
* intended to be used to iterate through the list of all possible matches
* whenever there is more than one match for the entered text. The
* @p returnPressed( const QString& ) signals are the same as QLineEdit's
* except it provides the current text in the widget as its argument whenever
* appropriate.
*
* This widget by default creates a completion object when you invoke
* the @ref completionObject( bool ) member function for the first time or
* use @ref setCompletionObject( OCompletion*, bool ) to assign your own
* completion object. Additionally, to make this widget more functional,
* OLineEdit will by default handle the text rotation and completion
* events internally when a completion object is created through either one
* of the methods mentioned above. If you do not need this functionality,
* simply use @ref OCompletionBase::setHandleSignals( bool ) or set the
* boolean parameter in the above functions to FALSE.
*
* The default key-bindings for completion and rotation is determined
* from the global settings in @ref OStdAccel. These values, however,
* can be overriden locally by invoking @ref OCompletionBase::setKeyBinding().
* The values can easily be reverted back to the default setting, by simply
* calling @ref useGlobalSettings(). An alternate method would be to default
* individual key-bindings by usning @ref setKeyBinding() with the default
* second argument.
*
* NOTE that if the @p EchoMode for this widget is set to something other
* than @p QLineEdit::Normal, the completion mode will always be defaulted
* to @ref PGlobalSettings::CompletionNone. This is done purposefully to guard
* against protected entries such as passwords being cached in @ref OCompletion's
* list. Hence, if the @p EchoMode is not @ref QLineEdit::Normal, the completion
* mode is automatically disabled.
*
- * @sect Useage
+ * @par Usage
*
* To enable the basic completion feature :
*
* <pre>
* OLineEdit *edit = new OLineEdit( this, "mywidget" );
* OCompletion *comp = edit->completionObject();
* // Fill the completion object with a list of possible matches
* QStringList list;
* list << "mickeyl@handhelds.org" << "mickey@tm.informatik.uni-frankfurt.de>" << "mickey@Vanille.de";
* comp->setItems( list );
* // Connect to the return pressed signal (optional)
* connect(edit,SIGNAL(returnPressed(const QString&)),comp,SLOT(addItem(const QString&));
* </pre>
*
* To use a customized completion objects or your
* own completion object :
*
* <pre>
* OLineEdit *edit = new OLineEdit( this,"mywidget" );
* KURLCompletion *comp = new KURLCompletion();
* edit->setCompletionObject( comp );
* // Connect to the return pressed signal - optional
* connect(edit,SIGNAL(returnPressed(const QString&)),comp,SLOT(addItem(const QString&));
* </pre>
*
* Note that you have to either delete the allocated completion object
* when you don't need it anymore, or call
* setAutoDeleteCompletionObject( true );
*
- * @sect Miscellaneous function calls :
+ * @par Miscellaneous function calls :
*
* <pre>
* // Tell the widget not to handle completion and
* // iteration internally.
* edit->setHandleSignals( false );
* // Set your own completion key for manual completions.
* edit->setKeyBinding( OCompletionBase::TextCompletion, Qt::End );
* // Hide the context (popup) menu
* edit->setContextMenuEnabled( false );
* // Temporarly disable signal emitions
* // (both completion & iteration signals)
* edit->disableSignals();
* // Default the key-bindings to system settings.
* edit->useGlobalKeyBindings();
* </pre>
*
* @short An enhanced single line input widget.
* @author Dawit Alemayehu <adawit@kde.org>
* @author Opie adaption by Michael Lauer <mickey@tm.informatik.uni-frankfurt.de>
*/
class OLineEdit : public QLineEdit, public OCompletionBase
{
friend class OComboBox;
Q_OBJECT
Q_PROPERTY( bool contextMenuEnabled READ isContextMenuEnabled WRITE setContextMenuEnabled )
Q_PROPERTY( bool urlDropsEnabled READ isURLDropsEnabled WRITE setURLDropsEnabled )
public:
/**
* Constructs a OLineEdit object with a default text, a parent,
* and a name.
*
* @param string Text to be shown in the edit widget.
* @param parent The parent object of this widget.
* @param name the name of this widget
*/
OLineEdit( const QString &string, QWidget *parent, const char *name = 0 );
/**
* Constructs a OLineEdit object with a parent and a name.
*
* @param string Text to be shown in the edit widget.
* @param parent The parent object of this widget.
* @param name The name of this widget.
*/
OLineEdit ( QWidget *parent=0, const char *name=0 );
/**
* Destructor.
*/
virtual ~OLineEdit ();
/**
* Sets @p url into the lineedit. It uses @ref KURL::prettyURL() so
* that the url is properly decoded for displaying.
*/
void setURL( const KURL& url );
/**
* Puts the text cursor at the end of the string.
*
* This method is deprecated. Use @ref QLineEdit::end()
* instead.
*
* @deprecated
* @ref QLineEdit::end()
*/
void cursorAtEnd() { end( false ); }
/**
* Re-implemented from @ref OCompletionBase for internal reasons.
*
* This function is re-implemented in order to make sure that
* the EchoMode is acceptable before we set the completion mode.
*
* See @ref OCompletionBase::setCompletionMode
*/
virtual void setCompletionMode( OGlobalSettings::Completion mode );
/**
* Enables/disables the popup (context) menu.
*
* Note that when this function is invoked with its argument
* set to @p true, then both the context menu and the completion
* menu item are enabled. If you do not want to the completion
* item to be visible simply invoke @ref hideModechanger() right
* after calling this method. Also by default, the context
* menu is automatically created if this widget is editable. Thus
* you need to call this function with the argument set to false
* if you do not want this behaviour.
*
* @param showMenu If @p true, show the context menu.
*/
virtual void setContextMenuEnabled( bool showMenu ) { m_bEnableMenu = showMenu; }
/**
* Returns @p true when the context menu is enabled.
*/
bool isContextMenuEnabled() const { return m_bEnableMenu; }
/**
* Enables/Disables handling of URL drops. If enabled and the user
* drops an URL, the decoded URL will be inserted. Otherwise the default
* behaviour of QLineEdit is used, which inserts the encoded URL.
*
* @param enable If @p true, insert decoded URLs
*/
void setURLDropsEnabled( bool enable );
/**
* Returns @p true when decoded URL drops are enabled
*/
bool isURLDropsEnabled() const;
/**
* By default, OLineEdit recognizes @p Key_Return and @p Key_Enter and emits
* the @ref returnPressed() signals, but it also lets the event pass,
* for example causing a dialog's default-button to be called.
*
* Call this method with @p trap = @p true to make @p OLineEdit stop these
* events. The signals will still be emitted of course.
*
* @see trapReturnKey()
*/
void setTrapReturnKey( bool trap );
/**
* @returns @p true if keyevents of @p Key_Return or
* @p Key_Enter will be stopped or if they will be propagated.
*
* @see setTrapReturnKey ()
*/
bool trapReturnKey() const;
/**
* Re-implemented for internal reasons. API not affected.
*
* @reimplemented
*/
virtual bool eventFilter( QObject *, QEvent * );
/**
* @returns the completion-box, that is used in completion mode
* @ref KGlobalSettings::CompletionPopup.
* This method will create a completion-box if none is there, yet.
*
* @param create Set this to false if you don't want the box to be created
* i.e. to test if it is available.
*/
OCompletionBox * completionBox( bool create = true );
/**
* Reimplemented for internal reasons, the API is not affected.
*/
virtual void setCompletionObject( OCompletion *, bool hsig = true );
signals:
/**
* Emitted when the user presses the return key.
*
* The argument is the current text. Note that this
* signal is @em not emitted if the widget's @p EchoMode is set to
* @ref QLineEdit::EchoMode.
*/
void returnPressed( const QString& );
/**
* Emitted when the completion key is pressed.
*
* Please note that this signal is @em not emitted if the
* completion mode is set to @p CompletionNone or @p EchoMode is
* @em normal.
*/
void completion( const QString& );
/**
* Emitted when the shortcut for substring completion is pressed.
*/
void substringCompletion( const QString& );
/**
* Emitted when the text rotation key-bindings are pressed.
*
* The argument indicates which key-binding was pressed.
* In OLineEdit's case this can be either one of two values:
* @ref PrevCompletionMatch or @ref NextCompletionMatch. See
* @ref OCompletionBase::setKeyBinding for details.
*
* Note that this signal is @em not emitted if the completion
* mode is set to @p KGlobalSettings::CompletionNone or @p echoMode() is @em not normal.
*/
void textRotation( OCompletionBase::KeyBindingType );
/**
* Emitted when the user changed the completion mode by using the
* popupmenu.
*/
void completionModeChanged( OGlobalSettings::Completion );
/**
* Emitted before the context menu is displayed.
*
* The signal allows you to add your own entries into the
* the context menu that is created on demand.
*
* NOTE: Do not store the pointer to the QPopupMenu
* provided through since it is created and deleted
* on demand.
*
* @param the context menu about to be displayed
*/
void aboutToShowContextMenu( QPopupMenu* );
public slots:
/**
* Re-implemented for internal reasons. API not changed.
*/
virtual void setReadOnly(bool);
/**
* Iterates through all possible matches of the completed text or
* the history list.
*
* This function simply iterates over all possible matches in case
* multimple matches are found as a result of a text completion request.
* It will have no effect if only a single match is found.
*
* @param type The key-binding invoked.
*/
void rotateText( OCompletionBase::KeyBindingType /* type */ );
/**
* See @ref OCompletionBase::setCompletedText.
*/
virtual void setCompletedText( const QString& );
/**
* Sets @p items into the completion-box if @ref completionMode() is
* CompletionPopup. The popup will be shown immediately.
*/
void setCompletedItems( const QStringList& items );
/**
* Reimplemented to workaround a buggy QLineEdit::clear()
* (changing the clipboard to the text we just had in the lineedit)
*/
virtual void clear();
protected slots: