Fix downloading several books. Update version.
[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 class Progress;
13 class TranslucentButton;
14
15 /**
16  * A toplevel window that can adopt a BookView and other children.
17  * On Maemo, it can also grab the volume keys.
18  */
19 class AdopterWindow: public QMainWindow
20 {
21     Q_OBJECT
22
23 public:
24     explicit AdopterWindow(QWidget *parent = 0);
25
26     /** Adopt book view and decorations. */
27     void takeBookView(BookView *bookView, Progress *prog,
28                       TranslucentButton *prev, TranslucentButton *next);
29
30     /** Release book view and decorations. */
31     void leaveBookView();
32
33     /** Return true if the book view is currently adopted. */
34     bool hasBookView();
35
36     /**
37      * Add action that is visible on the tool bar.
38      * @param   receiver    Object receiving "activated" signal.
39      * @param   slot        Slot receiving "activated" signal.
40      * @param   iconName    Base name of tool bar icon in resource file.
41      * @param   text        Tool bar item text.
42      * @param   important   On Symbian, only "important" actions are added to
43      *                      the tool bar. All actions are added to the Options
44      *                      menu though.
45      */
46     QAction *addToolBarAction(QObject *receiver, const char *slot,
47                               const QString &iconName, const QString &text,
48                               bool important = false);
49
50     /** Add spacing to tool bar. */
51     void addToolBarSpace();
52
53     /** Show window. */
54     void show();
55
56     /** If grab is true, volume keys will navigate the book view. */
57     void grabVolumeKeys(bool grab);
58
59 public slots:
60     /** Handle settings changes. */
61     void onSettingsChanged(const QString &key);
62
63 signals:
64     /** Emitted when Page Up or Volume Up pressed. */
65     void pageUp();
66
67     /** Emitted when Page Down or Volume Down pressed. */
68     void pageDown();
69
70 protected:
71     /** Handle key press events. */
72     void keyPressEvent(QKeyEvent *event);
73
74     /**
75      * Handle show events.
76      * On Symbian, volume keys can only be grabbed, if the window is shown.
77      */
78     void showEvent(QShowEvent *event);
79
80     /** Handle resize event: Restore reading position. */
81     void resizeEvent(QResizeEvent *event);
82
83     /** Handle close event. */
84     void closeEvent(QCloseEvent *event);
85
86     /** Handle leave event: Save reading position. */
87     void leaveEvent(QEvent *event);
88
89 #ifdef Q_OS_SYMBIAN
90     /** Update toolbar visibility. */
91     void updateToolBar();
92
93     /** Return true in portrait mode. */
94     bool portrait();
95 #endif // Q_OS_SYMBIAN
96
97 #ifdef Q_WS_MAEMO_5
98     /** Actually grab the volume keys. */
99     void doGrabVolumeKeys(bool grab);
100 #endif // Q_WS_MAEMO_5
101
102     /** Hide tool bar if visible. */
103     void hideToolBar();
104
105 protected slots:
106     void placeDecorations();
107     void onPageDown();
108     void onPageUp();
109
110 private:
111     BookView *bookView;     /**< Book view widget. */
112     bool grabbingVolumeKeys;/**< True, if volume keys should be grabbed. */
113     QToolBar *toolBar;      /**< Tool bar. */
114     Progress *progress;     /**< Reading progress indicator. */
115     TranslucentButton *previousButton;  /**< Previous page indicator. */
116     TranslucentButton *nextButton;      /**< Next page indicator. */
117 };
118
119 #endif // ADOPTERWINDOW_H