summaryrefslogtreecommitdiff
path: root/core/applets
Side-by-side diff
Diffstat (limited to 'core/applets') (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/cardmon/cardmon.cpp8
-rw-r--r--core/applets/clipboardapplet/clipboard.cpp8
-rw-r--r--core/applets/clockapplet/clock.cpp6
-rw-r--r--core/applets/irdaapplet/irda.cpp4
-rw-r--r--core/applets/multikeyapplet/multikey.cpp4
-rw-r--r--core/applets/rotateapplet/rotate.cpp4
-rw-r--r--core/applets/screenshotapplet/screenshot.cpp6
-rw-r--r--core/applets/vmemo/vmemo.cpp4
-rw-r--r--core/applets/volumeapplet/volume.cpp36
9 files changed, 40 insertions, 40 deletions
diff --git a/core/applets/cardmon/cardmon.cpp b/core/applets/cardmon/cardmon.cpp
index 7625545..e8072c6 100644
--- a/core/applets/cardmon/cardmon.cpp
+++ b/core/applets/cardmon/cardmon.cpp
@@ -1,157 +1,157 @@
/*
* cardmon.cpp
*
* ---------------------
*
* copyright : (c) 2002 by Maximilian Reiss
* email : max.reiss@gmx.de
* based on two apps by Devin Butterfield
*/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "cardmon.h"
/* OPIE */
#include <opie2/odevice.h>
#include <opie2/otaskbarapplet.h>
#include <qpe/applnk.h>
#include <qpe/resource.h>
/* QT */
#include <qcopchannel_qws.h>
#include <qpainter.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qsound.h>
#include <qtimer.h>
/* STD */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
#include <sys/vfs.h>
#include <mntent.h>
#endif
using namespace Opie;
CardMonitor::CardMonitor( QWidget * parent ) : QWidget( parent ),
pm( Resource::loadPixmap( "cardmon/pcmcia" ) )
{
QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this );
connect( pcmciaChannel,
- SIGNAL( received( const QCString &, const QByteArray & ) ), this,
- SLOT( cardMessage( const QCString &, const QByteArray & ) ) );
+ SIGNAL( received(const QCString&,const QByteArray&) ), this,
+ SLOT( cardMessage(const QCString&,const QByteArray&) ) );
QCopChannel *sdChannel = new QCopChannel( "QPE/Card", this );
connect( sdChannel,
- SIGNAL( received( const QCString &, const QByteArray & ) ), this,
- SLOT( cardMessage( const QCString &, const QByteArray & ) ) );
+ SIGNAL( received(const QCString&,const QByteArray&) ), this,
+ SLOT( cardMessage(const QCString&,const QByteArray&) ) );
cardInPcmcia0 = FALSE;
cardInPcmcia1 = FALSE;
cardInSd = FALSE;
setFocusPolicy( NoFocus );
setFixedWidth ( AppLnk::smallIconSize() );
setFixedHeight ( AppLnk::smallIconSize() );
getStatusPcmcia( TRUE );
getStatusSd( TRUE );
repaint( FALSE );
popupMenu = 0;
}
CardMonitor::~CardMonitor()
{
if ( popupMenu )
{
delete popupMenu;
}
}
void CardMonitor::popUp( QString message, QString icon )
{
if ( !popupMenu )
{
popupMenu = new QPopupMenu( this );
}
popupMenu->clear();
if ( icon.isEmpty() )
{
popupMenu->insertItem( message, 0 );
}
else
{
popupMenu->insertItem( QIconSet( Resource::loadPixmap( icon ) ),
message, 0 );
}
QPoint p = mapToGlobal( QPoint( 0, 0 ) );
QSize s = popupMenu->sizeHint();
popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ),
p.y() - s.height() ), 0 );
QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) );
}
void CardMonitor::popupTimeout()
{
popupMenu->hide();
}
void CardMonitor::mousePressEvent( QMouseEvent * )
{
QPopupMenu * menu = new QPopupMenu( this );
QString cmd;
int err = 0;
if ( cardInSd )
{
menu->insertItem( QIconSet( Resource::loadPixmap( "cardmon/ide" ) ),
tr( "Eject SD/MMC card" ), 0 );
}
if ( cardInPcmcia0 )
{
menu->
insertItem( QIconSet
( Resource::loadPixmap( "cardmon/" + cardInPcmcia0Type ) ),
tr( "Eject card 0: %1" ).arg( cardInPcmcia0Name ), 1 );
}
if ( cardInPcmcia1 )
{
menu->
insertItem( QIconSet
( Resource::loadPixmap( "cardmon/" + cardInPcmcia1Type ) ),
tr( "Eject card 1: %1" ).arg( cardInPcmcia1Name ), 2 );
}
QPoint p = mapToGlobal( QPoint( 0, 0 ) );
QSize s = menu->sizeHint();
int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ),
p.y() - s.height() ), 0 );
if ( opt == 1 )
{
cmd = "/sbin/cardctl eject 0";
err = system( ( const char * ) cmd );
if ( err != 0 )
{
qDebug( "Could not execute `/sbin/cardctl eject 0'! err=%d",
err );
diff --git a/core/applets/clipboardapplet/clipboard.cpp b/core/applets/clipboardapplet/clipboard.cpp
index 34d151e..4fc8076 100644
--- a/core/applets/clipboardapplet/clipboard.cpp
+++ b/core/applets/clipboardapplet/clipboard.cpp
@@ -1,189 +1,189 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of 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 "clipboard.h"
#include <opie2/otaskbarapplet.h>
#include <qpe/resource.h>
#include <qpe/applnk.h>
#include <qpainter.h>
#include <qpopupmenu.h>
#include <qwindowsystem_qws.h>
#include <qapplication.h>
#include <qclipboard.h>
#include <qtimer.h>
//===========================================================================
ClipboardApplet::ClipboardApplet( QWidget *parent, const char *name ) : QWidget( parent, name )
{
setFixedWidth ( AppLnk::smallIconSize() );
setFixedHeight ( AppLnk::smallIconSize() );
QImage img = Resource::loadImage( "paste");
img = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
m_clipboardPixmap.convertFromImage( img );
m_timer = new QTimer ( this );
- connect ( QApplication::clipboard ( ), SIGNAL( dataChanged ( )), this, SLOT( newData ( )));
- connect ( m_timer, SIGNAL( timeout ( )), this, SLOT( newData ( )));
- connect ( qApp, SIGNAL( aboutToQuit ( )), this, SLOT( shutdown ( )));
+ connect ( QApplication::clipboard ( ), SIGNAL( dataChanged()), this, SLOT( newData()));
+ connect ( m_timer, SIGNAL( timeout()), this, SLOT( newData()));
+ connect ( qApp, SIGNAL( aboutToQuit()), this, SLOT( shutdown()));
m_menu = 0;
m_dirty = true;
m_lasttext = QString::null;
m_timer-> start ( 0, true );
}
ClipboardApplet::~ClipboardApplet ( )
{
}
int ClipboardApplet::position()
{
return 6;
}
void ClipboardApplet::shutdown ( )
{
// the timer has to be stopped, or Qt/E will hang on quit()
// see launcher/desktop.cpp
m_timer-> stop ( );
}
void ClipboardApplet::mousePressEvent ( QMouseEvent *)
{
if ( m_dirty ) {
delete m_menu;
m_menu = new QPopupMenu ( this );
m_menu-> setCheckable ( true );
if ( m_history. count ( )) {
for ( unsigned int i = 0; i < m_history. count ( ); i++ ) {
QString str = m_history [i];
if ( str. length ( ) > 20 )
str = str. left ( 20 ) + "...";
m_menu-> insertItem ( QString ( "%1: %2" ). arg ( i + 1 ). arg ( str ), i );
m_menu-> setItemChecked ( i, false );
}
m_menu-> setItemChecked ( m_history. count ( ) - 1, true );
m_menu-> insertSeparator ( );
}
m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "cut" )), tr( "Cut" ), 100 );
m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "copy" )), tr( "Copy" ), 101 );
m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "paste" )), tr( "Paste" ), 102 );
- connect ( m_menu, SIGNAL( activated ( int )), this, SLOT( action ( int )));
+ connect ( m_menu, SIGNAL( activated(int)), this, SLOT( action(int)));
m_dirty = false;
}
QPoint p = mapToGlobal ( QPoint ( 0, 0 ));
QSize s = m_menu-> sizeHint ( );
m_menu-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( )));
}
void ClipboardApplet::action(int id)
{
ushort unicode = 0;
int scan = 0;
switch ( id ) {
case 100:
unicode = 'X' - '@';
scan = Key_X; // Cut
break;
case 101:
unicode = 'C' - '@';
scan = Key_C; // Copy
break;
case 102:
unicode = 'V' - '@';
scan = Key_V; // Paste
break;
default:
if (( id >= 0 ) && ( uint( id ) < m_history. count ( ))) {
QApplication::clipboard ( )-> setText ( m_history [id] );
for ( uint i = 0; i < m_history. count ( ); i++ )
m_menu-> setItemChecked ( i, i == uint( id ));
unicode = 'V' - '@';
scan = Key_V;
}
break;
}
if ( scan ) {
qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, true, false );
qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, false, false );
}
}
void ClipboardApplet::paintEvent ( QPaintEvent* )
{
QPainter p ( this );
/* center the height but our pixmap is as big as the height ;)*/
p. drawPixmap( 0, 0,
m_clipboardPixmap );
}
void ClipboardApplet::newData ( )
{
static bool excllock = false;
if ( excllock )
return;
else
excllock = true;
m_timer-> stop ( );
QCString type = "plain";
QString txt = QApplication::clipboard ( )-> text ( type );
if ( !txt. isEmpty ( ) && !m_history. contains ( txt )) {
m_history. append ( txt );
if ( m_history. count ( ) > 5 )
m_history. remove ( m_history. begin ( ));
m_dirty = true;
}
m_timer-> start ( 1500, true );
excllock = false;
}
Q_EXPORT_INTERFACE()
{
Q_CREATE_INSTANCE( OTaskbarAppletWrapper<ClipboardApplet> );
}
diff --git a/core/applets/clockapplet/clock.cpp b/core/applets/clockapplet/clock.cpp
index 9fead03..120a019 100644
--- a/core/applets/clockapplet/clock.cpp
+++ b/core/applets/clockapplet/clock.cpp
@@ -1,121 +1,121 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of 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 "clock.h"
#include <opie2/otaskbarapplet.h>
#include <qpe/qpeapplication.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/config.h>
LauncherClock::LauncherClock( QWidget *parent ) : QLabel( parent )
{
// If you want a sunken border around the clock do this:
// setFrameStyle( QFrame::Panel | QFrame::Sunken );
//setFont( QFont( "Helvetica", , QFont::Normal ) );
- connect( qApp, SIGNAL( timeChanged() ), this, SLOT( updateTime( ) ) );
- connect( qApp, SIGNAL( clockChanged( bool ) ),
- this, SLOT( slotClockChanged( bool ) ) );
+ connect( qApp, SIGNAL( timeChanged() ), this, SLOT( updateTime() ) );
+ connect( qApp, SIGNAL( clockChanged(bool) ),
+ this, SLOT( slotClockChanged(bool) ) );
readConfig();
timerId = 0;
timerEvent( 0 );
show();
}
int LauncherClock::position()
{
return 10;
}
void LauncherClock::readConfig() {
Config config( "qpe" );
config.setGroup( "Time" );
ampmFormat = config.readBoolEntry( "AMPM", TRUE );
config.setGroup( "Date" );
format = config.readNumEntry("ClockApplet",0);
}
void LauncherClock::mouseReleaseEvent( QMouseEvent * )
{
QCString setTimeApp;
setTimeApp="systemtime";
QCopEnvelope e("QPE/Application/"+setTimeApp, "raise()");
}
void LauncherClock::timerEvent( QTimerEvent *e )
{
if ( !e || e->timerId() == timerId ) {
killTimer( timerId );
changeTime();
QTime t = QTime::currentTime();
int ms = (60 - t.second())*1000 - t.msec();
timerId = startTimer( ms );
} else {
QLabel::timerEvent( e );
}
}
void LauncherClock::updateTime( void )
{
changeTime();
}
void LauncherClock::changeTime( void )
{
QTime tm = QDateTime::currentDateTime().time();
QString s;
if( ampmFormat ) {
int hour = tm.hour();
if (hour == 0)
hour = 12;
if (hour > 12)
hour -= 12;
s.sprintf( "%2d:%02d %s", hour, tm.minute(),
(tm.hour() >= 12) ? "PM" : "AM" );
} else
s.sprintf( "%2d:%02d", tm.hour(), tm.minute() );
if (format==1) {
QDate dm = QDate::currentDate();
QString d;
d.sprintf("%d/%d ", dm.day(), dm.month());
setText( d+s );
} else if (format==2) {
QDate dm = QDate::currentDate();
QString d;
d.sprintf("%d/%d ", dm.month(), dm.day());
setText( d+s );
} else {
setText( s );
}
}
void LauncherClock::slotClockChanged( bool pm )
{
readConfig();
updateTime();
}
Q_EXPORT_INTERFACE()
{
Q_CREATE_INSTANCE( OTaskbarAppletWrapper<LauncherClock> );
}
diff --git a/core/applets/irdaapplet/irda.cpp b/core/applets/irdaapplet/irda.cpp
index afc0592..dde8050 100644
--- a/core/applets/irdaapplet/irda.cpp
+++ b/core/applets/irdaapplet/irda.cpp
@@ -1,196 +1,196 @@
/**********************************************************************
** Copyright (C) 2002 David Woodhouse <dwmw2@infradead.org>
** Max Reiss <harlekin@handhelds.org> [trivial stuff]
** Robert Griebl <sandman@handhelds.org>
** Holger Freyther <zecke@handhelds.org> QCOP Interface
**
** 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.
**
**********************************************************************/
#include "irda.h"
/* OPIE */
#include <opie2/otaskbarapplet.h>
#include <qpe/resource.h>
#include <qpe/qcopenvelope_qws.h>
/* QT */
#include <qpainter.h>
#include <qfile.h>
#include <qtimer.h>
#include <qtextstream.h>
/* STD */
#include <unistd.h>
#include <net/if.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
//===========================================================================
IrdaApplet::IrdaApplet ( QWidget *parent, const char *name )
: QWidget ( parent, name )
{
setFixedHeight ( 18 );
setFixedWidth ( 14 );
m_sockfd = ::socket ( PF_INET, SOCK_DGRAM, IPPROTO_IP );
m_irdaOnPixmap = Resource::loadPixmap( "irdaapplet/irdaon" );
m_irdaOffPixmap = Resource::loadPixmap( "irdaapplet/irdaoff" );
m_irdaDiscoveryOnPixmap = Resource::loadPixmap( "irdaapplet/magglass" );
m_receiveActivePixmap = Resource::loadPixmap( "irdaapplet/receive" );
m_irda_active = false;
m_irda_discovery_active = false;
m_receive_active = false;
m_receive_state_changed = false;
m_popup = 0;
m_wasOn = false;
m_wasDiscover = false;
QCopChannel* chan = new QCopChannel("QPE/IrDaApplet", this );
connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ),
- this, SLOT(slotMessage(const QCString&, const QByteArray& ) ) );
+ this, SLOT(slotMessage(const QCString&,const QByteArray&) ) );
}
int IrdaApplet::position()
{
return 6;
}
void IrdaApplet::show()
{
QWidget::show ( );
startTimer ( 2000 );
}
IrdaApplet::~IrdaApplet()
{
if ( m_sockfd >= 0 )
::close ( m_sockfd );
}
void IrdaApplet::popup ( QString message, QString icon )
{
if ( !m_popup )
m_popup = new QPopupMenu ( this );
m_popup-> clear ( );
if ( icon. isEmpty ( ))
m_popup-> insertItem ( message, 0 );
else
m_popup-> insertItem ( QIconSet ( Resource::loadPixmap ( icon )), message, 0 );
QPoint p = mapToGlobal ( QPoint ( 0, 0 ));
QSize s = m_popup-> sizeHint ( );
m_popup-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ),
p. y ( ) - s. height ( )));
- QTimer::singleShot ( 2000, this, SLOT( popupTimeout ( )));
+ QTimer::singleShot ( 2000, this, SLOT( popupTimeout()));
}
void IrdaApplet::popupTimeout ( )
{
m_popup-> hide ( );
}
bool IrdaApplet::checkIrdaStatus ( )
{
struct ifreq ifr;
strcpy ( ifr. ifr_name, "irda0" );
if ( ::ioctl ( m_sockfd, SIOCGIFFLAGS, &ifr ) < 0 )
return false;
return ( ifr. ifr_flags & IFF_UP );
}
bool IrdaApplet::setIrdaStatus ( bool b )
{
struct ifreq ifr;
strcpy ( ifr. ifr_name, "irda0" );
if ( ::ioctl ( m_sockfd, SIOCGIFFLAGS, &ifr ) < 0 )
return false;
if ( b ) {
ifr. ifr_flags |= IFF_UP;
}
else {
setIrdaDiscoveryStatus ( 0 );
setIrdaReceiveStatus ( 0 );
ifr. ifr_flags &= ~IFF_UP;
}
if ( ::ioctl ( m_sockfd, SIOCSIFFLAGS, &ifr ) < 0 )
return false;
return true;
}
bool IrdaApplet::checkIrdaDiscoveryStatus ( )
{
QFile discovery ( "/proc/sys/net/irda/discovery" );
QString streamIn = "0";
if ( discovery. open ( IO_ReadOnly )) {
QTextStream stream ( &discovery );
streamIn = stream. read ( );
}
return streamIn. toInt ( ) > 0;
}
bool IrdaApplet::setIrdaDiscoveryStatus ( bool d )
{
QFile discovery ( "/proc/sys/net/irda/discovery" );
if ( discovery. open ( IO_WriteOnly | IO_Raw )) {
discovery.putch ( d ? '1' : '0' );
return true;
}
return false;
}
bool IrdaApplet::setIrdaReceiveStatus ( bool d )
{
QCopEnvelope e ( "QPE/Obex", "receive(int)" );
e << ( d ? 1 : 0 );
m_receive_active = d;
m_receive_state_changed = true;
return true;
}
void IrdaApplet::showDiscovered ( )
{
// static Sound snd_found ( "irdaapplet/irdaon" );
// static Sound snd_lost ( "irdaapplet/irdaoff" );
QFile discovery ( "/proc/net/irda/discovery" );
if ( discovery. open ( IO_ReadOnly )) {
bool qcopsend = false;
QString discoveredDevice;
QString deviceAddr;
// since it is /proc we _must_ use QTextStream
QStringList list = QStringList::split ( "\n", QTextStream ( &discovery ). read ( ));
diff --git a/core/applets/multikeyapplet/multikey.cpp b/core/applets/multikeyapplet/multikey.cpp
index b17498d..fc5f093 100644
--- a/core/applets/multikeyapplet/multikey.cpp
+++ b/core/applets/multikeyapplet/multikey.cpp
@@ -1,124 +1,124 @@
/**********************************************************************
** Copyright (C) 2004 Anton Kachalov mouse@altlinux.ru
** All rights reserved.
**
** 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.
**
**********************************************************************/
#include "multikey.h"
/* OPIE */
#include <opie2/otaskbarapplet.h>
#include <qpe/qcopenvelope_qws.h>
/* QT */
#include <qdir.h>
Multikey::Multikey(QWidget *parent) : QLabel(parent), popupMenu(this), current("EN")
{
QCopChannel* swChannel = new QCopChannel("MultiKey/Switcher", this);
- connect( swChannel, SIGNAL(received(const QCString &, const QByteArray &)),
- this, SLOT(message(const QCString &, const QByteArray &)));
+ connect( swChannel, SIGNAL(received(const QCString&,const QByteArray&)),
+ this, SLOT(message(const QCString&,const QByteArray&)));
setFont( QFont( "Helvetica", 10, QFont::Normal ) );
QPEApplication::setStylusOperation(this, QPEApplication::RightOnHold);
lang = 0;
QCopEnvelope e("MultiKey/Keyboard", "getmultikey()");
setText("EN");
popupMenu.insertItem("EN", 0);
show();
}
void Multikey::mousePressEvent(QMouseEvent *ev)
{
if (!sw_maps.count())
return;
if (ev->button() == RightButton) {
QPoint p = mapToGlobal(QPoint(0, 0));
QSize s = popupMenu.sizeHint();
int opt = popupMenu.exec(QPoint(p.x() + (width() / 2) - (s.width() / 2),
p.y() - s.height()), 0);
if (opt == -1)
return;
lang = opt;
QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)");
e << sw_maps[lang];
setText(labels[lang]);
}
QWidget::mousePressEvent(ev);
}
void Multikey::mouseReleaseEvent(QMouseEvent *ev)
{
if (!sw_maps.count())
return;
lang = lang < sw_maps.count()-1 ? lang+1 : 0;
QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)");
//qDebug("Lang=%d, count=%d, lab=%s", lang, sw_maps.count(), labels[lang].ascii());
e << sw_maps[lang];
setText(labels[lang]);
}
void Multikey::message(const QCString &message, const QByteArray &data)
{
if ( message == "setsw(QString,QString)" ) {
QDataStream stream(data, IO_ReadOnly);
QString maps, current_map;
stream >> maps >> current_map;
QStringList sw = QStringList::split(QChar('|'), maps);
sw.append(current_map);
QDir map_dir(QPEApplication::qpeDir() + "/share/multikey/", "*.keymap");
lang = 0;
labels.clear();
sw_maps.clear();
popupMenu.clear();
for (uint i = 0; i < sw.count(); ++i) {
QString keymap_map;
if (sw[i][0] != '/') {
keymap_map = map_dir.absPath() + "/" + sw[i];
} else {
if ((map_dir.exists(QFileInfo(sw[i]).fileName(), false)
&& i != sw.count()-1) || !QFile::exists(sw[i])) {
continue;
}
keymap_map = sw[i];
}
QFile map(keymap_map);
if (map.open(IO_ReadOnly)) {
QString line;
map.readLine(line, 1024);
while (!map.atEnd()) {
if (line.find(QRegExp("^sw\\s*=\\s*")) != -1) {
if (i != sw.count()-1) {
if (keymap_map == current_map) {
lang = i;
}
sw_maps.append(keymap_map);
labels.append(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace());
popupMenu.insertItem(labels[labels.count()-1], labels.count()-1);
} else {
current = line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace();
}
break;
}
diff --git a/core/applets/rotateapplet/rotate.cpp b/core/applets/rotateapplet/rotate.cpp
index dcbf809..0488c36 100644
--- a/core/applets/rotateapplet/rotate.cpp
+++ b/core/applets/rotateapplet/rotate.cpp
@@ -1,148 +1,148 @@
/*
This file is part of the OPIE Project
Copyright (C) 2003 Maximilian Reiss <harlekin@handhelds.org>
Copyright (C) 2003 Greg Gilbert <ggilbert@treke.net>
               =. Copyright (C) 2004 Michael Lauer <mickey@Vanille.de>
             .=l.
           .>+-=
 _;:,     .>    :=|. This library 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 library is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=| MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-= this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "rotate.h"
/* OPIE */
#include <opie/odevice.h>
#include <qpe/config.h>
#include <qpe/power.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/resource.h>
using namespace Opie;
/* QT */
#include <time.h>
RotateApplet::RotateApplet()
:QObject( 0, "RotateApplet" ), m_flipped( false )
{
#if !defined(QT_NO_COP)
QCopChannel *rotateChannel = new QCopChannel( "QPE/Rotation" , this );
- connect ( rotateChannel, SIGNAL( received( const QCString &, const QByteArray &) ),
- this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) );
+ connect ( rotateChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
+ this, SLOT ( channelReceived(const QCString&,const QByteArray&) ) );
#endif
}
RotateApplet::~RotateApplet ( )
{}
/**
* Qcop receive method.
*/
void RotateApplet::channelReceived( const QCString &msg, const QByteArray & data )
{
qDebug( "RotateApplet::channelReceived( '%s' )", (const char*) msg );
if ( ODevice::inst()->hasHingeSensor() )
{
struct timespec interval;
struct timespec remain;
interval.tv_sec = 0;
interval.tv_nsec = 600000;
::nanosleep( &interval, &remain );
OHingeStatus status = ODevice::inst()->readHingeSensor();
qDebug( "RotateApplet::readHingeSensor = %d", (int) status );
Config cfg( "apm" );
cfg.setGroup( PowerStatusManager::readStatus().acStatus() == PowerStatus::Online ? "AC" : "Battery" );
int action = cfg.readNumEntry( "CloseHingeAction", 0 );
if ( status == CASE_CLOSED )
{
switch ( action )
{
case 1: /* DISPLAY OFF */ ODevice::inst()->setDisplayBrightness( 0 ); break;
case 2: /* SUSPEND */ ODevice::inst()->suspend(); break;
default: /* IGNORE */ break;
}
}
else /* status != CASE_CLOSED */
{
switch ( action )
{
case 1: /* DISPLAY OFF */ ODevice::inst()->setDisplayBrightness( 127 ); break;
case 2: /* SUSPEND */ /* How to wake up the device from kernel? */; break;
default: /* IGNORE */ break;
}
}
qDebug( "RotateApplet::switchAction %d performed.", cfg.readNumEntry( "CloseHingeAction", 0 ) );
}
QDataStream stream( data, IO_ReadOnly );
if ( msg == "flip()" )
{
activated ( );
}
else if ( msg == "rotateDefault()")
{
rotateDefault();
}
}
int RotateApplet::position() const
{
return 3;
}
QString RotateApplet::name() const
{
return tr( "Rotate shortcut" );
}
QString RotateApplet::text() const
{
return tr( "Rotate" );
}
/*QString RotateApplet::tr( const char* s ) const
{
return qApp->translate( "RotateApplet", s, 0 );
}
QString RotateApplet::tr( const char* s, const char* p ) const
{
return qApp->translate( "RotateApplet", s, p );
}
*/
QIconSet RotateApplet::icon() const
{
QPixmap pix;
QImage img = Resource::loadImage( "Rotation" );
if ( !img.isNull() )
pix.convertFromImage( img.smoothScale( 14, 14 ) );
return pix;
}
QPopupMenu* RotateApplet::popup(QWidget*) const
diff --git a/core/applets/screenshotapplet/screenshot.cpp b/core/applets/screenshotapplet/screenshot.cpp
index 5d6bce4..20e1c9b 100644
--- a/core/applets/screenshotapplet/screenshot.cpp
+++ b/core/applets/screenshotapplet/screenshot.cpp
@@ -206,195 +206,195 @@ static char * snapshot_xpm[] = {
"F. c #5A525E",
"G. c #425868",
"H. c #04448E",
"I. c #28828A",
"J. c #2D8593",
"K. c #12427A",
"L. c #054696",
"M. c #042B5E",
"N. c #134F95",
"O. c #1E6ABB",
"P. c #1A5E96",
"Q. c #022E67",
"R. c #0C3E7C",
"S. c #023E8A",
"T. c #021A3E",
" ",
" ",
" ",
" . + @ # + ",
" $ # % & * * = - # $ ",
"; > % @ = , ' ) ' ! ~ { % @ . ] ^ / ( ",
"; + ' * ) _ ) ) ' : : ! { { % < . [ ( } ",
"| @ 1 2 3 _ _ ) ' : : : : 4 5 6 6 # 7 8 } ",
"9 0 a b b b c _ ) : : ! ! ~ ~ 5 ~ d e f [ 8 g h h } ",
"| i j k j l m n 3 ) : ! ! ! ~ o o o p 6 q f / r r r s ",
"t u v w x y y z a 1 3 ' : ! ~ A A B A p = C D E F G ( s ",
"| u H I J K L M H k N 3 3 : ~ o o 5 O P Q R S T T U V W X Y ",
"| Z ` J .....+.@.z #.3 _ 3 3 ) $.P W %.S &.*.*.&.S W Q P =.-. ",
";.>.,.'.).!.!.).~.,.{.) : ) 3 ].h ^./.(._._._.:.<.[.g }.= & |. ",
";.>.1.2.3.4.4.5.6.,.{._ : : : 7.8.9.0.a.b.b.c.d.} e.4 = 6 q # ",
";.>.z f.g.h.i.j.k.l.N ) : ! ! 4 m.n.c.o.p.q.r.|.5 { d e e s.. ",
"t Z l t.f.u.g.1.v.#.w.' : ! ~ ~ 7.|.n.x.y.z.A.A q - e e e B.> ",
"| 0 c k t.t.l l C.D.) * * ! 5 { B o E.F.F.G.= H.e e e e q B.. ",
"; + D.I.J.I.I.I.w.) : : * o K.7 - L.= O = }.6 6 e q q e q s.> ",
"9 + ) ) ) ) ' ' , * : ! ! ! K.< . M.q 6 B N.{ d q e e e e s.9 ",
"9 # O.) ) ' , , P.* ! ! ! ! = % . . M.e d p L.d B.B.e B.B.Q.9 ",
"; < ' ' ' ' , , 4 4 ~ ! ! ~ ! 5 e q e e q A H.d q q e e B.Q.9 ",
"; $ R.K.5 4 4 ' ! ! 4 ~ ! ~ ~ ~ o { B o A A L.S.B.B.B.B.B.Q.> ",
" ] $ 0 R.= ' ' 4 4 5 4 5 5 o B o B p A A L.d e e B.B.B.Q.9 ",
" # + - { 4 4 ~ ! o { o L.p p p p p H.S.B.B.s.Q.Q.M.T. ",
" + s.6 B o o 5 B p L.p p L.p H.q B.Q.Q.Q.Q.M.; ",
" < # s.- B o B p p L.L.H.L.H.d B.Q.Q.Q.Q.Q.9 ",
" $ . s.d 6 B A p H.S.L.H.q B.Q.Q.M.M.. ; ",
" ; 9 . 6 L.p L.d L.H.d Q.M.M.. 9 ; ] ",
" | > e L.d L.H.e M.. ; ] ] ",
" > 9 . S.Q.. ; ] ",
" T.; ] "};
static const char *SCAP_hostname = "www.handhelds.org";
static const int SCAP_port = 80;
ScreenshotControl::ScreenshotControl( QWidget *parent, const char *name )
: QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup )
{
setFrameStyle( QFrame::PopupPanel | QFrame::Raised );
QVBoxLayout *vbox = new QVBoxLayout ( this, 5, 3 );
QHBoxLayout *hbox;
hbox = new QHBoxLayout ( vbox );
QLabel *l = new QLabel ( tr( "Delay" ), this );
hbox-> addWidget ( l );
delaySpin = new QSpinBox( 0, 60, 1, this, "Spinner" );
delaySpin-> setButtonSymbols ( QSpinBox::PlusMinus );
delaySpin-> setSuffix ( tr( "sec" ));
delaySpin-> setFocusPolicy( QWidget::NoFocus );
delaySpin-> setValue ( 1 );
hbox-> addWidget ( delaySpin );
saveNamedCheck = new QCheckBox ( tr( "Save named" ), this);
saveNamedCheck-> setFocusPolicy ( QWidget::NoFocus );
vbox->addWidget( saveNamedCheck);
vbox-> addSpacing ( 3 );
l = new QLabel ( tr( "Save screenshot as..." ), this );
vbox-> addWidget ( l, AlignCenter );
hbox = new QHBoxLayout ( vbox );
grabItButton = new QPushButton( tr( "File" ), this, "GrabButton" );
grabItButton ->setFocusPolicy( QWidget::TabFocus );
hbox-> addWidget ( grabItButton );
scapButton = new QPushButton( tr( "Scap" ), this, "ScapButton" );
scapButton ->setFocusPolicy( QWidget::TabFocus );
hbox-> addWidget ( scapButton );
setFixedSize ( sizeHint ( ));
setFocusPolicy ( QWidget::NoFocus );
grabTimer = new QTimer ( this, "grab timer");
- connect ( grabTimer, SIGNAL( timeout ( )), this, SLOT( performGrab ( )));
- connect ( grabItButton, SIGNAL( clicked ( )), SLOT( slotGrab ( )));
- connect ( scapButton, SIGNAL( clicked ( )), SLOT( slotScap ( )));
+ connect ( grabTimer, SIGNAL( timeout()), this, SLOT( performGrab()));
+ connect ( grabItButton, SIGNAL( clicked()), SLOT( slotGrab()));
+ connect ( scapButton, SIGNAL( clicked()), SLOT( slotScap()));
}
void ScreenshotControl::slotGrab()
{
buttonPushed = 1;
hide();
setFileName = FALSE;
if ( saveNamedCheck->isChecked()) {
setFileName = TRUE;
InputDialog *fileDlg;
fileDlg = new InputDialog( 0 , tr("Name of screenshot "), TRUE, 0);
fileDlg->exec();
fileDlg->raise();
QString fileName, list;
if ( fileDlg->result() == 1 ) {
fileName = fileDlg->LineEdit1->text();
if (fileName.find("/", 0, TRUE) == -1)
FileNamePath = QDir::homeDirPath() + "/Documents/image/png/" + fileName;
else
FileNamePath = fileName;
}
delete fileDlg;
}
if ( delaySpin->value() )
grabTimer->start( delaySpin->value() * 1000, true );
else
show();
}
void ScreenshotControl::slotScap()
{
buttonPushed = 2;
hide();
if ( delaySpin->value() )
grabTimer->start( delaySpin->value() * 1000, true );
else
show();
}
void ScreenshotControl::savePixmap()
{
DocLnk lnk;
QString fileName;
if ( setFileName) {
fileName = FileNamePath;
//not sure why this is needed here, but it forgets fileName
// if this is below the braces
if (fileName.right(3) != "png")
fileName = fileName + ".png";
lnk.setFile(fileName); //sets File property
qDebug("saving file " + fileName);
snapshot.save( fileName, "PNG");
QFileInfo fi( fileName);
lnk.setName( fi.fileName()); //sets file name
if (!lnk.writeLink())
qDebug("Writing doclink did not work");
}
else {
fileName = "sc_" + QDateTime::currentDateTime().toString();
fileName.replace(QRegExp("'"), "");
fileName.replace(QRegExp(" "), "_");
fileName.replace(QRegExp(":"), ".");
fileName.replace(QRegExp(","), "");
QString dirName = QDir::homeDirPath() + "/Documents/image/png/";
if ( !QDir( dirName).exists() ) {
qDebug("making dir " + dirName);
QString msg = "mkdir -p " + dirName;
system(msg.latin1());
}
fileName = dirName + fileName;
if (fileName.right(3) != "png")
fileName = fileName + ".png";
lnk.setFile(fileName); //sets File property
qDebug("saving file " + fileName);
snapshot.save( fileName, "PNG");
QFileInfo fi( fileName);
lnk.setName( fi.fileName()); //sets file name
if (!lnk.writeLink())
qDebug("Writing doclink did not work");
}
QPEApplication::beep();
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp
index 563d110..27f6015 100644
--- a/core/applets/vmemo/vmemo.cpp
+++ b/core/applets/vmemo/vmemo.cpp
@@ -120,194 +120,194 @@ static char * vmemo_xpm[] = {
"f c #5B5B60",
"g c #8A8A8F",
"h c #6B6B6E",
"i c #ADADB2",
"j c #828289",
"k c #3E3E41",
"l c #CFCFD7",
"m c #4C4C50",
"n c #000000",
"o c #66666A",
"p c #505054",
"q c #838388",
"r c #A1A1A7",
"s c #A9A9AE",
"t c #A8A8B0",
"u c #5E5E63",
"v c #3A3A3E",
"w c #BDBDC6",
"x c #59595E",
"y c #76767C",
"z c #373738",
"A c #717174",
"B c #727278",
"C c #1C1C1E",
"D c #3C3C3F",
"E c #ADADB6",
"F c #54555A",
"G c #8B8C94",
"H c #5A5A5F",
"I c #BBBBC3",
"J c #C4C4CB",
"K c #909098",
"L c #737379",
"M c #343437",
"N c #8F8F98",
"O c #000407",
"P c #2D3137",
"Q c #B0B1BC",
"R c #3B3C40",
"S c #6E6E74",
"T c #95959C",
"U c #74747A",
"V c #1D1D1E",
"W c #91929A",
"X c #42444A",
"Y c #22282E",
"Z c #B0B2BC",
"` c #898A90",
" . c #65656A",
".. c #999AA2",
"+. c #52535A",
"@. c #151B21",
"#. c #515257",
"$. c #B5B5BE",
"%. c #616167",
"&. c #1A1D22",
"*. c #000713",
"=. c #1F1F21",
" ",
" . + @ # ",
" $ % & * = - ",
" ; > , ' ) ! ~ ",
" { ] ^ / ( _ : ",
" < [ } | 1 2 3 ",
" 4 5 6 7 8 9 0 a b c ",
" d e f g h i j 3 k l m n ",
" o p q r s t u v w n ",
" o x y z A B C D E n ",
" F G H I J K L M N O ",
" P Q R S T U V W X ",
" Y Z ` b ...+. ",
" @.#.$.%.&. ",
" *.B =. ",
" n n n n n n n n n "};
VMemo::VMemo( QWidget *parent, const char *_name )
: QWidget( parent, _name ) {
setFixedHeight( 18 );
setFixedWidth( 14 );
t_timer = new QTimer( this );
connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) );
Config vmCfg("Vmemo");
vmCfg.setGroup("Defaults");
int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1));
useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0);
qDebug("toggleKey %d", toggleKey);
if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ))
systemZaurus=TRUE;
else
systemZaurus=FALSE;
myChannel = new QCopChannel( "QPE/VMemo", this );
- connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)),
- this, SLOT(receive(const QCString&, const QByteArray&)) );
+ connect( myChannel, SIGNAL(received(const QCString&,const QByteArray&)),
+ this, SLOT(receive(const QCString&,const QByteArray&)) );
if( toggleKey != -1 ) {
// keyRegister(key, channel, message)
QCopEnvelope e("QPE/Launcher", "keyRegister(int,QCString,QCString)");
// e << 4096; // Key_Escape
// e << Key_F5; //4148
e << toggleKey;
e << QString("QPE/VMemo");
e << QString("toggleRecord()");
}
if(toggleKey == 1)
usingIcon=TRUE;
else
usingIcon=FALSE;
if( vmCfg.readNumEntry("hideIcon",0) == 1)
hide();
recording = FALSE;
// }
}
VMemo::~VMemo() {
}
int VMemo::position()
{
return 6;
}
void VMemo::receive( const QCString &msg, const QByteArray &data ) {
qDebug("receive");
QDataStream stream( data, IO_ReadOnly );
if (msg == "toggleRecord()") {
if (recording) {
fromToggle = TRUE;
stopRecording();
} else {
fromToggle = TRUE;
startRecording();
}
}
}
void VMemo::paintEvent( QPaintEvent* ) {
QPainter p(this);
p.drawPixmap( 0, 1,( const char** ) vmemo_xpm );
}
void VMemo::mousePressEvent( QMouseEvent * me) {
/* No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions
mousePressEvent and mouseReleaseEvent with a NULL parameter. */
// if (!systemZaurus && me != NULL)
// return;
// }
if(!recording)
startRecording();
else
stopRecording();
}
void VMemo::mouseReleaseEvent( QMouseEvent * ) {
}
bool VMemo::startRecording() {
Config config( "Vmemo" );
config.setGroup( "System" );
useAlerts = config.readBoolEntry("Alert",1);
if(useAlerts) {
msgLabel = new QLabel( 0, "alertLabel" );
msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>");
msgLabel->show();
}
qDebug("Start recording engines");
recording = TRUE;
if (openDSP() == -1) {
recording = FALSE;
return FALSE;
}
config.setGroup("Defaults");
date = TimeString::dateString( QDateTime::currentDateTime(),false,true);
date.replace(QRegExp("'"),"");
date.replace(QRegExp(" "),"_");
date.replace(QRegExp(":"),".");
date.replace(QRegExp(","),"");
QString fName;
config.setGroup( "System" );
fName = QPEApplication::documentDir() ;
diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp
index 8fd88f6..942cebb 100644
--- a/core/applets/volumeapplet/volume.cpp
+++ b/core/applets/volumeapplet/volume.cpp
@@ -315,213 +315,213 @@ VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *pa
bassSlider->setMaximumHeight( 40 );
bassSlider-> setFocusPolicy ( QWidget::NoFocus );
QLabel *bassLabel = new QLabel ( this );
bassLabel-> setPixmap ( QPixmap ( bass_xpm ));
QLabel *trebleLabel = new QLabel( this );
trebleLabel->setPixmap( QPixmap ( treble_xpm ) );
grid->addWidget( trebleLabel, 0, 4, AlignCenter );
grid->addWidget( basstrebleBox, 1, 4, AlignCenter );
grid-> addWidget ( bassLabel, 2, 4, AlignCenter );
if ( !has_bass ) {
bassSlider->hide();
bassLabel->hide();
}
if ( !has_treble ) {
trebleSlider->hide();
trebleLabel->hide();
}
micSlider = new QSlider ( this );
micSlider-> setRange ( 0, 100 );
micSlider-> setTickmarks ( QSlider::Both );
micSlider-> setTickInterval ( 20 );
micSlider-> setFocusPolicy ( QWidget::NoFocus );
l = new QLabel ( this );
l-> setPixmap ( QPixmap ( mic_xpm ));
grid-> addWidget ( l, 0, 2, AlignCenter );
grid-> addWidget ( micSlider, 1, 2, AlignCenter );
micLed = new OLedBox ( red, this );
micLed-> setFocusPolicy ( QWidget::NoFocus );
micLed-> setFixedSize ( 16, 16 );
grid-> addWidget ( micLed, 2, 2, AlignCenter );
alarmSlider = new QSlider ( this );
alarmSlider-> setRange ( 0, 100 );
alarmSlider-> setTickmarks ( QSlider::Both );
alarmSlider-> setTickInterval ( 20 );
alarmSlider-> setFocusPolicy ( QWidget::NoFocus );
QLabel *alarmLabel = new QLabel ( this );
alarmLabel-> setPixmap ( QPixmap ( alarm_xpm ));
grid-> addWidget ( alarmLabel, 0, 3, AlignCenter );
grid-> addWidget ( alarmSlider, 1, 3, AlignCenter );
alarmLed = new OLedBox ( yellow, this );
alarmLed-> setFocusPolicy ( QWidget::NoFocus );
alarmLed-> setFixedSize ( 16, 16 );
grid-> addWidget ( alarmLed, 2, 3, AlignCenter );
if ( !has_wav_alarm ) {
alarmSlider-> hide ( );
alarmLabel-> hide ( );
alarmLed-> hide ( );
}
grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 6, AlignVCenter | AlignLeft );
vbox = new QVBoxLayout ( );
vbox-> setSpacing ( 4 );
grid-> addMultiCellLayout ( vbox, 1, 2, 6, 6 );
tapBox = new QCheckBox ( tr( "Screen Taps" ), this );
tapBox-> setFocusPolicy ( QWidget::NoFocus );
vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft );
keyBox = new QCheckBox ( tr( "Key Clicks" ), this );
keyBox-> setFocusPolicy ( QWidget::NoFocus );
vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft );
alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this );
alarmBox-> setFocusPolicy ( QWidget::NoFocus );
vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft );
if ( has_wav_alarm ) {
alarmBox-> hide ( );
}
vbox-> addStretch ( 100 );
setFixedSize ( sizeHint ( ));
setFocusPolicy ( QWidget::NoFocus );
rateTimer = new QTimer( this );
- connect ( rateTimer, SIGNAL( timeout ( )), this, SLOT( rateTimerDone ( )));
+ connect ( rateTimer, SIGNAL( timeout()), this, SLOT( rateTimerDone()));
- connect ( upButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( )));
- connect ( upButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( )));
- connect ( downButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( )));
- connect ( downButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( )));
+ connect ( upButton, SIGNAL( pressed()), this, SLOT( buttonChanged()));
+ connect ( upButton, SIGNAL( released()), this, SLOT( buttonChanged()));
+ connect ( downButton, SIGNAL( pressed()), this, SLOT( buttonChanged()));
+ connect ( downButton, SIGNAL( released()), this, SLOT( buttonChanged()));
- connect ( micSlider, SIGNAL( valueChanged ( int )), this, SLOT( micMoved( int )));
- connect ( volSlider, SIGNAL( valueChanged ( int )), this, SLOT( volMoved( int )));
- connect ( alarmSlider, SIGNAL( valueChanged ( int )), this, SLOT( alarmMoved( int )));
- connect ( bassSlider, SIGNAL( valueChanged ( int )), this, SLOT( bassMoved( int )));
- connect ( trebleSlider, SIGNAL( valueChanged ( int )), this, SLOT( trebleMoved( int )));
+ connect ( micSlider, SIGNAL( valueChanged(int)), this, SLOT( micMoved(int)));
+ connect ( volSlider, SIGNAL( valueChanged(int)), this, SLOT( volMoved(int)));
+ connect ( alarmSlider, SIGNAL( valueChanged(int)), this, SLOT( alarmMoved(int)));
+ connect ( bassSlider, SIGNAL( valueChanged(int)), this, SLOT( bassMoved(int)));
+ connect ( trebleSlider, SIGNAL( valueChanged(int)), this, SLOT( trebleMoved(int)));
- connect ( volLed, SIGNAL( toggled ( bool )), this, SLOT( volMuteToggled ( bool )));
- connect ( micLed, SIGNAL( toggled ( bool )), this, SLOT( micMuteToggled ( bool )));
- connect ( alarmLed, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool )));
+ connect ( volLed, SIGNAL( toggled(bool)), this, SLOT( volMuteToggled(bool)));
+ connect ( micLed, SIGNAL( toggled(bool)), this, SLOT( micMuteToggled(bool)));
+ connect ( alarmLed, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool)));
- connect ( alarmBox, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool )));
- connect ( keyBox, SIGNAL( toggled ( bool )), this, SLOT( keyClickToggled ( bool )));
- connect ( tapBox, SIGNAL( toggled ( bool )), this, SLOT( screenTapToggled ( bool )));
+ connect ( alarmBox, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool)));
+ connect ( keyBox, SIGNAL( toggled(bool)), this, SLOT( keyClickToggled(bool)));
+ connect ( tapBox, SIGNAL( toggled(bool)), this, SLOT( screenTapToggled(bool)));
// initialize variables
readConfig ( true );
// initialize the config file, in case some entries are missing
writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None );
writeConfigEntry ( "BassPercent", m_vol_percent, UPD_None );
writeConfigEntry ( "TreblePercent", m_vol_percent, UPD_None );
writeConfigEntry ( "Mute", m_vol_muted, UPD_None );
writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None );
writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None );
writeConfigEntry ( "KeySound", m_snd_key, UPD_None );
writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol );
writeConfigEntry ( "Mic", m_mic_percent, UPD_None );
writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic );
}
bool VolumeControl::volMuted ( ) const
{
return m_vol_muted;
}
int VolumeControl::volPercent ( ) const
{
return m_vol_percent;
}
void VolumeControl::keyPressEvent ( QKeyEvent *e )
{
switch ( e-> key ( )) {
case Key_Up:
volSlider-> subtractStep ( );
break;
case Key_Down:
volSlider-> addStep ( );
break;
case Key_Space:
volLed-> toggle ( );
break;
case Key_Escape:
hide ( );
break;
}
}
void VolumeControl::buttonChanged ( )
{
if ( upButton-> isDown ( ) || downButton->isDown ( )) {
rateTimerDone ( ); // Call it one time manually, otherwise it wont get
// called at all when a button is pressed for a time
// shorter than RATE_TIMER_INTERVAL.
rateTimer-> start ( RATE_TIMER_INTERVAL, false );
}
else
rateTimer-> stop ( );
}
void VolumeControl::rateTimerDone ( )
{
if ( upButton-> isDown ( ))
volSlider-> setValue ( volSlider-> value ( ) - 2 );
else // if ( downButton-> isDown ( ))
volSlider-> setValue ( volSlider-> value ( ) + 2 );
}
void VolumeControl::show ( bool /*showMic*/ )
{
readConfig ( );
QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 ));
int w = sizeHint ( ). width ( );
int x = curPos.x ( ) - ( w / 2 );
if (( x + w ) > QPEApplication::desktop ( )-> width ( ))
x = QPEApplication::desktop ( )-> width ( ) - w;
move ( x, curPos. y ( ) - sizeHint ( ). height ( ));
QFrame::show ( );
}
void VolumeControl::readConfig ( bool force )
{
Config cfg ( "qpe" );
cfg. setGroup ( "Volume" );
int old_vp = m_vol_percent;
int old_mp = m_mic_percent;
int old_bass = m_bass_percent;
int old_treble = m_treble_percent;
bool old_vm = m_vol_muted;
bool old_mm = m_mic_muted;
@@ -631,153 +631,153 @@ void VolumeControl::volMoved ( int percent )
// clamp volume percent to be between 0 and 100
m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent );
// repaint just the little volume rectangle
m_icon-> redraw ( false );
writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol );
}
void VolumeControl::micMoved ( int percent )
{
m_mic_percent = 100 - percent;
// clamp volume percent to be between 0 and 100
m_mic_percent = ( m_mic_percent < 0 ) ? 0 : (( m_mic_percent > 100 ) ? 100 : m_mic_percent );
writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic );
}
void VolumeControl::alarmMoved ( int percent )
{
m_alarm_percent = 100 - percent;
// clamp volume percent to be between 0 and 100
m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent );
writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None );
}
void VolumeControl::bassMoved ( int percent )
{
m_bass_percent = 100 - percent;
// clamp bass percent to be between 0 and 100
m_bass_percent = ( m_bass_percent < 0 ) ? 0 : (( m_bass_percent > 100 ) ? 100 : m_bass_percent );
writeConfigEntry ( "BassPercent", m_bass_percent, UPD_Bass );
}
void VolumeControl::trebleMoved ( int percent )
{
m_treble_percent = 100 - percent;
// clamp treble percent to be between 0 and 100
m_treble_percent = ( m_treble_percent < 0 ) ? 0 : (( m_treble_percent > 100 ) ? 100 : m_treble_percent );
writeConfigEntry ( "TreblePercent", m_treble_percent, UPD_Treble );
}
void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd )
{
Config cfg ( "qpe" );
cfg. setGroup ( "Volume" );
cfg. writeEntry ( entry, val );
// cfg. write ( );
#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
switch ( upd ) {
case UPD_Vol: {
QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted;
break;
}
case UPD_Mic: {
QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted;
break;
}
case UPD_Bass: {
QCopEnvelope ( "QPE/System", "bassChange(bool)" ) << true;
break;
}
case UPD_Treble: {
QCopEnvelope ( "QPE/System", "trebleChange(bool)" ) << true;
break;
}
case UPD_None:
break;
}
#endif
}
//===========================================================================
VolumeApplet::VolumeApplet( QWidget *parent, const char *name )
: QWidget( parent, name )
{
setFixedWidth ( AppLnk::smallIconSize() );
setFixedHeight ( AppLnk::smallIconSize()+4 );
m_pixmap = new QPixmap ( Resource::loadPixmap ( "volume" ));
m_dialog = new VolumeControl ( this, true, this, "volumecontrol" );
- connect ( qApp, SIGNAL( volumeChanged ( bool )), m_dialog, SLOT( volumeChanged( bool )));
- connect ( qApp, SIGNAL( micChanged ( bool )), m_dialog, SLOT ( micChanged( bool )));
+ connect ( qApp, SIGNAL( volumeChanged(bool)), m_dialog, SLOT( volumeChanged(bool)));
+ connect ( qApp, SIGNAL( micChanged(bool)), m_dialog, SLOT ( micChanged(bool)));
}
VolumeApplet::~VolumeApplet()
{
delete m_pixmap;
}
int VolumeApplet::position()
{
return 6;
}
void VolumeApplet::mousePressEvent ( QMouseEvent * )
{
if ( m_dialog-> isVisible ( ))
m_dialog-> hide ( );
else
m_dialog-> show ( true );
}
void VolumeApplet::redraw ( bool all )
{
if ( all )
repaint ( true );
else
repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false );
}
void VolumeApplet::paintEvent ( QPaintEvent * )
{
QPainter p ( this );
p. drawPixmap ( (width()- m_pixmap->width())/2, QMAX( (height()-4-m_pixmap->height() )/2, 1), *m_pixmap );
p. setPen ( darkGray );
p. drawRect ( 1, height() - 4, width() - 2, 4 );
int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100;
p. fillRect ( 2, height() - 3, pixelsWide, 2, red );
p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray );
if ( m_dialog-> volMuted ( )) {
p. setPen ( red );
p. drawLine ( 1, 2, width() - 2, height() - 5 );
p. drawLine ( 1, 3, width() - 2, height() - 4 );
p. drawLine ( width() - 2, 2, 1, height() - 5 );
p. drawLine ( width() - 2, 3, 1, height() - 4 );
}
}
Q_EXPORT_INTERFACE()
{
Q_CREATE_INSTANCE( OTaskbarAppletWrapper<VolumeApplet> );
}