|
|
|
|
@ -18,6 +18,7 @@ class QuoteFloatingWidget(QWidget):
|
|
|
|
|
# 定义信号
|
|
|
|
|
closed = pyqtSignal() # 窗口关闭信号
|
|
|
|
|
refresh_requested = pyqtSignal() # 刷新请求信号
|
|
|
|
|
insert_requested = pyqtSignal(str) # 插入请求信号,传递要插入的文本
|
|
|
|
|
|
|
|
|
|
def __init__(self, parent=None):
|
|
|
|
|
super().__init__(parent)
|
|
|
|
|
@ -111,6 +112,13 @@ class QuoteFloatingWidget(QWidget):
|
|
|
|
|
bottom_layout.addWidget(self.refresh_btn)
|
|
|
|
|
|
|
|
|
|
bottom_layout.addStretch()
|
|
|
|
|
|
|
|
|
|
# 插入按钮
|
|
|
|
|
self.insert_btn = QPushButton("插入")
|
|
|
|
|
self.insert_btn.setObjectName("insertButton")
|
|
|
|
|
self.insert_btn.clicked.connect(self.on_insert_clicked)
|
|
|
|
|
bottom_layout.addWidget(self.insert_btn)
|
|
|
|
|
|
|
|
|
|
main_layout.addLayout(bottom_layout)
|
|
|
|
|
|
|
|
|
|
# 设置主布局
|
|
|
|
|
@ -184,7 +192,7 @@ class QuoteFloatingWidget(QWidget):
|
|
|
|
|
color: white;
|
|
|
|
|
border-radius: 6px;
|
|
|
|
|
}}
|
|
|
|
|
QPushButton#refreshButton {{
|
|
|
|
|
QPushButton#refreshButton, QPushButton#insertButton {{
|
|
|
|
|
background-color: {colors['accent']};
|
|
|
|
|
color: white;
|
|
|
|
|
border: none;
|
|
|
|
|
@ -193,7 +201,7 @@ class QuoteFloatingWidget(QWidget):
|
|
|
|
|
font-size: 11px;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
}}
|
|
|
|
|
QPushButton#refreshButton:hover {{
|
|
|
|
|
QPushButton#refreshButton:hover, QPushButton#insertButton:hover {{
|
|
|
|
|
background-color: {colors['accent_hover']};
|
|
|
|
|
}}
|
|
|
|
|
""")
|
|
|
|
|
@ -254,7 +262,7 @@ class QuoteFloatingWidget(QWidget):
|
|
|
|
|
color: white;
|
|
|
|
|
border-radius: 6px;
|
|
|
|
|
}}
|
|
|
|
|
QPushButton#refreshButton {{
|
|
|
|
|
QPushButton#refreshButton, QPushButton#insertButton {{
|
|
|
|
|
background-color: {colors['accent']};
|
|
|
|
|
color: white;
|
|
|
|
|
border: none;
|
|
|
|
|
@ -263,7 +271,7 @@ class QuoteFloatingWidget(QWidget):
|
|
|
|
|
font-size: 11px;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
}}
|
|
|
|
|
QPushButton#refreshButton:hover {{
|
|
|
|
|
QPushButton#refreshButton:hover, QPushButton#insertButton:hover {{
|
|
|
|
|
background-color: {colors['accent_hover']};
|
|
|
|
|
}}
|
|
|
|
|
""")
|
|
|
|
|
@ -295,6 +303,22 @@ class QuoteFloatingWidget(QWidget):
|
|
|
|
|
# 同时直接获取新的内容并更新显示
|
|
|
|
|
self.fetch_and_update_quote()
|
|
|
|
|
|
|
|
|
|
def on_insert_clicked(self):
|
|
|
|
|
"""插入按钮点击事件"""
|
|
|
|
|
# 发送插入请求信号,传递完整的诗句信息
|
|
|
|
|
quote = self.quote_data.get("quote", "")
|
|
|
|
|
author = self.quote_data.get("author", "佚名")
|
|
|
|
|
source = self.quote_data.get("source", "")
|
|
|
|
|
|
|
|
|
|
# 构造完整的诗句文本
|
|
|
|
|
if source:
|
|
|
|
|
full_quote_text = f"{quote} —— {author}《{source}》"
|
|
|
|
|
else:
|
|
|
|
|
full_quote_text = f"{quote} —— {author}"
|
|
|
|
|
|
|
|
|
|
if quote:
|
|
|
|
|
self.insert_requested.emit(full_quote_text)
|
|
|
|
|
|
|
|
|
|
def fetch_and_update_quote(self):
|
|
|
|
|
"""获取新的谏言内容并更新显示"""
|
|
|
|
|
try:
|
|
|
|
|
|