New version. Update home page link in About box.
[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 class QVBoxLayout;
12
13 /**
14  * A toplevel window that can adopt a BookView and other children.
15  * On Maemo, it can also grab the volume keys.
16  */
17 class AdopterWindow: public QMainWindow
18 {
19     Q_OBJECT
20
21 public:
22     explicit AdopterWindow(QWidget *parent = 0);
23
24     /** Adopt children "bookView" and "others". */
25     void takeChildren(BookView *bookView, const QList<QWidget *> &others);
26
27     /** Release current children (adopted in @see takeChildren). */
28     void leaveChildren();
29
30     /** Return true if a child is currently adopted. */
31     bool hasChild(QWidget *child);
32
33     /**
34      * Add action that is visible on the tool bar.
35      * @param   receiver    Object receiving "activated" signal.
36      * @param   slot        Slot receiving "activated" signal.
37      * @param   iconName    Base name of tool bar icon in resource file.
38      * @param   text        Tool bar item text.
39      * @param   important   On Symbian, only "important" actions are added to
40      *                      the tool bar. All actions are added to the Options
41      *                      menu though.
42      */
43     QAction *addToolBarAction(QObject *receiver, const char *slot,
44                               const QString &iconName, const QString &text,
45                               bool important = false);
46
47     /** Add spacing to tool bar. */
48     void addToolBarSpace();
49
50     /** Show window. */
51     void show();
52
53     /** If grab is true, volume keys will generate pageUp/Down key events. */
54     void grabVolumeKeys(bool grab);
55
56 public slots:
57     /** Handle settings changes. */
58     void onSettingsChanged(const QString &key);
59
60 protected:
61     void keyPressEvent(QKeyEvent *event);
62 #ifdef Q_WS_MAEMO_5
63     void showEvent(QShowEvent *event);
64     void doGrabVolumeKeys(bool grab);
65 #endif
66     BookView *bookView;
67     bool grabbingVolumeKeys;/**< True, if volume keys should be grabbed. */
68     QToolBar *toolBar;
69 };
70
71 #endif // ADOPTERWINDOW_H