Make orientation switch explicit on Symbian, too.
[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 Maemo, 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, if the window is shown.
55      */
56     void showEvent(QShowEvent *event);
57
58     /** Handle resize event: Restore reading position. */
59     void resizeEvent(QResizeEvent *event);
60
61     /** Handle close event. */
62     void closeEvent(QCloseEvent *event);
63
64     /** Handle leave event: Save reading position. */
65     void leaveEvent(QEvent *event);
66
67 #ifdef Q_WS_MAEMO_5
68     /** Actually grab the volume keys. */
69     void doGrabVolumeKeys(bool grab);
70 #endif // Q_WS_MAEMO_5
71
72 protected slots:
73     void placeDecorations();
74     void onPageDown();
75     void onPageUp();
76
77 private:
78     BookView *bookView;     /**< Book view widget. */
79     bool grabbingVolumeKeys;/**< True, if volume keys should be grabbed. */
80     Progress *progress;     /**< Reading progress indicator. */
81     TranslucentButton *previousButton;  /**< Previous page indicator. */
82     TranslucentButton *nextButton;      /**< Next page indicator. */
83 };
84
85 #endif // ADOPTERWINDOW_H