luna-sysmgr-common
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HostBase.h
Go to the documentation of this file.
1 /* @@@LICENSE
2 *
3 * Copyright (c) 2008-2012 Hewlett-Packard Development Company, L.P.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * LICENSE@@@ */
27 #ifndef HOSTBASE_H
28 #define HOSTBASE_H
29 
30 #include "Common.h"
31 
32 
33 
34 #include "TaskBase.h"
35 #include "Mutex.h"
36 #include "CustomEvents.h"
37 #include "InputControl.h"
38 #include "LedControl.h"
39 
40 #include <Qt>
41 #include <QImage>
42 
43 class QWidget;
44 
48 struct HostInfo
49 {
54 
64 
69 
74 
79 
84 
89 
94 
99 };
100 
111 class HostBase : public QObject,
112  public TaskBase
113 {
114  Q_OBJECT
115 public:
123  static HostBase* instance();
124 
135  virtual ~HostBase();
136 
148  virtual void init(int w, int h) = 0;
149 
160  virtual void show() {}
161 
170  inline const HostInfo& getInfo() const { return m_info; }
171 
172  //Documented in parent.
173  virtual void run();
174 
175  //Documented in parent.
176  virtual void quit();
177 
183  static bool hostIsQemu ();
184 
194  virtual const char* hardwareName() const = 0;
195 
209  virtual unsigned short translateKeyWithMeta( unsigned short key, bool withShift, bool withAlt );
210 
219 
224 
230  virtual void setMetaModifier( bool metaKeyDown ) { m_metaKeyDown = metaKeyDown; }
231 
237  virtual bool metaModifier() { return m_metaKeyDown; }
238 
249  virtual int getNumberOfSwitches() const { return 0; }
250 
261  void turboModeSubscription(bool add);
262 
274  virtual void setCentralWidget(QWidget* view) {}
275 
284  virtual void flip() {}
285 
295  virtual bool hasAltKey(Qt::KeyboardModifiers modifiers);
296 
304  virtual QImage takeScreenShot() const { return QImage(); }
305 
313  virtual QImage takeAppDirectRenderingScreenShot() const { return QImage(); }
314 
326  virtual void setAppDirectRenderingLayerEnabled(bool enable) {}
327 
337 
344  QPoint map(const QPoint& pt) { return m_trans.map(pt); }
345 
355  virtual void setRenderingLayerEnabled(bool enable) {}
356 
364  virtual InputControl* getInputControlALS() { return 0; }
365 
374 
382  virtual InputControl* getInputControlProximity() { return 0; }
383 
391  virtual InputControl* getInputControlTouchpanel() { return 0; }
392 
402  virtual InputControl* getInputControlKeys() { return 0; }
403 
413  virtual LedControl* getLedControlKeypadAndDisplay() { return 0; }
414 
420  virtual void OrientationSensorOn(bool enable) {}
421 
434  {
435  if (currOrientation)
436  {
437  return (new OrientationEvent(currOrientation->orientation(),0,0));
438  }
439  return 0;
440  }
441 
452  virtual bool homeButtonWakesUpScreen() { return false; }
453 
461  virtual void setBluetoothKeyboardActive(bool active) {}
462 
470  virtual bool bluetoothKeyboardActive() const { return false; }
471 
479 Q_SIGNALS:
480  void signalBluetoothKeyboardActive(bool active);
481 
482 protected:
492  HostBase();
493 
494  //Documented in parent.
495  virtual void handleEvent(sptr<Event>) {}
496 
506  virtual void turboMode(bool enable) {}
507 
512 
517 
522 
529 
533  QTransform m_trans;
534 
544 
551 };
552 
553 #endif /* HOSTBASE_H */