summaryrefslogtreecommitdiff
path: root/core
authorllornkcor <llornkcor>2002-05-23 02:01:23 (UTC)
committer llornkcor <llornkcor>2002-05-23 02:01:23 (UTC)
commit7cec3bc3d3b8945e80c9171b9173d3d2dbdd2eaf (patch) (side-by-side diff)
tree6c196a83ee8688a692e843279dae918960418163 /core
parentae177d167999f204a968ea21ae4a4a804d939e6d (diff)
downloadopie-7cec3bc3d3b8945e80c9171b9173d3d2dbdd2eaf.zip
opie-7cec3bc3d3b8945e80c9171b9173d3d2dbdd2eaf.tar.gz
opie-7cec3bc3d3b8945e80c9171b9173d3d2dbdd2eaf.tar.bz2
make sound conform to sharps sense of conf
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp28
-rw-r--r--core/launcher/desktop.h4
2 files changed, 18 insertions, 14 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index 649862b..6771a66 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -1,94 +1,91 @@
/**********************************************************************
** 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 "desktop.h"
#include "info.h"
#include "launcher.h"
#include "mrulist.h"
#include "qcopbridge.h"
#include "shutdownimpl.h"
#include "startmenu.h"
#include "taskbar.h"
#include "transferserver.h"
#include "irserver.h"
#include "packageslave.h"
#include <qpe/applnk.h>
#include <qpe/mimetype.h>
#include <qpe/password.h>
#include <qpe/config.h>
#include <qpe/power.h>
#include <qpe/timeconversion.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/global.h>
#ifdef QT_QWS_CUSTOM
#include "qpe/custom.h"
#endif
-#if defined(QT_QWS_IPAQ)
-#include "qpe/custom-ipaq.h"
-#endif
#include <qgfx_qws.h>
#include <qmainwindow.h>
#include <qmessagebox.h>
#include <qtimer.h>
#include <qwindowsystem_qws.h>
#include <qvaluelist.h>
#include <stdlib.h>
#include <unistd.h>
class QCopKeyRegister
{
public:
QCopKeyRegister() : keyCode(0) { }
QCopKeyRegister(int k, const QString &c, const QString &m)
: keyCode(k), channel(c), message(m) { }
int getKeyCode() const { return keyCode; }
QString getChannel() const { return channel; }
QString getMessage() const { return message; }
private:
int keyCode;
QString channel, message;
};
typedef QValueList<QCopKeyRegister> KeyRegisterList;
KeyRegisterList keyRegisterList;
static Desktop* qpedesktop = 0;
static int loggedin=0;
static void login(bool at_poweron)
{
if ( !loggedin ) {
Global::terminateBuiltin("calibrate");
Password::authenticate(at_poweron);
loggedin=1;
QCopEnvelope e( "QPE/Desktop", "unlocked()" );
}
}
bool Desktop::screenLocked()
{
return loggedin == 0;
}
@@ -123,130 +120,131 @@ void DesktopPowerAlerter::alert( const QString &text, int priority )
if ( alertCount < priority )
return;
if ( priority > currentPriority )
return;
currentPriority = priority;
setText( text );
show();
}
void DesktopPowerAlerter::hideEvent( QHideEvent *e )
{
QMessageBox::hideEvent( e );
alertCount = 0;
currentPriority = INT_MAX;
}
DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType )
: QPEApplication( argc, argv, appType )
{
QTimer *t = new QTimer( this );
connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) );
t->start( 10000 );
ps = new PowerStatus;
pa = new DesktopPowerAlerter( 0 );
channel = new QCopChannel( "QPE/Desktop", this );
connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
this, SLOT(receive(const QCString&, const QByteArray&)) );
}
DesktopApplication::~DesktopApplication()
{
delete ps;
delete pa;
}
void DesktopApplication::receive( const QCString &msg, const QByteArray &data )
{
QDataStream stream( data, IO_ReadOnly );
if (msg == "keyRegister(int key, QString channel, QString message)")
{
int k;
QString c, m;
-
stream >> k;
stream >> c;
stream >> m;
- qWarning("KeyRegisterRecieved: %i, %s, %s", k, (const char*)c, (const char *)m);
+ qWarning("KeyRegisterReceived: %i, %s, %s", k, (const char*)c, (const char *)m );
keyRegisterList.append(QCopKeyRegister(k,c,m));
}
else if (msg == "suspend()"){
emit power();
}
}
enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown;
#ifdef Q_WS_QWS
bool DesktopApplication::qwsEventFilter( QWSEvent *e )
{
qpedesktop->checkMemory();
if ( e->type == QWSEvent::Key ) {
QWSKeyEvent *ke = (QWSKeyEvent *)e;
if ( !loggedin && ke->simpleData.keycode != Key_F34 )
return TRUE;
bool press = ke->simpleData.is_press;
- bool autoRepeat = ke ->simpleData.is_auto_repeat;
+ bool autoRepeat= ke->simpleData.is_auto_repeat;
if (!keyRegisterList.isEmpty())
{
KeyRegisterList::Iterator it;
for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it )
{
- if ((*it).getKeyCode() == ke->simpleData.keycode && !autoRepeat)
- QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8());
+ if ((*it).getKeyCode() == ke->simpleData.keycode && !autoRepeat) {
+ if(press) qDebug("press"); else qDebug("release");
+ QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8());
+ }
}
}
if ( !keyboardGrabbed() ) {
if ( ke->simpleData.keycode == Key_F9 ) {
if ( press ) emit datebook();
return TRUE;
}
if ( ke->simpleData.keycode == Key_F10 ) {
if ( !press && cardSendTimer ) {
emit contacts();
delete cardSendTimer;
} else if ( press ) {
cardSendTimer = new QTimer();
cardSendTimer->start( 2000, TRUE );
connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) );
}
return TRUE;
}
/* menu key now opens application menu/toolbar
if ( ke->simpleData.keycode == Key_F11 ) {
if ( press ) emit menu();
return TRUE;
}
*/
if ( ke->simpleData.keycode == Key_F12 ) {
while( activePopupWidget() )
activePopupWidget()->close();
if ( press ) emit launch();
return TRUE;
}
if ( ke->simpleData.keycode == Key_F13 ) {
if ( press ) emit email();
return TRUE;
}
}
if ( ke->simpleData.keycode == Key_F34 ) {
if ( press ) emit power();
return TRUE;
}
if ( ke->simpleData.keycode == Key_SysReq ) {
if ( press ) emit power();
return TRUE;
}
if ( ke->simpleData.keycode == Key_F35 ) {
if ( press ) emit backlight();
return TRUE;
@@ -696,93 +694,99 @@ void DesktopApplication::restart()
#ifdef Q_WS_QWS
for ( int fd = 3; fd < 100; fd++ )
close( fd );
#if defined(QT_DEMO_SINGLE_FLOPPY)
execl( "/sbin/init", "qpe", 0 );
#elif defined(QT_QWS_CASSIOPEIA)
execl( "/bin/sh", "sh", 0 );
#else
execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 );
#endif
exit(1);
#endif
}
void Desktop::startTransferServer()
{
// start qcop bridge server
qcopBridge = new QCopBridge( 4243 );
if ( !qcopBridge->ok() ) {
delete qcopBridge;
qcopBridge = 0;
}
// start transfer server
transferServer = new TransferServer( 4242 );
if ( !transferServer->ok() ) {
delete transferServer;
transferServer = 0;
}
if ( !transferServer || !qcopBridge )
startTimer( 2000 );
}
void Desktop::timerEvent( QTimerEvent *e )
{
killTimer( e->timerId() );
startTransferServer();
}
void Desktop::terminateServers()
{
delete transferServer;
delete qcopBridge;
transferServer = 0;
qcopBridge = 0;
}
void Desktop::rereadVolumes()
{
- Config cfg("Sound");
- cfg.setGroup("System");
- touchclick = cfg.readBoolEntry("Touch");
- keyclick = cfg.readBoolEntry("Key");
+ Config cfg("qpe");
+ cfg.setGroup("Volume");
+ touchclick = cfg.readBoolEntry("TouchSound");
+ keyclick = cfg.readBoolEntry("KeySound");
+ alarmsound = cfg.readBoolEntry("AlarmSound");
+// Config cfg("Sound");
+// cfg.setGroup("System");
+// touchclick = cfg.readBoolEntry("Touch");
+// keyclick = cfg.readBoolEntry("Key");
}
void Desktop::keyClick()
{
#ifdef CUSTOM_SOUND_KEYCLICK
if ( keyclick )
CUSTOM_SOUND_KEYCLICK;
#endif
}
void Desktop::screenClick()
{
#ifdef CUSTOM_SOUND_TOUCH
if ( touchclick )
CUSTOM_SOUND_TOUCH;
#endif
}
void Desktop::soundAlarm()
{
#ifdef CUSTOM_SOUND_ALARM
+ if (alarmsound)
CUSTOM_SOUND_ALARM;
#endif
}
bool Desktop::eventFilter( QObject *w, QEvent *ev )
{
if ( ev->type() == QEvent::KeyPress ) {
QKeyEvent *ke = (QKeyEvent *)ev;
if ( ke->key() == Qt::Key_F11 ) { // menu key
QWidget *active = qApp->activeWindow();
if ( active && active->isPopup() ) {
active->close();
}
raiseMenu();
return TRUE;
}
}
return FALSE;
}
diff --git a/core/launcher/desktop.h b/core/launcher/desktop.h
index e094dc0..9bc4be9 100644
--- a/core/launcher/desktop.h
+++ b/core/launcher/desktop.h
@@ -30,107 +30,107 @@
#include <qdatetime.h>
class Background;
class Launcher;
class TaskBar;
class PowerStatus;
class QCopBridge;
class TransferServer;
class DesktopPowerAlerter;
class PackageSlave;
class DesktopApplication : public QPEApplication
{
Q_OBJECT
public:
DesktopApplication( int& argc, char **argv, Type t );
~DesktopApplication();
signals:
void home();
void datebook();
void contacts();
void launch();
void email();
void backlight();
void power();
void symbol();
void numLockStateToggle();
void capsLockStateToggle();
void prepareForRestart();
protected:
#ifdef Q_WS_QWS
bool qwsEventFilter( QWSEvent * );
#endif
void shutdown();
void restart();
public slots:
void receive( const QCString &msg, const QByteArray &data );
protected slots:
void shutdown(ShutdownImpl::Type);
void psTimeout();
void sendCard();
private:
DesktopPowerAlerter *pa;
PowerStatus *ps;
QTimer *cardSendTimer;
- QCopChannel *channel;
+ QCopChannel *channel;
};
class Desktop : public QWidget {
Q_OBJECT
public:
Desktop();
~Desktop();
static bool screenLocked();
void show();
void checkMemory();
void keyClick();
void screenClick();
static void soundAlarm();
public slots:
void raiseDatebook();
void raiseContacts();
void raiseMenu();
void raiseLauncher();
void raiseEmail();
void execAutoStart();
void togglePower();
void toggleLight();
void toggleNumLockState();
void toggleCapsLockState();
void toggleSymbolInput();
void terminateServers();
void rereadVolumes();
protected:
void executeOrModify(const QString& appLnkFile);
void styleChange( QStyle & );
void timerEvent( QTimerEvent *e );
bool eventFilter( QObject *, QEvent * );
QWidget *bg;
Launcher *launcher;
TaskBar *tb;
private:
void startTransferServer();
bool recoverMemory();
QCopBridge *qcopBridge;
TransferServer *transferServer;
PackageSlave *packageSlave;
QDateTime suspendTime;
- bool keyclick,touchclick;
+ bool keyclick,touchclick,alarmsound;
};
#endif // __DESKTOP_H__