diff --git a/source/src/labeledittype.cpp b/source/src/labeledittype.cpp old mode 100644 new mode 100755 index 229f0a9..9c8e281 --- a/source/src/labeledittype.cpp +++ b/source/src/labeledittype.cpp @@ -3,6 +3,7 @@ #include #include +// LabelEditType 类的构造函数 LabelEditType::LabelEditType(QWidget *parent) : QLabel(parent) { setContentsMargins(0, 0, 0, 0); @@ -15,6 +16,7 @@ LabelEditType::LabelEditType(QWidget *parent) : QLabel(parent) connect(m_editor, &QLineEdit::editingFinished, this, &LabelEditType::onFinishedEdit); } +// 打开编辑器 void LabelEditType::openEditor() { m_editor->setText(text()); @@ -25,6 +27,7 @@ void LabelEditType::openEditor() emit editingStarted(); } +// 编辑完成后的处理 void LabelEditType::onFinishedEdit() { m_editor->hide(); @@ -32,4 +35,4 @@ void LabelEditType::onFinishedEdit() setText(m_editor->text()); } emit editingFinished(text()); -} +} \ No newline at end of file diff --git a/source/src/labeledittype.h b/source/src/labeledittype.h old mode 100644 new mode 100755 index b381617..eae9ceb --- a/source/src/labeledittype.h +++ b/source/src/labeledittype.h @@ -3,25 +3,32 @@ #include +// 自定义LabelEditType类,继承自QLabel class QLineEdit; class LabelEditType : public QLabel { Q_OBJECT public: + // 构造函数,接受一个父部件指针 explicit LabelEditType(QWidget *parent = nullptr); public slots: + // 打开编辑器的槽函数 void openEditor(); private slots: + // 编辑完成后的槽函数 void onFinishedEdit(); signals: + // 编辑开始信号 void editingStarted(); + // 编辑完成信号,携带编辑的文本 void editingFinished(const QString &text); private: + // 编辑器指针 QLineEdit *m_editor; }; -#endif // LABELEDITTYPE_H +#endif // LABELEDITTYPE_H \ No newline at end of file diff --git a/source/src/listviewlogic.cpp b/source/src/listviewlogic.cpp old mode 100644 new mode 100755 index 3b248c4..2640460 --- a/source/src/listviewlogic.cpp +++ b/source/src/listviewlogic.cpp @@ -10,6 +10,7 @@ #include "tagpool.h" #include +// 检查当前笔记 ID 是否无效 static bool isInvalidCurrentNotesId(const QSet ¤tNotesId) { if (currentNotesId.isEmpty()) { @@ -24,6 +25,7 @@ static bool isInvalidCurrentNotesId(const QSet ¤tNotesId) return isInvalid; } +// ListViewLogic 类的构造函数,负责初始化相关组件并设置信号与槽 ListViewLogic::ListViewLogic(NoteListView *noteView, NoteListModel *noteModel, QLineEdit *searchEdit, QToolButton *clearButton, TagPool *tagPool, DBManager *dbManager, QObject *parent) @@ -125,6 +127,7 @@ ListViewLogic::ListViewLogic(NoteListView *noteView, NoteListModel *noteModel, &ListViewLogic::onListViewClicked); } +// 选择指定的笔记 void ListViewLogic::selectNote(const QModelIndex ¬eIndex) { if (noteIndex.isValid()) { @@ -138,6 +141,7 @@ void ListViewLogic::selectNote(const QModelIndex ¬eIndex) } } +// 将笔记移动到列表顶部 void ListViewLogic::moveNoteToTop(const NodeData ¬e) { QModelIndex noteIndex = m_listModel->getNoteIndex(note.id()); @@ -164,6 +168,7 @@ void ListViewLogic::moveNoteToTop(const NodeData ¬e) } } +// 设置笔记的数据 void ListViewLogic::setNoteData(const NodeData ¬e) { QModelIndex noteIndex = m_listModel->getNoteIndex(note.id()); @@ -188,6 +193,7 @@ void ListViewLogic::setNoteData(const NodeData ¬e) } } +// 处理笔记编辑关闭事件 void ListViewLogic::onNoteEditClosed(const NodeData ¬e, bool selectNext) { if (note.isTempNote()) { @@ -209,12 +215,14 @@ void ListViewLogic::onNoteEditClosed(const NodeData ¬e, bool selectNext) } } +// 请求删除笔记 void ListViewLogic::deleteNoteRequested(const NodeData ¬e) { auto index = m_listModel->getNoteIndex(note.id()); deleteNoteRequestedI({ index }); } +// 选择当前笔记的上一笔记 void ListViewLogic::selectNoteUp() { auto currentIndex = m_listView->currentIndex(); @@ -235,6 +243,7 @@ void ListViewLogic::selectNoteUp() } } +// 选择当前笔记的下一笔记 void ListViewLogic::selectNoteDown() { auto currentIndex = m_listView->currentIndex(); @@ -259,15 +268,14 @@ void ListViewLogic::selectNoteDown() /*! * \brief ListViewLogic::onSearchEditTextChanged - * When text on searchEdit change: - * If there is a temp note "New Note" while searching, we delete it - * Saving the last selected note for recovery after searching - * Clear all the notes from scrollArea and - * If text is empty, reload all the notes from database - * Else, load all the notes contain the string in searchEdit from database + * 当搜索框文本改变时: + * 如果存在临时笔记"新笔记",在搜索时删除它 + * 保存最后选择的笔记以便在搜索后恢复 + * 清空滚动区域中的所有笔记 + * 如果文本为空,则从数据库重新加载所有笔记 + * 否则,从数据库中加载包含搜索框字符串的所有笔记 * \param keyword */ - void ListViewLogic::onSearchEditTextChanged(const QString &keyword) { if (keyword.isEmpty()) { @@ -287,6 +295,7 @@ void ListViewLogic::onSearchEditTextChanged(const QString &keyword) } } +// 清除搜索 void ListViewLogic::clearSearch(bool createNewNote, int scrollToId) { m_listViewInfo.needCreateNewNote = createNewNote; @@ -295,6 +304,7 @@ void ListViewLogic::clearSearch(bool createNewNote, int scrollToId) emit requestClearSearchUI(); } +// 加载笔记列表模型 void ListViewLogic::loadNoteListModel(const QVector ¬eList, const ListViewInfo &inf) { auto currentNotesId = m_listViewInfo.currentNotesId; @@ -363,6 +373,7 @@ void ListViewLogic::loadNoteListModel(const QVector ¬eList, const L selectFirstNote(); } +// 添加标签请求处理 void ListViewLogic::onAddTagRequest(const QModelIndex &index, int tagId) { if (index.isValid()) { @@ -382,12 +393,14 @@ void ListViewLogic::onAddTagRequest(const QModelIndex &index, int tagId) } } +// 直接请求添加标签 void ListViewLogic::onAddTagRequestD(int noteId, int tagId) { auto index = m_listModel->getNoteIndex(noteId); onAddTagRequest(index, tagId); } +// 笔记移动到其他区域的处理 void ListViewLogic::onNoteMovedOut(int nodeId, int targetId) { auto index = m_listModel->getNoteIndex(nodeId); @@ -415,6 +428,7 @@ void ListViewLogic::onNoteMovedOut(int nodeId, int targetId) } } +// 设置最后选择的笔记 void ListViewLogic::setLastSelectedNote() { auto indexes = m_listView->selectedIndex(); @@ -427,11 +441,13 @@ void ListViewLogic::setLastSelectedNote() setLastSavedState(ids, 0); } +// 请求加载最后选择的笔记 void ListViewLogic::loadLastSelectedNoteRequested() { requestLoadSavedState(2); } +// 处理文件夹中的笔记列表请求 void ListViewLogic::onNotesListInFolderRequested(int parentID, bool isRecursive, bool newNote, int scrollToId) { @@ -449,6 +465,7 @@ void ListViewLogic::onNotesListInFolderRequested(int parentID, bool isRecursive, } } +// 处理标签中的笔记列表请求 void ListViewLogic::onNotesListInTagsRequested(const QSet &tagIds, bool newNote, int scrollToId) { @@ -465,6 +482,7 @@ void ListViewLogic::onNotesListInTagsRequested(const QSet &tagIds, bool new } } +// 选择多个笔记 void ListViewLogic::selectNotes(const QModelIndexList &indexes) { m_listView->clearSelection(); @@ -482,6 +500,7 @@ void ListViewLogic::selectNotes(const QModelIndexList &indexes) onNotePressed(indexes); } +// 处理移除标签请求 void ListViewLogic::onRemoveTagRequest(const QModelIndex &index, int tagId) { if (index.isValid()) { @@ -503,14 +522,13 @@ void ListViewLogic::onRemoveTagRequest(const QModelIndex &index, int tagId) /*! * \brief MainWindow::onNotePressed - * When clicking on a note in the scrollArea: - * Unhighlight the previous selected note - * If selecting a note when temporery note exist, delete the temp note - * Highlight the selected note - * Load the selected note content into textedit + * 当点击滚动区域中的笔记时: + * 取消高亮先前选择的笔记 + * 如果在选择笔记时存在临时笔记,删除临时笔记 + * 高亮选择的笔记 + * 加载选定笔记的内容到文本编辑器中 * \param index */ - void ListViewLogic::onNotePressed(const QModelIndexList &indexes) { QVector notes; @@ -527,6 +545,7 @@ void ListViewLogic::onNotePressed(const QModelIndexList &indexes) m_listView->setCurrentRowActive(false); } +// 删除笔记请求的内部处理 void ListViewLogic::deleteNoteRequestedI(const QModelIndexList &indexes) { if (!indexes.empty()) { @@ -582,6 +601,7 @@ void ListViewLogic::deleteNoteRequestedI(const QModelIndexList &indexes) } } +// 请求恢复笔记的内部处理 void ListViewLogic::restoreNotesRequestedI(const QModelIndexList &indexes) { QModelIndexList needRestoredI; @@ -617,6 +637,7 @@ void ListViewLogic::restoreNotesRequestedI(const QModelIndexList &indexes) } } +// 更新列表视图的标签 void ListViewLogic::updateListViewLabel() { QString l1, l2; @@ -650,6 +671,7 @@ void ListViewLogic::updateListViewLabel() emit listViewLabelChanged(l1, l2); } +// 行数变化的处理 void ListViewLogic::onRowCountChanged() { m_listView->closeAllEditor(); @@ -667,6 +689,7 @@ void ListViewLogic::onRowCountChanged() } } +// 双击笔记的处理 void ListViewLogic::onNoteDoubleClicked(const QModelIndex &index) { if (!index.isValid() || !m_listViewInfo.isInSearch) { @@ -676,11 +699,13 @@ void ListViewLogic::onNoteDoubleClicked(const QModelIndex &index) clearSearch(false, id); } +// 请求设置笔记为置顶的处理 void ListViewLogic::onSetPinnedNoteRequested(const QModelIndexList &indexes, bool isPinned) { m_listModel->setNotesIsPinned(indexes, isPinned); } +// 列表视图点击的处理 void ListViewLogic::onListViewClicked() { if (m_listModel->rowCount() > 1) { @@ -700,6 +725,7 @@ void ListViewLogic::onListViewClicked() } } +// 选择第一笔记 void ListViewLogic::selectFirstNote() { if (m_listModel->rowCount() > 0) { @@ -714,6 +740,7 @@ void ListViewLogic::selectFirstNote() } } +// 设置主题 void ListViewLogic::setTheme(Theme::Value theme) { m_listView->setTheme(theme); @@ -721,22 +748,26 @@ void ListViewLogic::setTheme(Theme::Value theme) m_listView->update(); } +// 检查动画是否正在运行 bool ListViewLogic::isAnimationRunning() { return m_listDelegate->animationState() == QTimeLine::Running; } +// 设置最后保存的状态 void ListViewLogic::setLastSavedState(const QSet &lastSelectedNotes, int needLoadSavedState) { m_needLoadSavedState = needLoadSavedState; m_lastSelectedNotes = lastSelectedNotes; } +// 请求加载保存的状态 void ListViewLogic::requestLoadSavedState(int needLoadSavedState) { m_needLoadSavedState = needLoadSavedState; } +// 选择所有笔记 void ListViewLogic::selectAllNotes() { if (m_listModel->rowCount() > 50) { @@ -771,7 +802,8 @@ void ListViewLogic::selectAllNotes() onNotePressed(m_listView->selectedIndex()); } +// 获取当前视图信息 const ListViewInfo &ListViewLogic::listViewInfo() const { return m_listViewInfo; -} +} \ No newline at end of file diff --git a/source/src/listviewlogic.h b/source/src/listviewlogic.h old mode 100644 new mode 100755 index e0984c7..faef943 --- a/source/src/listviewlogic.h +++ b/source/src/listviewlogic.h @@ -16,83 +16,136 @@ class QLineEdit; class QToolButton; class TagPool; +// 负责笔记列表视图逻辑的类 class ListViewLogic : public QObject { Q_OBJECT public: + // 构造函数,初始化笔记视图、笔记模型、搜索框等 explicit ListViewLogic(NoteListView *noteView, NoteListModel *noteModel, QLineEdit *searchEdit, QToolButton *clearButton, TagPool *tagPool, DBManager *dbManager, QObject *parent = nullptr); + // 选择指定索引的笔记 void selectNote(const QModelIndex ¬eIndex); + // 获取当前列表视图的信息 const ListViewInfo &listViewInfo() const; + // 选择第一个笔记 void selectFirstNote(); + // 设置主题 void setTheme(Theme::Value theme); + // 检查动画是否正在运行 bool isAnimationRunning(); + // 设置最后保存的状态 void setLastSavedState(const QSet &lastSelectedNotes, int needLoadSavedState = 2); + // 请求加载保存的状态 void requestLoadSavedState(int needLoadSavedState); + // 选择所有笔记 void selectAllNotes(); public slots: + // 将笔记移动到顶部 void moveNoteToTop(const NodeData ¬e); + // 设置笔记数据 void setNoteData(const NodeData ¬e); + // 笔记编辑关闭后的处理 void onNoteEditClosed(const NodeData ¬e, bool selectNext); + // 请求删除笔记 void deleteNoteRequested(const NodeData ¬e); + // 选择上一个笔记 void selectNoteUp(); + // 选择下一个笔记 void selectNoteDown(); + // 搜索框文本改变的处理 void onSearchEditTextChanged(const QString &keyword); + // 清除搜索 void clearSearch(bool createNewNote = false, int scrollToId = SpecialNodeID::InvalidNodeId); + // 添加标签请求的处理 void onAddTagRequestD(int noteId, int tagId); + // 笔记移动事件处理 void onNoteMovedOut(int nodeId, int targetId); + // 设置最后选择的笔记 void setLastSelectedNote(); + // 请求加载最后选择的笔记 void loadLastSelectedNoteRequested(); + // 请求在文件夹中获取笔记列表 void onNotesListInFolderRequested(int parentID, bool isRecursive, bool newNote, int scrollToId); + // 请求通过标签获取笔记列表 void onNotesListInTagsRequested(const QSet &tagIds, bool newNote, int scrollToId); + // 选择笔记 void selectNotes(const QModelIndexList &indexes); signals: + // 显示笔记在编辑器中的信号 void showNotesInEditor(const QVector ¬esData); + // 请求添加标签到数据库的信号 void requestAddTagDb(int noteId, int tagId); + // 请求从数据库中移除标签的信号 void requestRemoveTagDb(int noteId, int tagId); + // 请求从数据库中移除笔记的信号 void requestRemoveNoteDb(const NodeData ¬eData); + // 请求将笔记移动到数据库的信号 void requestMoveNoteDb(int noteId, const NodeData &targetFolder); + // 请求高亮搜索的信号 void requestHighlightSearch(); + // 关闭笔记编辑器的信号 void closeNoteEditor(); + // 笔记标签列表更改的信号 void noteTagListChanged(int noteId, const QSet &tagIds); + // 请求在数据库中搜索的信号 void requestSearchInDb(const QString &keyword, const ListViewInfo &inf); + // 请求清除数据库中的搜索的信号 void requestClearSearchDb(const ListViewInfo &inf); + // 请求清除UI中的搜索的信号 void requestClearSearchUI(); + // 请求新笔记的信号 void requestNewNote(); + // 请求移动笔记的信号 void moveNoteRequested(int id, int target); + // 列表视图标签改变的信号 void listViewLabelChanged(const QString &label1, const QString &label2); + // 设置新笔记按钮可见性的信号 void setNewNoteButtonVisible(bool visible); + // 请求在文件夹中获取笔记列表的信号 void requestNotesListInFolder(int parentID, bool isRecursive, bool newNote, int scrollToId); + // 请求通过标签获取笔记列表的信号 void requestNotesListInTags(const QSet &tagIds, bool newNote, int scrollToId); private slots: + // 加载笔记列表模型 void loadNoteListModel(const QVector ¬eList, const ListViewInfo &inf); + // 处理添加标签请求 void onAddTagRequest(const QModelIndex &index, int tagId); + // 处理移除标签请求 void onRemoveTagRequest(const QModelIndex &index, int tagId); + // 处理笔记按下事件 void onNotePressed(const QModelIndexList &indexes); + // 请求删除笔记的处理 void deleteNoteRequestedI(const QModelIndexList &indexes); + // 请求恢复笔记的处理 void restoreNotesRequestedI(const QModelIndexList &indexes); + // 更新列表视图标签 void updateListViewLabel(); + // 行数改变的处理 void onRowCountChanged(); + // 处理双击笔记事件 void onNoteDoubleClicked(const QModelIndex &index); + // 请求设置固定笔记的处理 void onSetPinnedNoteRequested(const QModelIndexList &indexes, bool isPinned); + // 处理列表视图点击事件 void onListViewClicked(); private: - NoteListView *m_listView; - NoteListModel *m_listModel; - QLineEdit *m_searchEdit; - QToolButton *m_clearButton; - DBManager *m_dbManager; - NoteListDelegate *m_listDelegate; - TagPool *m_tagPool; - ListViewInfo m_listViewInfo; - QVector m_editorIndexes; + NoteListView *m_listView; // 笔记列表视图 + NoteListModel *m_listModel; // 笔记列表模型 + QLineEdit *m_searchEdit; // 搜索框 + QToolButton *m_clearButton; // 清除按钮 + DBManager *m_dbManager; // 数据库管理器 + NoteListDelegate *m_listDelegate; // 笔记列表委托 + TagPool *m_tagPool; // 标签池 + ListViewInfo m_listViewInfo; // 列表视图信息 + QVector m_editorIndexes; // 编辑器索引 - int m_needLoadSavedState; - QSet m_lastSelectedNotes; + int m_needLoadSavedState; // 需要加载的保存状态 + QSet m_lastSelectedNotes; // 最后选择的笔记集合 }; -#endif // LISTVIEWLOGIC_H +#endif // LISTVIEWLOGIC_H \ No newline at end of file diff --git a/source/src/lqtutils_enum.h b/source/src/lqtutils_enum.h old mode 100644 new mode 100755 index b448f1a..80d770f --- a/source/src/lqtutils_enum.h +++ b/source/src/lqtutils_enum.h @@ -23,32 +23,33 @@ **/ // Credit: https://github.com/carlonluca/lqtutils - #ifndef LQTUTILS_ENUM_H #define LQTUTILS_ENUM_H #include #include -#define L_DECLARE_ENUM(enumName, ...) \ - namespace enumName { \ - Q_NAMESPACE \ - enum Value { __VA_ARGS__ }; \ - Q_ENUM_NS(Value) \ - inline int qmlRegister##enumName(const char *uri, int major, int minor) \ - { \ - return qmlRegisterUncreatableMetaObject(enumName::staticMetaObject, uri, major, minor, \ - #enumName, "Access to enums & flags only"); \ - } \ - inline int qRegisterMetaType() \ - { \ - return ::qRegisterMetaType(#enumName); \ - } \ - inline void registerEnum(const char *uri, int major, int minor) \ - { \ - enumName::qmlRegister##enumName(uri, major, minor); \ - enumName::qRegisterMetaType(); \ - } \ - } +// 宏定义 L_DECLARE_ENUM 用于声明枚举类型及其相关函数 +#define L_DECLARE_ENUM(enumName, ...) \ + namespace enumName { \ + Q_NAMESPACE \ + enum Value { __VA_ARGS__ }; \ + Q_ENUM_NS(Value) \ +// 注册 QML 中的枚举类型 +inline int qmlRegister##enumName(const char *uri, int major, int minor) +{ + return qmlRegisterUncreatableMetaObject(enumName::staticMetaObject, uri, major, minor, + #enumName, "Access to enums & flags only"); +} // 注册元类型 +inline int qRegisterMetaType() +{ + return ::qRegisterMetaType(#enumName); +} // 注册枚举类型 +inline void registerEnum(const char *uri, int major, int minor) +{ + enumName::qmlRegister##enumName(uri, major, minor); + enumName::qRegisterMetaType(); +} +} -#endif // LQTUTILS_ENUM_H +#endif // LQTUTILS_ENUM_H \ No newline at end of file diff --git a/source/src/main.cpp b/source/src/main.cpp old mode 100644 new mode 100755 index bfcf36b..672a554 --- a/source/src/main.cpp +++ b/source/src/main.cpp @@ -3,16 +3,11 @@ * Just a meantime project to see the ability of qt, the framework that my OS might be based on * And for those linux users that believe in the power of notes *********************************************************************************************/ - -#include "mainwindow.h" -#include "singleinstance.h" -#include -#include - +// 主函数,程序入口 int main(int argc, char *argv[]) { QApplication app(argc, argv); - // Set application information + // 设置应用程序信息 app.setApplicationName("Notes"); app.setApplicationVersion(APP_VERSION); @@ -24,6 +19,7 @@ int main(int argc, char *argv[]) app.setAttribute(Qt::AA_DisableWindowContextHelpButton); #endif + // 尝试加载字体并报告错误 if (QFontDatabase::addApplicationFont(":/fonts/fontawesome/fa-solid-900.ttf") < 0) qWarning() << "FontAwesome Solid cannot be loaded !"; @@ -36,7 +32,7 @@ int main(int argc, char *argv[]) if (QFontDatabase::addApplicationFont(":/fonts/material/material-symbols-outlined.ttf") < 0) qWarning() << "Material Symbols cannot be loaded !"; - // Load fonts from resources + // 从资源加载字体 // Roboto QFontDatabase::addApplicationFont(":/fonts/roboto-hinted/Roboto-Bold.ttf"); QFontDatabase::addApplicationFont(":/fonts/roboto-hinted/Roboto-Medium.ttf"); @@ -56,38 +52,38 @@ int main(int argc, char *argv[]) QFontDatabase::addApplicationFont(":/fonts/sourcesanspro/SourceSansPro-SemiBold.ttf"); QFontDatabase::addApplicationFont(":/fonts/sourcesanspro/SourceSansPro-SemiBoldItalic.ttf"); - // Trykker + // Trykker 字体 QFontDatabase::addApplicationFont(":/fonts/trykker/Trykker-Regular.ttf"); - // Mate + // Mate 字体 QFontDatabase::addApplicationFont(":/fonts/mate/Mate-Regular.ttf"); QFontDatabase::addApplicationFont(":/fonts/mate/Mate-Italic.ttf"); - // PT Serif + // PT Serif 字体 QFontDatabase::addApplicationFont(":/fonts/ptserif/PTSerif-Regular.ttf"); QFontDatabase::addApplicationFont(":/fonts/ptserif/PTSerif-Italic.ttf"); QFontDatabase::addApplicationFont(":/fonts/ptserif/PTSerif-Bold.ttf"); QFontDatabase::addApplicationFont(":/fonts/ptserif/PTSerif-BoldItalic.ttf"); - // iA Mono + // iA Mono 字体 QFontDatabase::addApplicationFont(":/fonts/iamono/iAWriterMonoS-Regular.ttf"); QFontDatabase::addApplicationFont(":/fonts/iamono/iAWriterMonoS-Italic.ttf"); QFontDatabase::addApplicationFont(":/fonts/iamono/iAWriterMonoS-Bold.ttf"); QFontDatabase::addApplicationFont(":/fonts/iamono/iAWriterMonoS-BoldItalic.ttf"); - // iA Duo + // iA Duo 字体 QFontDatabase::addApplicationFont(":/fonts/iaduo/iAWriterDuoS-Regular.ttf"); QFontDatabase::addApplicationFont(":/fonts/iaduo/iAWriterDuoS-Italic.ttf"); QFontDatabase::addApplicationFont(":/fonts/iaduo/iAWriterDuoS-Bold.ttf"); QFontDatabase::addApplicationFont(":/fonts/iaduo/iAWriterDuoS-BoldItalic.ttf"); - // iA Quattro + // iA Quattro 字体 QFontDatabase::addApplicationFont(":/fonts/iaquattro/iAWriterQuattroS-Regular.ttf"); QFontDatabase::addApplicationFont(":/fonts/iaquattro/iAWriterQuattroS-Italic.ttf"); QFontDatabase::addApplicationFont(":/fonts/iaquattro/iAWriterQuattroS-Bold.ttf"); QFontDatabase::addApplicationFont(":/fonts/iaquattro/iAWriterQuattroS-BoldItalic.ttf"); - // Prevent many instances of the app to be launched + // 防止多个应用实例启动 QString name = "com.awsomeness.notes"; SingleInstance instance; if (instance.hasPrevious(name)) { @@ -96,13 +92,13 @@ int main(int argc, char *argv[]) instance.listen(name); - // Create and Show the app + // 创建并显示应用程序窗口 MainWindow w; w.show(); - // Bring the Notes window to the front + // 将Notes窗口置于最前 QObject::connect(&instance, &SingleInstance::newInstance, &w, [&]() { (&w)->setMainWindowVisibility(true); }); return app.exec(); -} +} \ No newline at end of file diff --git a/source/src/mainwindow.cpp b/source/src/mainwindow.cpp old mode 100644 new mode 100755 index 100daf8..7b57f45 --- a/source/src/mainwindow.cpp +++ b/source/src/mainwindow.cpp @@ -34,6 +34,7 @@ /*! * \brief MainWindow::MainWindow * \param parent + * 构造函数,初始化主窗口及其组件 */ MainWindow::MainWindow(QWidget *parent) : MainWindowBase(parent), @@ -171,6 +172,7 @@ MainWindow::MainWindow(QWidget *parent) /*! * \brief MainWindow::InitData * Init the data from database and select the first note if there is one + * 初始化数据库中的数据,并选择第一个笔记(如果存在) */ void MainWindow::InitData() { @@ -220,6 +222,7 @@ void MainWindow::InitData() /*! * \brief Toggles visibility of the main window upon system tray activation * \param reason The reason the system tray was activated + * 切换主窗口的可见性,取决于系统托盘的激活原因 */ void MainWindow::onSystemTrayIconActivated(QSystemTrayIcon::ActivationReason reason) { @@ -231,6 +234,7 @@ void MainWindow::onSystemTrayIconActivated(QSystemTrayIcon::ActivationReason rea /*! * \brief MainWindow::setMainWindowVisibility * \param state + * 设置主窗口的可见性 */ void MainWindow::setMainWindowVisibility(bool state) { @@ -249,6 +253,13 @@ void MainWindow::setMainWindowVisibility(bool state) } } +/*! + * \brief MainWindow::saveLastSelectedFolderTags + * \param isFolder + * \param folderPath + * \param tagId + * 保存最后选择的文件夹标签 + */ void MainWindow::saveLastSelectedFolderTags(bool isFolder, const QString &folderPath, const QSet &tagId) { @@ -261,11 +272,21 @@ void MainWindow::saveLastSelectedFolderTags(bool isFolder, const QString &folder m_settingsDatabase->setValue("currentSelectTagsId", sl); } +/*! + * \brief MainWindow::saveExpandedFolder + * \param folderPaths + * 保存展开的文件夹路径 + */ void MainWindow::saveExpandedFolder(const QStringList &folderPaths) { m_settingsDatabase->setValue("currentExpandedFolder", folderPaths); } +/*! + * \brief MainWindow::saveLastSelectedNote + * \param notesId + * 保存最后选择的笔记ID + */ void MainWindow::saveLastSelectedNote(const QSet ¬esId) { QStringList sl; @@ -278,6 +299,7 @@ void MainWindow::saveLastSelectedNote(const QSet ¬esId) /*! * \brief MainWindow::paintEvent * \param event + * 处理绘制事件 */ void MainWindow::paintEvent(QPaintEvent *event) { @@ -309,6 +331,7 @@ void MainWindow::paintEvent(QPaintEvent *event) /*! * \brief MainWindow::resizeEvent * \param event + * 处理窗口调整大小事件 */ void MainWindow::resizeEvent(QResizeEvent *event) { @@ -328,6 +351,7 @@ void MainWindow::resizeEvent(QResizeEvent *event) /*! * \brief MainWindow::resizeAndPositionEditorSettingsWindow + * 调整并定位编辑器设置窗口 */ void MainWindow::resizeAndPositionEditorSettingsWindow() { @@ -348,6 +372,7 @@ void MainWindow::resizeAndPositionEditorSettingsWindow() /*! * \brief MainWindow::~MainWindow * Deconstructor of the class + * 析构函数 */ MainWindow::~MainWindow() { @@ -361,6 +386,8 @@ MainWindow::~MainWindow() * \brief MainWindow::setupMainWindow * Setting up main window prefrences like frameless window and the minimum size of the window * Setting the window background color to be white + * 设置主窗口的偏好选项,如无边框窗口和窗口的最小大小 + * 设置窗口背景色为白色 */ void MainWindow::setupMainWindow() { @@ -676,6 +703,9 @@ void MainWindow::setupSplitter() * Make only the buttons icon visible * And install this class event filter to them, to act when hovering on one of them */ +/*! + * \brief 设置主窗口的按钮样式和功能 + */ void MainWindow::setupButtons() { QString ss = QStringLiteral("QPushButton { " @@ -752,7 +782,7 @@ void MainWindow::setupButtons() /*! * \brief MainWindow::setupSignalsSlots - * connect between signals and slots + * 连接信号和槽 */ void MainWindow::setupSignalsSlots() { @@ -941,9 +971,8 @@ void MainWindow::setupSignalsSlots() } /*! - * \brief MainWindow::autoCheckForUpdates - * Checks for updates, if an update is found, then the updater dialog will show - * up, otherwise, no notification shall be showed + * \brief 自动检查更新 + * 检查更新,如果找到更新,则显示更新对话框,否则不显示通知 */ #if defined(UPDATE_CHECKER) void MainWindow::autoCheckForUpdates() @@ -955,8 +984,8 @@ void MainWindow::autoCheckForUpdates() #endif /*! - * \brief MainWindow::setupSearchEdit - * Set the lineedit to start a bit to the right and end a bit to the left (pedding) + * \brief 设置搜索框属性 + * 设置输入框开始和结束的边距 */ void MainWindow::setupSearchEdit() { @@ -999,6 +1028,10 @@ void MainWindow::setupSearchEdit() m_searchEdit->installEventFilter(this); } +/*! + * \brief 设置订阅窗口 + * 注册订阅状态并加载订阅窗口 + */ void MainWindow::setupSubscrirptionWindow() { SubscriptionStatus::registerEnum("nuttyartist.notes", 1, 0); @@ -1026,6 +1059,10 @@ void MainWindow::setupSubscrirptionWindow() verifyLicenseSignalsSlots(); } +/*! + * \brief 设置编辑器设置 + * 注册编辑器相关选项 + */ void MainWindow::setupEditorSettings() { FontTypeface::registerEnum("nuttyartist.notes", 1, 0); @@ -1093,8 +1130,8 @@ void MainWindow::setupEditorSettings() } /*! - * \brief MainWindow::setCurrentFontBasedOnTypeface - * Set the current font based on a given typeface + * \brief 根据字体类型设置当前字体 + * 根据所选的字体类型设置当前字体 */ void MainWindow::setCurrentFontBasedOnTypeface(FontTypeface::Value selectedFontTypeFace) { @@ -1154,8 +1191,8 @@ void MainWindow::setCurrentFontBasedOnTypeface(FontTypeface::Value selectedFontT } /*! - * \brief MainWindow::resetEditorSettings - * Reset editor settings to default options + * \brief 重置编辑器设置 + * 将编辑器设置重置为默认选项 */ void MainWindow::resetEditorSettings() { @@ -1180,6 +1217,10 @@ void MainWindow::resetEditorSettings() setTheme(m_currentTheme); } +/*! + * \brief 设置文本编辑器样式表 + * 设置文本编辑器的左边距和右边距 + */ void MainWindow::setupTextEditStyleSheet(int paddingLeft, int paddingRight) { #if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0) @@ -1191,9 +1232,8 @@ void MainWindow::setupTextEditStyleSheet(int paddingLeft, int paddingRight) } /*! - * \brief MainWindow::alignTextEditText - * If textEdit's text can be contained (enough space for current chars limit per font) - * then, align textEdit's text to the center by padding textEdit's margins + * \brief 对齐文本编辑器文本 + * 如果文本可以被容纳,则将文本居中对齐 */ void MainWindow::alignTextEditText() { @@ -1230,11 +1270,8 @@ void MainWindow::alignTextEditText() } /*! - * \brief MainWindow::setupTextEdit - * Setting up textEdit: - * Setup the style of the scrollBar and set textEdit background to an image - * Make the textEdit pedding few pixels right and left, to compel with a beautiful proportional grid - * And install this class event filter to catch when text edit is having focus + * \brief 设置文本编辑器 + * 设置文本编辑器的样式和行为 */ void MainWindow::setupTextEdit() { @@ -1279,6 +1316,10 @@ void MainWindow::setupTextEdit() m_textEdit->setAcceptRichText(false); } +/*! + * \brief 设置看板视图 + * 使用 QQuickView 加载看板视图 + */ #if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0) void MainWindow::setupKanbanView() { @@ -1325,6 +1366,11 @@ void MainWindow::setupKanbanView() /*! * \brief MainWindow::initializeSettingsDatabase */ +/*! + * \brief 初始化设置数据库 + * 该函数用于初始化应用程序的设置数据库,包括应用程序版本、窗口几何形状 + * 和分隔器大小等设置。 + */ void MainWindow::initializeSettingsDatabase() { // Why are we not updating the app version in Settings? @@ -1354,7 +1400,8 @@ void MainWindow::initializeSettingsDatabase() } /*! - * \brief MainWindow::setActivationSuccessful + * \brief 设置激活成功状态 + * 该函数在许可证成功激活后调用,并更新相关状态和信息。 */ void MainWindow::setActivationSuccessful(QString licenseKey, bool removeGracePeriodStartedDate) { @@ -1367,7 +1414,8 @@ void MainWindow::setActivationSuccessful(QString licenseKey, bool removeGracePer } /*! - * \brief MainWindow::getPaymentDetails + * \brief 获取付款信息的信号和槽 + * 该函数用于处理获取付款信息的网络请求和响应。 */ void MainWindow::getPaymentDetailsSignalsSlots() { @@ -1393,7 +1441,8 @@ void MainWindow::getPaymentDetailsSignalsSlots() } /*! - * \brief MainWindow::getSubscriptionStatus + * \brief 获取订阅状态 + * 该函数用于检查用户的订阅状态,包括许可证的有效性和状态。 */ void MainWindow::getSubscriptionStatus() { @@ -1534,7 +1583,8 @@ void MainWindow::getSubscriptionStatus() } /*! - * \brief MainWindow::verifyLicenseSignalsSlots + * \brief 验证许可证的信号和槽 + * 该函数设置验证许可证过程中需要的信号和槽连接。 */ void MainWindow::verifyLicenseSignalsSlots() { @@ -1577,7 +1627,8 @@ void MainWindow::verifyLicenseSignalsSlots() } /*! - * \brief MainWindow::checkProVersion + * \brief 检查专业版状态 + * 该函数用于检查用户的专业版激活情况以及相关数据的获取。 */ void MainWindow::checkProVersion() { @@ -1616,19 +1667,27 @@ void MainWindow::checkProVersion() #endif } +/*! + * \brief 获取用户的许可证密钥 + * \return 用户许可证密钥的 QVariant 包装 + */ QVariant MainWindow::getUserLicenseKey() { return QVariant(m_userLicenseKey); } +/*! + * \brief 打开订阅窗口 + * 该函数用于显示订阅窗口供用户查看或处理订阅信息。 + */ void MainWindow::openSubscriptionWindow() { m_subscriptionWindow->show(); } /*! - * \brief MainWindow::setupDatabases - * Setting up the database: + * \brief 设置数据库 + * 初始化和设置数据库相关的配置及连接。 */ void MainWindow::setupDatabases() { @@ -1742,7 +1801,8 @@ void MainWindow::setupDatabases() } /*! - * \brief MainWindow::setupModelView + * \brief 设置模型视图 + * 该函数用于设置应用程序中的界面模型视图及其逻辑。 */ void MainWindow::setupModelView() { @@ -1771,9 +1831,8 @@ void MainWindow::setupModelView() } /*! - * \brief MainWindow::restoreStates - * Restore the latest states (if there are any) of the window and the splitter from - * the settings database + * \brief 恢复状态 + * 从设置数据库中恢复窗口和分隔器的最新状态(如果有)。 */ void MainWindow::restoreStates() { @@ -1955,8 +2014,9 @@ void MainWindow::restoreStates() } /*! - * \brief MainWindow::setButtonsAndFieldsEnabled - * \param doEnable + * \brief 设置按钮和字段的启用状态 + * \param doEnable 启用或禁用状态 + * 该函数用于根据提供的布尔值启用或禁用界面中的按钮和输入字段。 */ void MainWindow::setButtonsAndFieldsEnabled(bool doEnable) { @@ -1975,6 +2035,7 @@ void MainWindow::setButtonsAndFieldsEnabled(bool doEnable) * \param isVisible * Either shows or hide the kanban view based on isVisible */ +// MainWindow类实现了主要的窗口界面和相应的操作功能 void MainWindow::setKanbanVisibility(bool isVisible) { auto inf = m_listViewLogic->listViewInfo(); @@ -2000,6 +2061,7 @@ void MainWindow::setKanbanVisibility(bool isVisible) /*! * \brief MainWindow::setEditorSettingsFromQuickViewVisibility * \param isVisible + * 设置编辑器设置是否可见 */ void MainWindow::setEditorSettingsFromQuickViewVisibility(bool isVisible) { @@ -2009,6 +2071,7 @@ void MainWindow::setEditorSettingsFromQuickViewVisibility(bool isVisible) /*! * \brief MainWindow::setEditorSettingsScrollBarPosition * \param isVisible + * 设置编辑器设置滚动条的当前位置 */ void MainWindow::setEditorSettingsScrollBarPosition(double position) { @@ -2017,7 +2080,7 @@ void MainWindow::setEditorSettingsScrollBarPosition(double position) /*! * \brief MainWindow::toggleMarkdown - * Enable or disable markdown + * 使能或禁用Markdown */ void MainWindow::setMarkdownEnabled(bool isMarkdownEnabled) { @@ -2027,8 +2090,7 @@ void MainWindow::setMarkdownEnabled(bool isMarkdownEnabled) /*! * \brief MainWindow::resetBlockFormat - * Removes applied formmatting: bold, italic, strikethrough, heading of the current line - * or selected text (selected text has to include the formatting chars) + * 移除当前行或选定文本的应用格式:加粗、斜体、删除线、标题 */ void MainWindow::resetBlockFormat() { @@ -2047,7 +2109,7 @@ void MainWindow::resetBlockFormat() /*! * \brief MainWindow::resetFormat * \param formatChars - * Removes applied formmatting: bold, italic, strikethrough + * 移除当前选定文本的应用格式:加粗、斜体、删除线 */ void MainWindow::resetFormat(const QString &formatChars) { @@ -2090,7 +2152,7 @@ void MainWindow::resetFormat(const QString &formatChars) /*! * \brief MainWindow::onNewNoteButtonClicked - * Create a new note when clicking the 'new note' button + * 点击“新建笔记”按钮时创建一条新笔记 */ void MainWindow::onNewNoteButtonClicked() { @@ -2113,7 +2175,7 @@ void MainWindow::onNewNoteButtonClicked() /*! * \brief MainWindow::onDotsButtonClicked - * Open up the menu when clicking the 3 dots button + * 点击三个点按钮时打开菜单 */ void MainWindow::onDotsButtonClicked() { @@ -2122,6 +2184,7 @@ void MainWindow::onDotsButtonClicked() /*! * \brief MainWindow::onSwitchToKanbanViewButtonClicked + * 点击切换到看板视图按钮时调用 */ void MainWindow::onSwitchToKanbanViewButtonClicked() { @@ -2130,6 +2193,7 @@ void MainWindow::onSwitchToKanbanViewButtonClicked() /*! * \brief MainWindow::setupGlobalSettingsMenu + * 设置全局设置菜单 */ void MainWindow::setupGlobalSettingsMenu() { @@ -2253,7 +2317,7 @@ void MainWindow::setupGlobalSettingsMenu() /*! * \brief MainWindow::onGlobalSettingsButtonClicked - * Open up the menu when clicking the global settings button + * 点击全局设置按钮时打开菜单 */ void MainWindow::onGlobalSettingsButtonClicked() { @@ -2263,7 +2327,7 @@ void MainWindow::onGlobalSettingsButtonClicked() /*! * \brief MainWindow::showEditorSettings - * Shows the Editor Settings popup + * 显示编辑器设置弹窗 */ void MainWindow::showEditorSettings() { @@ -2281,7 +2345,7 @@ void MainWindow::showEditorSettings() /*! * \brief MainWindow::toggleEditorSettings - * Toggle the Editor Settings popup + * 切换编辑器设置弹窗的显示和隐藏 */ void MainWindow::toggleEditorSettings() { @@ -2294,6 +2358,7 @@ void MainWindow::toggleEditorSettings() /*! * \brief MainWindow::updateSelectedOptionsEditorSettings + * 更新当前选项的编辑器设置 */ void MainWindow::updateSelectedOptionsEditorSettings() { @@ -2313,7 +2378,7 @@ void MainWindow::updateSelectedOptionsEditorSettings() /*! * \brief MainWindow::changeEditorFontTypeFromStyleButtons - * Change the font based on the type passed from the Style Editor Window + * 根据从样式编辑器窗口传递的类型改变字体 */ void MainWindow::changeEditorFontTypeFromStyleButtons(FontTypeface::Value fontTypeface, int chosenFontIndex) @@ -2346,8 +2411,8 @@ void MainWindow::changeEditorFontTypeFromStyleButtons(FontTypeface::Value fontTy /*! * \brief MainWindow::changeEditorFontSizeFromStyleButtons - * Change the font size based on the button pressed in the Style Editor Window - * Increase / Decrease + * 根据样式编辑器窗口中按下的按钮改变字体大小 + * 增加/减少 */ void MainWindow::changeEditorFontSizeFromStyleButtons(FontSizeAction::Value fontSizeAction) { @@ -2366,8 +2431,8 @@ void MainWindow::changeEditorFontSizeFromStyleButtons(FontSizeAction::Value font /*! * \brief MainWindow::changeEditorTextWidthFromStyleButtons - * Change the text width of the text editor - * FullWidth / Increase / Decrease + * 改变文本编辑器的文本宽度 + * 全宽/增加/减少 */ void MainWindow::changeEditorTextWidthFromStyleButtons(EditorTextWidth::Value editorTextWidth) { @@ -2415,7 +2480,7 @@ void MainWindow::changeEditorTextWidthFromStyleButtons(EditorTextWidth::Value ed /*! * \brief MainWindow::setTheme - * Changes the app theme + * 更改应用程序主题 */ void MainWindow::setTheme(Theme::Value theme) { @@ -2484,8 +2549,7 @@ void MainWindow::deleteSelectedNote() /*! * \brief MainWindow::onClearButtonClicked - * clears the search and - * select the note that was selected before searching if it is still valid. + * 清除搜索并选择之前选中的笔记(如果仍然有效) */ void MainWindow::onClearButtonClicked() { @@ -2494,9 +2558,9 @@ void MainWindow::onClearButtonClicked() /*! * \brief MainWindow::createNewNote - * create a new note - * add it to the database - * add it to the scrollArea + * 创建一条新笔记 + * 添加到数据库 + * 添加到滚动区域 */ void MainWindow::createNewNote() { @@ -2558,7 +2622,7 @@ void MainWindow::selectNoteDown() /*! * \brief MainWindow::setFocusOnText - * Set focus on textEdit + * 设置焦点到文本编辑器 */ void MainWindow::setFocusOnText() { @@ -2576,7 +2640,7 @@ void MainWindow::selectNoteUp() /*! * \brief MainWindow::fullscreenWindow - * Switch to fullscreen mode + * 切换到全屏模式 */ void MainWindow::fullscreenWindow() { @@ -2624,9 +2688,8 @@ void MainWindow::makeStrikethrough() /*! * \brief MainWindow::applyFormat - * Make selected text bold, italic, or strikethrough it, by inserting the passed formatting char(s) - * before and after the selection. If nothing is selected, insert formatting char(s) before/after - * the word under the cursor + * 通过在选定内容前后插入传入的格式字符使选定文本加粗、斜体或删除线, + * 如果没有选定内容,则在光标下的单词前后插入格式字符 */ void MainWindow::applyFormat(const QString &formatChars) { @@ -2666,7 +2729,7 @@ void MainWindow::applyFormat(const QString &formatChars) /*! * \brief MainWindow::maximizeWindow - * Maximize the window + * 最大化窗口 */ void MainWindow::maximizeWindow() { @@ -2701,7 +2764,7 @@ void MainWindow::maximizeWindow() /*! * \brief MainWindow::minimizeWindow - * Minimize the window + * 最小化窗口 */ void MainWindow::minimizeWindow() { @@ -2716,9 +2779,9 @@ void MainWindow::minimizeWindow() /*! * \brief MainWindow::QuitApplication - * Exit the application - * Save the geometry of the app to the settings - * Save the current note if it's note temporary one otherwise remove it from DB + * 退出应用程序 + * 保存应用程序的几何形状到设置 + * 保存当前笔记(如果不是临时的),否则从数据库中移除 */ void MainWindow::QuitApplication() { @@ -2766,8 +2829,8 @@ void MainWindow::QuitApplication() /*! * \brief MainWindow::checkForUpdates - * Called when the "Check for Updates" menu item is clicked, this function - * instructs the updater window to check if there are any updates available + * 当点击“检查更新”菜单项时调用该函数, + * 指示更新程序窗口检查是否有可用的更新 */ #if defined(UPDATE_CHECKER) void MainWindow::checkForUpdates() @@ -2778,10 +2841,10 @@ void MainWindow::checkForUpdates() /*! * \brief MainWindow::importNotesFile - * Called when the "Import Notes" menu button is clicked. this function will - * prompt the user to select a file, attempt to load the file, and update the DB - * if valid. - * The user is presented with a dialog box if the upload/import fails for any reason. + * 当点击“导入笔记”菜单按钮时调用该函数。 + * 此函数将提示用户选择一个文件,尝试加载该文件, + * 如果有效则更新数据库。 + * 如果上传/导入因任何原因失败,则会向用户显示对话框。 */ void MainWindow::importNotesFile() { @@ -2790,10 +2853,10 @@ void MainWindow::importNotesFile() /*! * \brief MainWindow::restoreNotesFile - * Called when the "Restore Notes" menu button is clicked. this function will - * prompt the user to select a file, attempt to load the file, and update the DB - * if valid. - * The user is presented with a dialog box if the upload/import/restore fails for any reason. + * 当点击“还原笔记”菜单按钮时调用该函数。 + * 此函数将提示用户选择一个文件,尝试加载该文件, + * 如果有效则更新数据库。 + * 如果上传/导入/还原因任何原因失败,则会向用户显示对话框。 */ void MainWindow::restoreNotesFile() { @@ -2813,8 +2876,8 @@ void MainWindow::restoreNotesFile() /*! * \brief MainWindow::executeImport - * Executes the note import process. if replace is true all current notes will be - * removed otherwise current notes will be kept. + * 执行笔记导入过程。如果replace为true,将移除所有当前笔记, + * 否则将保留当前笔记。 * \param replace */ void MainWindow::executeImport(const bool replace) @@ -2844,10 +2907,9 @@ void MainWindow::executeImport(const bool replace) /*! * \brief MainWindow::exportNotesFile - * Called when the "Export Notes" menu button is clicked. this function will - * prompt the user to select a location for the export file, and then builds - * the file. - * The user is presented with a dialog box if the file cannot be opened for any reason. + * 当点击“导出笔记”菜单按钮时调用该函数。 + * 此函数将提示用户选择导出文件的位置,然后构建文件。 + * 如果无法打开文件,将向用户显示对话框。 * \param clicked */ void MainWindow::exportNotesFile() @@ -2895,7 +2957,9 @@ void MainWindow::collapseFolderTree() } #endif } - +/*! + * \brief 展开文件夹树视图 + */ void MainWindow::expandFolderTree() { m_toggleTreeViewButton->setText(u8"\uec73"); // keyboard_tab_rtl @@ -2913,6 +2977,9 @@ void MainWindow::expandFolderTree() #endif } +/*! + * \brief 切换笔记列表的显示状态 + */ void MainWindow::toggleNoteList() { if (m_noteListWidget->isHidden()) { @@ -2923,6 +2990,9 @@ void MainWindow::toggleNoteList() updateSelectedOptionsEditorSettings(); } +/*! + * \brief 收起笔记列表 + */ void MainWindow::collapseNoteList() { m_noteListWidget->setHidden(true); @@ -2930,6 +3000,9 @@ void MainWindow::collapseNoteList() updateSelectedOptionsEditorSettings(); } +/*! + * \brief 展开笔记列表 + */ void MainWindow::expandNoteList() { m_noteListWidget->setHidden(false); @@ -2938,8 +3011,7 @@ void MainWindow::expandNoteList() } /*! - * \brief MainWindow::onGreenMaximizeButtonPressed - * When the green button is pressed set it's icon accordingly + * \brief 当绿色最大化按钮被按下时,设置相应的图标 */ void MainWindow::onGreenMaximizeButtonPressed() { @@ -2954,8 +3026,7 @@ void MainWindow::onGreenMaximizeButtonPressed() } /*! - * \brief MainWindow::onYellowMinimizeButtonPressed - * When the yellow button is pressed set it's icon accordingly + * \brief 当黄色最小化按钮被按下时,设置相应的图标 */ void MainWindow::onYellowMinimizeButtonPressed() { @@ -2973,8 +3044,7 @@ void MainWindow::onYellowMinimizeButtonPressed() } /*! - * \brief MainWindow::onRedCloseButtonPressed - * When the red button is pressed set it's icon accordingly + * \brief 当红色关闭按钮被按下时,设置相应的图标 */ void MainWindow::onRedCloseButtonPressed() { @@ -2986,8 +3056,7 @@ void MainWindow::onRedCloseButtonPressed() } /*! - * \brief MainWindow::onGreenMaximizeButtonClicked - * When the green button is released the window goes fullscrren + * \brief 当绿色最大化按钮被释放时,窗口进入全屏 */ void MainWindow::onGreenMaximizeButtonClicked() { @@ -3004,8 +3073,7 @@ void MainWindow::onGreenMaximizeButtonClicked() } /*! - * \brief MainWindow::onYellowMinimizeButtonClicked - * When yellow button is released the window is minimized + * \brief 当黄色最小化按钮被释放时,窗口最小化 */ void MainWindow::onYellowMinimizeButtonClicked() { @@ -3026,9 +3094,8 @@ void MainWindow::onYellowMinimizeButtonClicked() } /*! - * \brief MainWindow::onRedCloseButtonClicked - * When red button is released the window get closed - * If a new note created but wasn't edited, delete it from the database + * \brief 当红色关闭按钮被释放时,窗口关闭 + * 如果新建的笔记尚未编辑,删除其数据库记录 */ void MainWindow::onRedCloseButtonClicked() { @@ -3046,8 +3113,8 @@ void MainWindow::onRedCloseButtonClicked() } /*! - * \brief MainWindow::closeEvent - * Called when the window is about to close + * \brief 窗口关闭事件 + * 被调用时,窗口即将关闭 * \param event */ void MainWindow::closeEvent(QCloseEvent *event) @@ -3067,7 +3134,7 @@ void MainWindow::closeEvent(QCloseEvent *event) } /*! - * \brief MainWindow::moveEvent + * \brief 移动事件 * \param event */ void MainWindow::moveEvent(QMoveEvent *event) @@ -3080,8 +3147,8 @@ void MainWindow::moveEvent(QMoveEvent *event) #ifndef _WIN32 /*! - * \brief MainWindow::mousePressEvent - * Set variables to the position of the window when the mouse is pressed + * \brief 鼠标按下事件 + * 当鼠标按下时设置窗口位置相关变量 * \param event */ void MainWindow::mousePressEvent(QMouseEvent *event) @@ -3141,8 +3208,8 @@ void MainWindow::mousePressEvent(QMouseEvent *event) } /*! - * \brief MainWindow::mouseMoveEvent - * Move the window according to the mouse positions + * \brief 鼠标移动事件 + * 根据鼠标位置移动窗口 * \param event */ void MainWindow::mouseMoveEvent(QMouseEvent *event) @@ -3319,8 +3386,8 @@ void MainWindow::mouseMoveEvent(QMouseEvent *event) } /*! - * \brief MainWindow::mouseReleaseEvent - * Initialize flags + * \brief 鼠标释放事件 + * 初始化标志位 * \param event */ void MainWindow::mouseReleaseEvent(QMouseEvent *event) @@ -3337,8 +3404,8 @@ void MainWindow::mouseReleaseEvent(QMouseEvent *event) } #else /*! - * \brief MainWindow::mousePressEvent - * Set variables to the position of the window when the mouse is pressed + * \brief 鼠标按下事件 + * 当鼠标按下时设置窗口位置相关变量 * \param event */ void MainWindow::mousePressEvent(QMouseEvent *event) @@ -3365,8 +3432,8 @@ void MainWindow::mousePressEvent(QMouseEvent *event) } /*! - * \brief MainWindow::mouseMoveEvent - * Move the window according to the mouse positions + * \brief 鼠标移动事件 + * 根据鼠标位置移动窗口 * \param event */ void MainWindow::mouseMoveEvent(QMouseEvent *event) @@ -3377,7 +3444,6 @@ void MainWindow::mouseMoveEvent(QMouseEvent *event) } if (m_canMoveWindow) { - // setCursor(Qt::ClosedHandCursor); int dx = event->globalPos().x() - m_mousePressX; int dy = event->globalY() - m_mousePressY; move(dx, dy); @@ -3385,8 +3451,8 @@ void MainWindow::mouseMoveEvent(QMouseEvent *event) } /*! - * \brief MainWindow::mouseReleaseEvent - * Initialize flags + * \brief 鼠标释放事件 + * 初始化标志位 * \param event */ void MainWindow::mouseReleaseEvent(QMouseEvent *event) @@ -3397,13 +3463,12 @@ void MainWindow::mouseReleaseEvent(QMouseEvent *event) } m_canMoveWindow = false; - // unsetCursor(); event->accept(); } #endif /*! - * \brief MainWindow::clearSearch + * \brief 清除搜索 */ void MainWindow::clearSearch() { @@ -3423,22 +3488,36 @@ void MainWindow::clearSearch() m_searchEdit->setFocus(); } +/*! + * \brief 显示错误信息 + * \param title + * \param content + */ void MainWindow::showErrorMessage(const QString &title, const QString &content) { QMessageBox::information(this, title, content); } +/*! + * \brief 设置笔记列表为加载中状态 + */ void MainWindow::setNoteListLoading() { ui->listviewLabel1->setText("Loading…"); ui->listviewLabel2->setText(""); } +/*! + * \brief 选择列表中的所有笔记 + */ void MainWindow::selectAllNotesInList() { m_listViewLogic->selectAllNotes(); } +/*! + * \brief 更新窗口框架 + */ void MainWindow::updateFrame() { if (m_foldersWidget->isHidden() && m_noteListWidget->isHidden()) { @@ -3449,7 +3528,7 @@ void MainWindow::updateFrame() } /*! - * \brief MainWindow::checkMigration + * \brief 检查迁移 */ void MainWindow::migrateFromV0_9_0() { @@ -3468,7 +3547,7 @@ void MainWindow::migrateFromV0_9_0() } /*! - * \brief MainWindow::migrateNote + * \brief 从旧版本迁移笔记 * \param notePath */ void MainWindow::migrateNoteFromV0_9_0(const QString ¬ePath) @@ -3507,7 +3586,7 @@ void MainWindow::migrateNoteFromV0_9_0(const QString ¬ePath) } /*! - * \brief MainWindow::migrateTrash + * \brief 从旧版本迁移垃圾箱 * \param trashPath */ void MainWindow::migrateTrashFromV0_9_0(const QString &trashPath) @@ -3546,7 +3625,7 @@ void MainWindow::migrateTrashFromV0_9_0(const QString &trashPath) } /*! - * \brief MainWindow::dropShadow + * \brief 添加阴影效果 * \param painter * \param type * \param side @@ -3635,7 +3714,7 @@ void MainWindow::dropShadow(QPainter &painter, ShadowType type, MainWindow::Shad } /*! - * \brief MainWindow::fillRectWithGradient + * \brief 使用渐变填充矩形 * \param painter * \param rect * \param gradient @@ -3658,7 +3737,7 @@ void MainWindow::fillRectWithGradient(QPainter &painter, QRect rect, QGradient & } /*! - * \brief MainWindow::gaussianDist + * \brief 高斯分布 * \param x * \param center * \param sigma @@ -3670,8 +3749,8 @@ double MainWindow::gaussianDist(double x, const double center, double sigma) con } /*! - * \brief MainWindow::mouseDoubleClickEvent - * When the blank area at the top of window is double-clicked the window get maximized + * \brief 鼠标双击事件 + * 当窗口顶部空白区域双击时窗口最大化 * \param event */ void MainWindow::mouseDoubleClickEvent(QMouseEvent *event) @@ -3691,7 +3770,7 @@ void MainWindow::mouseDoubleClickEvent(QMouseEvent *event) } /*! - * \brief MainWindow::leaveEvent + * \brief 离开事件 */ void MainWindow::leaveEvent(QEvent *) { @@ -3699,7 +3778,7 @@ void MainWindow::leaveEvent(QEvent *) } /*! - * \brief MainWindow::changeEvent + * \brief 窗口状态变化事件 */ void MainWindow::changeEvent(QEvent *event) { @@ -3715,8 +3794,9 @@ void MainWindow::changeEvent(QEvent *event) } /*! - * \brief MainWindow::setVisibilityOfFrameRightWidgets - * Either show or hide all widgets which are not m_textEdit + * \brief 设置右侧框架小部件的可见性 + * 选择性显示或隐藏除了 m_textEdit 之外的所有小部件 + * \param isVisible */ void MainWindow::setVisibilityOfFrameRightWidgets(bool isVisible) { @@ -3731,7 +3811,7 @@ void MainWindow::setVisibilityOfFrameRightWidgets(bool isVisible) m_switchToKanbanViewButton->setVisible(isVisible); #endif - // If the notes list is collapsed, hide the window buttons + // 如果笔记列表被折叠,则隐藏窗口按钮 if (m_splitter) { if (m_foldersWidget->isHidden() && m_noteListWidget->isHidden()) { setWindowButtonsVisible(false); @@ -3743,11 +3823,13 @@ void MainWindow::setVisibilityOfFrameRightWidgets(bool isVisible) * \brief MainWindow::setVisibilityOfFrameRightNonEditor * Either show or hide all widgets which are not m_textEdit */ +// 设置右侧非编辑框的可见性 void MainWindow::setVisibilityOfFrameRightNonEditor(bool isVisible) { ui->frameRightTop->setVisible(isVisible); } +// 设置窗口按钮的可见性 void MainWindow::setWindowButtonsVisible(bool isVisible) { #ifdef __APPLE__ @@ -3762,7 +3844,7 @@ void MainWindow::setWindowButtonsVisible(bool isVisible) /*! * \brief MainWindow::eventFilter - * Mostly take care on the event happened on widget whose filter installed to the mainwindow + * 处理在安装到主窗口的部件上发生的事件 * \param object * \param event * \return @@ -3793,8 +3875,7 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event) QIcon(QStringLiteral(":images/windows_minimize_hovered.png"))); } #else - // When hovering one of the traffic light buttons (red, yellow, green), - // set new icons to show their function + // 当鼠标悬停在红黄绿交通灯按钮时,设置新的图标以显示其功能 if (object == m_redCloseButton || object == m_yellowMinimizeButton || object == m_greenMaximizeButton) { @@ -3825,7 +3906,7 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event) } case QEvent::Leave: { if (qApp->applicationState() == Qt::ApplicationActive) { - // When not hovering, change back the icons of the traffic lights to their default icon + // 当鼠标不再悬停时,将交通灯图标更改为其默认图标 if (object == m_redCloseButton || object == m_yellowMinimizeButton || object == m_greenMaximizeButton) { @@ -3854,8 +3935,7 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event) case QEvent::ActivationChange: { if (m_editorSettingsWidget->isHidden()) { QApplication::setActiveWindow( - this); // TODO: The docs say this function is deprecated but it's the only one - // that works in returning the user input from m_editorSettingsWidget + this); // TODO: 文档说这个函数已被弃用但它是唯一可以返回用户输入的函数 // Qt::Popup m_textEdit->setFocus(); } @@ -3998,7 +4078,7 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event) setFocusOnText(); return true; } else if (keyEvent->key() == Qt::Key_Escape && isFullScreen()) { - // exit fullscreen + // 退出全屏 fullscreenWindow(); } break; @@ -4027,7 +4107,7 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event) /*! * \brief MainWindow::alreadyAppliedFormat * \param formatChars - * Checks whether the bold/italic/strikethrough formatting was already applied + * 检查粗体/斜体/删除线格式是否已经应用 */ bool MainWindow::alreadyAppliedFormat(const QString &formatChars) { @@ -4084,7 +4164,7 @@ void MainWindow::moveCurrentNoteToTrash() /*! * \brief MainWindow::increaseHeading - * Increase markdown heading level + * 增加 markdown 级别 */ void MainWindow::increaseHeading() { @@ -4099,7 +4179,7 @@ void MainWindow::increaseHeading() /*! * \brief MainWindow::decreaseHeading - * Decrease markdown heading level + * 减少 markdown 级别 */ void MainWindow::decreaseHeading() { @@ -4114,7 +4194,7 @@ void MainWindow::decreaseHeading() /*! * \brief MainWindow::setHeading - * Set markdown heading level + * 设置 markdown 级别 * \param level */ void MainWindow::setHeading(int level) @@ -4124,8 +4204,7 @@ void MainWindow::setHeading(int level) QString new_text = "\n"; if (cursor.hasSelection()) { QString selected_text = cursor.selectedText(); - if (selected_text.at(0).unicode() - != 8233) { // if it doesn't start with a paragraph delimiter (first line) + if (selected_text.at(0).unicode() != 8233) { // 如果不以段落分隔符开头(第一行) new_text.clear(); } selected_text = selected_text.trimmed().remove(QRegularExpression("^#*\\s?")); @@ -4150,7 +4229,7 @@ void MainWindow::setUseNativeWindowFrame(bool useNativeWindowFrame) m_redCloseButton->setVisible(!useNativeWindowFrame); m_yellowMinimizeButton->setVisible(!useNativeWindowFrame); - // Reset window flags to its initial state. + // 将窗口标志重置为其初始状态。 Qt::WindowFlags flags = Qt::Window; if (!useNativeWindowFrame) { @@ -4175,6 +4254,7 @@ void MainWindow::setUseNativeWindowFrame(bool useNativeWindowFrame) setMainWindowVisibility(true); } +// 设置是否隐藏到系统托盘 void MainWindow::setHideToTray(bool enabled) { m_hideToTray = enabled; @@ -4199,9 +4279,9 @@ void MainWindow::onSearchEditReturnPressed() QString searchText = m_searchEdit->text(); QTextDocument *doc = m_textEdit->document(); - // get current cursor + // 获取当前光标 QTextCursor from = m_textEdit->textCursor(); - // search + // 搜索 QTextCursor found = doc->find(searchText, from); m_textEdit->setTextCursor(found); } @@ -4219,12 +4299,13 @@ void MainWindow::setMargins(QMargins margins) m_trafficLightLayout.setGeometry(QRect(4 + margins.left(), 4 + margins.top(), 56, 16)); } +// 检查给定坐标是否在标题栏内 bool MainWindow::isTitleBar(int x, int y) const { if (m_useNativeWindowFrame) return false; - // The width of the title bar is essentially the width of the main window. + // 标题栏的宽度本质上是主窗口的宽度。 int titleBarWidth = width(); int titleBarHeight = ui->globalSettingsButton->height(); @@ -4239,4 +4320,4 @@ bool MainWindow::isTitleBar(int x, int y) const return (adjustedX >= 0 && adjustedX <= titleBarWidth && adjustedY >= 0 && adjustedY <= titleBarHeight); -} +} \ No newline at end of file diff --git a/source/src/mainwindow.h b/source/src/mainwindow.h old mode 100644 new mode 100755 index 4b40700..771dacf --- a/source/src/mainwindow.h +++ b/source/src/mainwindow.h @@ -6,7 +6,6 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H - #include #include #include @@ -52,12 +51,15 @@ #include "nodetreeview.h" #include "editorsettingsoptions.h" +// 定义订阅状态枚举 L_DECLARE_ENUM(SubscriptionStatus, NoSubscription, Active, ActivationLimitReached, Expired, Invalid, EnteredGracePeriod, GracePeriodOver, NoInternetConnection, UnknownError) namespace Ui { class MainWindow; } + +// 前向声明类 class TreeViewLogic; class ListViewLogic; class NoteEditorLogic; @@ -75,6 +77,8 @@ using MainWindowBase = CFramelessWindow; #else using MainWindowBase = QMainWindow; #endif + +// 主窗口类 class MainWindow : public MainWindowBase { Q_OBJECT @@ -109,129 +113,232 @@ public: Q_ENUM(ShadowSide) Q_ENUM(StretchSide) + // 构造函数 explicit MainWindow(QWidget *parent = nullptr); + // 析构函数 ~MainWindow() override; + // 设置主窗口可见性 void setMainWindowVisibility(bool state); public slots: + // 保存最近选择的文件夹标签 void saveLastSelectedFolderTags(bool isFolder, const QString &folderPath, const QSet &tagId); + // 保存展开的文件夹 void saveExpandedFolder(const QStringList &folderPaths); + // 保存最近选择的笔记 void saveLastSelectedNote(const QSet ¬esId); + // 从样式按钮改变编辑器字体类型 void changeEditorFontTypeFromStyleButtons(FontTypeface::Value fontType, int chosenFontIndex); + // 从样式按钮改变编辑器字体大小 void changeEditorFontSizeFromStyleButtons(FontSizeAction::Value fontSizeAction); + // 从样式按钮改变编辑器文本宽度 void changeEditorTextWidthFromStyleButtons(EditorTextWidth::Value editorTextWidth); + // 重置编辑器设置 void resetEditorSettings(); + // 设置主题 void setTheme(Theme::Value theme); + // 设置看板可见性 void setKanbanVisibility(bool isVisible); + // 折叠笔记列表 void collapseNoteList(); + // 展开笔记列表 void expandNoteList(); + // 折叠文件夹树 void collapseFolderTree(); + // 展开文件夹树 void expandFolderTree(); + // 设置Markdown启用状态 void setMarkdownEnabled(bool isMarkdownEnabled); + // 设置窗口置顶 void stayOnTop(bool checked); + // 将当前笔记移至回收站 void moveCurrentNoteToTrash(); + // 切换编辑器设置 void toggleEditorSettings(); + // 从快速视图设置编辑器设置可见性 void setEditorSettingsFromQuickViewVisibility(bool isVisible); + // 设置编辑器设置滚动条位置 void setEditorSettingsScrollBarPosition(double position); + // 设置激活成功的状态 void setActivationSuccessful(QString licenseKey, bool removeGracePeriodStartedDate = true); + // 检查专业版 void checkProVersion(); + // 获取用户许可密钥 QVariant getUserLicenseKey(); protected: + // 重新绘制事件 void paintEvent(QPaintEvent *event) override; + // 重新调整事件 void resizeEvent(QResizeEvent *event) override; + // 关闭事件 void closeEvent(QCloseEvent *event) override; + // 鼠标按下事件 void mousePressEvent(QMouseEvent *event) override; + // 鼠标移动事件 void mouseMoveEvent(QMouseEvent *event) override; + // 移动事件 void moveEvent(QMoveEvent *event) override; + // 鼠标释放事件 void mouseReleaseEvent(QMouseEvent *event) override; + // 鼠标双击事件 void mouseDoubleClickEvent(QMouseEvent *event) override; + // 离开事件 void leaveEvent(QEvent *) override; + // 变更事件 void changeEvent(QEvent *event) override; + // 事件过滤器 bool eventFilter(QObject *object, QEvent *event) override; private: + // UI界面指针 Ui::MainWindow *ui; + // 设置数据库指针 QSettings *m_settingsDatabase; + // 清除按钮 QToolButton *m_clearButton; + // 搜索按钮 QToolButton *m_searchButton; + // 绿色最大化按钮 QPushButton *m_greenMaximizeButton; + // 红色关闭按钮 QPushButton *m_redCloseButton; + // 黄色最小化按钮 QPushButton *m_yellowMinimizeButton; + // 交通灯布局 QHBoxLayout m_trafficLightLayout; + // 新笔记按钮 QPushButton *m_newNoteButton; + // 点点按钮 QPushButton *m_dotsButton; + // 全局设置按钮 QPushButton *m_globalSettingsButton; + // 切换树视图按钮 QPushButton *m_toggleTreeViewButton; + // 切换文本视图按钮 QPushButton *m_switchToTextViewButton; + // 切换看板视图按钮 QPushButton *m_switchToKanbanViewButton; + // 文本编辑器 CustomDocument *m_textEdit; + // 笔记编辑器逻辑 NoteEditorLogic *m_noteEditorLogic; + // 搜索框 QLineEdit *m_searchEdit; + // 编辑器日期标签 QLabel *m_editorDateLabel; + // 分割器 QSplitter *m_splitter; + // 笔记列表小部件 QWidget *m_noteListWidget; + // 文件夹小部件 QWidget *m_foldersWidget; + // 系统托盘图标 QSystemTrayIcon *m_trayIcon; #if !defined(Q_OS_MAC) + // 恢复动作 QAction *m_restoreAction; + // 退出动作 QAction *m_quitAction; #endif + // 笔记列表视图 NoteListView *m_listView; + // 笔记列表模型 NoteListModel *m_listModel; + // 列表视图逻辑 ListViewLogic *m_listViewLogic; + // 节点树视图 NodeTreeView *m_treeView; + // 节点树模型 NodeTreeModel *m_treeModel; + // 树视图逻辑 TreeViewLogic *m_treeViewLogic; #if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0) + // 看板快速视图 QQuickView m_kanbanQuickView; + // 看板小部件 QWidget *m_kanbanWidget; #endif + // 编辑器设置快速视图 QQuickView m_editorSettingsQuickView; + // 编辑器设置小部件 QWidget *m_editorSettingsWidget; + // 标签池 TagPool *m_tagPool; + // 数据库管理器 DBManager *m_dbManager; + // 数据库线程 QThread *m_dbThread; + // 分割器样式 SplitterStyle *m_splitterStyle; #if defined(UPDATE_CHECKER) + // 更新窗口 UpdaterWindow m_updater; #endif + // 关于窗口 AboutWindow m_aboutWindow; + // 拉伸边 StretchSide m_stretchSide; + // 自启动 Autostart m_autostart; + // 鼠标按下坐标 int m_mousePressX; int m_mousePressY; + // 回收站计数器 int m_trashCounter; + // 布局边距 int m_layoutMargin; + // 阴影宽度 int m_shadowWidth; + // 节点树宽度 int m_nodeTreeWidth; + // 小编辑器宽度 int m_smallEditorWidth; + // 大编辑器宽度 int m_largeEditorWidth; + // 能否移动窗口 bool m_canMoveWindow; + // 能否调整窗口大小 bool m_canStretchWindow; + // 临时标志 bool m_isTemp; + // 列表视图滚动条隐藏标志 bool m_isListViewScrollBarHidden; + // 操作运行标志 bool m_isOperationRunning; #if defined(UPDATE_CHECKER) + // 不显示更新窗口标志 bool m_dontShowUpdateWindow; #endif + // 始终置顶标志 bool m_alwaysStayOnTop; + // 使用本机窗口框架标志 bool m_useNativeWindowFrame; + // 隐藏到托盘标志 bool m_hideToTray; + // 样式表 QString m_styleSheet; + // Serif字体列表 QStringList m_listOfSerifFonts; + // Sans Serif字体列表 QStringList m_listOfSansSerifFonts; + // Mono字体列表 QStringList m_listOfMonoFonts; + // 选择的Serif字体索引 int m_chosenSerifFontIndex; + // 选择的Sans Serif字体索引 int m_chosenSansSerifFontIndex; + // 选择的Mono字体索引 int m_chosenMonoFontIndex; + // 编辑器中等字体大小 int m_editorMediumFontSize; + // 当前字体大小 int m_currentFontPointSize; struct m_charsLimitPerFont { @@ -239,166 +346,309 @@ private: int serif; int sansSerif; } m_currentCharsLimitPerFont; + // 当前字体类型 FontTypeface::Value m_currentFontTypeface; + // 当前字体家族 QString m_currentFontFamily; + // 当前选定字体 QFont m_currentSelectedFont; + // 显示字体 QString m_displayFont; + // 当前主题 Theme::Value m_currentTheme; + // 当前编辑器文本颜色 QColor m_currentEditorTextColor; + // 非编辑器小部件可见性标志 bool m_areNonEditorWidgetsVisible; #if !defined(Q_OS_MAC) + // 文本编辑滚动条定时器 QTimer *m_textEditScrollBarTimer; + // 文本编辑滚动条定时器持续时间 int m_textEditScrollBarTimerDuration; #endif + // 帧右上小部件可见性标志 bool m_isFrameRightTopWidgetsVisible; + // 从快速视图可见的编辑器设置标志 bool m_isEditorSettingsFromQuickViewVisible; + // 专业版激活标志 bool m_isProVersionActivated; + // 本地许可数据 QSettings *m_localLicenseData; + // 支付详情 QJsonObject m_paymentDetails; + // 订阅状态 SubscriptionStatus::Value m_subscriptionStatus; + // 订阅窗口快速视图 QQuickView m_subscriptionWindowQuickView; + // 订阅窗口小部件 QWidget *m_subscriptionWindowWidget; + // 订阅窗口引擎 QQmlApplicationEngine m_subscriptionWindowEngine; + // 订阅窗口 QWindow *m_subscriptionWindow; + // 购买数据备用1 QString m_purchaseDataAlt1; + // 购买数据备用2 QString m_purchaseDataAlt2; + // 数据缓冲区 QByteArray *m_dataBuffer; + // 网络访问管理器 QNetworkAccessManager *m_netManager; + // 备用请求1 QNetworkRequest m_reqAlt1; + // 备用请求2 QNetworkRequest m_reqAlt2; + // 第一次尝试的网络购买数据回复 QNetworkReply *m_netPurchaseDataReplyFirstAttempt; + // 第二次尝试的网络购买数据回复 QNetworkReply *m_netPurchaseDataReplySecondAttempt; + // 用户许可密钥 QString m_userLicenseKey; + // 主菜单 QMenu m_mainMenu; + // 购买或管理订阅动作 QAction *m_buyOrManageSubscriptionAction; + // 检查格式是否已应用 bool alreadyAppliedFormat(const QString &formatChars); + // 应用格式 void applyFormat(const QString &formatChars); + // 设置主窗口 void setupMainWindow(); + // 设置字体 void setupFonts(); + // 设置托盘图标 void setupTrayIcon(); + // 设置快捷键 void setupKeyboardShortcuts(); + // 设置分割器 void setupSplitter(); + // 设置按钮 void setupButtons(); + // 设置信号与槽 void setupSignalsSlots(); #if defined(UPDATE_CHECKER) + // 自动检查更新 void autoCheckForUpdates(); #endif + // 设置搜索框 void setupSearchEdit(); + // 设置订阅窗口 void setupSubscrirptionWindow(); - void setupEditorSettings(); + // 设置编辑器样式表 void setupTextEditStyleSheet(int paddingLeft, int paddingRight); + // 对齐文本编辑器文本 void alignTextEditText(); + // 设置文本编辑器 void setupTextEdit(); #if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0) + // 设置看板视图 void setupKanbanView(); #endif + // 设置数据库 void setupDatabases(); + // 设置模型视图 void setupModelView(); + // 设置全局设置菜单 void setupGlobalSettingsMenu(); + // 初始化设置数据库 void initializeSettingsDatabase(); + // 为滚动区域设置布局 void setLayoutForScrollArea(); + // 设置按钮和字段的启用状态 void setButtonsAndFieldsEnabled(bool doEnable); + // 重置格式 void resetFormat(const QString &formatChars); + // 恢复状态 void restoreStates(); + // 从版本0.9.0迁移 void migrateFromV0_9_0(); + // 执行导入 void executeImport(const bool replace); + // 从版本0.9.0迁移笔记 void migrateNoteFromV0_9_0(const QString ¬ePath); + // 从版本0.9.0迁移回收站 void migrateTrashFromV0_9_0(const QString &trashPath); + // 根据字体类型设置当前字体 void setCurrentFontBasedOnTypeface(FontTypeface::Value selectedFontTypeFace); + // 设置右侧小部件可见性 void setVisibilityOfFrameRightWidgets(bool isVisible); + // 设置非编辑器小部件可见性 void setVisibilityOfFrameRightNonEditor(bool isVisible); + // 设置窗口按钮可见性 void setWindowButtonsVisible(bool isVisible); + // 显示编辑器设置 void showEditorSettings(); + // 更新选定的编辑器设置选项 void updateSelectedOptionsEditorSettings(); + // 添加阴影 void dropShadow(QPainter &painter, ShadowType type, ShadowSide side); + // 使用渐变填充矩形 void fillRectWithGradient(QPainter &painter, QRect rect, QGradient &gradient); + // 高斯分布 double gaussianDist(double x, const double center, double sigma) const; + // 调整并定位编辑器设置窗口 void resizeAndPositionEditorSettingsWindow(); + // 获取支付详情信号与槽 void getPaymentDetailsSignalsSlots(); + // 验证许可证信号与槽 void verifyLicenseSignalsSlots(); + // 获取订阅状态 void getSubscriptionStatus(); + // 设置边距 void setMargins(QMargins margins); private slots: + // 初始化数据 void InitData(); + // 系统托盘图标激活 void onSystemTrayIconActivated(QSystemTrayIcon::ActivationReason reason); + // 新笔记按钮点击 void onNewNoteButtonClicked(); + // 点点按钮点击 void onDotsButtonClicked(); + // 切换到看板视图按钮点击 void onSwitchToKanbanViewButtonClicked(); + // 全局设置按钮点击 void onGlobalSettingsButtonClicked(); + // 清除按钮点击 void onClearButtonClicked(); + // 绿色最大化按钮按下 void onGreenMaximizeButtonPressed(); + // 黄色最小化按钮按下 void onYellowMinimizeButtonPressed(); + // 红色关闭按钮按下 void onRedCloseButtonPressed(); + // 绿色最大化按钮点击 void onGreenMaximizeButtonClicked(); + // 黄色最小化按钮点击 void onYellowMinimizeButtonClicked(); + // 红色关闭按钮点击 void onRedCloseButtonClicked(); + // 重置块格式 void resetBlockFormat(); + // 创建新笔记 void createNewNote(); + // 向下选择笔记 void selectNoteDown(); + // 向上选择笔记 void selectNoteUp(); + // 设置文本焦点 void setFocusOnText(); + // 全屏窗口 void fullscreenWindow(); + // 制作代码 void makeCode(); + // 制作粗体 void makeBold(); + // 制作斜体 void makeItalic(); + // 制作删除线 void makeStrikethrough(); + // 最大化窗口 void maximizeWindow(); + // 最小化窗口 void minimizeWindow(); + // 退出应用程序 void QuitApplication(); #if defined(UPDATE_CHECKER) + // 检查更新 void checkForUpdates(); #endif + // 切换笔记列表 void toggleNoteList(); + // 切换文件夹树 void toggleFolderTree(); + // 导入笔记文件 void importNotesFile(); + // 导出笔记文件 void exportNotesFile(); + // 恢复笔记文件 void restoreNotesFile(); + // 增加标题 void increaseHeading(); + // 减小标题 void decreaseHeading(); + // 设置标题 void setHeading(int level); + // 设置使用本机窗口框架 void setUseNativeWindowFrame(bool useNativeWindowFrame); + // 设置隐藏到托盘 void setHideToTray(bool enabled); + // 切换始终置顶 void toggleStayOnTop(); + // 搜索框回车按下 void onSearchEditReturnPressed(); + // 删除选中笔记 void deleteSelectedNote(); + // 清除搜索框 void clearSearch(); + // 显示错误信息 void showErrorMessage(const QString &title, const QString &content); + // 设置笔记列表加载状态 void setNoteListLoading(); + // 选择所有笔记 void selectAllNotesInList(); + // 更新框架 void updateFrame(); + // 检查是否是标题栏 bool isTitleBar(int x, int y) const; + // 打开订阅窗口 void openSubscriptionWindow(); signals: + // 请求节点树 void requestNodesTree(); + // 请求打开数据库管理器 void requestOpenDBManager(const QString &path, bool doCreate); + // 请求恢复笔记 void requestRestoreNotes(const QString &filePath); + // 请求导入笔记 void requestImportNotes(const QString &filePath); + // 请求导出笔记 void requestExportNotes(QString fileName); + // 请求从版本0.9.0迁移笔记 void requestMigrateNotesFromV0_9_0(QVector ¬eList); + // 请求从版本0.9.0迁移回收站 void requestMigrateTrashFromV0_9_0(QVector ¬eList); + // 请求从版本1.5.0迁移笔记 void requestMigrateNotesFromV1_5_0(const QString &path); + // 请求更改数据库路径 void requestChangeDatabasePath(const QString &newPath); + // 主题变化信号 void themeChanged(QVariant theme); + // 平台设置信号 void platformSet(QVariant platform); + // Qt版本设置信号 void qtVersionSet(QVariant qtVersion); + // 编辑器设置显示信号 void editorSettingsShowed(QVariant data); + // 主窗口大小改变信号 void mainWindowResized(QVariant data); + // 主窗口移动信号 void mainWindowMoved(QVariant data); + // 设置显示字体信号 void displayFontSet(QVariant data); + // 设置改变信号 void settingsChanged(QVariant data); + // 字体改变信号 void fontsChanged(QVariant data); + // 切换编辑器设置快捷键触发信号 void toggleEditorSettingsKeyboardShorcutFired(); + // 编辑器设置滚动条位置改变信号 void editorSettingsScrollBarPositionChanged(QVariant data); + // 专业版检查信号 void proVersionCheck(QVariant data); + // 尝试获取第二种购买数据 void tryPurchaseDataSecondAlternative(); + // 远程获取支付详情完成信号 void fetchingPaymentDetailsRemotelyFinished(); + // 获取支付详情完成信号 void gettingPaymentDetailsFinished(); + // 订阅状态改变信号 void subscriptionStatusChanged(QVariant subscriptionStatus); }; -#endif // MAINWINDOW_H +#endif // MAINWINDOW_H \ No newline at end of file