f09a05b50e25a674f13d46a2d97bb5d2fe63a39d
[dorian] / widgets / adopterwindow.h
1 #ifndef ADOPTERWINDOW_H
2 #define ADOPTERWINDOW_H
3
4 #include <QMainWindow>
5 #include <QList>
6
7 #ifdef Q_OS_SYMBIAN
8 #   include "mediakeysobserver.h"
9 #endif
10
11 class QWidget;
12 class QToolBar;
13 class QAction;
14
15 /**
16   * A main window that can adopt other windows' children, and grabs the
17   * zoom (volume) keys on Maemo.
18   */
19 class AdopterWindow: public QMainWindow
20 {
21     Q_OBJECT
22 public:
23     explicit AdopterWindow(QWidget *parent = 0);
24
25     /* If true, zoom (volume) keys will generate Key_F7 and Key_F8 events. */
26     void grabZoomKeys(bool grab);
27
28     /** Adopt children "main" and "others". */
29     void takeChildren(QWidget *main, const QList<QWidget *> &others);
30
31     /** Release current children (adopted in @see takeChildren). */
32     void leaveChildren();
33
34     /**
35      * Add action that is visible on the tool bar (except on Symbian, where
36      * it is visible on the Options menu).
37      */
38     QAction *addToolBarAction(QObject *receiver, const char *slot,
39                               const QString &iconName, const QString &text);
40
41     /** Add space. */
42     void addToolBarSpace();
43
44     /** Show window. */
45     void show();
46
47 signals:
48
49 protected slots:
50 #ifdef Q_OS_SYMBIAN
51     void onMediaKeysPressed(MediaKeysObserver::MediaKeys key);
52 #endif
53
54 protected:
55     void showEvent(QShowEvent *e);
56     void doGrabZoomKeys(bool grab);
57     bool grabbingZoomKeys;
58     QWidget *mainChild;
59 #ifndef Q_OS_SYMBIAN
60     QToolBar *toolBar;
61 #endif
62 };
63
64 #endif // ADOPTERWINDOW_H