forked from altairwei/WizNotePlus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WizMainWindow.h
executable file
·590 lines (456 loc) · 19 KB
/
WizMainWindow.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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
#ifndef WIZMAINWINDOW_H
#define WIZMAINWINDOW_H
#include <QtGlobal>
#include <QMainWindow>
#include <QPushButton>
#include <QSystemTrayIcon>
#include <QList>
#include <QJsonObject>
#include <memory>
#include "WizDef.h"
#include "share/WizUIHelper.h"
#include "share/WizSettings.h"
#include "share/WizFramelessWindow.h"
#include "utils/ExternalEditorLauncher.h"
#define WIZ_SINGLE_APPLICATION "WIZ_SINGLE_APPLICATION"
class QToolBar;
class QLabel;
class QSystemTrayIcon;
class QComboBox;
class QActionGroup;
class QFileSystemWatcher;
struct TemplateData;
class WizProgressDialog;
class WizDocumentListView;
class WizDocumentSelectionView;
class WizDocumentTransitionView;
class WizActions;
class WizDocumentViewHistory;
class WizFixedSpacer;
class WizMacFixedSpacer;
class WizSplitter;
class WizAnimateAction;
class WizOptionsWidget;
class WizIAPDialog;
class WizTemplatePurchaseDialog;
class WizSearchView;
class WizSearcher;
class WizUserInfoWidget;
class QtSegmentControl;
class WizObjectDownloaderHost;
class CWizUserAvatarDownloaderHost;
class WizKMSyncThread;
class WizUserVerifyDialog;
class WizImageButton;
class WizMacToolBar;
class QNetworkDiskCache;
class WizConsoleDialog;
class WizUpgradeChecker;
class WizCategoryView;
class QListWidgetItem;
class WizCategoryViewMessageItem;
class WizCategoryViewShortcutItem;
class WizDocumentWebView;
class WizTrayIcon;
class WizMobileFileReceiver;
class ICore;
class WizMainTabBrowser;
class WizMessageListView;
class WizMessageSelector;
class WizMessageListTitleBar;
class WizDocumentView;
class WizDocumentSaverThread;
class WizDocumentLoaderThread;
class WizSingleDocumentViewManager;
class QWebEngineView;
class QProgressDialog;
class ApiWizExplorerApp;
class PublicAPIsServer;
#ifdef Q_OS_MAC
class WizMacToolBarButtonItem;
#endif
class WizMainWindow
: public WizFramelessWindow<QMainWindow>
, public WizExplorerApp
{
Q_OBJECT
typedef WizFramelessWindow<QMainWindow> _baseClass;
public:
explicit WizMainWindow(WizDatabaseManager& dbMgr, QWidget *parent = nullptr);
virtual void init();
void saveStatus();
void restoreStatus();
~WizMainWindow();
void cleanOnQuit();
void setRestart(bool b) { m_bRestart = b; }
bool isRestart() const { return m_bRestart; }
Q_PROPERTY(bool restart READ isRestart WRITE setRestart)
bool isLogout() const { return m_bLogoutRestart; }
WizSearcher* searcher();
QString searchKeywords() const { return m_strSearchKeywords; }
static WizMainWindow* instance();
QNetworkDiskCache* webViewNetworkCache();
WizDocumentView* docView();
void trySaveCurrentNote(std::function<void(const QVariant &)> callback);
protected:
bool eventFilter(QObject* watched, QEvent* event);
void resizeEvent(QResizeEvent* event);
void closeEvent(QCloseEvent* event);
void mousePressEvent(QMouseEvent* event);
void mouseMoveEvent(QMouseEvent* event);
void mouseReleaseEvent(QMouseEvent* event);
void changeEvent(QEvent *event);
void moveEvent(QMoveEvent* ev);
private:
WizDatabaseManager& m_dbMgr;
WizProgressDialog* m_progress;
WizUserSettings* m_settings;
WizKMSyncThread* m_syncFull;
WizKMSyncThread* m_syncQuick;
WizUserVerifyDialog* m_userVerifyDialog;
WizConsoleDialog* m_console;
WizUpgradeChecker* m_upgrade;
WizIAPDialog* m_iapDialog;
WizTemplatePurchaseDialog* m_templateIAPDialog;
bool m_quiting;
WizTrayIcon* m_tray;
QMenu* m_trayMenu;
QToolBar* m_toolBar;
WizFixedSpacer* m_spacerForToolButtonAdjust;
QMenuBar* m_menuBar;
QMenu* m_dockMenu;
QMenu* m_windowListMenu;
QMenu* m_newNoteExtraMenu;
QActionGroup* m_viewTypeActions;
QActionGroup* m_sortTypeActions;
QMenu* m_menu;
QToolButton* m_menuButton;
QWidget* m_clienWgt;
#ifndef Q_OS_MAC
QLabel* m_labelNotice;
QAction* m_optionsAction;
#endif
WizActions* m_actions;
WizCategoryView* m_category;
WizDocumentListView* m_documents;
WizMessageListView* m_msgList;
QWidget* m_noteListWidget;
QWidget* m_msgListWidget;
WizMessageListTitleBar* m_msgListTitleBar;
WizDocumentSelectionView* m_documentSelection;
WizDocumentView* m_doc;
WizMainTabBrowser* m_mainTabBrowser;
QWidget* m_documentPanel;
std::shared_ptr<WizSplitter> m_splitter;
QWidget* m_docListContainer;
WizSingleDocumentViewManager* m_singleViewMgr;
QLabel* m_labelDocumentsHint;
// QLabel* m_labelDocumentsCount;
WizImageButton* m_btnMarkDocumentsReaded;
WizDocumentViewHistory* m_history;
WizAnimateAction* m_animateSync;
WizSearcher* m_searcher;
QString m_strSearchKeywords;
WizSearchView* m_searchWidget;
WizUserInfoWidget* m_userInfoWidget;
WizMobileFileReceiver *m_mobileFileReceiver;
bool m_bRestart;
bool m_bLogoutRestart;
bool m_bUpdatingSelection;
bool m_bQuickDownloadMessageEnable;
WIZDOCUMENTDATA m_documentForEditing;
ApiWizExplorerApp* m_IWizExplorerApp;
PublicAPIsServer *m_publicAPIsServer;
ExternalEditorLauncher *m_externalEditorLauncher;
WizDocumentSaverThread *m_docSaver;
WizDocumentLoaderThread *m_docLoader;
QProgressDialog *m_quitProgress;
private:
void initQuitHandler();
void initSearcher();
void initSyncFull();
void initSyncQuick();
void initActions();
void initToolBar();
void initToolBarPluginButtons();
void initClient();
virtual void layoutTitleBar();
void initMenuList();
void initMenuBar();
void initMenuActionState();
void initViewTypeActionGroup();
void initSortTypeActionGroup();
void initDockMenu();
QWidget* createNoteListView();
QWidget* createMessageListView();
void promptServiceExpr(bool free, WIZGROUPDATA group);
public:
// CWizDocument passthrough methods
QSize clientSize() const { return m_splitter->widget(2)->size(); }
QWidget* client() const;
WizDocumentView* documentView() const;
WizDocumentListView* documentList() const { return m_documents; }
WizKMSyncThread* fullSync() const { return m_syncFull; }
WizKMSyncThread* quickSync() const { return m_syncQuick; }
void quickSyncKb(const QString& kbGuid);
void setNeedResetGroups();
WizActions* actions() const { return m_actions; }
//FIXME: why provide download host and dialog by mainwidnow ???
WizObjectDownloaderHost* downloaderHost() const;
WizProgressDialog* progressDialog() const { return m_progress; }
WizIAPDialog* iapDialog();
QObject* publicAPIsObject();
void resetPermission(const QString& strKbGUID, const QString& strDocumentOwner);
void viewDocument(const WIZDOCUMENTDATAEX& data, bool addToHistory);
void viewDocument(const WIZDOCUMENTDATAEX& data);
void viewAttachment(const WIZDOCUMENTATTACHMENTDATA &data);
void checkWizUpdate();
void setSystemTrayIconVisible(bool bVisible);
void setMobileFileReceiverEnable(bool bEnable);
void viewDocumentByWizKMURL(const QString& strKMURL);
void viewAttachmentByWizKMURL(const QString& strKbGUID, const QString& strKMURL);
void createNoteWithAttachments(const QStringList& strAttachList);
void createNoteWithText(const QString& strText);
void createNoteByTemplateCore(const TemplateData& tmplData);
WizMainTabBrowser* mainTabView();
WizDocumentSaverThread *docSaver() { return m_docSaver; }
WizDocumentLoaderThread *docLoader() { return m_docLoader; }
signals:
void documentsViewTypeChanged(int);
void documentsSortTypeChanged(int);
void pluginPopupRequest(QAction *ac, const QPoint &pos);
public Q_SLOTS:
void on_actionExit_triggered();
void on_actionClose_triggered();
void on_actionConsole_triggered();
void on_actionAutoSync_triggered();
void on_actionSync_triggered();
void on_actionNewNote_triggered();
void on_actionNewNoteByTemplate_triggered();
void on_actionLogout_triggered();
void on_actionAbout_triggered();
void on_actionPreference_triggered();
void on_actionFeedback_triggered();
void on_actionSupport_triggered();
void on_actionManual_triggered();
void on_actionSearch_triggered();
void on_actionResetSearch_triggered();
void on_actionDownloadManager_triggered();
void on_actionJSConsole_triggered();
void on_actionFindReplace_triggered();
void on_actionSaveAsPDF_triggered();
void on_actionSaveAsHtml_triggered();
void on_actionSaveAsMarkdown_triggered();
void on_actionImportFile_triggered();
void on_actionExportFile_triggered();
void on_actionPrintMargin_triggered();
// menu editing
void on_actionEditingUndo_triggered();
void on_actionEditingRedo_triggered();
void on_actionEditingCut_triggered();
void on_actionEditingCopy_triggered();
void on_actionEditingPaste_triggered();
void on_actionEditingPastePlain_triggered();
void on_actionEditingDelete_triggered();
void on_actionEditingSelectAll_triggered();
// menu view
void on_actionViewToggleCategory_triggered();
void on_actionLayoutCategoryView_triggered();
void on_actionLayoutDocumentListView_triggered();
void on_actionLayoutTabBrowser_triggered();
void on_actionViewShowSubFolderDocuments_triggered();
void on_actionViewToggleFullscreen_triggered();
#ifdef Q_OS_MAC
void on_actionViewToggleClientFullscreen_triggered();
#endif // Q_OS_MAC
void on_actionViewMinimize_triggered();
void on_actionZoom_triggered();
void on_actionBringFront_triggered();
void on_actionOpenWelcomePage_triggered();
void on_actionCategoryMessageCenter_triggered();
void on_actionCategoryShortcuts_triggered();
void on_actionCategoryQuickSearch_triggered();
void on_actionCategoryFolders_triggered();
void on_actionCategoryTags_triggered();
void on_actionCategoryBizGroups_triggered();
void on_actionCategoryPersonalGroups_triggered();
void on_actionThumbnailView_triggered();
void on_actionSearchResultView_triggered();
void on_actionTwoLineView_triggered();
void on_actionOneLineView_triggered();
void on_actionSortByCreatedTime_triggered();
void on_actionSortByUpdatedTime_triggered();
void on_actionSortByAccessTime_triggered();
void on_actionSortByTitle_triggered();
void on_actionSortByFolder_triggered();
void on_actionSortBySize_triggered();
void on_actionSkinReloadStyleSheet_triggered();
void on_categoryUnreadButton_triggered();
void on_actionMarkAllMessageRead_triggered(bool removeItems);
void on_messageSelector_senderSelected(QString userGUID);
// menu format
void on_actionMenuFormatJustifyLeft_triggered();
void on_actionMenuFormatJustifyRight_triggered();
void on_actionMenuFormatJustifyCenter_triggered();
void on_actionMenuFormatJustifyJustify_triggered();
void on_actionMenuFormatIndent_triggered();
void on_actionMenuFormatOutdent_triggered();
void on_actionMenuFormatInsertOrderedList_triggered();
void on_actionMenuFormatInsertUnorderedList_triggered();
void on_actionMenuFormatInsertLink_triggered();
void on_actionMenuFormatBold_triggered();
void on_actionMenuFormatItalic_triggered();
void on_actionMenuFormatUnderLine_triggered();
void on_actionMenuFormatStrikeThrough_triggered();
void on_actionMenuFormatSubscript_triggered();
void on_actionMenuFormatSuperscript_triggered();
void on_actionMenuFormatInsertHorizontal_triggered();
void on_actionMenuFormatInsertDate_triggered();
void on_actionMenuFormatInsertTime_triggered();
void on_actionMenuFormatRemoveFormat_triggered();
void on_actionMenuFormatInsertCheckList_triggered();
void on_actionMenuFormatInsertCode_triggered();
void on_actionMenuFormatInsertImage_triggered();
void on_actionMenuFormatScreenShot_triggered();
void on_actionMenuFormatInsertTable(int row, int col);
void on_searchProcess(const QString &strKeywords, const CWizDocumentDataArray& arrayDocument,
bool bStart, bool bEnd);
void on_actionGoBack_triggered();
void on_actionGoForward_triggered();
void on_category_itemSelectionChanged();
void on_documents_itemSelectionChanged();
void on_documents_itemDoubleClicked(QListWidgetItem * item);
void on_documents_lastDocumentDeleted();
// void on_documents_documentCountChanged();
// void on_documents_hintChanged(const QString& strHint);
void on_btnMarkDocumentsRead_triggered();
void on_documents_viewTypeChanged(int type);
void on_documents_sortingTypeChanged(int type);
//void on_document_contentChanged();
void on_search_doSearch(const QString& keywords);
void on_options_settingsChanged(WizOptionsType type);
void on_syncLogined();
void on_syncStarted(bool syncAll);
void on_syncDone(int nErrorcode, bool isNetworkError, const QString& strErrorMsg, bool isBackground);
void on_syncDone_userVerified();
void on_syncProcessLog(const QString& strMsg);
void on_promptMessage_request(int nType, const QString& strTitle, const QString& strMsg);
void on_promptFreeServiceExpr(WIZGROUPDATA group);
void on_promptVipServiceExpr(WIZGROUPDATA group);
void on_bubbleNotification_request(const QVariant& param);
void on_TokenAcquired(const QString& strToken);
void on_quickSync_request(const QString& strKbGUID);
void on_options_restartForSettings();
void on_editor_statusChanged(const QString& currentStyle);
void createNoteByTemplate(const TemplateData& tmplData);
void on_mobileFileRecived(const QString& strFile);
void on_shareDocumentByLink_request(const QString& strKbGUID, const QString& strGUID);
#ifndef Q_OS_MAC
void on_actionPopupMainMenu_triggered();
void on_menuButtonClicked();
#endif
void adjustToolBarLayout();
void on_client_splitterMoved(int pos, int index);
void on_application_aboutToQuit();
void on_application_messageAvailable(const QString& strMsg);
void on_checkUpgrade_finished(QJsonObject latestStable, QJsonObject latestTest);
#ifdef WIZ_OBOSOLETE
void on_upgradeThread_finished();
#endif
void on_trayIcon_newDocument_clicked();
void on_hideTrayIcon_clicked();
void handleTrayIconActived(QSystemTrayIcon::ActivationReason reason);
void showBubbleNotification(const QString& strTitle, const QString& strInfo);
void showTrayIconMenu();
void on_viewMessage_request(qint64 messageID);
void on_viewMessage_request(const WIZMESSAGEDATA& msg);
void on_viewMessage_requestNormal(QVariant messageData);
void on_dockMenuAction_triggered();
void shiftVisableStatus();
void showNewFeatureGuide();
void showMobileFileReceiverUserGuide();
void setDoNotShowMobileFileReceiverUserGuideAgain(bool bNotAgain);
void locateDocument(const WIZDOCUMENTDATA& data);
void locateDocument(const QString& strKbGuid, const QString& strGuid);
void titleChanged();
void viewNoteInSeparateWindow(const WIZDOCUMENTDATA& data);
void viewCurrentNoteInSeparateWindow();
void onAttachmentModified(QString strKbGUID, QString strGUID,QString strFileName,
QString strMD5, QDateTime dtLastModified);
void setCurrentDocumentView(WizDocumentView* newDocView);
void on_mainTabWidget_currentChanged(int pageIndex);
void showHomePage();
public:
// WizExplorerApp pointer
virtual QWidget* mainWindow();
virtual QObject* object();
virtual WizDatabaseManager& databaseManager() { return m_dbMgr; }
virtual WizCategoryBaseView& category();
virtual WizUserSettings& userSettings();
//WizExplorerApp API:
QObject* Window() { return this; }
Q_PROPERTY(QObject* Window READ Window)
QObject* CategoryCtrl(); // deprecated
WizCategoryView* CategoryView();
Q_PROPERTY(QObject* CategoryCtrl READ CategoryCtrl)
QObject* DocumentsCtrl();
Q_PROPERTY(QObject* DocumentsCtrl READ DocumentsCtrl)
QObject* DatabaseManager();
WizDatabaseManager* DatabaseManagerEx();
Q_PROPERTY(QObject* DatabaseManager READ DatabaseManager)
QObject* CurrentDocumentBrowserObject();
Q_PROPERTY(QObject* CurrentDocumentBrowserObject READ CurrentDocumentBrowserObject)
Q_INVOKABLE QObject* CreateWizObject(const QString& strObjectID);
Q_INVOKABLE void SetSavingDocument(bool saving);
Q_INVOKABLE void ProcessClipboardBeforePaste(const QVariantMap& data);
//NOTE: these functions would called by web page, do not delete
Q_INVOKABLE QString TranslateString(const QString& string);
Q_INVOKABLE void OpenURLInDefaultBrowser(const QString& strUrl);
Q_INVOKABLE void GetToken(const QString& strFunctionName);
Q_INVOKABLE void SetDialogResult(int nResult);
Q_INVOKABLE void AppStoreIAP();
Q_INVOKABLE void copyLink(const QString& link);
Q_INVOKABLE void onClickedImage(const QString& src, const QString& list);
private:
void syncAllData();
void reconnectServer();
void setFocusForNewNote(WIZDOCUMENTDATA doc);
void initTrayIcon(QSystemTrayIcon* trayIcon);
void startSearchStatus();
void quitSearchStatus();
void resetSearchStatus();
void initVariableBeforCreateNote();
bool needShowNewFeatureGuide();
void resortDocListAfterViewDocument(const WIZDOCUMENTDATA& doc);
void showCommentWidget();
WizDocumentWebView* getActiveEditor();
WizDocumentView* createDocumentView();
WizDocumentView* currentDocumentView();
void waitForAllDocumentViewDone();
void processAllDocumentViews(std::function<void(WizDocumentView*)> callback);
void showDocumentList();
void showDocumentList(WizCategoryBaseView* category);
void showMessageList(WizCategoryViewMessageItem* pItem);
void viewDocumentByShortcut(WizCategoryViewShortcutItem *pShortcut);
void searchNotesBySQL(const QString& strSQLWhere);
void searchNotesBySQLAndKeyword(const QString& strSQLWhere, const QString& strKeyword, int searchScope);
void updateHistoryButtonStatus();
void openAttachment(const WIZDOCUMENTATTACHMENTDATA& attachment, const QString& strFileName);
void downloadAttachment(const WIZDOCUMENTATTACHMENTDATA& attachment);
void openVipPageInWebBrowser();
void loadMessageByUserGuid(const QString& guid);
void resetWindowListMenu(QMenu* menu, bool removeExists);
void changeDocumentsSortTypeByAction(QAction* action);
bool processApplicationActiveEvent();
void prepareNewNoteMenu();
private slots:
void windowActived();
void resetDockMenu();
void resetWindowMenu();
void removeWindowsMenuItem(QString guid);
void showVipUpgradePage();
void on_newNoteByExtraMenu_request();
private:
void showTemplateIAPDlg(const TemplateData& tmpl);
};
#endif // WIZMAINWINDOW_H