00001 // -*- c++ -*- 00002 00003 /* 00004 * 00005 * Copyright (C) 2002 George Staikos <staikos@kde.org> 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Library General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2 of the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Library General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Library General Public License 00018 * along with this library; see the file COPYING.LIB. If not, write to 00019 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00020 * Boston, MA 02111-1307, USA. 00021 */ 00022 00023 #ifndef __QTVISION_H 00024 #define __QTVISION_H 00025 00026 #include <qmap.h> 00027 #include <qcolor.h> 00028 #include <qobject.h> 00029 #include <qpixmap.h> 00030 #include <qstring.h> 00031 #include <qguardedptr.h> 00032 00033 #include "cfgdata.h" 00034 #include "channel.h" 00035 00036 #include "qtvisioniface.h" 00037 #include "qvsrcplugin.h" 00038 #include "view.h" 00039 00040 class KConfig; 00041 00042 class ViewManager; 00043 class AudioManager; 00044 class OSDManager; 00045 class ChannelStore; 00046 class StatusManager; 00047 class MiscManager; 00048 class PluginFactory; 00049 00050 typedef QMap<QString,QString> DeviceMap; 00051 typedef QMap<QString,QStringList> SourceMap; 00052 00056 class QtVision : public QObject, virtual public QtVisionIface 00057 { 00058 Q_OBJECT 00059 00060 public: 00061 QtVision( QObject *parent = 0, const char* name = 0); 00062 ~QtVision(); 00063 00067 QtVisionView *screen() { return _view; } 00068 00072 DCOPRef channelStoreIface(); 00073 00077 DCOPRef channelIface(); 00078 00082 QString channelName() const; 00083 00087 int channelNumber() const; 00088 00092 bool hasDevice() const { return _vsrc ? true : false; } 00093 00097 QVSourcePlugin *device() const { return _vsrc; } 00098 00102 ViewManager *views() const { return _viewmng; } 00103 00107 AudioManager *audioManager() const { return _am; } 00108 00112 OSDManager *osdManager() const { return _osd; } 00113 00117 MiscManager *miscManager() const { return _mm; } 00118 00122 StatusManager *statusManager() const { return _sm; } 00123 00127 PluginFactory *pluginFactory() const { return _pf; } 00128 00132 ChannelStore *channels() { return _cs; } 00133 00137 ConfigData *config() const { return _cfg; } 00138 00142 KConfig *configHandle () const { return _config; } 00143 00151 virtual QtVisionView *createScreen( QWidget *parent=0, const char *name=0 ); 00152 00156 int brightness(); 00157 int colour(); 00158 int hue(); 00159 int contrast(); 00160 int whiteness(); 00161 QColor colourKey(); 00162 Channel *channel() { return _chan; } 00163 00164 public slots: 00168 bool tryAutoStart(); 00169 00173 virtual void selectDevice(); 00174 00178 void setDevice( QVSourcePlugin *dev ); 00179 00183 virtual void setSource( const QString &src ); 00184 00188 virtual void stopDevice(); 00189 00193 void setChannel( Channel *channel ); 00194 00198 void setChannel(int channel); 00199 00200 00205 virtual void channelDown(); 00206 00211 virtual void channelUp(); 00212 00216 virtual void previousChannel(); 00217 00221 virtual void volumeMute(); 00222 00226 virtual void volumeUp(); 00227 00231 virtual void volumeDown(); 00232 00236 virtual void setVolume(int left, int right); 00237 virtual void setVolume(int vol); 00238 00239 virtual void start(); 00240 virtual void stop(); 00241 virtual void startCapture(); 00242 virtual void snapshot(); 00243 00244 virtual void startVideo(); 00245 virtual void stopVideo(); 00246 00250 virtual void settings(); 00251 00255 virtual int launchWizard(); 00256 00260 void setTunerMode( int mode ); 00261 00265 virtual void setBrightness(int val); 00266 virtual void setColour(int val); 00267 virtual void setHue(int val); 00268 virtual void setContrast(int val); 00269 virtual void setWhiteness(int val); 00270 00274 virtual void setVideoDesktop(bool on); 00275 00279 virtual bool doMigration(); 00280 00284 virtual void importDefaultChannels(); 00285 00289 virtual bool importLegacyChannels(); 00290 00294 virtual void openChannelFile(); 00295 00300 virtual void importChannelFile(); 00301 00305 virtual void openChannelFile(const QString &filename); 00306 00310 virtual void processNumberKeyEvent(int); 00311 00312 signals: 00316 void volumeChanged( int left, int right ); 00317 00321 void volumeMuted(bool); 00322 00326 void channelChanged( int num ); 00327 00331 void channelChanged( const QString &name ); 00332 00336 void channelChanged( Channel *channel ); 00337 00341 void deviceChanged( QVSourcePlugin *dev ); 00342 00346 void channelText(const QString &); 00347 00348 protected: 00349 void timerEvent (QTimerEvent *ev); 00350 00351 private slots: 00352 void viewResized(int w, int h); 00353 void viewMoved(int x, int y); 00354 void aboutToQuit(); 00355 00357 void setMuteVolume (bool); 00358 00359 void slotKeyPressTimeout(); 00360 00361 private: 00362 ChannelStore *_cs; 00363 00364 QGuardedPtr<Channel> _chan; 00365 00366 OSDManager *_osd; 00367 AudioManager *_am; 00368 StatusManager *_sm; 00369 MiscManager *_mm; 00370 QtVisionView *_view; 00371 PluginFactory *_pf; 00372 QVSourcePlugin *_vsrc; 00373 ViewManager *_viewmng; 00374 ConfigData* _cfg; 00375 KConfig* _config; 00376 QPixmap grabPix; 00377 00378 QTimer *_keypresstimer; 00379 QString _number; 00380 00381 int _prevChannel; 00382 00383 bool _muted; // We have to keep track since some devices are broken 00384 bool _quitting; 00385 00386 struct { 00387 int left; // Left volume 00388 int right; // Right volume 00389 int changeEventId; // Id 00390 } ChannelVolState; 00391 00392 class QtVisionPrivate; 00393 QtVisionPrivate *d; 00394 }; 00395 00396 #endif 00397