.
[dorian] / adopterwindow.h
1 #ifndef ADOPTERWINDOW_H
2 #define ADOPTERWINDOW_H
3
4 #include <QList>
5 #include "mainbase.h"
6
7 class QWidget;
8 class QAction;
9 class BookView;
10 class Progress;
11 class TranslucentButton;
12
13 /**
14  * A toplevel window that can adopt a BookView and other children.
15  * On some platforms, it can also grab the volume keys.
16  */
17 class AdopterWindow: public MainBase
18 {
19     Q_OBJECT
20
21 public:
22     explicit AdopterWindow(QWidget *parent = 0);
23
24     /** Adopt book view and decorations. */
25     void takeBookView(BookView *bookView, Progress *prog,
26                       TranslucentButton *prev, TranslucentButton *next);
27
28     /** Release book view and decorations. */
29     void leaveBookView();
30
31     /** Return true if the book view is currently adopted. */
32     bool hasBookView();
33
34     /** If grab is true, volume keys will navigate the book view. */
35     void grabVolumeKeys(bool grab);
36
37 public slots:
38     /** Handle settings changes. */
39     void onSettingsChanged(const QString &key);
40
41 signals:
42     /** Emitted when Page Up or Volume Up pressed. */
43     void pageUp();
44
45     /** Emitted when Page Down or Volume Down pressed. */
46     void pageDown();
47
48 protected:
49     /** Handle key press events. */
50     void keyPressEvent(QKeyEvent *event);
51
52     /**
53      * Handle show events.
54      * On Symbian, volume keys can only be grabbed, when the window is shown.
55      * So we do it from here.
56      */
57     void showEvent(QShowEvent *event);
58
59     /** Handle resize event: Restore reading position. */
60     void resizeEvent(QResizeEvent *event);
61
62     /** Handle close event: Save reading position. */
63     void closeEvent(QCloseEvent *event);
64
65     /** Handle leave event: Save reading position. */
66     void leaveEvent(QEvent *event);
67
68 #ifdef Q_WS_MAEMO_5
69     /** Actually grab the volume keys. */
70     void doGrabVolumeKeys(bool grab);
71 #endif // Q_WS_MAEMO_5
72
73 protected slots:
74     void placeDecorations();
75     void onPageDown();
76     void onPageUp();
77
78 private:
79     BookView *bookView;     /**< Book view widget. */
80     bool grabbingVolumeKeys;/**< True, if volume keys should be grabbed. */
81     Progress *progress;     /**< Reading progress indicator. */
82     TranslucentButton *previousButton;  /**< Previous page indicator. */
83     TranslucentButton *nextButton;      /**< Next page indicator. */
84 };
85
86 #endif // ADOPTERWINDOW_H