summaryrefslogtreecommitdiff
authorsimon <simon>2003-03-25 20:30:12 (UTC)
committer simon <simon>2003-03-25 20:30:12 (UTC)
commit3a4ee8d8a53ca17703b34f84e1a411056ee7e50f (patch) (side-by-side diff)
tree6010cc8c464767725a7ab8b973428945dca62994
parentf7395e72a415322101ee3e22cb0e10b6bdf60a63 (diff)
downloadopie-3a4ee8d8a53ca17703b34f84e1a411056ee7e50f.zip
opie-3a4ee8d8a53ca17703b34f84e1a411056ee7e50f.tar.gz
opie-3a4ee8d8a53ca17703b34f84e1a411056ee7e50f.tar.bz2
- keep an eye on resize events on the desktop widget, which are an
indication for things like life rotation. upon a resize re-layout things (taskbar, tabs and maxwindow rect)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp31
-rw-r--r--core/launcher/desktop.h2
-rw-r--r--core/launcher/taskbar.h3
3 files changed, 28 insertions, 8 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index 86527f6..6def126 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -462,113 +462,114 @@ bool DesktopApplication::qwsEventFilter( QWSEvent *e )
if ( me-> simpleData. state & LeftButton ) {
if ( up ) {
up = false;
if ( m_screentap_sound )
ODevice::inst ( ) -> touchSound ( );
}
}
else {
up = true;
}
}
return QPEApplication::qwsEventFilter ( e );
}
#endif
#if defined(QPE_HAVE_MEMALERTER)
QPE_MEMALERTER_IMPL
#endif
//===========================================================================
Desktop::Desktop() :
QWidget( 0, 0, WStyle_Tool | WStyle_Customize ),
qcopBridge( 0 ),
transferServer( 0 ),
packageSlave( 0 )
{
qpedesktop = this;
// bg = new Info( this );
tb = new TaskBar;
launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader );
connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) );
connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) );
int displayw = qApp->desktop() ->width();
int displayh = qApp->desktop() ->height();
QSize sz = tb->sizeHint();
setGeometry( 0, displayh - sz.height(), displayw, sz.height() );
- tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() );
+ layout();
tb->show();
launcher->showMaximized();
launcher->show();
launcher->raise();
#if defined(QPE_HAVE_MEMALERTER)
initMemalerter();
#endif
// start services
startTransferServer();
( void ) new IrServer( this );
packageSlave = new PackageSlave( this );
qApp->installEventFilter( this );
+ qApp->desktop()->installEventFilter( this );
qApp-> setMainWidget ( launcher );
}
void Desktop::show()
{
login( TRUE );
QWidget::show();
}
Desktop::~Desktop()
{
delete launcher;
delete tb;
delete qcopBridge;
delete transferServer;
}
bool Desktop::recoverMemory()
{
return tb->recoverMemory();
}
void Desktop::checkMemory()
{
#if defined(QPE_HAVE_MEMALERTER)
static bool ignoreNormal = FALSE;
static bool existingMessage = FALSE;
if ( existingMessage )
return ; // don't show a second message while still on first
existingMessage = TRUE;
switch ( memstate ) {
case Unknown:
break;
case Low:
memstate = Unknown;
if ( recoverMemory() )
ignoreNormal = TRUE;
else
QMessageBox::warning( 0 , "Memory Status",
"The memory smacks of shortage. \n"
"Please save data. " );
break;
case Normal:
memstate = Unknown;
if ( ignoreNormal )
@@ -687,175 +688,191 @@ void Desktop::togglePower()
QGfx *g = qt_screen-> screenGfx ( );
g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( ));
delete g;
}
#endif
ODevice::inst ( )-> suspend ( );
DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call
QWSServer::screenSaverActivate ( false );
{
QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep
}
if ( wasloggedin )
login ( true );
execAutoStart();
//qcopBridge->closeOpenConnections();
excllock = false;
}
void Desktop::toggleLight()
{
QCopEnvelope e( "QPE/System", "setBacklight(int)" );
e << -2; // toggle
}
void Desktop::toggleSymbolInput()
{
tb->toggleSymbolInput();
}
void Desktop::toggleNumLockState()
{
tb->toggleNumLockState();
}
void Desktop::toggleCapsLockState()
{
tb->toggleCapsLockState();
}
void Desktop::styleChange( QStyle &s )
{
QWidget::styleChange( s );
- int displayw = qApp->desktop() ->width();
- int displayh = qApp->desktop() ->height();
-
- QSize sz = tb->sizeHint();
-
- tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() );
+ layout();
}
void DesktopApplication::shutdown()
{
if ( type() != GuiServer )
return ;
ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose );
connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ),
this, SLOT( shutdown( ShutdownImpl::Type ) ) );
sd->showMaximized();
}
void DesktopApplication::shutdown( ShutdownImpl::Type t )
{
char *opt = 0;
switch ( t ) {
case ShutdownImpl::ShutdownSystem:
opt = "-h";
// fall through
case ShutdownImpl::RebootSystem:
if ( opt == 0 )
opt = "-r";
if ( execl( "/sbin/shutdown", "shutdown", opt, "now", ( void* ) 0) < 0 )
perror("shutdown");
// ::syslog ( LOG_ERR, "Erroring execing shutdown\n" );
break;
case ShutdownImpl::RestartDesktop:
restart();
break;
case ShutdownImpl::TerminateDesktop:
prepareForTermination( FALSE );
// This is a workaround for a Qt bug
// clipboard applet has to stop its poll timer, or Qt/E
// will hang on quit() right before it emits aboutToQuit()
emit aboutToQuit ( );
quit();
break;
}
}
void DesktopApplication::restart()
{
prepareForTermination( TRUE );
#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::layout()
+{
+ int displayw = qApp->desktop() ->width();
+ int displayh = qApp->desktop() ->height();
+
+ QSize sz = tb->sizeHint();
+
+ tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() );
+ tb->calcMaxWindowRect();
+}
+
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();
}
+bool Desktop::eventFilter( QObject *o, QEvent *ev )
+{
+ if ( o != qApp->desktop() || ev->type() != QEvent::Resize )
+ return QWidget::eventFilter( o, ev );
+
+ layout();
+
+ return QWidget::eventFilter( o, ev );
+}
+
void Desktop::terminateServers()
{
delete transferServer;
delete qcopBridge;
transferServer = 0;
qcopBridge = 0;
}
void DesktopApplication::rereadVolumes()
{
Config cfg( "qpe" );
cfg. setGroup ( "Volume" );
m_screentap_sound = cfg. readBoolEntry ( "TouchSound" );
m_keyclick_sound = cfg. readBoolEntry ( "KeySound" );
m_alarm_sound = cfg. readBoolEntry ( "AlarmSound" );
}
void DesktopApplication::soundAlarm()
{
if ( me ( )-> m_alarm_sound )
ODevice::inst ( )-> alarmSound ( );
}
DesktopApplication *DesktopApplication::me ( )
{
return (DesktopApplication *) qApp;
}
diff --git a/core/launcher/desktop.h b/core/launcher/desktop.h
index 4024c38..86d8aa8 100644
--- a/core/launcher/desktop.h
+++ b/core/launcher/desktop.h
@@ -89,67 +89,69 @@ private:
static DesktopApplication *me ( );
private:
void reloadPowerWarnSettings();
DesktopPowerAlerter *pa;
PowerStatus *m_ps, *m_ps_last;
QTimer *cardSendTimer;
QCopChannel *channel;
OpieScreenSaver *m_screensaver;
QTimer * m_apm_timer;
int m_powerVeryLow;
int m_powerCritical;
int m_currentPowerLevel;
const Opie::ODeviceButton *m_last_button;
QTimer *m_button_timer;
bool m_keyclick_sound : 1;
bool m_screentap_sound : 1;
bool m_alarm_sound : 1;
};
class Desktop : public QWidget
{
Q_OBJECT
public:
Desktop();
~Desktop();
static bool screenLocked();
void show();
void checkMemory();
public slots:
void execAutoStart();
void togglePower();
void toggleLight();
void toggleNumLockState();
void toggleCapsLockState();
void toggleSymbolInput();
void terminateServers();
protected:
void executeOrModify( const QString& appLnkFile );
void styleChange( QStyle & );
void timerEvent( QTimerEvent *e );
+ virtual bool eventFilter( QObject *o, QEvent *ev );
QWidget *bg;
Launcher *launcher;
TaskBar *tb;
private:
+ void layout();
void startTransferServer();
bool recoverMemory();
QCopBridge *qcopBridge;
TransferServer *transferServer;
PackageSlave *packageSlave;
QDateTime suspendTime;
};
#endif // __DESKTOP_H__
diff --git a/core/launcher/taskbar.h b/core/launcher/taskbar.h
index cd631ef..a0bf395 100644
--- a/core/launcher/taskbar.h
+++ b/core/launcher/taskbar.h
@@ -16,69 +16,70 @@
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#ifndef __TASKBAR_H__
#define __TASKBAR_H__
#include <qhbox.h>
class QLabel;
class QTimer;
class InputMethods;
class Wait;
class SysTray;
//class MRUList;
class RunningAppBar;
class QWidgetStack;
class QTimer;
class QLabel;
class StartMenu;
class LockKeyState;
class TaskBar : public QHBox {
Q_OBJECT
public:
TaskBar();
~TaskBar();
static QWidget *calibrate( bool );
bool recoverMemory();
StartMenu *startMenu() const { return sm; }
public slots:
void startWait();
void stopWait(const QString&);
void stopWait();
void clearStatusBar();
void toggleNumLockState();
void toggleCapsLockState();
void toggleSymbolInput();
protected:
void resizeEvent( QResizeEvent * );
void styleChange( QStyle & );
void setStatusMessage( const QString &text );
-private slots:
+public slots:
void calcMaxWindowRect();
+private slots:
void receive( const QCString &msg, const QByteArray &data );
private:
QTimer *waitTimer;
Wait *waitIcon;
InputMethods *inputMethods;
SysTray *sysTray;
// MRUList *mru;
RunningAppBar* runningAppBar;
QWidgetStack *stack;
QTimer *clearer;
QLabel *label;
LockKeyState* lockState;
StartMenu *sm;
};
#endif // __TASKBAR_H__