develop
kkk 3 months ago
parent c5d4a9b9d9
commit c34f275c6b

@ -3,6 +3,7 @@
#include <QBoxLayout> #include <QBoxLayout>
#include <QDebug> #include <QDebug>
// LabelEditType 类的构造函数
LabelEditType::LabelEditType(QWidget *parent) : QLabel(parent) LabelEditType::LabelEditType(QWidget *parent) : QLabel(parent)
{ {
setContentsMargins(0, 0, 0, 0); setContentsMargins(0, 0, 0, 0);
@ -15,6 +16,7 @@ LabelEditType::LabelEditType(QWidget *parent) : QLabel(parent)
connect(m_editor, &QLineEdit::editingFinished, this, &LabelEditType::onFinishedEdit); connect(m_editor, &QLineEdit::editingFinished, this, &LabelEditType::onFinishedEdit);
} }
// 打开编辑器
void LabelEditType::openEditor() void LabelEditType::openEditor()
{ {
m_editor->setText(text()); m_editor->setText(text());
@ -25,6 +27,7 @@ void LabelEditType::openEditor()
emit editingStarted(); emit editingStarted();
} }
// 编辑完成后的处理
void LabelEditType::onFinishedEdit() void LabelEditType::onFinishedEdit()
{ {
m_editor->hide(); m_editor->hide();

@ -3,24 +3,31 @@
#include <QLabel> #include <QLabel>
// 自定义LabelEditType类继承自QLabel
class QLineEdit; class QLineEdit;
class LabelEditType : public QLabel class LabelEditType : public QLabel
{ {
Q_OBJECT Q_OBJECT
public: public:
// 构造函数,接受一个父部件指针
explicit LabelEditType(QWidget *parent = nullptr); explicit LabelEditType(QWidget *parent = nullptr);
public slots: public slots:
// 打开编辑器的槽函数
void openEditor(); void openEditor();
private slots: private slots:
// 编辑完成后的槽函数
void onFinishedEdit(); void onFinishedEdit();
signals: signals:
// 编辑开始信号
void editingStarted(); void editingStarted();
// 编辑完成信号,携带编辑的文本
void editingFinished(const QString &text); void editingFinished(const QString &text);
private: private:
// 编辑器指针
QLineEdit *m_editor; QLineEdit *m_editor;
}; };

@ -10,6 +10,7 @@
#include "tagpool.h" #include "tagpool.h"
#include <QTimer> #include <QTimer>
// 检查当前笔记 ID 是否无效
static bool isInvalidCurrentNotesId(const QSet<int> &currentNotesId) static bool isInvalidCurrentNotesId(const QSet<int> &currentNotesId)
{ {
if (currentNotesId.isEmpty()) { if (currentNotesId.isEmpty()) {
@ -24,6 +25,7 @@ static bool isInvalidCurrentNotesId(const QSet<int> &currentNotesId)
return isInvalid; return isInvalid;
} }
// ListViewLogic 类的构造函数,负责初始化相关组件并设置信号与槽
ListViewLogic::ListViewLogic(NoteListView *noteView, NoteListModel *noteModel, ListViewLogic::ListViewLogic(NoteListView *noteView, NoteListModel *noteModel,
QLineEdit *searchEdit, QToolButton *clearButton, TagPool *tagPool, QLineEdit *searchEdit, QToolButton *clearButton, TagPool *tagPool,
DBManager *dbManager, QObject *parent) DBManager *dbManager, QObject *parent)
@ -125,6 +127,7 @@ ListViewLogic::ListViewLogic(NoteListView *noteView, NoteListModel *noteModel,
&ListViewLogic::onListViewClicked); &ListViewLogic::onListViewClicked);
} }
// 选择指定的笔记
void ListViewLogic::selectNote(const QModelIndex &noteIndex) void ListViewLogic::selectNote(const QModelIndex &noteIndex)
{ {
if (noteIndex.isValid()) { if (noteIndex.isValid()) {
@ -138,6 +141,7 @@ void ListViewLogic::selectNote(const QModelIndex &noteIndex)
} }
} }
// 将笔记移动到列表顶部
void ListViewLogic::moveNoteToTop(const NodeData &note) void ListViewLogic::moveNoteToTop(const NodeData &note)
{ {
QModelIndex noteIndex = m_listModel->getNoteIndex(note.id()); QModelIndex noteIndex = m_listModel->getNoteIndex(note.id());
@ -164,6 +168,7 @@ void ListViewLogic::moveNoteToTop(const NodeData &note)
} }
} }
// 设置笔记的数据
void ListViewLogic::setNoteData(const NodeData &note) void ListViewLogic::setNoteData(const NodeData &note)
{ {
QModelIndex noteIndex = m_listModel->getNoteIndex(note.id()); QModelIndex noteIndex = m_listModel->getNoteIndex(note.id());
@ -188,6 +193,7 @@ void ListViewLogic::setNoteData(const NodeData &note)
} }
} }
// 处理笔记编辑关闭事件
void ListViewLogic::onNoteEditClosed(const NodeData &note, bool selectNext) void ListViewLogic::onNoteEditClosed(const NodeData &note, bool selectNext)
{ {
if (note.isTempNote()) { if (note.isTempNote()) {
@ -209,12 +215,14 @@ void ListViewLogic::onNoteEditClosed(const NodeData &note, bool selectNext)
} }
} }
// 请求删除笔记
void ListViewLogic::deleteNoteRequested(const NodeData &note) void ListViewLogic::deleteNoteRequested(const NodeData &note)
{ {
auto index = m_listModel->getNoteIndex(note.id()); auto index = m_listModel->getNoteIndex(note.id());
deleteNoteRequestedI({ index }); deleteNoteRequestedI({ index });
} }
// 选择当前笔记的上一笔记
void ListViewLogic::selectNoteUp() void ListViewLogic::selectNoteUp()
{ {
auto currentIndex = m_listView->currentIndex(); auto currentIndex = m_listView->currentIndex();
@ -235,6 +243,7 @@ void ListViewLogic::selectNoteUp()
} }
} }
// 选择当前笔记的下一笔记
void ListViewLogic::selectNoteDown() void ListViewLogic::selectNoteDown()
{ {
auto currentIndex = m_listView->currentIndex(); auto currentIndex = m_listView->currentIndex();
@ -259,15 +268,14 @@ void ListViewLogic::selectNoteDown()
/*! /*!
* \brief ListViewLogic::onSearchEditTextChanged * \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 * \param keyword
*/ */
void ListViewLogic::onSearchEditTextChanged(const QString &keyword) void ListViewLogic::onSearchEditTextChanged(const QString &keyword)
{ {
if (keyword.isEmpty()) { if (keyword.isEmpty()) {
@ -287,6 +295,7 @@ void ListViewLogic::onSearchEditTextChanged(const QString &keyword)
} }
} }
// 清除搜索
void ListViewLogic::clearSearch(bool createNewNote, int scrollToId) void ListViewLogic::clearSearch(bool createNewNote, int scrollToId)
{ {
m_listViewInfo.needCreateNewNote = createNewNote; m_listViewInfo.needCreateNewNote = createNewNote;
@ -295,6 +304,7 @@ void ListViewLogic::clearSearch(bool createNewNote, int scrollToId)
emit requestClearSearchUI(); emit requestClearSearchUI();
} }
// 加载笔记列表模型
void ListViewLogic::loadNoteListModel(const QVector<NodeData> &noteList, const ListViewInfo &inf) void ListViewLogic::loadNoteListModel(const QVector<NodeData> &noteList, const ListViewInfo &inf)
{ {
auto currentNotesId = m_listViewInfo.currentNotesId; auto currentNotesId = m_listViewInfo.currentNotesId;
@ -363,6 +373,7 @@ void ListViewLogic::loadNoteListModel(const QVector<NodeData> &noteList, const L
selectFirstNote(); selectFirstNote();
} }
// 添加标签请求处理
void ListViewLogic::onAddTagRequest(const QModelIndex &index, int tagId) void ListViewLogic::onAddTagRequest(const QModelIndex &index, int tagId)
{ {
if (index.isValid()) { if (index.isValid()) {
@ -382,12 +393,14 @@ void ListViewLogic::onAddTagRequest(const QModelIndex &index, int tagId)
} }
} }
// 直接请求添加标签
void ListViewLogic::onAddTagRequestD(int noteId, int tagId) void ListViewLogic::onAddTagRequestD(int noteId, int tagId)
{ {
auto index = m_listModel->getNoteIndex(noteId); auto index = m_listModel->getNoteIndex(noteId);
onAddTagRequest(index, tagId); onAddTagRequest(index, tagId);
} }
// 笔记移动到其他区域的处理
void ListViewLogic::onNoteMovedOut(int nodeId, int targetId) void ListViewLogic::onNoteMovedOut(int nodeId, int targetId)
{ {
auto index = m_listModel->getNoteIndex(nodeId); auto index = m_listModel->getNoteIndex(nodeId);
@ -415,6 +428,7 @@ void ListViewLogic::onNoteMovedOut(int nodeId, int targetId)
} }
} }
// 设置最后选择的笔记
void ListViewLogic::setLastSelectedNote() void ListViewLogic::setLastSelectedNote()
{ {
auto indexes = m_listView->selectedIndex(); auto indexes = m_listView->selectedIndex();
@ -427,11 +441,13 @@ void ListViewLogic::setLastSelectedNote()
setLastSavedState(ids, 0); setLastSavedState(ids, 0);
} }
// 请求加载最后选择的笔记
void ListViewLogic::loadLastSelectedNoteRequested() void ListViewLogic::loadLastSelectedNoteRequested()
{ {
requestLoadSavedState(2); requestLoadSavedState(2);
} }
// 处理文件夹中的笔记列表请求
void ListViewLogic::onNotesListInFolderRequested(int parentID, bool isRecursive, bool newNote, void ListViewLogic::onNotesListInFolderRequested(int parentID, bool isRecursive, bool newNote,
int scrollToId) int scrollToId)
{ {
@ -449,6 +465,7 @@ void ListViewLogic::onNotesListInFolderRequested(int parentID, bool isRecursive,
} }
} }
// 处理标签中的笔记列表请求
void ListViewLogic::onNotesListInTagsRequested(const QSet<int> &tagIds, bool newNote, void ListViewLogic::onNotesListInTagsRequested(const QSet<int> &tagIds, bool newNote,
int scrollToId) int scrollToId)
{ {
@ -465,6 +482,7 @@ void ListViewLogic::onNotesListInTagsRequested(const QSet<int> &tagIds, bool new
} }
} }
// 选择多个笔记
void ListViewLogic::selectNotes(const QModelIndexList &indexes) void ListViewLogic::selectNotes(const QModelIndexList &indexes)
{ {
m_listView->clearSelection(); m_listView->clearSelection();
@ -482,6 +500,7 @@ void ListViewLogic::selectNotes(const QModelIndexList &indexes)
onNotePressed(indexes); onNotePressed(indexes);
} }
// 处理移除标签请求
void ListViewLogic::onRemoveTagRequest(const QModelIndex &index, int tagId) void ListViewLogic::onRemoveTagRequest(const QModelIndex &index, int tagId)
{ {
if (index.isValid()) { if (index.isValid()) {
@ -503,14 +522,13 @@ void ListViewLogic::onRemoveTagRequest(const QModelIndex &index, int tagId)
/*! /*!
* \brief MainWindow::onNotePressed * \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 * \param index
*/ */
void ListViewLogic::onNotePressed(const QModelIndexList &indexes) void ListViewLogic::onNotePressed(const QModelIndexList &indexes)
{ {
QVector<NodeData> notes; QVector<NodeData> notes;
@ -527,6 +545,7 @@ void ListViewLogic::onNotePressed(const QModelIndexList &indexes)
m_listView->setCurrentRowActive(false); m_listView->setCurrentRowActive(false);
} }
// 删除笔记请求的内部处理
void ListViewLogic::deleteNoteRequestedI(const QModelIndexList &indexes) void ListViewLogic::deleteNoteRequestedI(const QModelIndexList &indexes)
{ {
if (!indexes.empty()) { if (!indexes.empty()) {
@ -582,6 +601,7 @@ void ListViewLogic::deleteNoteRequestedI(const QModelIndexList &indexes)
} }
} }
// 请求恢复笔记的内部处理
void ListViewLogic::restoreNotesRequestedI(const QModelIndexList &indexes) void ListViewLogic::restoreNotesRequestedI(const QModelIndexList &indexes)
{ {
QModelIndexList needRestoredI; QModelIndexList needRestoredI;
@ -617,6 +637,7 @@ void ListViewLogic::restoreNotesRequestedI(const QModelIndexList &indexes)
} }
} }
// 更新列表视图的标签
void ListViewLogic::updateListViewLabel() void ListViewLogic::updateListViewLabel()
{ {
QString l1, l2; QString l1, l2;
@ -650,6 +671,7 @@ void ListViewLogic::updateListViewLabel()
emit listViewLabelChanged(l1, l2); emit listViewLabelChanged(l1, l2);
} }
// 行数变化的处理
void ListViewLogic::onRowCountChanged() void ListViewLogic::onRowCountChanged()
{ {
m_listView->closeAllEditor(); m_listView->closeAllEditor();
@ -667,6 +689,7 @@ void ListViewLogic::onRowCountChanged()
} }
} }
// 双击笔记的处理
void ListViewLogic::onNoteDoubleClicked(const QModelIndex &index) void ListViewLogic::onNoteDoubleClicked(const QModelIndex &index)
{ {
if (!index.isValid() || !m_listViewInfo.isInSearch) { if (!index.isValid() || !m_listViewInfo.isInSearch) {
@ -676,11 +699,13 @@ void ListViewLogic::onNoteDoubleClicked(const QModelIndex &index)
clearSearch(false, id); clearSearch(false, id);
} }
// 请求设置笔记为置顶的处理
void ListViewLogic::onSetPinnedNoteRequested(const QModelIndexList &indexes, bool isPinned) void ListViewLogic::onSetPinnedNoteRequested(const QModelIndexList &indexes, bool isPinned)
{ {
m_listModel->setNotesIsPinned(indexes, isPinned); m_listModel->setNotesIsPinned(indexes, isPinned);
} }
// 列表视图点击的处理
void ListViewLogic::onListViewClicked() void ListViewLogic::onListViewClicked()
{ {
if (m_listModel->rowCount() > 1) { if (m_listModel->rowCount() > 1) {
@ -700,6 +725,7 @@ void ListViewLogic::onListViewClicked()
} }
} }
// 选择第一笔记
void ListViewLogic::selectFirstNote() void ListViewLogic::selectFirstNote()
{ {
if (m_listModel->rowCount() > 0) { if (m_listModel->rowCount() > 0) {
@ -714,6 +740,7 @@ void ListViewLogic::selectFirstNote()
} }
} }
// 设置主题
void ListViewLogic::setTheme(Theme::Value theme) void ListViewLogic::setTheme(Theme::Value theme)
{ {
m_listView->setTheme(theme); m_listView->setTheme(theme);
@ -721,22 +748,26 @@ void ListViewLogic::setTheme(Theme::Value theme)
m_listView->update(); m_listView->update();
} }
// 检查动画是否正在运行
bool ListViewLogic::isAnimationRunning() bool ListViewLogic::isAnimationRunning()
{ {
return m_listDelegate->animationState() == QTimeLine::Running; return m_listDelegate->animationState() == QTimeLine::Running;
} }
// 设置最后保存的状态
void ListViewLogic::setLastSavedState(const QSet<int> &lastSelectedNotes, int needLoadSavedState) void ListViewLogic::setLastSavedState(const QSet<int> &lastSelectedNotes, int needLoadSavedState)
{ {
m_needLoadSavedState = needLoadSavedState; m_needLoadSavedState = needLoadSavedState;
m_lastSelectedNotes = lastSelectedNotes; m_lastSelectedNotes = lastSelectedNotes;
} }
// 请求加载保存的状态
void ListViewLogic::requestLoadSavedState(int needLoadSavedState) void ListViewLogic::requestLoadSavedState(int needLoadSavedState)
{ {
m_needLoadSavedState = needLoadSavedState; m_needLoadSavedState = needLoadSavedState;
} }
// 选择所有笔记
void ListViewLogic::selectAllNotes() void ListViewLogic::selectAllNotes()
{ {
if (m_listModel->rowCount() > 50) { if (m_listModel->rowCount() > 50) {
@ -771,6 +802,7 @@ void ListViewLogic::selectAllNotes()
onNotePressed(m_listView->selectedIndex()); onNotePressed(m_listView->selectedIndex());
} }
// 获取当前视图信息
const ListViewInfo &ListViewLogic::listViewInfo() const const ListViewInfo &ListViewLogic::listViewInfo() const
{ {
return m_listViewInfo; return m_listViewInfo;

@ -16,83 +16,136 @@ class QLineEdit;
class QToolButton; class QToolButton;
class TagPool; class TagPool;
// 负责笔记列表视图逻辑的类
class ListViewLogic : public QObject class ListViewLogic : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
// 构造函数,初始化笔记视图、笔记模型、搜索框等
explicit ListViewLogic(NoteListView *noteView, NoteListModel *noteModel, QLineEdit *searchEdit, explicit ListViewLogic(NoteListView *noteView, NoteListModel *noteModel, QLineEdit *searchEdit,
QToolButton *clearButton, TagPool *tagPool, DBManager *dbManager, QToolButton *clearButton, TagPool *tagPool, DBManager *dbManager,
QObject *parent = nullptr); QObject *parent = nullptr);
// 选择指定索引的笔记
void selectNote(const QModelIndex &noteIndex); void selectNote(const QModelIndex &noteIndex);
// 获取当前列表视图的信息
const ListViewInfo &listViewInfo() const; const ListViewInfo &listViewInfo() const;
// 选择第一个笔记
void selectFirstNote(); void selectFirstNote();
// 设置主题
void setTheme(Theme::Value theme); void setTheme(Theme::Value theme);
// 检查动画是否正在运行
bool isAnimationRunning(); bool isAnimationRunning();
// 设置最后保存的状态
void setLastSavedState(const QSet<int> &lastSelectedNotes, int needLoadSavedState = 2); void setLastSavedState(const QSet<int> &lastSelectedNotes, int needLoadSavedState = 2);
// 请求加载保存的状态
void requestLoadSavedState(int needLoadSavedState); void requestLoadSavedState(int needLoadSavedState);
// 选择所有笔记
void selectAllNotes(); void selectAllNotes();
public slots: public slots:
// 将笔记移动到顶部
void moveNoteToTop(const NodeData &note); void moveNoteToTop(const NodeData &note);
// 设置笔记数据
void setNoteData(const NodeData &note); void setNoteData(const NodeData &note);
// 笔记编辑关闭后的处理
void onNoteEditClosed(const NodeData &note, bool selectNext); void onNoteEditClosed(const NodeData &note, bool selectNext);
// 请求删除笔记
void deleteNoteRequested(const NodeData &note); void deleteNoteRequested(const NodeData &note);
// 选择上一个笔记
void selectNoteUp(); void selectNoteUp();
// 选择下一个笔记
void selectNoteDown(); void selectNoteDown();
// 搜索框文本改变的处理
void onSearchEditTextChanged(const QString &keyword); void onSearchEditTextChanged(const QString &keyword);
// 清除搜索
void clearSearch(bool createNewNote = false, int scrollToId = SpecialNodeID::InvalidNodeId); void clearSearch(bool createNewNote = false, int scrollToId = SpecialNodeID::InvalidNodeId);
// 添加标签请求的处理
void onAddTagRequestD(int noteId, int tagId); void onAddTagRequestD(int noteId, int tagId);
// 笔记移动事件处理
void onNoteMovedOut(int nodeId, int targetId); void onNoteMovedOut(int nodeId, int targetId);
// 设置最后选择的笔记
void setLastSelectedNote(); void setLastSelectedNote();
// 请求加载最后选择的笔记
void loadLastSelectedNoteRequested(); void loadLastSelectedNoteRequested();
// 请求在文件夹中获取笔记列表
void onNotesListInFolderRequested(int parentID, bool isRecursive, bool newNote, int scrollToId); void onNotesListInFolderRequested(int parentID, bool isRecursive, bool newNote, int scrollToId);
// 请求通过标签获取笔记列表
void onNotesListInTagsRequested(const QSet<int> &tagIds, bool newNote, int scrollToId); void onNotesListInTagsRequested(const QSet<int> &tagIds, bool newNote, int scrollToId);
// 选择笔记
void selectNotes(const QModelIndexList &indexes); void selectNotes(const QModelIndexList &indexes);
signals: signals:
// 显示笔记在编辑器中的信号
void showNotesInEditor(const QVector<NodeData> &notesData); void showNotesInEditor(const QVector<NodeData> &notesData);
// 请求添加标签到数据库的信号
void requestAddTagDb(int noteId, int tagId); void requestAddTagDb(int noteId, int tagId);
// 请求从数据库中移除标签的信号
void requestRemoveTagDb(int noteId, int tagId); void requestRemoveTagDb(int noteId, int tagId);
// 请求从数据库中移除笔记的信号
void requestRemoveNoteDb(const NodeData &noteData); void requestRemoveNoteDb(const NodeData &noteData);
// 请求将笔记移动到数据库的信号
void requestMoveNoteDb(int noteId, const NodeData &targetFolder); void requestMoveNoteDb(int noteId, const NodeData &targetFolder);
// 请求高亮搜索的信号
void requestHighlightSearch(); void requestHighlightSearch();
// 关闭笔记编辑器的信号
void closeNoteEditor(); void closeNoteEditor();
// 笔记标签列表更改的信号
void noteTagListChanged(int noteId, const QSet<int> &tagIds); void noteTagListChanged(int noteId, const QSet<int> &tagIds);
// 请求在数据库中搜索的信号
void requestSearchInDb(const QString &keyword, const ListViewInfo &inf); void requestSearchInDb(const QString &keyword, const ListViewInfo &inf);
// 请求清除数据库中的搜索的信号
void requestClearSearchDb(const ListViewInfo &inf); void requestClearSearchDb(const ListViewInfo &inf);
// 请求清除UI中的搜索的信号
void requestClearSearchUI(); void requestClearSearchUI();
// 请求新笔记的信号
void requestNewNote(); void requestNewNote();
// 请求移动笔记的信号
void moveNoteRequested(int id, int target); void moveNoteRequested(int id, int target);
// 列表视图标签改变的信号
void listViewLabelChanged(const QString &label1, const QString &label2); void listViewLabelChanged(const QString &label1, const QString &label2);
// 设置新笔记按钮可见性的信号
void setNewNoteButtonVisible(bool visible); void setNewNoteButtonVisible(bool visible);
// 请求在文件夹中获取笔记列表的信号
void requestNotesListInFolder(int parentID, bool isRecursive, bool newNote, int scrollToId); void requestNotesListInFolder(int parentID, bool isRecursive, bool newNote, int scrollToId);
// 请求通过标签获取笔记列表的信号
void requestNotesListInTags(const QSet<int> &tagIds, bool newNote, int scrollToId); void requestNotesListInTags(const QSet<int> &tagIds, bool newNote, int scrollToId);
private slots: private slots:
// 加载笔记列表模型
void loadNoteListModel(const QVector<NodeData> &noteList, const ListViewInfo &inf); void loadNoteListModel(const QVector<NodeData> &noteList, const ListViewInfo &inf);
// 处理添加标签请求
void onAddTagRequest(const QModelIndex &index, int tagId); void onAddTagRequest(const QModelIndex &index, int tagId);
// 处理移除标签请求
void onRemoveTagRequest(const QModelIndex &index, int tagId); void onRemoveTagRequest(const QModelIndex &index, int tagId);
// 处理笔记按下事件
void onNotePressed(const QModelIndexList &indexes); void onNotePressed(const QModelIndexList &indexes);
// 请求删除笔记的处理
void deleteNoteRequestedI(const QModelIndexList &indexes); void deleteNoteRequestedI(const QModelIndexList &indexes);
// 请求恢复笔记的处理
void restoreNotesRequestedI(const QModelIndexList &indexes); void restoreNotesRequestedI(const QModelIndexList &indexes);
// 更新列表视图标签
void updateListViewLabel(); void updateListViewLabel();
// 行数改变的处理
void onRowCountChanged(); void onRowCountChanged();
// 处理双击笔记事件
void onNoteDoubleClicked(const QModelIndex &index); void onNoteDoubleClicked(const QModelIndex &index);
// 请求设置固定笔记的处理
void onSetPinnedNoteRequested(const QModelIndexList &indexes, bool isPinned); void onSetPinnedNoteRequested(const QModelIndexList &indexes, bool isPinned);
// 处理列表视图点击事件
void onListViewClicked(); void onListViewClicked();
private: private:
NoteListView *m_listView; NoteListView *m_listView; // 笔记列表视图
NoteListModel *m_listModel; NoteListModel *m_listModel; // 笔记列表模型
QLineEdit *m_searchEdit; QLineEdit *m_searchEdit; // 搜索框
QToolButton *m_clearButton; QToolButton *m_clearButton; // 清除按钮
DBManager *m_dbManager; DBManager *m_dbManager; // 数据库管理器
NoteListDelegate *m_listDelegate; NoteListDelegate *m_listDelegate; // 笔记列表委托
TagPool *m_tagPool; TagPool *m_tagPool; // 标签池
ListViewInfo m_listViewInfo; ListViewInfo m_listViewInfo; // 列表视图信息
QVector<QModelIndex> m_editorIndexes; QVector<QModelIndex> m_editorIndexes; // 编辑器索引
int m_needLoadSavedState; int m_needLoadSavedState; // 需要加载的保存状态
QSet<int> m_lastSelectedNotes; QSet<int> m_lastSelectedNotes; // 最后选择的笔记集合
}; };
#endif // LISTVIEWLOGIC_H #endif // LISTVIEWLOGIC_H

@ -23,32 +23,33 @@
**/ **/
// Credit: https://github.com/carlonluca/lqtutils // Credit: https://github.com/carlonluca/lqtutils
#ifndef LQTUTILS_ENUM_H #ifndef LQTUTILS_ENUM_H
#define LQTUTILS_ENUM_H #define LQTUTILS_ENUM_H
#include <QObject> #include <QObject>
#include <QQmlEngine> #include <QQmlEngine>
// 宏定义 L_DECLARE_ENUM 用于声明枚举类型及其相关函数
#define L_DECLARE_ENUM(enumName, ...) \ #define L_DECLARE_ENUM(enumName, ...) \
namespace enumName { \ namespace enumName { \
Q_NAMESPACE \ Q_NAMESPACE \
enum Value { __VA_ARGS__ }; \ enum Value { __VA_ARGS__ }; \
Q_ENUM_NS(Value) \ Q_ENUM_NS(Value) \
inline int qmlRegister##enumName(const char *uri, int major, int minor) \ // 注册 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"); \ return qmlRegisterUncreatableMetaObject(enumName::staticMetaObject, uri, major, minor,
} \ #enumName, "Access to enums & flags only");
inline int qRegisterMetaType() \ } // 注册元类型
{ \ inline int qRegisterMetaType()
return ::qRegisterMetaType<enumName::Value>(#enumName); \ {
} \ return ::qRegisterMetaType<enumName::Value>(#enumName);
inline void registerEnum(const char *uri, int major, int minor) \ } // 注册枚举类型
{ \ inline void registerEnum(const char *uri, int major, int minor)
enumName::qmlRegister##enumName(uri, major, minor); \ {
enumName::qRegisterMetaType(); \ enumName::qmlRegister##enumName(uri, major, minor);
} \ enumName::qRegisterMetaType();
} }
}
#endif // LQTUTILS_ENUM_H #endif // LQTUTILS_ENUM_H

@ -3,16 +3,11 @@
* Just a meantime project to see the ability of qt, the framework that my OS might be based on * 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 * And for those linux users that believe in the power of notes
*********************************************************************************************/ *********************************************************************************************/
// 主函数,程序入口
#include "mainwindow.h"
#include "singleinstance.h"
#include <QApplication>
#include <QFontDatabase>
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QApplication app(argc, argv); QApplication app(argc, argv);
// Set application information // 设置应用程序信息
app.setApplicationName("Notes"); app.setApplicationName("Notes");
app.setApplicationVersion(APP_VERSION); app.setApplicationVersion(APP_VERSION);
@ -24,6 +19,7 @@ int main(int argc, char *argv[])
app.setAttribute(Qt::AA_DisableWindowContextHelpButton); app.setAttribute(Qt::AA_DisableWindowContextHelpButton);
#endif #endif
// 尝试加载字体并报告错误
if (QFontDatabase::addApplicationFont(":/fonts/fontawesome/fa-solid-900.ttf") < 0) if (QFontDatabase::addApplicationFont(":/fonts/fontawesome/fa-solid-900.ttf") < 0)
qWarning() << "FontAwesome Solid cannot be loaded !"; 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) if (QFontDatabase::addApplicationFont(":/fonts/material/material-symbols-outlined.ttf") < 0)
qWarning() << "Material Symbols cannot be loaded !"; qWarning() << "Material Symbols cannot be loaded !";
// Load fonts from resources // 从资源加载字体
// Roboto // Roboto
QFontDatabase::addApplicationFont(":/fonts/roboto-hinted/Roboto-Bold.ttf"); QFontDatabase::addApplicationFont(":/fonts/roboto-hinted/Roboto-Bold.ttf");
QFontDatabase::addApplicationFont(":/fonts/roboto-hinted/Roboto-Medium.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-SemiBold.ttf");
QFontDatabase::addApplicationFont(":/fonts/sourcesanspro/SourceSansPro-SemiBoldItalic.ttf"); QFontDatabase::addApplicationFont(":/fonts/sourcesanspro/SourceSansPro-SemiBoldItalic.ttf");
// Trykker // Trykker 字体
QFontDatabase::addApplicationFont(":/fonts/trykker/Trykker-Regular.ttf"); QFontDatabase::addApplicationFont(":/fonts/trykker/Trykker-Regular.ttf");
// Mate // Mate 字体
QFontDatabase::addApplicationFont(":/fonts/mate/Mate-Regular.ttf"); QFontDatabase::addApplicationFont(":/fonts/mate/Mate-Regular.ttf");
QFontDatabase::addApplicationFont(":/fonts/mate/Mate-Italic.ttf"); QFontDatabase::addApplicationFont(":/fonts/mate/Mate-Italic.ttf");
// PT Serif // PT Serif 字体
QFontDatabase::addApplicationFont(":/fonts/ptserif/PTSerif-Regular.ttf"); QFontDatabase::addApplicationFont(":/fonts/ptserif/PTSerif-Regular.ttf");
QFontDatabase::addApplicationFont(":/fonts/ptserif/PTSerif-Italic.ttf"); QFontDatabase::addApplicationFont(":/fonts/ptserif/PTSerif-Italic.ttf");
QFontDatabase::addApplicationFont(":/fonts/ptserif/PTSerif-Bold.ttf"); QFontDatabase::addApplicationFont(":/fonts/ptserif/PTSerif-Bold.ttf");
QFontDatabase::addApplicationFont(":/fonts/ptserif/PTSerif-BoldItalic.ttf"); QFontDatabase::addApplicationFont(":/fonts/ptserif/PTSerif-BoldItalic.ttf");
// iA Mono // iA Mono 字体
QFontDatabase::addApplicationFont(":/fonts/iamono/iAWriterMonoS-Regular.ttf"); QFontDatabase::addApplicationFont(":/fonts/iamono/iAWriterMonoS-Regular.ttf");
QFontDatabase::addApplicationFont(":/fonts/iamono/iAWriterMonoS-Italic.ttf"); QFontDatabase::addApplicationFont(":/fonts/iamono/iAWriterMonoS-Italic.ttf");
QFontDatabase::addApplicationFont(":/fonts/iamono/iAWriterMonoS-Bold.ttf"); QFontDatabase::addApplicationFont(":/fonts/iamono/iAWriterMonoS-Bold.ttf");
QFontDatabase::addApplicationFont(":/fonts/iamono/iAWriterMonoS-BoldItalic.ttf"); QFontDatabase::addApplicationFont(":/fonts/iamono/iAWriterMonoS-BoldItalic.ttf");
// iA Duo // iA Duo 字体
QFontDatabase::addApplicationFont(":/fonts/iaduo/iAWriterDuoS-Regular.ttf"); QFontDatabase::addApplicationFont(":/fonts/iaduo/iAWriterDuoS-Regular.ttf");
QFontDatabase::addApplicationFont(":/fonts/iaduo/iAWriterDuoS-Italic.ttf"); QFontDatabase::addApplicationFont(":/fonts/iaduo/iAWriterDuoS-Italic.ttf");
QFontDatabase::addApplicationFont(":/fonts/iaduo/iAWriterDuoS-Bold.ttf"); QFontDatabase::addApplicationFont(":/fonts/iaduo/iAWriterDuoS-Bold.ttf");
QFontDatabase::addApplicationFont(":/fonts/iaduo/iAWriterDuoS-BoldItalic.ttf"); QFontDatabase::addApplicationFont(":/fonts/iaduo/iAWriterDuoS-BoldItalic.ttf");
// iA Quattro // iA Quattro 字体
QFontDatabase::addApplicationFont(":/fonts/iaquattro/iAWriterQuattroS-Regular.ttf"); QFontDatabase::addApplicationFont(":/fonts/iaquattro/iAWriterQuattroS-Regular.ttf");
QFontDatabase::addApplicationFont(":/fonts/iaquattro/iAWriterQuattroS-Italic.ttf"); QFontDatabase::addApplicationFont(":/fonts/iaquattro/iAWriterQuattroS-Italic.ttf");
QFontDatabase::addApplicationFont(":/fonts/iaquattro/iAWriterQuattroS-Bold.ttf"); QFontDatabase::addApplicationFont(":/fonts/iaquattro/iAWriterQuattroS-Bold.ttf");
QFontDatabase::addApplicationFont(":/fonts/iaquattro/iAWriterQuattroS-BoldItalic.ttf"); QFontDatabase::addApplicationFont(":/fonts/iaquattro/iAWriterQuattroS-BoldItalic.ttf");
// Prevent many instances of the app to be launched // 防止多个应用实例启动
QString name = "com.awsomeness.notes"; QString name = "com.awsomeness.notes";
SingleInstance instance; SingleInstance instance;
if (instance.hasPrevious(name)) { if (instance.hasPrevious(name)) {
@ -96,11 +92,11 @@ int main(int argc, char *argv[])
instance.listen(name); instance.listen(name);
// Create and Show the app // 创建并显示应用程序窗口
MainWindow w; MainWindow w;
w.show(); w.show();
// Bring the Notes window to the front // 将Notes窗口置于最前
QObject::connect(&instance, &SingleInstance::newInstance, &w, QObject::connect(&instance, &SingleInstance::newInstance, &w,
[&]() { (&w)->setMainWindowVisibility(true); }); [&]() { (&w)->setMainWindowVisibility(true); });

File diff suppressed because it is too large Load Diff

@ -6,7 +6,6 @@
#ifndef MAINWINDOW_H #ifndef MAINWINDOW_H
#define MAINWINDOW_H #define MAINWINDOW_H
#include <QMainWindow> #include <QMainWindow>
#include <QtGui> #include <QtGui>
#include <QtCore> #include <QtCore>
@ -52,12 +51,15 @@
#include "nodetreeview.h" #include "nodetreeview.h"
#include "editorsettingsoptions.h" #include "editorsettingsoptions.h"
// 定义订阅状态枚举
L_DECLARE_ENUM(SubscriptionStatus, NoSubscription, Active, ActivationLimitReached, Expired, Invalid, L_DECLARE_ENUM(SubscriptionStatus, NoSubscription, Active, ActivationLimitReached, Expired, Invalid,
EnteredGracePeriod, GracePeriodOver, NoInternetConnection, UnknownError) EnteredGracePeriod, GracePeriodOver, NoInternetConnection, UnknownError)
namespace Ui { namespace Ui {
class MainWindow; class MainWindow;
} }
// 前向声明类
class TreeViewLogic; class TreeViewLogic;
class ListViewLogic; class ListViewLogic;
class NoteEditorLogic; class NoteEditorLogic;
@ -75,6 +77,8 @@ using MainWindowBase = CFramelessWindow;
#else #else
using MainWindowBase = QMainWindow; using MainWindowBase = QMainWindow;
#endif #endif
// 主窗口类
class MainWindow : public MainWindowBase class MainWindow : public MainWindowBase
{ {
Q_OBJECT Q_OBJECT
@ -109,129 +113,232 @@ public:
Q_ENUM(ShadowSide) Q_ENUM(ShadowSide)
Q_ENUM(StretchSide) Q_ENUM(StretchSide)
// 构造函数
explicit MainWindow(QWidget *parent = nullptr); explicit MainWindow(QWidget *parent = nullptr);
// 析构函数
~MainWindow() override; ~MainWindow() override;
// 设置主窗口可见性
void setMainWindowVisibility(bool state); void setMainWindowVisibility(bool state);
public slots: public slots:
// 保存最近选择的文件夹标签
void saveLastSelectedFolderTags(bool isFolder, const QString &folderPath, void saveLastSelectedFolderTags(bool isFolder, const QString &folderPath,
const QSet<int> &tagId); const QSet<int> &tagId);
// 保存展开的文件夹
void saveExpandedFolder(const QStringList &folderPaths); void saveExpandedFolder(const QStringList &folderPaths);
// 保存最近选择的笔记
void saveLastSelectedNote(const QSet<int> &notesId); void saveLastSelectedNote(const QSet<int> &notesId);
// 从样式按钮改变编辑器字体类型
void changeEditorFontTypeFromStyleButtons(FontTypeface::Value fontType, int chosenFontIndex); void changeEditorFontTypeFromStyleButtons(FontTypeface::Value fontType, int chosenFontIndex);
// 从样式按钮改变编辑器字体大小
void changeEditorFontSizeFromStyleButtons(FontSizeAction::Value fontSizeAction); void changeEditorFontSizeFromStyleButtons(FontSizeAction::Value fontSizeAction);
// 从样式按钮改变编辑器文本宽度
void changeEditorTextWidthFromStyleButtons(EditorTextWidth::Value editorTextWidth); void changeEditorTextWidthFromStyleButtons(EditorTextWidth::Value editorTextWidth);
// 重置编辑器设置
void resetEditorSettings(); void resetEditorSettings();
// 设置主题
void setTheme(Theme::Value theme); void setTheme(Theme::Value theme);
// 设置看板可见性
void setKanbanVisibility(bool isVisible); void setKanbanVisibility(bool isVisible);
// 折叠笔记列表
void collapseNoteList(); void collapseNoteList();
// 展开笔记列表
void expandNoteList(); void expandNoteList();
// 折叠文件夹树
void collapseFolderTree(); void collapseFolderTree();
// 展开文件夹树
void expandFolderTree(); void expandFolderTree();
// 设置Markdown启用状态
void setMarkdownEnabled(bool isMarkdownEnabled); void setMarkdownEnabled(bool isMarkdownEnabled);
// 设置窗口置顶
void stayOnTop(bool checked); void stayOnTop(bool checked);
// 将当前笔记移至回收站
void moveCurrentNoteToTrash(); void moveCurrentNoteToTrash();
// 切换编辑器设置
void toggleEditorSettings(); void toggleEditorSettings();
// 从快速视图设置编辑器设置可见性
void setEditorSettingsFromQuickViewVisibility(bool isVisible); void setEditorSettingsFromQuickViewVisibility(bool isVisible);
// 设置编辑器设置滚动条位置
void setEditorSettingsScrollBarPosition(double position); void setEditorSettingsScrollBarPosition(double position);
// 设置激活成功的状态
void setActivationSuccessful(QString licenseKey, bool removeGracePeriodStartedDate = true); void setActivationSuccessful(QString licenseKey, bool removeGracePeriodStartedDate = true);
// 检查专业版
void checkProVersion(); void checkProVersion();
// 获取用户许可密钥
QVariant getUserLicenseKey(); QVariant getUserLicenseKey();
protected: protected:
// 重新绘制事件
void paintEvent(QPaintEvent *event) override; void paintEvent(QPaintEvent *event) override;
// 重新调整事件
void resizeEvent(QResizeEvent *event) override; void resizeEvent(QResizeEvent *event) override;
// 关闭事件
void closeEvent(QCloseEvent *event) override; void closeEvent(QCloseEvent *event) override;
// 鼠标按下事件
void mousePressEvent(QMouseEvent *event) override; void mousePressEvent(QMouseEvent *event) override;
// 鼠标移动事件
void mouseMoveEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override;
// 移动事件
void moveEvent(QMoveEvent *event) override; void moveEvent(QMoveEvent *event) override;
// 鼠标释放事件
void mouseReleaseEvent(QMouseEvent *event) override; void mouseReleaseEvent(QMouseEvent *event) override;
// 鼠标双击事件
void mouseDoubleClickEvent(QMouseEvent *event) override; void mouseDoubleClickEvent(QMouseEvent *event) override;
// 离开事件
void leaveEvent(QEvent *) override; void leaveEvent(QEvent *) override;
// 变更事件
void changeEvent(QEvent *event) override; void changeEvent(QEvent *event) override;
// 事件过滤器
bool eventFilter(QObject *object, QEvent *event) override; bool eventFilter(QObject *object, QEvent *event) override;
private: private:
// UI界面指针
Ui::MainWindow *ui; Ui::MainWindow *ui;
// 设置数据库指针
QSettings *m_settingsDatabase; QSettings *m_settingsDatabase;
// 清除按钮
QToolButton *m_clearButton; QToolButton *m_clearButton;
// 搜索按钮
QToolButton *m_searchButton; QToolButton *m_searchButton;
// 绿色最大化按钮
QPushButton *m_greenMaximizeButton; QPushButton *m_greenMaximizeButton;
// 红色关闭按钮
QPushButton *m_redCloseButton; QPushButton *m_redCloseButton;
// 黄色最小化按钮
QPushButton *m_yellowMinimizeButton; QPushButton *m_yellowMinimizeButton;
// 交通灯布局
QHBoxLayout m_trafficLightLayout; QHBoxLayout m_trafficLightLayout;
// 新笔记按钮
QPushButton *m_newNoteButton; QPushButton *m_newNoteButton;
// 点点按钮
QPushButton *m_dotsButton; QPushButton *m_dotsButton;
// 全局设置按钮
QPushButton *m_globalSettingsButton; QPushButton *m_globalSettingsButton;
// 切换树视图按钮
QPushButton *m_toggleTreeViewButton; QPushButton *m_toggleTreeViewButton;
// 切换文本视图按钮
QPushButton *m_switchToTextViewButton; QPushButton *m_switchToTextViewButton;
// 切换看板视图按钮
QPushButton *m_switchToKanbanViewButton; QPushButton *m_switchToKanbanViewButton;
// 文本编辑器
CustomDocument *m_textEdit; CustomDocument *m_textEdit;
// 笔记编辑器逻辑
NoteEditorLogic *m_noteEditorLogic; NoteEditorLogic *m_noteEditorLogic;
// 搜索框
QLineEdit *m_searchEdit; QLineEdit *m_searchEdit;
// 编辑器日期标签
QLabel *m_editorDateLabel; QLabel *m_editorDateLabel;
// 分割器
QSplitter *m_splitter; QSplitter *m_splitter;
// 笔记列表小部件
QWidget *m_noteListWidget; QWidget *m_noteListWidget;
// 文件夹小部件
QWidget *m_foldersWidget; QWidget *m_foldersWidget;
// 系统托盘图标
QSystemTrayIcon *m_trayIcon; QSystemTrayIcon *m_trayIcon;
#if !defined(Q_OS_MAC) #if !defined(Q_OS_MAC)
// 恢复动作
QAction *m_restoreAction; QAction *m_restoreAction;
// 退出动作
QAction *m_quitAction; QAction *m_quitAction;
#endif #endif
// 笔记列表视图
NoteListView *m_listView; NoteListView *m_listView;
// 笔记列表模型
NoteListModel *m_listModel; NoteListModel *m_listModel;
// 列表视图逻辑
ListViewLogic *m_listViewLogic; ListViewLogic *m_listViewLogic;
// 节点树视图
NodeTreeView *m_treeView; NodeTreeView *m_treeView;
// 节点树模型
NodeTreeModel *m_treeModel; NodeTreeModel *m_treeModel;
// 树视图逻辑
TreeViewLogic *m_treeViewLogic; TreeViewLogic *m_treeViewLogic;
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0) #if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
// 看板快速视图
QQuickView m_kanbanQuickView; QQuickView m_kanbanQuickView;
// 看板小部件
QWidget *m_kanbanWidget; QWidget *m_kanbanWidget;
#endif #endif
// 编辑器设置快速视图
QQuickView m_editorSettingsQuickView; QQuickView m_editorSettingsQuickView;
// 编辑器设置小部件
QWidget *m_editorSettingsWidget; QWidget *m_editorSettingsWidget;
// 标签池
TagPool *m_tagPool; TagPool *m_tagPool;
// 数据库管理器
DBManager *m_dbManager; DBManager *m_dbManager;
// 数据库线程
QThread *m_dbThread; QThread *m_dbThread;
// 分割器样式
SplitterStyle *m_splitterStyle; SplitterStyle *m_splitterStyle;
#if defined(UPDATE_CHECKER) #if defined(UPDATE_CHECKER)
// 更新窗口
UpdaterWindow m_updater; UpdaterWindow m_updater;
#endif #endif
// 关于窗口
AboutWindow m_aboutWindow; AboutWindow m_aboutWindow;
// 拉伸边
StretchSide m_stretchSide; StretchSide m_stretchSide;
// 自启动
Autostart m_autostart; Autostart m_autostart;
// 鼠标按下坐标
int m_mousePressX; int m_mousePressX;
int m_mousePressY; int m_mousePressY;
// 回收站计数器
int m_trashCounter; int m_trashCounter;
// 布局边距
int m_layoutMargin; int m_layoutMargin;
// 阴影宽度
int m_shadowWidth; int m_shadowWidth;
// 节点树宽度
int m_nodeTreeWidth; int m_nodeTreeWidth;
// 小编辑器宽度
int m_smallEditorWidth; int m_smallEditorWidth;
// 大编辑器宽度
int m_largeEditorWidth; int m_largeEditorWidth;
// 能否移动窗口
bool m_canMoveWindow; bool m_canMoveWindow;
// 能否调整窗口大小
bool m_canStretchWindow; bool m_canStretchWindow;
// 临时标志
bool m_isTemp; bool m_isTemp;
// 列表视图滚动条隐藏标志
bool m_isListViewScrollBarHidden; bool m_isListViewScrollBarHidden;
// 操作运行标志
bool m_isOperationRunning; bool m_isOperationRunning;
#if defined(UPDATE_CHECKER) #if defined(UPDATE_CHECKER)
// 不显示更新窗口标志
bool m_dontShowUpdateWindow; bool m_dontShowUpdateWindow;
#endif #endif
// 始终置顶标志
bool m_alwaysStayOnTop; bool m_alwaysStayOnTop;
// 使用本机窗口框架标志
bool m_useNativeWindowFrame; bool m_useNativeWindowFrame;
// 隐藏到托盘标志
bool m_hideToTray; bool m_hideToTray;
// 样式表
QString m_styleSheet; QString m_styleSheet;
// Serif字体列表
QStringList m_listOfSerifFonts; QStringList m_listOfSerifFonts;
// Sans Serif字体列表
QStringList m_listOfSansSerifFonts; QStringList m_listOfSansSerifFonts;
// Mono字体列表
QStringList m_listOfMonoFonts; QStringList m_listOfMonoFonts;
// 选择的Serif字体索引
int m_chosenSerifFontIndex; int m_chosenSerifFontIndex;
// 选择的Sans Serif字体索引
int m_chosenSansSerifFontIndex; int m_chosenSansSerifFontIndex;
// 选择的Mono字体索引
int m_chosenMonoFontIndex; int m_chosenMonoFontIndex;
// 编辑器中等字体大小
int m_editorMediumFontSize; int m_editorMediumFontSize;
// 当前字体大小
int m_currentFontPointSize; int m_currentFontPointSize;
struct m_charsLimitPerFont struct m_charsLimitPerFont
{ {
@ -239,165 +346,308 @@ private:
int serif; int serif;
int sansSerif; int sansSerif;
} m_currentCharsLimitPerFont; } m_currentCharsLimitPerFont;
// 当前字体类型
FontTypeface::Value m_currentFontTypeface; FontTypeface::Value m_currentFontTypeface;
// 当前字体家族
QString m_currentFontFamily; QString m_currentFontFamily;
// 当前选定字体
QFont m_currentSelectedFont; QFont m_currentSelectedFont;
// 显示字体
QString m_displayFont; QString m_displayFont;
// 当前主题
Theme::Value m_currentTheme; Theme::Value m_currentTheme;
// 当前编辑器文本颜色
QColor m_currentEditorTextColor; QColor m_currentEditorTextColor;
// 非编辑器小部件可见性标志
bool m_areNonEditorWidgetsVisible; bool m_areNonEditorWidgetsVisible;
#if !defined(Q_OS_MAC) #if !defined(Q_OS_MAC)
// 文本编辑滚动条定时器
QTimer *m_textEditScrollBarTimer; QTimer *m_textEditScrollBarTimer;
// 文本编辑滚动条定时器持续时间
int m_textEditScrollBarTimerDuration; int m_textEditScrollBarTimerDuration;
#endif #endif
// 帧右上小部件可见性标志
bool m_isFrameRightTopWidgetsVisible; bool m_isFrameRightTopWidgetsVisible;
// 从快速视图可见的编辑器设置标志
bool m_isEditorSettingsFromQuickViewVisible; bool m_isEditorSettingsFromQuickViewVisible;
// 专业版激活标志
bool m_isProVersionActivated; bool m_isProVersionActivated;
// 本地许可数据
QSettings *m_localLicenseData; QSettings *m_localLicenseData;
// 支付详情
QJsonObject m_paymentDetails; QJsonObject m_paymentDetails;
// 订阅状态
SubscriptionStatus::Value m_subscriptionStatus; SubscriptionStatus::Value m_subscriptionStatus;
// 订阅窗口快速视图
QQuickView m_subscriptionWindowQuickView; QQuickView m_subscriptionWindowQuickView;
// 订阅窗口小部件
QWidget *m_subscriptionWindowWidget; QWidget *m_subscriptionWindowWidget;
// 订阅窗口引擎
QQmlApplicationEngine m_subscriptionWindowEngine; QQmlApplicationEngine m_subscriptionWindowEngine;
// 订阅窗口
QWindow *m_subscriptionWindow; QWindow *m_subscriptionWindow;
// 购买数据备用1
QString m_purchaseDataAlt1; QString m_purchaseDataAlt1;
// 购买数据备用2
QString m_purchaseDataAlt2; QString m_purchaseDataAlt2;
// 数据缓冲区
QByteArray *m_dataBuffer; QByteArray *m_dataBuffer;
// 网络访问管理器
QNetworkAccessManager *m_netManager; QNetworkAccessManager *m_netManager;
// 备用请求1
QNetworkRequest m_reqAlt1; QNetworkRequest m_reqAlt1;
// 备用请求2
QNetworkRequest m_reqAlt2; QNetworkRequest m_reqAlt2;
// 第一次尝试的网络购买数据回复
QNetworkReply *m_netPurchaseDataReplyFirstAttempt; QNetworkReply *m_netPurchaseDataReplyFirstAttempt;
// 第二次尝试的网络购买数据回复
QNetworkReply *m_netPurchaseDataReplySecondAttempt; QNetworkReply *m_netPurchaseDataReplySecondAttempt;
// 用户许可密钥
QString m_userLicenseKey; QString m_userLicenseKey;
// 主菜单
QMenu m_mainMenu; QMenu m_mainMenu;
// 购买或管理订阅动作
QAction *m_buyOrManageSubscriptionAction; QAction *m_buyOrManageSubscriptionAction;
// 检查格式是否已应用
bool alreadyAppliedFormat(const QString &formatChars); bool alreadyAppliedFormat(const QString &formatChars);
// 应用格式
void applyFormat(const QString &formatChars); void applyFormat(const QString &formatChars);
// 设置主窗口
void setupMainWindow(); void setupMainWindow();
// 设置字体
void setupFonts(); void setupFonts();
// 设置托盘图标
void setupTrayIcon(); void setupTrayIcon();
// 设置快捷键
void setupKeyboardShortcuts(); void setupKeyboardShortcuts();
// 设置分割器
void setupSplitter(); void setupSplitter();
// 设置按钮
void setupButtons(); void setupButtons();
// 设置信号与槽
void setupSignalsSlots(); void setupSignalsSlots();
#if defined(UPDATE_CHECKER) #if defined(UPDATE_CHECKER)
// 自动检查更新
void autoCheckForUpdates(); void autoCheckForUpdates();
#endif #endif
// 设置搜索框
void setupSearchEdit(); void setupSearchEdit();
// 设置订阅窗口
void setupSubscrirptionWindow(); void setupSubscrirptionWindow();
void setupEditorSettings(); // 设置编辑器样式表
void setupTextEditStyleSheet(int paddingLeft, int paddingRight); void setupTextEditStyleSheet(int paddingLeft, int paddingRight);
// 对齐文本编辑器文本
void alignTextEditText(); void alignTextEditText();
// 设置文本编辑器
void setupTextEdit(); void setupTextEdit();
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0) #if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
// 设置看板视图
void setupKanbanView(); void setupKanbanView();
#endif #endif
// 设置数据库
void setupDatabases(); void setupDatabases();
// 设置模型视图
void setupModelView(); void setupModelView();
// 设置全局设置菜单
void setupGlobalSettingsMenu(); void setupGlobalSettingsMenu();
// 初始化设置数据库
void initializeSettingsDatabase(); void initializeSettingsDatabase();
// 为滚动区域设置布局
void setLayoutForScrollArea(); void setLayoutForScrollArea();
// 设置按钮和字段的启用状态
void setButtonsAndFieldsEnabled(bool doEnable); void setButtonsAndFieldsEnabled(bool doEnable);
// 重置格式
void resetFormat(const QString &formatChars); void resetFormat(const QString &formatChars);
// 恢复状态
void restoreStates(); void restoreStates();
// 从版本0.9.0迁移
void migrateFromV0_9_0(); void migrateFromV0_9_0();
// 执行导入
void executeImport(const bool replace); void executeImport(const bool replace);
// 从版本0.9.0迁移笔记
void migrateNoteFromV0_9_0(const QString &notePath); void migrateNoteFromV0_9_0(const QString &notePath);
// 从版本0.9.0迁移回收站
void migrateTrashFromV0_9_0(const QString &trashPath); void migrateTrashFromV0_9_0(const QString &trashPath);
// 根据字体类型设置当前字体
void setCurrentFontBasedOnTypeface(FontTypeface::Value selectedFontTypeFace); void setCurrentFontBasedOnTypeface(FontTypeface::Value selectedFontTypeFace);
// 设置右侧小部件可见性
void setVisibilityOfFrameRightWidgets(bool isVisible); void setVisibilityOfFrameRightWidgets(bool isVisible);
// 设置非编辑器小部件可见性
void setVisibilityOfFrameRightNonEditor(bool isVisible); void setVisibilityOfFrameRightNonEditor(bool isVisible);
// 设置窗口按钮可见性
void setWindowButtonsVisible(bool isVisible); void setWindowButtonsVisible(bool isVisible);
// 显示编辑器设置
void showEditorSettings(); void showEditorSettings();
// 更新选定的编辑器设置选项
void updateSelectedOptionsEditorSettings(); void updateSelectedOptionsEditorSettings();
// 添加阴影
void dropShadow(QPainter &painter, ShadowType type, ShadowSide side); void dropShadow(QPainter &painter, ShadowType type, ShadowSide side);
// 使用渐变填充矩形
void fillRectWithGradient(QPainter &painter, QRect rect, QGradient &gradient); void fillRectWithGradient(QPainter &painter, QRect rect, QGradient &gradient);
// 高斯分布
double gaussianDist(double x, const double center, double sigma) const; double gaussianDist(double x, const double center, double sigma) const;
// 调整并定位编辑器设置窗口
void resizeAndPositionEditorSettingsWindow(); void resizeAndPositionEditorSettingsWindow();
// 获取支付详情信号与槽
void getPaymentDetailsSignalsSlots(); void getPaymentDetailsSignalsSlots();
// 验证许可证信号与槽
void verifyLicenseSignalsSlots(); void verifyLicenseSignalsSlots();
// 获取订阅状态
void getSubscriptionStatus(); void getSubscriptionStatus();
// 设置边距
void setMargins(QMargins margins); void setMargins(QMargins margins);
private slots: private slots:
// 初始化数据
void InitData(); void InitData();
// 系统托盘图标激活
void onSystemTrayIconActivated(QSystemTrayIcon::ActivationReason reason); void onSystemTrayIconActivated(QSystemTrayIcon::ActivationReason reason);
// 新笔记按钮点击
void onNewNoteButtonClicked(); void onNewNoteButtonClicked();
// 点点按钮点击
void onDotsButtonClicked(); void onDotsButtonClicked();
// 切换到看板视图按钮点击
void onSwitchToKanbanViewButtonClicked(); void onSwitchToKanbanViewButtonClicked();
// 全局设置按钮点击
void onGlobalSettingsButtonClicked(); void onGlobalSettingsButtonClicked();
// 清除按钮点击
void onClearButtonClicked(); void onClearButtonClicked();
// 绿色最大化按钮按下
void onGreenMaximizeButtonPressed(); void onGreenMaximizeButtonPressed();
// 黄色最小化按钮按下
void onYellowMinimizeButtonPressed(); void onYellowMinimizeButtonPressed();
// 红色关闭按钮按下
void onRedCloseButtonPressed(); void onRedCloseButtonPressed();
// 绿色最大化按钮点击
void onGreenMaximizeButtonClicked(); void onGreenMaximizeButtonClicked();
// 黄色最小化按钮点击
void onYellowMinimizeButtonClicked(); void onYellowMinimizeButtonClicked();
// 红色关闭按钮点击
void onRedCloseButtonClicked(); void onRedCloseButtonClicked();
// 重置块格式
void resetBlockFormat(); void resetBlockFormat();
// 创建新笔记
void createNewNote(); void createNewNote();
// 向下选择笔记
void selectNoteDown(); void selectNoteDown();
// 向上选择笔记
void selectNoteUp(); void selectNoteUp();
// 设置文本焦点
void setFocusOnText(); void setFocusOnText();
// 全屏窗口
void fullscreenWindow(); void fullscreenWindow();
// 制作代码
void makeCode(); void makeCode();
// 制作粗体
void makeBold(); void makeBold();
// 制作斜体
void makeItalic(); void makeItalic();
// 制作删除线
void makeStrikethrough(); void makeStrikethrough();
// 最大化窗口
void maximizeWindow(); void maximizeWindow();
// 最小化窗口
void minimizeWindow(); void minimizeWindow();
// 退出应用程序
void QuitApplication(); void QuitApplication();
#if defined(UPDATE_CHECKER) #if defined(UPDATE_CHECKER)
// 检查更新
void checkForUpdates(); void checkForUpdates();
#endif #endif
// 切换笔记列表
void toggleNoteList(); void toggleNoteList();
// 切换文件夹树
void toggleFolderTree(); void toggleFolderTree();
// 导入笔记文件
void importNotesFile(); void importNotesFile();
// 导出笔记文件
void exportNotesFile(); void exportNotesFile();
// 恢复笔记文件
void restoreNotesFile(); void restoreNotesFile();
// 增加标题
void increaseHeading(); void increaseHeading();
// 减小标题
void decreaseHeading(); void decreaseHeading();
// 设置标题
void setHeading(int level); void setHeading(int level);
// 设置使用本机窗口框架
void setUseNativeWindowFrame(bool useNativeWindowFrame); void setUseNativeWindowFrame(bool useNativeWindowFrame);
// 设置隐藏到托盘
void setHideToTray(bool enabled); void setHideToTray(bool enabled);
// 切换始终置顶
void toggleStayOnTop(); void toggleStayOnTop();
// 搜索框回车按下
void onSearchEditReturnPressed(); void onSearchEditReturnPressed();
// 删除选中笔记
void deleteSelectedNote(); void deleteSelectedNote();
// 清除搜索框
void clearSearch(); void clearSearch();
// 显示错误信息
void showErrorMessage(const QString &title, const QString &content); void showErrorMessage(const QString &title, const QString &content);
// 设置笔记列表加载状态
void setNoteListLoading(); void setNoteListLoading();
// 选择所有笔记
void selectAllNotesInList(); void selectAllNotesInList();
// 更新框架
void updateFrame(); void updateFrame();
// 检查是否是标题栏
bool isTitleBar(int x, int y) const; bool isTitleBar(int x, int y) const;
// 打开订阅窗口
void openSubscriptionWindow(); void openSubscriptionWindow();
signals: signals:
// 请求节点树
void requestNodesTree(); void requestNodesTree();
// 请求打开数据库管理器
void requestOpenDBManager(const QString &path, bool doCreate); void requestOpenDBManager(const QString &path, bool doCreate);
// 请求恢复笔记
void requestRestoreNotes(const QString &filePath); void requestRestoreNotes(const QString &filePath);
// 请求导入笔记
void requestImportNotes(const QString &filePath); void requestImportNotes(const QString &filePath);
// 请求导出笔记
void requestExportNotes(QString fileName); void requestExportNotes(QString fileName);
// 请求从版本0.9.0迁移笔记
void requestMigrateNotesFromV0_9_0(QVector<NodeData> &noteList); void requestMigrateNotesFromV0_9_0(QVector<NodeData> &noteList);
// 请求从版本0.9.0迁移回收站
void requestMigrateTrashFromV0_9_0(QVector<NodeData> &noteList); void requestMigrateTrashFromV0_9_0(QVector<NodeData> &noteList);
// 请求从版本1.5.0迁移笔记
void requestMigrateNotesFromV1_5_0(const QString &path); void requestMigrateNotesFromV1_5_0(const QString &path);
// 请求更改数据库路径
void requestChangeDatabasePath(const QString &newPath); void requestChangeDatabasePath(const QString &newPath);
// 主题变化信号
void themeChanged(QVariant theme); void themeChanged(QVariant theme);
// 平台设置信号
void platformSet(QVariant platform); void platformSet(QVariant platform);
// Qt版本设置信号
void qtVersionSet(QVariant qtVersion); void qtVersionSet(QVariant qtVersion);
// 编辑器设置显示信号
void editorSettingsShowed(QVariant data); void editorSettingsShowed(QVariant data);
// 主窗口大小改变信号
void mainWindowResized(QVariant data); void mainWindowResized(QVariant data);
// 主窗口移动信号
void mainWindowMoved(QVariant data); void mainWindowMoved(QVariant data);
// 设置显示字体信号
void displayFontSet(QVariant data); void displayFontSet(QVariant data);
// 设置改变信号
void settingsChanged(QVariant data); void settingsChanged(QVariant data);
// 字体改变信号
void fontsChanged(QVariant data); void fontsChanged(QVariant data);
// 切换编辑器设置快捷键触发信号
void toggleEditorSettingsKeyboardShorcutFired(); void toggleEditorSettingsKeyboardShorcutFired();
// 编辑器设置滚动条位置改变信号
void editorSettingsScrollBarPositionChanged(QVariant data); void editorSettingsScrollBarPositionChanged(QVariant data);
// 专业版检查信号
void proVersionCheck(QVariant data); void proVersionCheck(QVariant data);
// 尝试获取第二种购买数据
void tryPurchaseDataSecondAlternative(); void tryPurchaseDataSecondAlternative();
// 远程获取支付详情完成信号
void fetchingPaymentDetailsRemotelyFinished(); void fetchingPaymentDetailsRemotelyFinished();
// 获取支付详情完成信号
void gettingPaymentDetailsFinished(); void gettingPaymentDetailsFinished();
// 订阅状态改变信号
void subscriptionStatusChanged(QVariant subscriptionStatus); void subscriptionStatusChanged(QVariant subscriptionStatus);
}; };

Loading…
Cancel
Save