summaryrefslogtreecommitdiff
authorsimon <simon>2003-03-25 20:30:12 (UTC)
committer simon <simon>2003-03-25 20:30:12 (UTC)
commit3a4ee8d8a53ca17703b34f84e1a411056ee7e50f (patch) (unidiff)
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
@@ -486,65 +486,66 @@ QPE_MEMALERTER_IMPL
486 486
487Desktop::Desktop() : 487Desktop::Desktop() :
488 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), 488 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ),
489 qcopBridge( 0 ), 489 qcopBridge( 0 ),
490 transferServer( 0 ), 490 transferServer( 0 ),
491 packageSlave( 0 ) 491 packageSlave( 0 )
492{ 492{
493 qpedesktop = this; 493 qpedesktop = this;
494 494
495 // bg = new Info( this ); 495 // bg = new Info( this );
496 tb = new TaskBar; 496 tb = new TaskBar;
497 497
498 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); 498 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader );
499 499
500 connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) ); 500 connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) );
501 connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) ); 501 connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) );
502 502
503 int displayw = qApp->desktop() ->width(); 503 int displayw = qApp->desktop() ->width();
504 int displayh = qApp->desktop() ->height(); 504 int displayh = qApp->desktop() ->height();
505 505
506 506
507 QSize sz = tb->sizeHint(); 507 QSize sz = tb->sizeHint();
508 508
509 setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); 509 setGeometry( 0, displayh - sz.height(), displayw, sz.height() );
510 tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); 510 layout();
511 511
512 tb->show(); 512 tb->show();
513 launcher->showMaximized(); 513 launcher->showMaximized();
514 launcher->show(); 514 launcher->show();
515 launcher->raise(); 515 launcher->raise();
516#if defined(QPE_HAVE_MEMALERTER) 516#if defined(QPE_HAVE_MEMALERTER)
517 517
518 initMemalerter(); 518 initMemalerter();
519#endif 519#endif
520 // start services 520 // start services
521 startTransferServer(); 521 startTransferServer();
522 ( void ) new IrServer( this ); 522 ( void ) new IrServer( this );
523 523
524 packageSlave = new PackageSlave( this ); 524 packageSlave = new PackageSlave( this );
525 525
526 qApp->installEventFilter( this ); 526 qApp->installEventFilter( this );
527 qApp->desktop()->installEventFilter( this );
527 528
528 qApp-> setMainWidget ( launcher ); 529 qApp-> setMainWidget ( launcher );
529} 530}
530 531
531void Desktop::show() 532void Desktop::show()
532{ 533{
533 login( TRUE ); 534 login( TRUE );
534 QWidget::show(); 535 QWidget::show();
535} 536}
536 537
537Desktop::~Desktop() 538Desktop::~Desktop()
538{ 539{
539 delete launcher; 540 delete launcher;
540 delete tb; 541 delete tb;
541 delete qcopBridge; 542 delete qcopBridge;
542 delete transferServer; 543 delete transferServer;
543} 544}
544 545
545bool Desktop::recoverMemory() 546bool Desktop::recoverMemory()
546{ 547{
547 return tb->recoverMemory(); 548 return tb->recoverMemory();
548} 549}
549 550
550void Desktop::checkMemory() 551void Desktop::checkMemory()
@@ -711,54 +712,49 @@ void Desktop::togglePower()
711void Desktop::toggleLight() 712void Desktop::toggleLight()
712{ 713{
713 QCopEnvelope e( "QPE/System", "setBacklight(int)" ); 714 QCopEnvelope e( "QPE/System", "setBacklight(int)" );
714 e << -2; // toggle 715 e << -2; // toggle
715} 716}
716 717
717void Desktop::toggleSymbolInput() 718void Desktop::toggleSymbolInput()
718{ 719{
719 tb->toggleSymbolInput(); 720 tb->toggleSymbolInput();
720} 721}
721 722
722void Desktop::toggleNumLockState() 723void Desktop::toggleNumLockState()
723{ 724{
724 tb->toggleNumLockState(); 725 tb->toggleNumLockState();
725} 726}
726 727
727void Desktop::toggleCapsLockState() 728void Desktop::toggleCapsLockState()
728{ 729{
729 tb->toggleCapsLockState(); 730 tb->toggleCapsLockState();
730} 731}
731 732
732void Desktop::styleChange( QStyle &s ) 733void Desktop::styleChange( QStyle &s )
733{ 734{
734 QWidget::styleChange( s ); 735 QWidget::styleChange( s );
735 int displayw = qApp->desktop() ->width(); 736 layout();
736 int displayh = qApp->desktop() ->height();
737
738 QSize sz = tb->sizeHint();
739
740 tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() );
741} 737}
742 738
743void DesktopApplication::shutdown() 739void DesktopApplication::shutdown()
744{ 740{
745 if ( type() != GuiServer ) 741 if ( type() != GuiServer )
746 return ; 742 return ;
747 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); 743 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose );
748 connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ), 744 connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ),
749 this, SLOT( shutdown( ShutdownImpl::Type ) ) ); 745 this, SLOT( shutdown( ShutdownImpl::Type ) ) );
750 sd->showMaximized(); 746 sd->showMaximized();
751} 747}
752 748
753void DesktopApplication::shutdown( ShutdownImpl::Type t ) 749void DesktopApplication::shutdown( ShutdownImpl::Type t )
754{ 750{
755 char *opt = 0; 751 char *opt = 0;
756 752
757 switch ( t ) { 753 switch ( t ) {
758 case ShutdownImpl::ShutdownSystem: 754 case ShutdownImpl::ShutdownSystem:
759 opt = "-h"; 755 opt = "-h";
760 // fall through 756 // fall through
761 case ShutdownImpl::RebootSystem: 757 case ShutdownImpl::RebootSystem:
762 if ( opt == 0 ) 758 if ( opt == 0 )
763 opt = "-r"; 759 opt = "-r";
764 760
@@ -785,72 +781,93 @@ void DesktopApplication::shutdown( ShutdownImpl::Type t )
785 781
786void DesktopApplication::restart() 782void DesktopApplication::restart()
787{ 783{
788 prepareForTermination( TRUE ); 784 prepareForTermination( TRUE );
789 785
790#ifdef Q_WS_QWS 786#ifdef Q_WS_QWS
791 787
792 for ( int fd = 3; fd < 100; fd++ ) 788 for ( int fd = 3; fd < 100; fd++ )
793 close( fd ); 789 close( fd );
794#if defined(QT_DEMO_SINGLE_FLOPPY) 790#if defined(QT_DEMO_SINGLE_FLOPPY)
795 791
796 execl( "/sbin/init", "qpe", 0 ); 792 execl( "/sbin/init", "qpe", 0 );
797#elif defined(QT_QWS_CASSIOPEIA) 793#elif defined(QT_QWS_CASSIOPEIA)
798 794
799 execl( "/bin/sh", "sh", 0 ); 795 execl( "/bin/sh", "sh", 0 );
800#else 796#else
801 797
802 execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 ); 798 execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 );
803#endif 799#endif
804 800
805 exit( 1 ); 801 exit( 1 );
806#endif 802#endif
807} 803}
808 804
805void Desktop::layout()
806{
807 int displayw = qApp->desktop() ->width();
808 int displayh = qApp->desktop() ->height();
809
810 QSize sz = tb->sizeHint();
811
812 tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() );
813 tb->calcMaxWindowRect();
814}
815
809void Desktop::startTransferServer() 816void Desktop::startTransferServer()
810{ 817{
811 // start qcop bridge server 818 // start qcop bridge server
812 qcopBridge = new QCopBridge( 4243 ); 819 qcopBridge = new QCopBridge( 4243 );
813 if ( !qcopBridge->ok() ) { 820 if ( !qcopBridge->ok() ) {
814 delete qcopBridge; 821 delete qcopBridge;
815 qcopBridge = 0; 822 qcopBridge = 0;
816 } 823 }
817 // start transfer server 824 // start transfer server
818 transferServer = new TransferServer( 4242 ); 825 transferServer = new TransferServer( 4242 );
819 if ( !transferServer->ok() ) { 826 if ( !transferServer->ok() ) {
820 delete transferServer; 827 delete transferServer;
821 transferServer = 0; 828 transferServer = 0;
822 } 829 }
823 if ( !transferServer || !qcopBridge ) 830 if ( !transferServer || !qcopBridge )
824 startTimer( 2000 ); 831 startTimer( 2000 );
825} 832}
826 833
827void Desktop::timerEvent( QTimerEvent *e ) 834void Desktop::timerEvent( QTimerEvent *e )
828{ 835{
829 killTimer( e->timerId() ); 836 killTimer( e->timerId() );
830 startTransferServer(); 837 startTransferServer();
831} 838}
832 839
840bool Desktop::eventFilter( QObject *o, QEvent *ev )
841{
842 if ( o != qApp->desktop() || ev->type() != QEvent::Resize )
843 return QWidget::eventFilter( o, ev );
844
845 layout();
846
847 return QWidget::eventFilter( o, ev );
848}
849
833void Desktop::terminateServers() 850void Desktop::terminateServers()
834{ 851{
835 delete transferServer; 852 delete transferServer;
836 delete qcopBridge; 853 delete qcopBridge;
837 transferServer = 0; 854 transferServer = 0;
838 qcopBridge = 0; 855 qcopBridge = 0;
839} 856}
840 857
841void DesktopApplication::rereadVolumes() 858void DesktopApplication::rereadVolumes()
842{ 859{
843 Config cfg( "qpe" ); 860 Config cfg( "qpe" );
844 cfg. setGroup ( "Volume" ); 861 cfg. setGroup ( "Volume" );
845 862
846 m_screentap_sound = cfg. readBoolEntry ( "TouchSound" ); 863 m_screentap_sound = cfg. readBoolEntry ( "TouchSound" );
847 m_keyclick_sound = cfg. readBoolEntry ( "KeySound" ); 864 m_keyclick_sound = cfg. readBoolEntry ( "KeySound" );
848 m_alarm_sound = cfg. readBoolEntry ( "AlarmSound" ); 865 m_alarm_sound = cfg. readBoolEntry ( "AlarmSound" );
849} 866}
850 867
851void DesktopApplication::soundAlarm() 868void DesktopApplication::soundAlarm()
852{ 869{
853 if ( me ( )-> m_alarm_sound ) 870 if ( me ( )-> m_alarm_sound )
854 ODevice::inst ( )-> alarmSound ( ); 871 ODevice::inst ( )-> alarmSound ( );
855} 872}
856 873
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
@@ -113,43 +113,45 @@ class Desktop : public QWidget
113{ 113{
114 Q_OBJECT 114 Q_OBJECT
115public: 115public:
116 Desktop(); 116 Desktop();
117 ~Desktop(); 117 ~Desktop();
118 118
119 static bool screenLocked(); 119 static bool screenLocked();
120 120
121 void show(); 121 void show();
122 void checkMemory(); 122 void checkMemory();
123 123
124public slots: 124public slots:
125 void execAutoStart(); 125 void execAutoStart();
126 void togglePower(); 126 void togglePower();
127 void toggleLight(); 127 void toggleLight();
128 void toggleNumLockState(); 128 void toggleNumLockState();
129 void toggleCapsLockState(); 129 void toggleCapsLockState();
130 void toggleSymbolInput(); 130 void toggleSymbolInput();
131 void terminateServers(); 131 void terminateServers();
132 132
133protected: 133protected:
134 void executeOrModify( const QString& appLnkFile ); 134 void executeOrModify( const QString& appLnkFile );
135 void styleChange( QStyle & ); 135 void styleChange( QStyle & );
136 void timerEvent( QTimerEvent *e ); 136 void timerEvent( QTimerEvent *e );
137 virtual bool eventFilter( QObject *o, QEvent *ev );
137 138
138 QWidget *bg; 139 QWidget *bg;
139 Launcher *launcher; 140 Launcher *launcher;
140 TaskBar *tb; 141 TaskBar *tb;
141 142
142private: 143private:
144 void layout();
143 void startTransferServer(); 145 void startTransferServer();
144 bool recoverMemory(); 146 bool recoverMemory();
145 147
146 QCopBridge *qcopBridge; 148 QCopBridge *qcopBridge;
147 TransferServer *transferServer; 149 TransferServer *transferServer;
148 PackageSlave *packageSlave; 150 PackageSlave *packageSlave;
149 151
150 QDateTime suspendTime; 152 QDateTime suspendTime;
151}; 153};
152 154
153 155
154#endif // __DESKTOP_H__ 156#endif // __DESKTOP_H__
155 157
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
@@ -40,45 +40,46 @@ class TaskBar : public QHBox {
40 Q_OBJECT 40 Q_OBJECT
41public: 41public:
42 TaskBar(); 42 TaskBar();
43 ~TaskBar(); 43 ~TaskBar();
44 44
45 static QWidget *calibrate( bool ); 45 static QWidget *calibrate( bool );
46 46
47 bool recoverMemory(); 47 bool recoverMemory();
48 48
49 StartMenu *startMenu() const { return sm; } 49 StartMenu *startMenu() const { return sm; }
50public slots: 50public slots:
51 void startWait(); 51 void startWait();
52 void stopWait(const QString&); 52 void stopWait(const QString&);
53 void stopWait(); 53 void stopWait();
54 void clearStatusBar(); 54 void clearStatusBar();
55 void toggleNumLockState(); 55 void toggleNumLockState();
56 void toggleCapsLockState(); 56 void toggleCapsLockState();
57 void toggleSymbolInput(); 57 void toggleSymbolInput();
58 58
59protected: 59protected:
60 void resizeEvent( QResizeEvent * ); 60 void resizeEvent( QResizeEvent * );
61 void styleChange( QStyle & ); 61 void styleChange( QStyle & );
62 void setStatusMessage( const QString &text ); 62 void setStatusMessage( const QString &text );
63 63
64private slots: 64public slots:
65 void calcMaxWindowRect(); 65 void calcMaxWindowRect();
66private slots:
66 void receive( const QCString &msg, const QByteArray &data ); 67 void receive( const QCString &msg, const QByteArray &data );
67 68
68private: 69private:
69 70
70 QTimer *waitTimer; 71 QTimer *waitTimer;
71 Wait *waitIcon; 72 Wait *waitIcon;
72 InputMethods *inputMethods; 73 InputMethods *inputMethods;
73 SysTray *sysTray; 74 SysTray *sysTray;
74 // MRUList *mru; 75 // MRUList *mru;
75 RunningAppBar* runningAppBar; 76 RunningAppBar* runningAppBar;
76 QWidgetStack *stack; 77 QWidgetStack *stack;
77 QTimer *clearer; 78 QTimer *clearer;
78 QLabel *label; 79 QLabel *label;
79 LockKeyState* lockState; 80 LockKeyState* lockState;
80 StartMenu *sm; 81 StartMenu *sm;
81}; 82};
82 83
83 84
84#endif // __TASKBAR_H__ 85#endif // __TASKBAR_H__