Add help utilities and executable version metadata
This commit is contained in:
@@ -2,8 +2,8 @@ from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from PySide6.QtCore import QSettings, QStandardPaths, Qt
|
||||
from PySide6.QtGui import QAction, QIcon, QKeySequence, QPainter
|
||||
from PySide6.QtCore import QSettings, QStandardPaths, Qt, QUrl
|
||||
from PySide6.QtGui import QAction, QDesktopServices, QIcon, QKeySequence, QPainter
|
||||
from PySide6.QtPrintSupport import QPrintDialog, QPrinter
|
||||
from PySide6.QtWidgets import (
|
||||
QCheckBox,
|
||||
@@ -760,7 +760,11 @@ class MainWindow(QMainWindow):
|
||||
edit_menu.addAction(self.cover_action)
|
||||
|
||||
help_menu = self.menuBar().addMenu("帮助")
|
||||
self.shortcuts_action = QAction("快捷键", self)
|
||||
self.open_log_dir_action = QAction("打开日志目录", self)
|
||||
self.about_action = QAction("关于", self)
|
||||
help_menu.addAction(self.shortcuts_action)
|
||||
help_menu.addAction(self.open_log_dir_action)
|
||||
help_menu.addAction(self.about_action)
|
||||
|
||||
def _build_toolbar(self) -> None:
|
||||
@@ -810,6 +814,8 @@ class MainWindow(QMainWindow):
|
||||
self.remove_password_action.triggered.connect(self.remove_password_file)
|
||||
self.print_action.triggered.connect(self.print_document)
|
||||
self.clear_recent_action.triggered.connect(self.clear_recent_files)
|
||||
self.shortcuts_action.triggered.connect(self.show_shortcuts)
|
||||
self.open_log_dir_action.triggered.connect(self.open_log_dir)
|
||||
self.about_action.triggered.connect(self.show_about)
|
||||
self.undo_action.triggered.connect(self.undo)
|
||||
self.redo_action.triggered.connect(self.redo)
|
||||
@@ -1105,17 +1111,41 @@ class MainWindow(QMainWindow):
|
||||
if window_state:
|
||||
self.restoreState(window_state)
|
||||
|
||||
def show_about(self) -> None:
|
||||
log_dir = Path(
|
||||
QStandardPaths.writableLocation(QStandardPaths.StandardLocation.AppDataLocation)
|
||||
def log_dir(self) -> Path:
|
||||
return Path(QStandardPaths.writableLocation(QStandardPaths.StandardLocation.AppDataLocation))
|
||||
|
||||
def open_log_dir(self) -> None:
|
||||
log_dir = self.log_dir()
|
||||
log_dir.mkdir(parents=True, exist_ok=True)
|
||||
QDesktopServices.openUrl(QUrl.fromLocalFile(str(log_dir)))
|
||||
|
||||
def show_shortcuts(self) -> None:
|
||||
QMessageBox.information(
|
||||
self,
|
||||
"快捷键",
|
||||
"打开:Ctrl+O\n"
|
||||
"保存:Ctrl+S\n"
|
||||
"另存为:Ctrl+Shift+S\n"
|
||||
"打印:Ctrl+P\n"
|
||||
"撤销:Ctrl+Z\n"
|
||||
"重做:Ctrl+Y\n"
|
||||
"上一页:Page Up\n"
|
||||
"下一页:Page Down\n"
|
||||
"放大:Ctrl++\n"
|
||||
"缩小:Ctrl+-\n"
|
||||
"跳转页码:Ctrl+G\n"
|
||||
"高亮:Ctrl+H\n"
|
||||
"文档信息:Ctrl+I",
|
||||
)
|
||||
|
||||
def show_about(self) -> None:
|
||||
QMessageBox.information(
|
||||
self,
|
||||
"关于 PDFReaderLite",
|
||||
"PDFReaderLite\n\n"
|
||||
f"版本:{__version__}\n"
|
||||
"定位:轻量 PDF 阅读与编辑工具\n\n"
|
||||
f"日志目录:{log_dir}",
|
||||
f"日志目录:{self.log_dir()}",
|
||||
)
|
||||
|
||||
def _update_title(self) -> None:
|
||||
|
||||
Reference in New Issue
Block a user