'update'
This commit is contained in:
@@ -7,6 +7,7 @@ from PyQt6.QtWidgets import (
|
||||
QFileDialog, QMessageBox, QLineEdit, QFormLayout, QDialog, QDialogButtonBox
|
||||
)
|
||||
from PyQt6.QtGui import QIcon
|
||||
from PyQt6 import uic
|
||||
import config
|
||||
from exportbooknotes import BookNotesExporter
|
||||
from booklist_parse import BookListManager
|
||||
@@ -34,12 +35,19 @@ class ConfigDialog(QDialog):
|
||||
class IBookExportApp(QWidget):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.setWindowTitle("iBooks 笔记导出工具")
|
||||
self.resize(600, 400)
|
||||
|
||||
# 加载 UI 文件
|
||||
ui_file = os.path.join(os.path.dirname(__file__), 'ibook_export_app.ui')
|
||||
uic.loadUi(ui_file, self)
|
||||
|
||||
# 设置窗口标题
|
||||
self.setWindowTitle("notesExporter")
|
||||
|
||||
# 设置窗口图标
|
||||
if os.path.exists(config.APP_ICON):
|
||||
self.setWindowIcon(QIcon(config.APP_ICON))
|
||||
|
||||
# 初始化数据
|
||||
self.exporter = BookNotesExporter(config)
|
||||
self.manager = BookListManager(plist_path=config.LOCAL_BOOKS_PLIST, db_path=config.LOCAL_LIBRARY_DB)
|
||||
self.booksinfo = self.manager.get_books_info()
|
||||
@@ -56,25 +64,17 @@ class IBookExportApp(QWidget):
|
||||
sorted_assetids = sorted(self.assetid2name.keys(), key=lambda aid: self.assetid2lastopen[aid], reverse=True)
|
||||
self.sorted_assetids = sorted_assetids
|
||||
|
||||
layout = QVBoxLayout(self)
|
||||
self.label = QLabel("请选择要导出的书籍:")
|
||||
layout.addWidget(self.label)
|
||||
|
||||
self.listwidget = QListWidget()
|
||||
# 填充书籍列表
|
||||
for aid in sorted_assetids:
|
||||
self.listwidget.addItem(f"{self.assetid2name[aid]} [{self.assetid2lastopen[aid]}]")
|
||||
layout.addWidget(self.listwidget)
|
||||
|
||||
# 连接信号
|
||||
self.export_btn.clicked.connect(self.export_notes)
|
||||
self.config_btn.clicked.connect(self.show_config)
|
||||
|
||||
# 回车直接导出(使用事件过滤器)
|
||||
self.listwidget.installEventFilter(self)
|
||||
|
||||
self.export_btn = QPushButton("导出")
|
||||
self.export_btn.clicked.connect(self.export_notes)
|
||||
self.config_btn = QPushButton("配置参数")
|
||||
self.config_btn.clicked.connect(self.show_config)
|
||||
|
||||
layout.addWidget(self.export_btn)
|
||||
layout.addWidget(self.config_btn)
|
||||
|
||||
def eventFilter(self, obj, event):
|
||||
from PyQt6.QtCore import QEvent, Qt
|
||||
if obj == self.listwidget and event.type() == QEvent.Type.KeyPress:
|
||||
@@ -114,6 +114,11 @@ class IBookExportApp(QWidget):
|
||||
if __name__ == "__main__":
|
||||
app = QApplication(sys.argv)
|
||||
|
||||
# 设置应用程序名称和组织信息
|
||||
app.setApplicationName("notesExporter")
|
||||
app.setApplicationDisplayName("notesExporter")
|
||||
app.setOrganizationName("iBook Tools")
|
||||
|
||||
# 设置应用程序图标
|
||||
if os.path.exists(config.APP_ICON):
|
||||
app.setWindowIcon(QIcon(config.APP_ICON))
|
||||
|
||||
Reference in New Issue
Block a user