author | jeremy <jeremy> | 2002-02-10 13:22:54 (UTC) |
---|---|---|
committer | jeremy <jeremy> | 2002-02-10 13:22:54 (UTC) |
commit | 261b98eff083215db69843da28a05cfd1f7b3795 (patch) (unidiff) | |
tree | 3e9ed039218f0a132c9413987e03a5b6dc5cb24e | |
parent | d0d626304ffb0de247e22760bc342e72406e301a (diff) | |
download | opie-261b98eff083215db69843da28a05cfd1f7b3795.zip opie-261b98eff083215db69843da28a05cfd1f7b3795.tar.gz opie-261b98eff083215db69843da28a05cfd1f7b3795.tar.bz2 |
Added support for setMic and micChange QCop messages. These additions
are exactly like setVolume and volumeChange excopt of course, they
change the mic input level instead of the volume out level.
-rw-r--r-- | library/opie-base.control | 2 | ||||
-rw-r--r-- | library/qpeapplication.cpp | 181 | ||||
-rw-r--r-- | library/qpeapplication.h | 6 |
3 files changed, 112 insertions, 77 deletions
diff --git a/library/opie-base.control b/library/opie-base.control index f883268..e610b8b 100644 --- a/library/opie-base.control +++ b/library/opie-base.control | |||
@@ -1,10 +1,10 @@ | |||
1 | Files: etc/qimpen etc/colors etc/init.d/qpe etc/rc2.d/S98qpe bin/qpe-reorgfiles $QTDIR/lib/libqpe.so.$VERSION_MAJ.$VERSION_MIN.$VERSION_PAT $QTDIR/lib/libqpe.so.$VERSION_MAJ.$VERSION_MIN $QTDIR/lib/libqpe.so.$VERSION_MAJ apps/__7separator.desktop apps/__9quit.desktop apps/*/.directory etc/mime.types apps/Settings/quit.desktop pics/UnknownDocument-14.png pics/UnknownDocument.png | 1 | Files: etc/qimpen etc/colors etc/init.d/qpe etc/rc2.d/S98qpe bin/qpe-reorgfiles $QTDIR/lib/libqpe.so.$VERSION_MAJ.$VERSION_MIN.$VERSION_PAT $QTDIR/lib/libqpe.so.$VERSION_MAJ.$VERSION_MIN $QTDIR/lib/libqpe.so.$VERSION_MAJ apps/__7separator.desktop apps/__9quit.desktop apps/*/.directory etc/mime.types apps/Settings/quit.desktop pics/UnknownDocument-14.png pics/UnknownDocument.png |
2 | Priority: required | 2 | Priority: required |
3 | Section: opie/system | 3 | Section: opie/system |
4 | Maintainer: Warwick Allison <warwick@trolltech.com> | 4 | Maintainer: Warwick Allison <warwick@trolltech.com> |
5 | Architecture: arm | 5 | Architecture: arm |
6 | Version: $QPE_VERSION-$SUB_VERSION | 6 | Version: $QPE_VERSION-$SUB_VERSION.1 |
7 | Depends: qt-embedded (>=$QTE_VERSION), opie-qcop, opie-taskbar, opie-pics, opie-sounds, apmd | 7 | Depends: qt-embedded (>=$QTE_VERSION), opie-qcop, opie-taskbar, opie-pics, opie-sounds, apmd |
8 | Description: Base Qtopia environment | 8 | Description: Base Qtopia environment |
9 | A complete GUI environment for handhelds. | 9 | A complete GUI environment for handhelds. |
10 | You will probably want to install one of the opie-i18n-* packages. | 10 | You will probably want to install one of the opie-i18n-* packages. |
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 4dbfbd8..a55f5f9 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -102,147 +102,167 @@ public: | |||
102 | bool rightpressed; | 102 | bool rightpressed; |
103 | int kbgrabber; | 103 | int kbgrabber; |
104 | bool kbregrab; | 104 | bool kbregrab; |
105 | bool notbusysent; | 105 | bool notbusysent; |
106 | QString appName; | 106 | QString appName; |
107 | struct QCopRec { | 107 | struct QCopRec { |
108 | QCopRec(const QCString &ch, const QCString &msg, | 108 | QCopRec(const QCString &ch, const QCString &msg, |
109 | const QByteArray &d) : | 109 | const QByteArray &d) : |
110 | channel(ch), message(msg), data(d) { } | 110 | channel(ch), message(msg), data(d) { } |
111 | 111 | ||
112 | QCString channel; | 112 | QCString channel; |
113 | QCString message; | 113 | QCString message; |
114 | QByteArray data; | 114 | QByteArray data; |
115 | }; | 115 | }; |
116 | bool preloaded; | 116 | bool preloaded; |
117 | bool forceshow; | 117 | bool forceshow; |
118 | bool nomaximize; | 118 | bool nomaximize; |
119 | QWidget* qpe_main_widget; | 119 | QWidget* qpe_main_widget; |
120 | bool keep_running; | 120 | bool keep_running; |
121 | QList<QCopRec> qcopq; | 121 | QList<QCopRec> qcopq; |
122 | 122 | ||
123 | void enqueueQCop(const QCString &ch, const QCString &msg, | 123 | void enqueueQCop(const QCString &ch, const QCString &msg, |
124 | const QByteArray &data) | 124 | const QByteArray &data) |
125 | { | 125 | { |
126 | qcopq.append(new QCopRec(ch,msg,data)); | 126 | qcopq.append(new QCopRec(ch,msg,data)); |
127 | } | 127 | } |
128 | void sendQCopQ() | 128 | void sendQCopQ() |
129 | { | 129 | { |
130 | QCopRec* r; | 130 | QCopRec* r; |
131 | for (QListIterator<QCopRec> it(qcopq); (r=it.current()); ++it) | 131 | for (QListIterator<QCopRec> it(qcopq); (r=it.current()); ++it) |
132 | QCopChannel::sendLocally(r->channel,r->message,r->data); | 132 | QCopChannel::sendLocally(r->channel,r->message,r->data); |
133 | qcopq.clear(); | 133 | qcopq.clear(); |
134 | } | 134 | } |
135 | }; | 135 | }; |
136 | 136 | ||
137 | class ResourceMimeFactory : public QMimeSourceFactory { | 137 | class ResourceMimeFactory : public QMimeSourceFactory { |
138 | public: | 138 | public: |
139 | ResourceMimeFactory() | 139 | ResourceMimeFactory() |
140 | { | 140 | { |
141 | setFilePath( Global::helpPath() ); | 141 | setFilePath( Global::helpPath() ); |
142 | setExtensionType("html","text/html;charset=UTF-8"); | 142 | setExtensionType("html","text/html;charset=UTF-8"); |
143 | } | 143 | } |
144 | 144 | ||
145 | const QMimeSource* data(const QString& abs_name) const | 145 | const QMimeSource* data(const QString& abs_name) const |
146 | { | 146 | { |
147 | const QMimeSource* r = QMimeSourceFactory::data(abs_name); | 147 | const QMimeSource* r = QMimeSourceFactory::data(abs_name); |
148 | if ( !r ) { | 148 | if ( !r ) { |
149 | int sl = abs_name.length(); | 149 | int sl = abs_name.length(); |
150 | do { | 150 | do { |
151 | sl = abs_name.findRev('/',sl-1); | 151 | sl = abs_name.findRev('/',sl-1); |
152 | QString name = sl>=0 ? abs_name.mid(sl+1) : abs_name; | 152 | QString name = sl>=0 ? abs_name.mid(sl+1) : abs_name; |
153 | int dot = name.findRev('.'); | 153 | int dot = name.findRev('.'); |
154 | if ( dot >= 0 ) | 154 | if ( dot >= 0 ) |
155 | name = name.left(dot); | 155 | name = name.left(dot); |
156 | QImage img = Resource::loadImage(name); | 156 | QImage img = Resource::loadImage(name); |
157 | if ( !img.isNull() ) | 157 | if ( !img.isNull() ) |
158 | r = new QImageDrag(img); | 158 | r = new QImageDrag(img); |
159 | } while (!r && sl>0); | 159 | } while (!r && sl>0); |
160 | } | 160 | } |
161 | return r; | 161 | return r; |
162 | } | 162 | } |
163 | }; | 163 | }; |
164 | 164 | ||
165 | static int muted=0; | 165 | static int muted=0; |
166 | static int micMuted=0; | ||
166 | 167 | ||
167 | static void setVolume(int t=0, int percent=-1) | 168 | static void setVolume(int t=0, int percent=-1) |
168 | { | 169 | { |
169 | switch (t) { | 170 | switch (t) { |
170 | case 0: { | 171 | case 0: { |
171 | Config cfg("Sound"); | 172 | Config cfg("Sound"); |
172 | cfg.setGroup("System"); | 173 | cfg.setGroup("System"); |
173 | if ( percent < 0 ) | 174 | if ( percent < 0 ) |
174 | percent = cfg.readNumEntry("Volume",50); | 175 | percent = cfg.readNumEntry("Volume",50); |
175 | int fd = 0; | 176 | int fd = 0; |
176 | if ((fd = open("/dev/mixer", O_RDWR))>=0) { | 177 | if ((fd = open("/dev/mixer", O_RDWR))>=0) { |
177 | int vol = muted ? 0 : percent; | 178 | int vol = muted ? 0 : percent; |
178 | // set both channels to same volume | 179 | // set both channels to same volume |
179 | vol |= vol << 8; | 180 | vol |= vol << 8; |
180 | ioctl(fd, MIXER_WRITE(0), &vol); | 181 | ioctl(fd, MIXER_WRITE(0), &vol); |
181 | ::close(fd); | 182 | ::close(fd); |
182 | } | 183 | } |
183 | } break; | 184 | } break; |
184 | } | 185 | } |
186 | } | ||
187 | |||
188 | static void setMic(int t=0, int percent=-1) | ||
189 | { | ||
190 | switch (t) { | ||
191 | case 0: { | ||
192 | Config cfg("Sound"); | ||
193 | cfg.setGroup("System"); | ||
194 | if ( percent < 0 ) | ||
195 | percent = cfg.readNumEntry("Mic",50); | ||
196 | |||
197 | int fd = 0; | ||
198 | int mic = micMuted ? 0 : percent; | ||
199 | if ((fd = open("/dev/mixer", O_RDWR))>=0) { | ||
200 | ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &mic); | ||
201 | ::close(fd); | ||
202 | } | ||
203 | } break; | ||
204 | } | ||
185 | } | 205 | } |
186 | 206 | ||
187 | int qpe_sysBrightnessSteps() | 207 | int qpe_sysBrightnessSteps() |
188 | { | 208 | { |
189 | #if defined(QT_QWS_IPAQ) | 209 | #if defined(QT_QWS_IPAQ) |
190 | return 255; | 210 | return 255; |
191 | #elif defined(QT_QWS_EBX) | 211 | #elif defined(QT_QWS_EBX) |
192 | return 4; | 212 | return 4; |
193 | #else | 213 | #else |
194 | return 255; // ? | 214 | return 255; // ? |
195 | #endif | 215 | #endif |
196 | } | 216 | } |
197 | 217 | ||
198 | 218 | ||
199 | static int& hack(int& i) | 219 | static int& hack(int& i) |
200 | { | 220 | { |
201 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 221 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
202 | // These should be created, but aren't in Qt 2.3.0 | 222 | // These should be created, but aren't in Qt 2.3.0 |
203 | (void)new QUtf8Codec; | 223 | (void)new QUtf8Codec; |
204 | (void)new QUtf16Codec; | 224 | (void)new QUtf16Codec; |
205 | #endif | 225 | #endif |
206 | return i; | 226 | return i; |
207 | } | 227 | } |
208 | 228 | ||
209 | static bool forced_off = FALSE; | 229 | static bool forced_off = FALSE; |
210 | static int curbl=-1; | 230 | static int curbl=-1; |
211 | 231 | ||
212 | static int backlight() | 232 | static int backlight() |
213 | { | 233 | { |
214 | if ( curbl == -1 ) { | 234 | if ( curbl == -1 ) { |
215 | // Read from config | 235 | // Read from config |
216 | Config config( "qpe" ); | 236 | Config config( "qpe" ); |
217 | config.setGroup( "Screensaver" ); | 237 | config.setGroup( "Screensaver" ); |
218 | curbl = config.readNumEntry("Brightness",255); | 238 | curbl = config.readNumEntry("Brightness",255); |
219 | } | 239 | } |
220 | return curbl; | 240 | return curbl; |
221 | } | 241 | } |
222 | 242 | ||
223 | static void setBacklight(int bright) | 243 | static void setBacklight(int bright) |
224 | { | 244 | { |
225 | if ( bright == -3 ) { | 245 | if ( bright == -3 ) { |
226 | // Forced on | 246 | // Forced on |
227 | forced_off = FALSE; | 247 | forced_off = FALSE; |
228 | bright = -1; | 248 | bright = -1; |
229 | } | 249 | } |
230 | if ( forced_off && bright != -2 ) | 250 | if ( forced_off && bright != -2 ) |
231 | return; | 251 | return; |
232 | if ( bright == -2 ) { | 252 | if ( bright == -2 ) { |
233 | // Toggle between off and on | 253 | // Toggle between off and on |
234 | bright = curbl ? 0 : -1; | 254 | bright = curbl ? 0 : -1; |
235 | forced_off = !bright; | 255 | forced_off = !bright; |
236 | } | 256 | } |
237 | if ( bright == -1 ) { | 257 | if ( bright == -1 ) { |
238 | // Read from config | 258 | // Read from config |
239 | Config config( "qpe" ); | 259 | Config config( "qpe" ); |
240 | config.setGroup( "Screensaver" ); | 260 | config.setGroup( "Screensaver" ); |
241 | bright = config.readNumEntry("Brightness",255); | 261 | bright = config.readNumEntry("Brightness",255); |
242 | } | 262 | } |
243 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) | 263 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) |
244 | if ( QFile::exists("/usr/bin/bl") ) { | 264 | if ( QFile::exists("/usr/bin/bl") ) { |
245 | QString cmd = "/usr/bin/bl 1 "; | 265 | QString cmd = "/usr/bin/bl 1 "; |
246 | cmd += bright<=0 ? "0 " : "1 "; | 266 | cmd += bright<=0 ? "0 " : "1 "; |
247 | cmd += QString::number(bright); | 267 | cmd += QString::number(bright); |
248 | system(cmd.latin1()); | 268 | system(cmd.latin1()); |
@@ -808,254 +828,263 @@ int QPEApplication::defaultRotation() | |||
808 | deforient = 90; | 828 | deforient = 90; |
809 | } else if ( d.contains("Rot180") ) { | 829 | } else if ( d.contains("Rot180") ) { |
810 | deforient = 180; | 830 | deforient = 180; |
811 | } else if ( d.contains("Rot270") ) { | 831 | } else if ( d.contains("Rot270") ) { |
812 | deforient = 270; | 832 | deforient = 270; |
813 | } else { | 833 | } else { |
814 | deforient=0; | 834 | deforient=0; |
815 | } | 835 | } |
816 | } | 836 | } |
817 | return deforient; | 837 | return deforient; |
818 | } | 838 | } |
819 | 839 | ||
820 | /*! | 840 | /*! |
821 | \internal | 841 | \internal |
822 | */ | 842 | */ |
823 | void QPEApplication::setDefaultRotation(int r) | 843 | void QPEApplication::setDefaultRotation(int r) |
824 | { | 844 | { |
825 | if ( qApp->type() == GuiServer ) { | 845 | if ( qApp->type() == GuiServer ) { |
826 | deforient = r; | 846 | deforient = r; |
827 | setenv("QWS_DISPLAY", QString("Transformed:Rot%1:0").arg(r).latin1(), 1); | 847 | setenv("QWS_DISPLAY", QString("Transformed:Rot%1:0").arg(r).latin1(), 1); |
828 | } else { | 848 | } else { |
829 | QCopEnvelope("QPE/System", "setDefaultRotation(int)") << r; | 849 | QCopEnvelope("QPE/System", "setDefaultRotation(int)") << r; |
830 | } | 850 | } |
831 | } | 851 | } |
832 | 852 | ||
833 | /*! | 853 | /*! |
834 | \internal | 854 | \internal |
835 | */ | 855 | */ |
836 | void QPEApplication::applyStyle() | 856 | void QPEApplication::applyStyle() |
837 | { | 857 | { |
838 | Config config( "qpe" ); | 858 | Config config( "qpe" ); |
839 | 859 | ||
840 | config.setGroup( "Appearance" ); | 860 | config.setGroup( "Appearance" ); |
841 | 861 | ||
842 | // Widget style | 862 | // Widget style |
843 | QString style = config.readEntry( "Style", "Light" ); | 863 | QString style = config.readEntry( "Style", "Light" ); |
844 | internalSetStyle( style ); | 864 | internalSetStyle( style ); |
845 | 865 | ||
846 | // Colors | 866 | // Colors |
847 | QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); | 867 | QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); |
848 | QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); | 868 | QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); |
849 | QPalette pal( btncolor, bgcolor ); | 869 | QPalette pal( btncolor, bgcolor ); |
850 | QString color = config.readEntry( "Highlight", "#800000" ); | 870 | QString color = config.readEntry( "Highlight", "#800000" ); |
851 | pal.setColor( QColorGroup::Highlight, QColor(color) ); | 871 | pal.setColor( QColorGroup::Highlight, QColor(color) ); |
852 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); | 872 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); |
853 | pal.setColor( QColorGroup::HighlightedText, QColor(color) ); | 873 | pal.setColor( QColorGroup::HighlightedText, QColor(color) ); |
854 | color = config.readEntry( "Text", "#000000" ); | 874 | color = config.readEntry( "Text", "#000000" ); |
855 | pal.setColor( QColorGroup::Text, QColor(color) ); | 875 | pal.setColor( QColorGroup::Text, QColor(color) ); |
856 | color = config.readEntry( "ButtonText", "#000000" ); | 876 | color = config.readEntry( "ButtonText", "#000000" ); |
857 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor(color) ); | 877 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor(color) ); |
858 | color = config.readEntry( "Base", "#FFFFFF" ); | 878 | color = config.readEntry( "Base", "#FFFFFF" ); |
859 | pal.setColor( QColorGroup::Base, QColor(color) ); | 879 | pal.setColor( QColorGroup::Base, QColor(color) ); |
860 | 880 | ||
861 | pal.setColor( QPalette::Disabled, QColorGroup::Text, | 881 | pal.setColor( QPalette::Disabled, QColorGroup::Text, |
862 | pal.color(QPalette::Active, QColorGroup::Background).dark() ); | 882 | pal.color(QPalette::Active, QColorGroup::Background).dark() ); |
863 | 883 | ||
864 | setPalette( pal, TRUE ); | 884 | setPalette( pal, TRUE ); |
865 | } | 885 | } |
866 | 886 | ||
867 | void QPEApplication::systemMessage( const QCString &msg, const QByteArray &data) | 887 | void QPEApplication::systemMessage( const QCString &msg, const QByteArray &data) |
868 | { | 888 | { |
869 | #ifdef Q_WS_QWS | 889 | #ifdef Q_WS_QWS |
870 | QDataStream stream( data, IO_ReadOnly ); | 890 | QDataStream stream( data, IO_ReadOnly ); |
871 | if ( msg == "applyStyle()" ) { | 891 | if ( msg == "applyStyle()" ) { |
872 | applyStyle(); | 892 | applyStyle(); |
873 | } else if ( msg == "setScreenSaverInterval(int)" ) { | 893 | } else if ( msg == "setScreenSaverInterval(int)" ) { |
874 | if ( type() == GuiServer ) { | 894 | if ( type() == GuiServer ) { |
875 | int time; | 895 | int time; |
876 | stream >> time; | 896 | stream >> time; |
877 | setScreenSaverInterval(time); | 897 | setScreenSaverInterval(time); |
878 | } | 898 | } |
879 | } else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { | 899 | } else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { |
880 | if ( type() == GuiServer ) { | 900 | if ( type() == GuiServer ) { |
881 | int t1,t2,t3; | 901 | int t1,t2,t3; |
882 | stream >> t1 >> t2 >> t3; | 902 | stream >> t1 >> t2 >> t3; |
883 | setScreenSaverIntervals(t1,t2,t3); | 903 | setScreenSaverIntervals(t1,t2,t3); |
884 | } | 904 | } |
885 | } else if ( msg == "setBacklight(int)" ) { | 905 | } else if ( msg == "setBacklight(int)" ) { |
886 | if ( type() == GuiServer ) { | 906 | if ( type() == GuiServer ) { |
887 | int bright; | 907 | int bright; |
888 | stream >> bright; | 908 | stream >> bright; |
889 | setBacklight(bright); | 909 | setBacklight(bright); |
890 | } | 910 | } |
891 | } else if ( msg == "setDefaultRotation(int)" ) { | 911 | } else if ( msg == "setDefaultRotation(int)" ) { |
892 | if ( type() == GuiServer ) { | 912 | if ( type() == GuiServer ) { |
893 | int r; | 913 | int r; |
894 | stream >> r; | 914 | stream >> r; |
895 | setDefaultRotation(r); | 915 | setDefaultRotation(r); |
896 | } | 916 | } |
897 | } else if ( msg == "shutdown()" ) { | 917 | } else if ( msg == "shutdown()" ) { |
898 | if ( type() == GuiServer ) | 918 | if ( type() == GuiServer ) |
899 | shutdown(); | 919 | shutdown(); |
900 | } else if ( msg == "quit()" ) { | 920 | } else if ( msg == "quit()" ) { |
901 | if ( type() != GuiServer ) | 921 | if ( type() != GuiServer ) |
902 | tryQuit(); | 922 | tryQuit(); |
903 | } else if ( msg == "forceQuit()" ) { | 923 | } else if ( msg == "forceQuit()" ) { |
904 | if ( type() != GuiServer ) | 924 | if ( type() != GuiServer ) |
905 | quit(); | 925 | quit(); |
906 | } else if ( msg == "restart()" ) { | 926 | } else if ( msg == "restart()" ) { |
907 | if ( type() == GuiServer ) | 927 | if ( type() == GuiServer ) |
908 | restart(); | 928 | restart(); |
909 | } else if ( msg == "grabKeyboard(QString)" ) { | 929 | } else if ( msg == "grabKeyboard(QString)" ) { |
910 | QString who; | 930 | QString who; |
911 | stream >> who; | 931 | stream >> who; |
912 | if ( who.isEmpty() ) | 932 | if ( who.isEmpty() ) |
913 | d->kbgrabber = 0; | 933 | d->kbgrabber = 0; |
914 | else if ( who != d->appName ) | 934 | else if ( who != d->appName ) |
915 | d->kbgrabber = 1; | 935 | d->kbgrabber = 1; |
916 | else | 936 | else |
917 | d->kbgrabber = 2; | 937 | d->kbgrabber = 2; |
918 | } else if ( msg == "language(QString)" ) { | 938 | } else if ( msg == "language(QString)" ) { |
919 | if ( type() == GuiServer ) { | 939 | if ( type() == GuiServer ) { |
920 | QString l; | 940 | QString l; |
921 | stream >> l; | 941 | stream >> l; |
922 | QString cl = getenv("LANG"); | 942 | QString cl = getenv("LANG"); |
923 | if ( cl != l ) { | 943 | if ( cl != l ) { |
924 | if ( l.isNull() ) | 944 | if ( l.isNull() ) |
925 | unsetenv( "LANG" ); | 945 | unsetenv( "LANG" ); |
926 | else | 946 | else |
927 | setenv( "LANG", l.latin1(), 1 ); | 947 | setenv( "LANG", l.latin1(), 1 ); |
928 | restart(); | 948 | restart(); |
929 | } | 949 | } |
930 | } | 950 | } |
931 | } else if ( msg == "timeChange(QString)" ) { | 951 | } else if ( msg == "timeChange(QString)" ) { |
932 | QString t; | 952 | QString t; |
933 | stream >> t; | 953 | stream >> t; |
934 | if ( t.isNull() ) | 954 | if ( t.isNull() ) |
935 | unsetenv( "TZ" ); | 955 | unsetenv( "TZ" ); |
936 | else | 956 | else |
937 | setenv( "TZ", t.latin1(), 1 ); | 957 | setenv( "TZ", t.latin1(), 1 ); |
938 | // emit the signal so everyone else knows... | 958 | // emit the signal so everyone else knows... |
939 | emit timeChanged(); | 959 | emit timeChanged(); |
940 | } else if ( msg == "execute(QString)" ) { | 960 | } else if ( msg == "execute(QString)" ) { |
941 | if ( type() == GuiServer ) { | 961 | if ( type() == GuiServer ) { |
942 | QString t; | 962 | QString t; |
943 | stream >> t; | 963 | stream >> t; |
944 | Global::execute( t ); | 964 | Global::execute( t ); |
945 | } | 965 | } |
946 | } else if ( msg == "execute(QString,QString)" ) { | 966 | } else if ( msg == "execute(QString,QString)" ) { |
947 | if ( type() == GuiServer ) { | 967 | if ( type() == GuiServer ) { |
948 | QString t,d; | 968 | QString t,d; |
949 | stream >> t >> d; | 969 | stream >> t >> d; |
950 | Global::execute( t, d ); | 970 | Global::execute( t, d ); |
951 | } | 971 | } |
952 | } else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { | 972 | } else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { |
953 | if ( type() == GuiServer ) { | 973 | if ( type() == GuiServer ) { |
954 | QDateTime when; | 974 | QDateTime when; |
955 | QCString channel, message; | 975 | QCString channel, message; |
956 | int data; | 976 | int data; |
957 | stream >> when >> channel >> message >> data; | 977 | stream >> when >> channel >> message >> data; |
958 | AlarmServer::addAlarm( when, channel, message, data ); | 978 | AlarmServer::addAlarm( when, channel, message, data ); |
959 | } | 979 | } |
960 | } else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { | 980 | } else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { |
961 | if ( type() == GuiServer ) { | 981 | if ( type() == GuiServer ) { |
962 | QDateTime when; | 982 | QDateTime when; |
963 | QCString channel, message; | 983 | QCString channel, message; |
964 | int data; | 984 | int data; |
965 | stream >> when >> channel >> message >> data; | 985 | stream >> when >> channel >> message >> data; |
966 | AlarmServer::deleteAlarm( when, channel, message, data ); | 986 | AlarmServer::deleteAlarm( when, channel, message, data ); |
967 | } | 987 | } |
968 | } else if ( msg == "clockChange(bool)" ) { | 988 | } else if ( msg == "clockChange(bool)" ) { |
969 | int tmp; | 989 | int tmp; |
970 | stream >> tmp; | 990 | stream >> tmp; |
971 | emit clockChanged( tmp ); | 991 | emit clockChanged( tmp ); |
972 | } else if ( msg == "weekChange(bool)" ) { | 992 | } else if ( msg == "weekChange(bool)" ) { |
973 | int tmp; | 993 | int tmp; |
974 | stream >> tmp; | 994 | stream >> tmp; |
975 | emit weekChanged( tmp ); | 995 | emit weekChanged( tmp ); |
976 | } else if ( msg == "setDateFormat(DateFormat)" ) { | 996 | } else if ( msg == "setDateFormat(DateFormat)" ) { |
977 | DateFormat tmp; | 997 | DateFormat tmp; |
978 | stream >> tmp; | 998 | stream >> tmp; |
979 | emit dateFormatChanged( tmp ); | 999 | emit dateFormatChanged( tmp ); |
980 | } else if ( msg == "setVolume(int,int)" ) { | 1000 | } else if ( msg == "setVolume(int,int)" ) { |
981 | int t,v; | 1001 | int t,v; |
982 | stream >> t >> v; | 1002 | stream >> t >> v; |
983 | setVolume(t,v); | 1003 | setVolume(t,v); |
984 | emit volumeChanged( muted ); | 1004 | emit volumeChanged( muted ); |
985 | } else if ( msg == "volumeChange(bool)" ) { | 1005 | } else if ( msg == "volumeChange(bool)" ) { |
986 | stream >> muted; | 1006 | stream >> muted; |
987 | setVolume(); | 1007 | setVolume(); |
988 | emit volumeChanged( muted ); | 1008 | emit volumeChanged( muted ); |
1009 | } else if ( msg == "setMic(int,int)") { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | ||
1010 | int t,v; | ||
1011 | stream >> t >> v; | ||
1012 | setMic(t,v); | ||
1013 | emit micChanged( micMuted ); | ||
1014 | } else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | ||
1015 | stream >> micMuted; | ||
1016 | setMic(); | ||
1017 | emit micChanged( micMuted ); | ||
989 | } else if ( msg == "setScreenSaverMode(int)" ) { | 1018 | } else if ( msg == "setScreenSaverMode(int)" ) { |
990 | if ( type() == GuiServer ) { | 1019 | if ( type() == GuiServer ) { |
991 | int old = disable_suspend; | 1020 | int old = disable_suspend; |
992 | stream >> disable_suspend; | 1021 | stream >> disable_suspend; |
993 | //qDebug("setScreenSaverMode(%d)", disable_suspend ); | 1022 | //qDebug("setScreenSaverMode(%d)", disable_suspend ); |
994 | if ( disable_suspend > old ) | 1023 | if ( disable_suspend > old ) |
995 | setScreenSaverInterval( -1 ); | 1024 | setScreenSaverInterval( -1 ); |
1025 | } | ||
996 | } | 1026 | } |
997 | } | ||
998 | #endif | 1027 | #endif |
999 | } | 1028 | } |
1000 | 1029 | ||
1001 | /*! | 1030 | /*! |
1002 | \internal | 1031 | \internal |
1003 | */ | 1032 | */ |
1004 | bool QPEApplication::raiseAppropriateWindow() | 1033 | bool QPEApplication::raiseAppropriateWindow() |
1005 | { | 1034 | { |
1006 | bool r=FALSE; | 1035 | bool r=FALSE; |
1007 | // ########## raise()ing main window should raise and set active | 1036 | // ########## raise()ing main window should raise and set active |
1008 | // ########## it and then all childen. This belongs in Qt/Embedded | 1037 | // ########## it and then all childen. This belongs in Qt/Embedded |
1009 | QWidget *top = d->qpe_main_widget; | 1038 | QWidget *top = d->qpe_main_widget; |
1010 | if ( !top ) top =mainWidget(); | 1039 | if ( !top ) top =mainWidget(); |
1011 | if ( top && d->keep_running ) { | 1040 | if ( top && d->keep_running ) { |
1012 | if ( top->isVisible() ) | 1041 | if ( top->isVisible() ) |
1013 | r = TRUE; | 1042 | r = TRUE; |
1014 | #ifdef Q_WS_QWS | 1043 | #ifdef Q_WS_QWS |
1015 | if ( !d->nomaximize ) | 1044 | if ( !d->nomaximize ) |
1016 | top->showMaximized(); | 1045 | top->showMaximized(); |
1017 | else | 1046 | else |
1018 | #endif | 1047 | #endif |
1019 | top->show(); | 1048 | top->show(); |
1020 | top->raise(); | 1049 | top->raise(); |
1021 | top->setActiveWindow(); | 1050 | top->setActiveWindow(); |
1022 | } | 1051 | } |
1023 | QWidget *topm = activeModalWidget(); | 1052 | QWidget *topm = activeModalWidget(); |
1024 | if ( topm && topm != top ) { | 1053 | if ( topm && topm != top ) { |
1025 | topm->show(); | 1054 | topm->show(); |
1026 | topm->raise(); | 1055 | topm->raise(); |
1027 | topm->setActiveWindow(); | 1056 | topm->setActiveWindow(); |
1028 | r = FALSE; | 1057 | r = FALSE; |
1029 | } | 1058 | } |
1030 | return r; | 1059 | return r; |
1031 | } | 1060 | } |
1032 | 1061 | ||
1033 | void QPEApplication::pidMessage( const QCString &msg, const QByteArray & data) | 1062 | void QPEApplication::pidMessage( const QCString &msg, const QByteArray & data) |
1034 | { | 1063 | { |
1035 | #ifdef Q_WS_QWS | 1064 | #ifdef Q_WS_QWS |
1036 | 1065 | ||
1037 | if ( msg == "quit()" ) { | 1066 | if ( msg == "quit()" ) { |
1038 | tryQuit(); | 1067 | tryQuit(); |
1039 | } else if ( msg == "quitIfInvisible()" ) { | 1068 | } else if ( msg == "quitIfInvisible()" ) { |
1040 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) | 1069 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) |
1041 | quit(); | 1070 | quit(); |
1042 | } else if ( msg == "close()" ) { | 1071 | } else if ( msg == "close()" ) { |
1043 | hideOrQuit(); | 1072 | hideOrQuit(); |
1044 | } else if ( msg == "disablePreload()" ) { | 1073 | } else if ( msg == "disablePreload()" ) { |
1045 | d->preloaded = FALSE; | 1074 | d->preloaded = FALSE; |
1046 | d->keep_running = TRUE; | 1075 | d->keep_running = TRUE; |
1047 | /* so that quit will quit */ | 1076 | /* so that quit will quit */ |
1048 | } else if ( msg == "enablePreload()" ) { | 1077 | } else if ( msg == "enablePreload()" ) { |
1049 | d->preloaded = TRUE; | 1078 | d->preloaded = TRUE; |
1050 | d->keep_running = TRUE; | 1079 | d->keep_running = TRUE; |
1051 | /* so next quit won't quit */ | 1080 | /* so next quit won't quit */ |
1052 | } else if ( msg == "raise()" ) { | 1081 | } else if ( msg == "raise()" ) { |
1053 | d->keep_running = TRUE; | 1082 | d->keep_running = TRUE; |
1054 | d->notbusysent = FALSE; | 1083 | d->notbusysent = FALSE; |
1055 | raiseAppropriateWindow(); | 1084 | raiseAppropriateWindow(); |
1056 | } else if ( msg == "flush()" ) { | 1085 | } else if ( msg == "flush()" ) { |
1057 | emit flush(); | 1086 | emit flush(); |
1058 | // we need to tell the desktop | 1087 | // we need to tell the desktop |
1059 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); | 1088 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); |
1060 | e << d->appName; | 1089 | e << d->appName; |
1061 | } else if ( msg == "reload()" ) { | 1090 | } else if ( msg == "reload()" ) { |
diff --git a/library/qpeapplication.h b/library/qpeapplication.h index fd5e57d..23606db 100644 --- a/library/qpeapplication.h +++ b/library/qpeapplication.h | |||
@@ -24,101 +24,107 @@ | |||
24 | #include <qapplication.h> | 24 | #include <qapplication.h> |
25 | #if defined(_WS_QWS_) && !defined(Q_WS_QWS) | 25 | #if defined(_WS_QWS_) && !defined(Q_WS_QWS) |
26 | #define Q_WS_QWS | 26 | #define Q_WS_QWS |
27 | #endif | 27 | #endif |
28 | #include "qpedecoration_qws.h" | 28 | #include "qpedecoration_qws.h" |
29 | #include "timestring.h" | 29 | #include "timestring.h" |
30 | 30 | ||
31 | class QCopChannel; | 31 | class QCopChannel; |
32 | class QPEApplicationData; | 32 | class QPEApplicationData; |
33 | class QWSEvent; | 33 | class QWSEvent; |
34 | class QWSKeyEvent; | 34 | class QWSKeyEvent; |
35 | 35 | ||
36 | class QPEApplication : public QApplication | 36 | class QPEApplication : public QApplication |
37 | { | 37 | { |
38 | Q_OBJECT | 38 | Q_OBJECT |
39 | public: | 39 | public: |
40 | QPEApplication( int& argc, char **argv, Type=GuiClient ); | 40 | QPEApplication( int& argc, char **argv, Type=GuiClient ); |
41 | ~QPEApplication(); | 41 | ~QPEApplication(); |
42 | 42 | ||
43 | static QString qpeDir(); | 43 | static QString qpeDir(); |
44 | static QString documentDir(); | 44 | static QString documentDir(); |
45 | void applyStyle(); | 45 | void applyStyle(); |
46 | static int defaultRotation(); | 46 | static int defaultRotation(); |
47 | static void setDefaultRotation(int r); | 47 | static void setDefaultRotation(int r); |
48 | static void grabKeyboard(); | 48 | static void grabKeyboard(); |
49 | static void ungrabKeyboard(); | 49 | static void ungrabKeyboard(); |
50 | 50 | ||
51 | enum StylusMode { | 51 | enum StylusMode { |
52 | LeftOnly, | 52 | LeftOnly, |
53 | RightOnHold | 53 | RightOnHold |
54 | // RightOnHoldLeftDelayed, etc. | 54 | // RightOnHoldLeftDelayed, etc. |
55 | }; | 55 | }; |
56 | static void setStylusOperation( QWidget*, StylusMode ); | 56 | static void setStylusOperation( QWidget*, StylusMode ); |
57 | static StylusMode stylusOperation( QWidget* ); | 57 | static StylusMode stylusOperation( QWidget* ); |
58 | 58 | ||
59 | enum InputMethodHint { | 59 | enum InputMethodHint { |
60 | Normal, | 60 | Normal, |
61 | AlwaysOff, | 61 | AlwaysOff, |
62 | AlwaysOn | 62 | AlwaysOn |
63 | }; | 63 | }; |
64 | 64 | ||
65 | enum screenSaverHint { | 65 | enum screenSaverHint { |
66 | Disable = 0, | 66 | Disable = 0, |
67 | DisableLightOff = 1, | 67 | DisableLightOff = 1, |
68 | DisableSuspend = 2, | 68 | DisableSuspend = 2, |
69 | Enable = 100 | 69 | Enable = 100 |
70 | }; | 70 | }; |
71 | 71 | ||
72 | static void setInputMethodHint( QWidget *, InputMethodHint ); | 72 | static void setInputMethodHint( QWidget *, InputMethodHint ); |
73 | static InputMethodHint inputMethodHint( QWidget * ); | 73 | static InputMethodHint inputMethodHint( QWidget * ); |
74 | 74 | ||
75 | void showMainWidget( QWidget*, bool nomax=FALSE ); | 75 | void showMainWidget( QWidget*, bool nomax=FALSE ); |
76 | void showMainDocumentWidget( QWidget*, bool nomax=FALSE ); | 76 | void showMainDocumentWidget( QWidget*, bool nomax=FALSE ); |
77 | 77 | ||
78 | static void setKeepRunning(); | 78 | static void setKeepRunning(); |
79 | bool keepRunning() const; | 79 | bool keepRunning() const; |
80 | 80 | ||
81 | int exec(); | 81 | int exec(); |
82 | 82 | ||
83 | signals: | 83 | signals: |
84 | void clientMoused(); | 84 | void clientMoused(); |
85 | void timeChanged(); | 85 | void timeChanged(); |
86 | void clockChanged( bool pm ); | 86 | void clockChanged( bool pm ); |
87 | void volumeChanged( bool muted ); | 87 | void volumeChanged( bool muted ); |
88 | void micChanged( bool muted ); | ||
88 | void appMessage( const QCString& msg, const QByteArray& data); | 89 | void appMessage( const QCString& msg, const QByteArray& data); |
89 | void weekChanged( bool startOnMonday ); | 90 | void weekChanged( bool startOnMonday ); |
90 | void dateFormatChanged( DateFormat ); | 91 | void dateFormatChanged( DateFormat ); |
91 | void flush(); | 92 | void flush(); |
92 | void reload(); | 93 | void reload(); |
93 | 94 | ||
94 | private slots: | 95 | private slots: |
95 | void systemMessage( const QCString &msg, const QByteArray &data ); | 96 | void systemMessage( const QCString &msg, const QByteArray &data ); |
96 | void pidMessage( const QCString &msg, const QByteArray &data ); | 97 | void pidMessage( const QCString &msg, const QByteArray &data ); |
97 | void removeSenderFromStylusDict(); | 98 | void removeSenderFromStylusDict(); |
98 | void hideOrQuit(); | 99 | void hideOrQuit(); |
99 | 100 | ||
100 | protected: | 101 | protected: |
101 | bool qwsEventFilter( QWSEvent * ); | 102 | bool qwsEventFilter( QWSEvent * ); |
102 | void internalSetStyle( const QString &style ); | 103 | void internalSetStyle( const QString &style ); |
103 | void prepareForTermination(bool willrestart); | 104 | void prepareForTermination(bool willrestart); |
104 | virtual void restart(); | 105 | virtual void restart(); |
105 | virtual void shutdown(); | 106 | virtual void shutdown(); |
106 | bool eventFilter( QObject *, QEvent * ); | 107 | bool eventFilter( QObject *, QEvent * ); |
107 | void timerEvent( QTimerEvent * ); | 108 | void timerEvent( QTimerEvent * ); |
108 | bool keyboardGrabbed() const; | 109 | bool keyboardGrabbed() const; |
109 | bool raiseAppropriateWindow(); | 110 | bool raiseAppropriateWindow(); |
110 | virtual void tryQuit(); | 111 | virtual void tryQuit(); |
111 | 112 | ||
112 | private: | 113 | private: |
113 | void mapToDefaultAction( QWSKeyEvent *ke, int defKey ); | 114 | void mapToDefaultAction( QWSKeyEvent *ke, int defKey ); |
114 | 115 | ||
115 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 116 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
116 | QCopChannel *sysChannel; | 117 | QCopChannel *sysChannel; |
117 | QCopChannel *pidChannel; | 118 | QCopChannel *pidChannel; |
118 | #endif | 119 | #endif |
119 | QPEApplicationData *d; | 120 | QPEApplicationData *d; |
121 | |||
122 | bool reserved_sh; | ||
123 | |||
124 | |||
125 | |||
120 | }; | 126 | }; |
121 | 127 | ||
122 | 128 | ||
123 | #endif | 129 | #endif |
124 | 130 | ||