diff --git a/README.md b/README.md index 7979605..3a97ae7 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,12 @@ 一个轻量的跨平台 Markdown 编辑器,基于 **Qt 5 / C++17** 构建。 -当前版本 **0.12.0**。 +当前版本 **0.12.1**。 ## 界面 -窗口从上到下依次是菜单栏、工具栏、侧栏 + 编辑区、状态栏。工具栏固定放 -**新建 / 打开 / 保存**,以及 **最近文件**、**最近目录** 两个下拉菜单。 +窗口从上到下依次是菜单栏、侧栏 + 编辑区、状态栏。菜单栏依次是 +**文件 / 编辑 / 视图 / 格式 / 最近文件 / 最近目录 / 帮助**。 | 浅色 · 编辑模式 | 深色 · 编辑模式 | | --- | --- | @@ -125,8 +125,7 @@ Windows / macOS 保留系统原生对话框。 ### 文件 - 新建、打开、保存、另存为 -- **最近文件** / **最近目录**:各记 8 条,文件菜单和工具栏上的下拉菜单都能打开, - 两个列表可以分别清空 +- **最近文件** / **最近目录**:菜单栏上各有一个下拉菜单,各记 8 条,两个列表可以分别清空 - **启动时自动打开上次编辑的文件**;文件已经被删掉就退回欢迎文档 - 保留原文件的 **BOM** 与 **CRLF** 换行风格,保存时原子写入(`QSaveFile`) - 关闭或切换文件时提示未保存的修改 @@ -256,7 +255,7 @@ src/ ├── ThemeManager.{h,cpp} 四种主题模式 + 系统检测 + 调色板 / QSS 生成 ├── LanguageManager.{h,cpp} 中英文切换 ├── AppConfig.{h,cpp} 所有设置共用的 config.ini -├── MainWindow.{h,cpp} 菜单、工具栏、文件读写、侧栏、Git 工具栏、状态栏、设置 +├── MainWindow.{h,cpp} 菜单、文件读写、侧栏、Git 工具栏、状态栏、设置 ├── MarkdownEditor.{h,cpp} 编辑器控件:行号、缩进、代码框装饰、源码模式 ├── MarkdownHighlighter.{h,cpp} Markdown 着色与就地渲染 ├── CodeHighlight.{h,cpp} 多语言语法高亮 tokenizer diff --git a/VoiletMark.pro b/VoiletMark.pro index 074c199..1be13ab 100644 --- a/VoiletMark.pro +++ b/VoiletMark.pro @@ -1,6 +1,6 @@ TEMPLATE = app TARGET = VoiletMark -VERSION = 0.12.0 +VERSION = 0.12.1 QT += core gui widgets diff --git a/docs/screenshot-dark.png b/docs/screenshot-dark.png index 02056b6..7d207d0 100644 Binary files a/docs/screenshot-dark.png and b/docs/screenshot-dark.png differ diff --git a/docs/screenshot-light.png b/docs/screenshot-light.png index 90098dd..0254fd4 100644 Binary files a/docs/screenshot-light.png and b/docs/screenshot-light.png differ diff --git a/docs/screenshot-source.png b/docs/screenshot-source.png index b004c9a..f95e8fb 100644 Binary files a/docs/screenshot-source.png and b/docs/screenshot-source.png differ diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 55f2e8a..df2a937 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -44,7 +44,6 @@ #include #include #include -#include #include #include #include @@ -179,7 +178,6 @@ MainWindow::MainWindow(QWidget *parent) createActions(); createMenus(); - createToolBar(); createSidebar(); createStatusBar(); loadSettings(); @@ -210,37 +208,6 @@ MainWindow::MainWindow(QWidget *parent) m_editor->setFocus(); } -void MainWindow::createToolBar() -{ - m_toolBar = addToolBar(tr("常用")); - m_toolBar->setObjectName(QStringLiteral("mainToolBar")); - m_toolBar->setMovable(false); - m_toolBar->setToolButtonStyle(Qt::ToolButtonTextOnly); - m_toolBar->setIconSize(QSize(16, 16)); - - m_toolBar->addAction(m_newAction); - m_toolBar->addAction(m_openAction); - m_toolBar->addAction(m_saveAction); - m_toolBar->addSeparator(); - - const auto makeMenuButton = [this](const QString &text, QMenu **target) { - QToolButton *button = new QToolButton(m_toolBar); - button->setText(text); - button->setPopupMode(QToolButton::InstantPopup); - button->setToolButtonStyle(Qt::ToolButtonTextOnly); - button->setCursor(Qt::PointingHandCursor); - - QMenu *menu = new QMenu(button); - button->setMenu(menu); - m_toolBar->addWidget(button); - *target = menu; - return button; - }; - - m_toolRecentFilesButton = makeMenuButton(tr("最近文件"), &m_toolRecentFilesMenu); - m_toolRecentFoldersButton = makeMenuButton(tr("最近目录"), &m_toolRecentFoldersMenu); -} - void MainWindow::createActions() { m_newAction = new QAction(tr("新建"), this); @@ -485,8 +452,6 @@ void MainWindow::createMenus() m_fileMenu->addAction(m_newAction); m_fileMenu->addAction(m_openAction); m_fileMenu->addAction(m_openFolderAction); - m_recentMenu = m_fileMenu->addMenu(tr("最近文件")); - m_recentFolderMenu = m_fileMenu->addMenu(tr("最近目录")); m_fileMenu->addSeparator(); m_fileMenu->addAction(m_saveAction); m_fileMenu->addAction(m_saveAsAction); @@ -566,6 +531,10 @@ void MainWindow::createMenus() } m_formatMenu->addAction(m_codeBlockAction); + // 「最近文件」「最近目录」直接排进菜单栏,「帮助」固定在最后 + m_recentMenu = menuBar()->addMenu(tr("最近文件")); + m_recentFolderMenu = menuBar()->addMenu(tr("最近目录")); + m_helpMenu = menuBar()->addMenu(tr("帮助")); m_aboutAction = m_helpMenu->addAction(tr("关于 VoiletMark"), this, &MainWindow::showAbout); } @@ -1004,12 +973,6 @@ void MainWindow::retranslateUi() m_helpMenu->setTitle(tr("帮助")); m_recentMenu->setTitle(tr("最近文件")); m_recentFolderMenu->setTitle(tr("最近目录")); - if (m_toolBar) - m_toolBar->setWindowTitle(tr("常用")); - if (m_toolRecentFilesButton) - m_toolRecentFilesButton->setText(tr("最近文件")); - if (m_toolRecentFoldersButton) - m_toolRecentFoldersButton->setText(tr("最近目录")); m_themeMenu->setTitle(tr("主题")); m_headingMenu->setTitle(tr("标题")); m_languageMenu->setTitle(tr("语言")); @@ -1120,9 +1083,7 @@ void MainWindow::loadRecentFiles() void MainWindow::refreshRecentMenu() { fillRecentFilesMenu(m_recentMenu); - fillRecentFilesMenu(m_toolRecentFilesMenu); fillRecentFoldersMenu(m_recentFolderMenu); - fillRecentFoldersMenu(m_toolRecentFoldersMenu); } void MainWindow::fillRecentFilesMenu(QMenu *menu) diff --git a/src/MainWindow.h b/src/MainWindow.h index a766d8b..95c0765 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -10,7 +10,6 @@ class QDockWidget; class QLabel; class QPushButton; class QStackedWidget; -class QToolBar; class QToolButton; class GitRunner; class QListWidget; @@ -36,7 +35,6 @@ private: enum class Eol { Lf, Crlf }; void createActions(); - void createToolBar(); void createSidebar(); void createMenus(); void createStatusBar(); @@ -180,11 +178,6 @@ private: QMenu *m_recentMenu = nullptr; QMenu *m_recentFolderMenu = nullptr; - QMenu *m_toolRecentFilesMenu = nullptr; - QMenu *m_toolRecentFoldersMenu = nullptr; - QToolButton *m_toolRecentFilesButton = nullptr; - QToolButton *m_toolRecentFoldersButton = nullptr; - QToolBar *m_toolBar = nullptr; QMenu *m_fileMenu = nullptr; QMenu *m_editMenu = nullptr; QMenu *m_viewMenu = nullptr; diff --git a/src/ThemeManager.cpp b/src/ThemeManager.cpp index 280bce1..b275d30 100644 --- a/src/ThemeManager.cpp +++ b/src/ThemeManager.cpp @@ -284,9 +284,6 @@ QMenu::item { padding: 6px 28px 6px 22px; border-radius: 5px; } QMenu::item:selected { background-color: @highlight; color: @highlightedText; } QMenu::item:disabled { color: @disabled; } QMenu::separator { height: 1px; background-color: @border; margin: 5px 8px; } -QToolBar { background-color: @window; border: none; border-bottom: 1px solid @border; - spacing: 2px; padding: 2px 6px; } -QToolBar::separator { width: 1px; background-color: @border; margin: 4px 6px; } QStatusBar { background-color: @window; color: @placeholder; border-top: 1px solid @border; } QStatusBar::item { border: none; } QPlainTextEdit { background-color: @editorBase; color: @editorText; border: none; @@ -308,7 +305,7 @@ QPushButton { background-color: @button; color: @buttonText; border: 1px solid @ QPushButton:hover { background-color: @highlight; color: @highlightedText; } QPushButton:default { background-color: @accent; color: #ffffff; border-color: @accent; } QToolTip { background-color: @menuBackground; color: @text; border: 1px solid @border; padding: 4px; } -QToolButton { border: none; border-radius: 5px; padding: 2px 8px; color: @text; background: transparent; } +QToolButton { border: none; border-radius: 5px; padding: 3px 8px; color: @text; background: transparent; } QToolButton:hover { background-color: @hoverBackground; } QToolButton:checked { background-color: @highlight; color: @highlightedText; } QDockWidget { color: @text; } diff --git a/translations/voiletmark_en.qm b/translations/voiletmark_en.qm index 544a9b9..4200b2f 100644 Binary files a/translations/voiletmark_en.qm and b/translations/voiletmark_en.qm differ diff --git a/translations/voiletmark_en.ts b/translations/voiletmark_en.ts index 8d34c97..94a6b31 100644 --- a/translations/voiletmark_en.ts +++ b/translations/voiletmark_en.ts @@ -14,487 +14,477 @@ MainWindow - - + + 新建 New - - + + 打开… Open… - - + + 保存 Save - - + + 另存为… Save As… - - + + 导出 PDF… Export PDF… - - + + 退出 Quit - - + + 撤销 Undo - - + + 重做 Redo - - + + 剪切 Cut - - + + 复制 Copy - - + + 粘贴 Paste - - + + 全选 Select All - - + + 自动换行 Word Wrap - - + + 放大 Zoom In - - + + 缩小 Zoom Out - - + + 实际大小 Actual Size - - + + 打开文件夹… Open Folder… - - - - + + + + 侧栏 Sidebar - - + + 源代码模式 Source Mode - - + + 代码块 Code Block - - + + 标题 %1 Heading %1 - + 文件夹 Folder - - + + 未打开文件夹 No folder open - - + + Git 仓库 Git repository - - + + 拉取 Pull - + git pull --ff-only git pull --ff-only - - + + 获取 Fetch - + git fetch --all --prune git fetch --all --prune - - - + + + 推送 Push - + git push git push - + 暂存 Stage - + git add -A git add -A - - - - - + + + + + 提交 Commit - + 把暂存区的内容提交 Commit the staged changes - - - + + + 文件 File - + 目录 Outline - - 最近打开 - Recent Files - - - - + + 编辑 Edit - - 常用 - Quick Access - - - - + + 最近文件 Recent Files - - + + 最近目录 Recent Folders - - + + 视图 View - - + + 主题 Theme - - + + 6:00–18:00 使用浅色,其余时间使用深色 Light from 6:00 to 18:00, dark the rest of the day - - + + 语言 Language - - + + 格式 Format - - + + 标题 Heading - - + + 帮助 Help - - - + + + 关于 VoiletMark About VoiletMark - - + + 显示 / 隐藏文件夹侧栏(Ctrl+B) Show / hide the folder sidebar (Ctrl+B) - - + + 源代码模式:关闭语法高亮与行号(Ctrl+Shift+M) Source mode: turn off highlighting and line numbers (Ctrl+Shift+M) - - + + 未命名 Untitled - + 打开 Markdown 文件 Open Markdown File - + Markdown 文件 (*.md *.markdown *.mdown *.mkd);;文本文件 (*.txt);;所有文件 (*) Markdown files (*.md *.markdown *.mdown *.mkd);;Text files (*.txt);;All files (*) - + 无法打开文件 Cannot Open File - + 读取「%1」失败:%2 Could not read "%1": %2 - + 另存为 Save As - + Markdown 文件 (*.md);;文本文件 (*.txt);;所有文件 (*) Markdown files (*.md);;Text files (*.txt);;All files (*) - + 导出 PDF Export PDF - + PDF 文件 (*.pdf) PDF files (*.pdf) - + 正在导出 PDF… Exporting PDF… - - + + 导出失败 Export Failed - + 文档排版结果异常,已中止导出。 The document layout looks broken; export was aborted. - + 没能写出「%1」,换个位置再试一次。 Could not write "%1". Try another location. - + 已导出 %1 Exported to %1 - - - + + + 无法保存文件 Cannot Save File - + 写入「%1」失败:%2 Could not write "%1": %2 - + 写入「%1」时发生错误。 An error occurred while writing "%1". - + 提交「%1」失败:%2 Could not commit "%1": %2 - + 已保存 %1 Saved to %1 - + VoiletMark VoiletMark - + 「%1」有未保存的修改,是否保存? "%1" has unsaved changes. Save them? - + %1[*] — VoiletMark %1[*] — VoiletMark - + 行 %1,列 %2 Line %1, Col %2 - + 已选 %1 字 %1 selected - + %1 字 %1 chars - + <h3>VoiletMark %1</h3><p>一个轻量的跨平台 Markdown 编辑器。</p><p>基于 Qt %2 与 C++17 构建。</p> <h3>VoiletMark %1</h3><p>A lightweight cross-platform Markdown editor.</p><p>Built with Qt %2 and C++17.</p> - + 配置文件:%1 Config file: %1 - - + + (暂无记录) (none) - - + + 清空列表 Clear List - + 打开文件夹 Open Folder - + 文件 → 打开文件夹… File → Open Folder… - + (没有 Markdown 文件) (no Markdown files) - + 正在%1… %1… - + Git 操作失败 Git Operation Failed - + %1失败: %2 @@ -503,69 +493,69 @@ %2 - + (没有输出) (no output) - + %1完成 %1 finished - + (没有标题) (no headings) - + 暂存区是空的,先点「暂存」把所有改动加进去。 Nothing is staged yet. Click "Stage" first to add all changes. - + 提交说明: Commit message: - + 添加到提交 Add to commit - + 「%1」已经在 .gitignore 里了 "%1" is already in .gitignore - + 忽略文件 Ignore File - + 打不开 .gitignore:%1 Cannot open .gitignore: %1 - + 已把 %1 写进 .gitignore Added %1 to .gitignore - - - + + + 删除远端 Delete from remote - + 「%1」没有被 git 跟踪,远端本来就没有它。 "%1" is not tracked by git, so the remote never had it. - + 从仓库删除「%1」并推送到远端? 本地文件会保留,远端和别人 pull 下来的仓库里会删掉它。 @@ -574,53 +564,53 @@ Your local file is kept, but the remote copy and everyone else's will be deleted. - + 删除并推送 Delete and push - + chore: 从仓库删除 %1 chore: remove %1 from repository - - + + 添加 Add - + git add 这个文件 git add this file - + 忽略 Ignore - + 把路径写进 .gitignore(不改仓库里已跟踪的文件) Add the path to .gitignore (does not untrack files already in the repo) - + git rm --cached 后提交并推送:远端删除,本地保留 git rm --cached, then commit and push: gone from the remote, kept locally - + 取消 Cancel - + 从仓库移除 Remove from repository - + 打开 Open @@ -669,22 +659,22 @@ Your local file is kept, but the remote copy and everyone else's will be de QObject - + 浅色 Light - + 深色 Dark - + 按时段自动 Scheduled - + 跟随系统 Follow System