forked from baumgarr/nixnote2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnixnote.h
288 lines (265 loc) · 8.27 KB
/
nixnote.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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
/*********************************************************************************
NixNote - An open-source client for the Evernote service.
Copyright (C) 2013 Randy Baumgarte
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 NIXNOTE_H
#define NIXNOTE_H
#include <QMainWindow>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QSplitter>
#include <QScrollArea>
#include <QSystemTrayIcon>
#include <QToolBar>
#include <QSlider>
#include <QSplashScreen>
#include "filters/remotequery.h"
#include "watcher/filewatchermanager.h"
#include "gui/ntabwidget.h"
#include "gui/lineedit.h"
#include "sql/databaseconnection.h"
#include "gui/ntableview.h"
#include "gui/ntagview.h"
#include "gui/nsearchview.h"
#include "threads/syncrunner.h"
#include "threads/indexrunner.h"
#include "gui/widgetpanel.h"
#include "gui/nnotebookview.h"
#include "gui/favoritesview.h"
#include "gui/nmainmenubar.h"
#include "gui/traymenu.h"
#include "gui/nattributetree.h"
#include "gui/ntrashtree.h"
#include "dialog/accountdialog.h"
#include "gui/findreplace.h"
#include "threads/counterrunner.h"
//#include "oauth/oauthwindow.h"
#include "html/thumbnailer.h"
#include "reminders/remindermanager.h"
//****************************************
//* This is the main NixNote class that
//* starts everything else. It is called
//* by main()
//****************************************
// Forward declare classes used later
class DatabaseConnection;
class NMainMenuBar;
class NixNote;
class SyncRunner;
class IndexRunner;
class CounterRunner;
class NTabWidget;
class Thumbnailer;
class NTableView;
class SyncRunner;
// Define the actual class
class NixNote : public QMainWindow
{
Q_OBJECT
private:
enum NewNoteButtonAction {
NewTextNote=1,
NewWebcamNote=2,
NewScreenNote=3
};
DatabaseConnection *db; // The database connection
NTableView *noteTableView;
NSearchView *searchTreeView;
NNotebookView *notebookTreeView;
FavoritesView *favoritesTreeView;
QLabel *leftSeparator1;
QLabel *leftSeparator2;
QLabel *leftSeparator3;
QLabel *leftseparator4;
QLabel *leftSeparator5;
NTrashTree *trashTree;
NTagView *tagTreeView;
QSplitter *mainSplitter;
QSplitter *leftPanelSplitter;
WidgetPanel *leftPanel;
QSplitter *rightPanelSplitter;
QScrollArea *leftScroll;
QToolButton *noteButton;
QWidget *topRightWidget;
QVBoxLayout *topRightLayout;
NAttributeTree *attributeTree;
FindReplace *findReplaceWindow;
bool finalSync;
QSystemTrayIcon *trayIcon;
QString saveLastPath; // Last path viewed in the restore dialog
FileWatcherManager *importManager;
// OAuthWindow *oauthWindow;
Thumbnailer *hammer;
// Tool & menu bar
NMainMenuBar *menuBar;
TrayMenu *trayIconContextMenu;
QToolBar *toolBar;
QAction *leftArrowButton;
QAction *rightArrowButton;
QAction *homeButton;
QAction *syncButton;
QAction *printNoteButton;
QAction *deleteNoteButton;
QAction *newNoteButton;
QAction *newWebcamNoteButton;
QAction *screenCaptureButton;
QAction *newExternalNoteButton;
QAction *trunkButton;
QAction *usageButton;
QAction *emailButton;
QAction *toolsAccountAction;
QAction *showAction;
//QAction *minimizeToTrayAction;
//QAction *closeToTrayAction;
QAction *closeAction;
bool minimizeToTray;
bool closeToTray;
bool closeFlag;
bool unhidingWindow;
// Sync Button rotate
QTimer syncButtonTimer;
QTimer syncTimer;
QList<QPixmap> syncIcons;
unsigned int synchronizeIconAngle;
QTimer heartbeatTimer; // Timer to check shared memory for other instance commands.
void setupGui();
void setupNoteList();
void setupSearchTree();
void setupTagTree();
void setupAttributeTree();
void setupFavoritesTree();
void setupTrashTree();
void setupSynchronizedNotebookTree();
void setupTabWindow();
void waitCursor(bool value);
void saveContents();
void saveNoteColumnPositions();
void saveNoteColumnWidths();
void checkLeftPanelSeparators();
QSplashScreen *splashScreen;
RemoteQuery *remoteQuery;
QShortcut *focusSearchShortcut;
QShortcut *focusTitleShortcut;
QShortcut *focusTagShortcut;
QShortcut *focusNoteShortcut;
QShortcut *focusUrlShortcut;
QShortcut *focusAuthorShortcut;
QShortcut *copyNoteUrlShortcut;
void setupShortcut(QShortcut *shortcut, QString keySequence);
public:
NixNote(QWidget *parent = 0); // Constructor
~NixNote(); //Destructor
SyncRunner syncRunner;
QThread syncThread;
QThread indexThread;
QThread counterThread;
IndexRunner indexRunner;
CounterRunner counterRunner;
void closeEvent(QCloseEvent *event);
//bool notify(QObject* receiver, QEvent* event);
bool event(QEvent *event);
LineEdit *searchText;
void setDebugLevel();
NTabWidget *tabWindow;
public slots:
void closeNixNote();
void synchronize();
void syncTimerExpired();
void disconnect();
void updateSyncButton();
void syncButtonReset();
void updateSelectionCriteria(bool afterSync=false);
void leftButtonTriggered();
void rightButtonTriggered();
void openNote(bool newWindow);
void noteImport();
void noteExport();
void databaseRestore(bool fullRestore=true);
void databaseBackup(bool backup=true);
void resetView();
void newNote();
void noteButtonClicked();
void newExternalNote();
void disableEditing();
void setSyncTimer();
void notesDeleted(QList<qint32> lid);
void openTrunk();
void openAccount();
void openDatabaseStatus();
void openAbout();
void openImportFolders();
void setMessage(QString msg, int timeout=15000);
void toggleLeftPanel();
void toggleFavoritesTree();
void toggleNotebookTree();
void toggleTagTree();
void toggleSavedSearchTree();
void toggleAttributesTree();
void toggleTrashTree();
void toggleNoteList();
void toggleTabWindow();
void toggleToolbar();
void toggleStatusbar();
void findReplaceInNote();
void findReplaceAllInNotePressed();
void findReplaceInNotePressed();
void findInNote();
void findNextInNote();
void findPrevInNote();
void viewNoteHistory();
void findReplaceWindowHidden();
void checkReadOnlyNotebook();
void heartbeatTimerTriggered();
void notesRestored(QList<qint32>);
void emailNote();
void printNote();
void printPreviewNote();
void fastPrintNote();
void trayActivated(QSystemTrayIcon::ActivationReason reason);
void toggleVisible();
//void trayIconBehavior();
void changeEvent(QEvent *e);
void openPreferences();
void notifySyncComplete();
void addAnotherUser();
void switchUser();
void userMaintenance();
void viewNoteListWide();
void viewNoteListNarrow();
void resourceExternallyUpdated(QString resource);
void screenCapture();
void reindexDatabase();
void noteSynchronized(qint32 lid, bool value);
void indexThreadStarted();
void syncThreadStarted();
void counterThreadStarted();
void openCloseNotebooks();
void newWebcamNote();
void deleteCurrentNote();
void duplicateCurrentNote();
void pinCurrentNote();
void unpinCurrentNote();
void spellCheckCurrentNote();
void openExternalNote(qint32 lid);
void pauseIndexing(bool value=true);
void openEvernoteSupport();
void openMessageLog();
void showDesktopUrl(const QUrl &url);
void reloadIcons();
void showMessage(QString title, QString msg, int timeout=10000);
signals:
void syncRequested();
void updateCounts();
};
#endif // NIXNOTE_H