-
Notifications
You must be signed in to change notification settings - Fork 1
/
mainwindow.h
206 lines (189 loc) · 5.65 KB
/
mainwindow.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/*
* Copyright (C) 2011-2015 Alexander Saprykin <xelfium@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QFrame>
#include <QScrollBar>
#include <QTextEdit>
#include <QPropertyAnimation>
#include <QPushButton>
#include <QToolButton>
#include "nsrabstractdocument.h"
#include "nsrtoolframe.h"
#include "nsrsettings.h"
#include "nsrscrollarea.h"
#include "nsranimationlabel.h"
#include "nsrrenderthread.h"
#include "nsrtextedit.h"
#include "nsrimagecontainer.h"
#include "nsrstartlabel.h"
#include "nsrdocumentmenu.h"
#include "nsraboutdialog.h"
#include "nsrpreferences.h"
#include "nsrnewsdialog.h"
#include "nsrlanguage.h"
#ifdef Q_OS_SYMBIAN
# include <remconcoreapitargetobserver.h>
# include <remconcoreapitarget.h>
# include <remconinterfaceselector.h>
# include <touchfeedback.h>
#elif !defined (Q_WS_MAEMO_5)
# include <resource-set.h>
#endif
namespace Ui {
class NSRMainWindow;
}
#ifdef Q_OS_SYMBIAN
class nsrMainWindow : public QMainWindow, MRemConCoreApiTargetObserver
#else
class nsrMainWindow : public QMainWindow
#endif
{
Q_OBJECT
public:
enum ScreenOrientation {
ScreenOrientationLockPortrait,
ScreenOrientationLockLandscape,
ScreenOrientationAuto
};
enum NSRViewMode {
NSRViewModeGraphic = 0,
NSRViewModeText = 1,
NSRViewModeStart = 2
};
explicit nsrMainWindow(QWidget *parent = 0);
virtual ~nsrMainWindow();
/* Note that this will only have an effect on Symbian and Fremantle. */
void setOrientation(ScreenOrientation orientation);
void showExpanded();
void updateAfterConstructor();
void loadDocument(const QString& file,
const NSRSession &session,
bool fromConstructor = false);
#if defined (Q_WS_X11) && !defined (Q_WS_MAEMO_5)
void disableSwipe ();
#endif
protected:
#ifdef Q_OS_SYMBIAN
/* MRemConCoreApiTargetObserver interface */
void MrccatoCommand(TRemConCoreApiOperationId aOperationId,
TRemConCoreApiButtonAction aButtonAct);
#endif
void resizeEvent(QResizeEvent *ev);
void closeEvent(QCloseEvent *ev);
bool eventFilter(QObject *obj, QEvent *ev);
void timerEvent(QTimerEvent *ev);
private:
void goToPage(int page, const QPoint& pos = QPoint (0, 0));
void updateNavigationButtons();
void updateToolFrame();
void updateFullscreenToggle();
void updatePageWithoutThread();
void updateStartLabel();
void updateBottomToolbar();
void updateTopToolbar();
void updateCentralWidget();
void pageToWidthWithoutThread();
void setToolbarsVisible(bool visible);
bool isPortraitMode();
QPoint autodetectPagePosition();
void switchViewMode(NSRViewMode mode);
void switchInvertedMode(bool isInverted, bool updatePage = true);
void stopKineticScroll();
void saveSession();
void checkViewModeOnLoad(const NSRSettings &settings);
#ifdef Q_WS_MAEMO_5
void grabZoomKeys (bool grab);
#endif
#ifdef Q_OS_SYMBIAN
/* For MRemConCoreApiTargetObserver interface */
CRemConInterfaceSelector *_iInterfaceSelector;
CRemConCoreApiTarget *_iCoreTarget;
MTouchFeedback *_iTouchFeedback;
#elif !defined (Q_WS_MAEMO_5)
ResourcePolicy::ResourceSet *_resourceSet;
#endif
Ui::NSRMainWindow *ui;
QPushButton *_prevButton;
QPushButton *_nextButton;
QPushButton *_openButton;
QPushButton *_advancedButton;
QPushButton *_documentButton;
QPushButton *_zoomInButton;
QPushButton *_zoomOutButton;
QLabel *_pagesLabel;
QLabel *_zoomLabel;
NSRViewMode _mode;
NSRViewMode _lateMode;
NSRToolFrame *_frame;
NSRAbstractDocument *_doc;
NSRRenderThread *_renderThread;
NSRAnimationLabel *_animationLabel;
NSRImageContainer *_imgContainer;
NSRStartLabel *_startLabel;
NSRTextEdit *_edit;
NSRDocumentMenu *_docMenu;
NSRAboutDialog *_aboutDlg;
NSRPreferences *_prefsDlg;
NSRNewsDialog *_newsDialog;
const NSRLanguageData *_langData;
QPoint _lastPos;
QToolButton *_fullscreenToggle;
QPixmap _cachedPixmap;
double _lastPinchFactor;
int _page;
int _pageCount;
int _lastZoom;
int _timerId;
bool _isFullscreenMode;
bool _isInvertedColors;
bool _isFormatSpecificMode;
bool _switchModeAfterRender;
QPropertyAnimation *_frameAnimation;
QPropertyAnimation *_docMenuAnimation;
bool _ignorePressEvent;
bool _delayedLoading;
private slots:
void onOpenButtonClicked ();
void onAdvancedButtonClicked ();
void onZoomOutButtonClicked ();
void onZoomInButtonClicked ();
void showPageSelectDialog ();
void showAboutDialog ();
void showZoomToDialog ();
void toggleFullscreenMode ();
void onPinchZoomRequest (double zoomFactor, QPoint scrollPoint);
void onDocumentButtonClicked ();
void fullscreenToggleClicked ();
void updateZoomButtons ();
void closeAboutDialog ();
void showPreferencesDialog ();
void closeNewsDialog ();
public slots:
void pageToWidth();
void updatePage();
void updatePageAfterRender();
void onNextButtonClicked();
void onPrevButtonClicked();
void handleDoubleClick (const QPoint& pos);
void rotatePageLeft();
void rotatePageRight();
void updatePreferences();
};
#endif // MAINWINDOW_H