Fix Symbian bugs.
[dorian] / adopterwindow.h
1 #ifndef ADOPTERWINDOW_H
2 #define ADOPTERWINDOW_H
3
4 #include <QMainWindow>
5 #include <QList>
6
7 class QWidget;
8 class QToolBar;
9 class QAction;
10 class BookView;
11
12 /**
13  * A toplevel window that can adopt a BookView and other children.
14  * On Maemo, it can also grab the volume keys.
15  */
16 class AdopterWindow: public QMainWindow
17 {
18     Q_OBJECT
19
20 public:
21     explicit AdopterWindow(QWidget *parent = 0);
22
23     /** Adopt children "bookView" and "others". */
24     void takeChildren(BookView *bookView, const QList<QWidget *> &others);
25
26     /** Release current children (adopted in @see takeChildren). */
27     void leaveChildren();
28
29     /** Return true if a child is currently adopted. */
30     bool hasChild(QWidget *child);
31
32     /**
33      * Add action that is visible on the tool bar (except on Symbian, where
34      * it is visible on the Options menu).
35      */
36     QAction *addToolBarAction(QObject *receiver, const char *slot,
37                               const QString &iconName, const QString &text);
38
39     /** Add spacing to tool bar. */
40     void addToolBarSpace();
41
42     /** Show window. */
43     void show();
44
45     /** If grab is true, volume keys will generate pageUp/Down keys. */
46     void grabVolumeKeys(bool grab);
47
48 public slots:
49     /** Handle settings changes. */
50     void onSettingsChanged(const QString &key);
51
52 protected:
53     void keyPressEvent(QKeyEvent *event);
54 #ifdef Q_WS_MAEMO_5
55     void showEvent(QShowEvent *event);
56     void doGrabVolumeKeys(bool grab);
57 #endif
58     BookView *bookView;
59     bool grabbingVolumeKeys;/**< True, if volume keys should be grabbed. */
60 #ifndef Q_OS_SYMBIAN
61     QToolBar *toolBar;
62 #endif
63 };
64
65 #endif // ADOPTERWINDOW_H