repdf 0.0.17__tar.gz → 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. {repdf-0.0.17 → repdf-0.1.0}/PKG-INFO +13 -4
  2. {repdf-0.0.17 → repdf-0.1.0}/README.md +12 -3
  3. {repdf-0.0.17 → repdf-0.1.0}/pyproject.toml +1 -1
  4. {repdf-0.0.17 → repdf-0.1.0}/pyproject.toml.orig +1 -1
  5. {repdf-0.0.17 → repdf-0.1.0}/src/repdf/app.py +6 -4
  6. repdf-0.1.0/src/repdf/assets/check-dark.svg +1 -0
  7. repdf-0.1.0/src/repdf/assets/partial-dark.svg +1 -0
  8. {repdf-0.0.17 → repdf-0.1.0}/src/repdf/icons.py +9 -4
  9. {repdf-0.0.17 → repdf-0.1.0}/src/repdf/page_view.py +8 -1
  10. {repdf-0.0.17 → repdf-0.1.0}/src/repdf/preview.py +1 -0
  11. {repdf-0.0.17 → repdf-0.1.0}/src/repdf/search_panel.py +60 -4
  12. {repdf-0.0.17 → repdf-0.1.0}/src/repdf/strings.py +1 -0
  13. {repdf-0.0.17 → repdf-0.1.0}/src/repdf/theme.py +35 -31
  14. {repdf-0.0.17 → repdf-0.1.0}/src/repdf/widgets.py +11 -2
  15. {repdf-0.0.17 → repdf-0.1.0}/src/repdf/__init__.py +0 -0
  16. {repdf-0.0.17 → repdf-0.1.0}/src/repdf/__main__.py +0 -0
  17. {repdf-0.0.17 → repdf-0.1.0}/src/repdf/assets/check.svg +0 -0
  18. {repdf-0.0.17 → repdf-0.1.0}/src/repdf/assets/partial.svg +0 -0
  19. {repdf-0.0.17 → repdf-0.1.0}/src/repdf/assets/repdf.ico +0 -0
  20. {repdf-0.0.17 → repdf-0.1.0}/src/repdf/assets/repdf.png +0 -0
  21. {repdf-0.0.17 → repdf-0.1.0}/src/repdf/core.py +0 -0
  22. {repdf-0.0.17 → repdf-0.1.0}/src/repdf/entrypoint.py +0 -0
  23. {repdf-0.0.17 → repdf-0.1.0}/src/repdf/images.py +0 -0
  24. {repdf-0.0.17 → repdf-0.1.0}/src/repdf/navigation.py +0 -0
  25. {repdf-0.0.17 → repdf-0.1.0}/src/repdf/ocr.py +0 -0
  26. {repdf-0.0.17 → repdf-0.1.0}/src/repdf/packaging_smoke.py +0 -0
  27. {repdf-0.0.17 → repdf-0.1.0}/src/repdf/pdf_navigation.py +0 -0
  28. {repdf-0.0.17 → repdf-0.1.0}/src/repdf/preferences.py +0 -0
  29. {repdf-0.0.17 → repdf-0.1.0}/src/repdf/print_preview.py +0 -0
  30. {repdf-0.0.17 → repdf-0.1.0}/src/repdf/printing.py +0 -0
  31. {repdf-0.0.17 → repdf-0.1.0}/src/repdf/render_worker.py +0 -0
  32. {repdf-0.0.17 → repdf-0.1.0}/src/repdf/renderer.py +0 -0
  33. {repdf-0.0.17 → repdf-0.1.0}/src/repdf/search.py +0 -0
  34. {repdf-0.0.17 → repdf-0.1.0}/src/repdf/toolbar.py +0 -0
  35. {repdf-0.0.17 → repdf-0.1.0}/src/repdf/workers.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: repdf
3
- Version: 0.0.17
3
+ Version: 0.1.0
4
4
  Summary: RePDF (Read the PDF): a desktop PDF reader with printing, search, bookmarks, OCR and page rearrangement.
5
5
  Requires-Dist: onnxruntime>=1.31.0,<2
6
6
  Requires-Dist: pillow>=11.0,<13
@@ -17,8 +17,15 @@ Description-Content-Type: text/markdown
17
17
 
18
18
  # RePDF — Read the PDF
19
19
 
20
+ [繁體中文](README.md) | [English](README.en.md)
21
+
20
22
  RePDF 代表 **Read the PDF**,命令與 Python 套件名稱為 `repdf`。這是一套桌面 PDF 閱讀器,支援多標籤閱讀、列印、書籤與目錄跳頁、文字搜尋、選字複製、OCR 及圖片擷取,也可勾選頁面,依標籤與頁面排列順序重組或拆分輸出。重組與拆分保留原始頁面品質。
21
23
 
24
+ ## 重點特色
25
+
26
+ - **支援規則表達式的搜尋**:可搜尋目前、勾選或所有標籤頁,並切換規則表達式、區分大小寫及僅限單字。點選搜尋結果即可跳到對應頁面,並以螢光筆效果標示命中文字。
27
+ - **直接擷取 PDF 內嵌圖片**:以滑鼠點選內嵌的點陣圖片,即可另存為 PNG,保留圖片的原始像素尺寸與透明度,不受閱讀時的縮放比例影響。
28
+
22
29
  ## 安裝與啟動
23
30
 
24
31
  ### 1. 下載發布的執行檔/App(建議)
@@ -157,7 +164,7 @@ repdf
157
164
  2. 輸入搜尋內容,選擇「目前標籤頁」、「勾選的標籤頁」或「所有標籤頁」;同一列的 `.*`、`Aa` 與底線 `ab` 狀態按鈕分別切換「規則表達式」、「區分大小寫」與「僅限單字」,亮起表示啟用。
158
165
  3. 按 <kbd>Enter</kbd> 或「搜尋」執行;修改條件後再次執行才會更新結果。
159
166
  4. 上方選取有命中的檔案,下方以交錯底色單行列出命中段落、原始頁碼與命中次數;內容過長時以 `...` 結尾,滑鼠停留可查看完整段落。
160
- 5. 單擊段落,切換到對應標籤與頁面;該頁命中以淡黃色標示,選取段落的命中以較深的琥珀色突出。
167
+ 5. 單擊段落,切換到對應標籤與頁面,捲至命中位置;尚未載入的頁面會自動載入。命中預設以黃色螢光筆標示,選取段落以較深的同色系突出。
161
168
 
162
169
  - 預設搜尋目前標籤頁、不區分大小寫、不使用規則表達式;三種範圍互斥。
163
170
  - 「僅限單字」預設關閉;啟用後,命中內容兩側不能緊接 Unicode 字母、數字、底線或組合標記,例如 `cat` 不會命中 `catalog`。可與規則表達式併用;此選項不會替連續中文斷詞。
@@ -165,12 +172,13 @@ repdf
165
172
  - 搜尋涵蓋範圍內已成功載入檔案的全部頁面,不受頁面勾選限制;密碼文件需先解鎖。
166
173
  - 只搜尋既有文字層,不啟動 OCR;掃描圖片或損壞的文字層可能搜尋不到。
167
174
  - 同段落內的多次命中合併為一筆;段落依文字行與版面位置推估,不跨頁搜尋,分欄及複雜版面可能有段落差異。
168
- - 視覺換行會合併;中日文字之間不補空格,其餘續行以空格銜接。
175
+ - 支援同一段落內的跨行搜尋:視覺換行會合併,中日文字之間不補空格,其餘續行以空格銜接;跨行命中會標示對應各行的文字。
169
176
  - 規則表達式採 Python 相容語法;無效規則會顯示錯誤,零長度位置不列為可高亮的命中。
170
177
  - 每段正則匹配最多 1 秒;逾時會停止搜尋並標示結果不完整。也可按「停止」保留目前已找到的結果。
171
178
  - 可拖曳右側窗格寬度與上下結果區的分隔線;搜尋不改動選頁、排序或縮放模式。
172
179
  - 視窗寬度小於 640px 時,搜尋與 PDF 改為單一窗格切換;點結果後顯示 PDF,再點搜尋按鈕可返回結果。
173
180
  - 視窗較矮時,從三點「選項」選單調整範圍、規則表達式、區分大小寫與僅限單字設定。
181
+ - 點選搜尋選項列的色塊按鈕可設定命中標示顏色;較矮視窗可從「選項 → 命中標示顏色」開啟。變更會立即更新現有標示,無須重新搜尋,並套用至全螢幕與之後載入的頁面;選擇會記住,取消選色不會變更設定。
174
182
  - 關閉搜尋窗格會停止搜尋並清除高亮,保留輸入與結果;文件關閉時會移除其結果。
175
183
  - 全螢幕使用搜尋快捷鍵時,會返回主視窗並開啟搜尋窗格。
176
184
 
@@ -198,7 +206,7 @@ repdf
198
206
  ### 複製文字、區域 OCR 與擷取圖片
199
207
 
200
208
  - 三種模式互斥;一般預覽與全螢幕皆可使用。
201
- - 啟用時按鈕會顯示選取底色;關閉後恢復拖放排序。
209
+ - 啟用時按鈕以 hover 底色與強調色圖示標示,不顯示外框;關閉後恢復拖放排序。
202
210
  - 複製文字:啟用後拖曳選取,放開滑鼠即可複製;掃描影像中的文字請使用區域 OCR。
203
211
  - 區域 OCR:啟用後拖曳矩形範圍,放開滑鼠後辨識並複製;空白範圍保留原剪貼簿。
204
212
  - 擷取圖片:啟用後點選內嵌點陣圖片,再選擇位置另存為 PNG。
@@ -214,6 +222,7 @@ repdf
214
222
 
215
223
  - 介面語言:跟隨系統 → 繁體中文 → English → 跟隨系統。系統顯示語言為中文時使用繁體中文,其他語言使用 English;tooltip 顯示目前模式與實際語言。
216
224
  - 介面配色:跟隨系統 → 淺色 → 深色 → 跟隨系統。手動指定配色後不受系統配色變化影響,回到系統模式則即時跟隨。
225
+ - 深色配色採《新世紀福音戰士》初號機風格,以紫黑背景、紫色面板、螢光綠強調色及少量橙色呈現;PDF 頁面保留原始顏色。
217
226
 
218
227
  - 語言與配色的選擇會記住,重新啟動仍保留。
219
228
  - 切換語言會更新既有頁面標籤、工具列、tooltip、狀態與對話框。
@@ -1,7 +1,14 @@
1
1
  # RePDF — Read the PDF
2
2
 
3
+ [繁體中文](README.md) | [English](README.en.md)
4
+
3
5
  RePDF 代表 **Read the PDF**,命令與 Python 套件名稱為 `repdf`。這是一套桌面 PDF 閱讀器,支援多標籤閱讀、列印、書籤與目錄跳頁、文字搜尋、選字複製、OCR 及圖片擷取,也可勾選頁面,依標籤與頁面排列順序重組或拆分輸出。重組與拆分保留原始頁面品質。
4
6
 
7
+ ## 重點特色
8
+
9
+ - **支援規則表達式的搜尋**:可搜尋目前、勾選或所有標籤頁,並切換規則表達式、區分大小寫及僅限單字。點選搜尋結果即可跳到對應頁面,並以螢光筆效果標示命中文字。
10
+ - **直接擷取 PDF 內嵌圖片**:以滑鼠點選內嵌的點陣圖片,即可另存為 PNG,保留圖片的原始像素尺寸與透明度,不受閱讀時的縮放比例影響。
11
+
5
12
  ## 安裝與啟動
6
13
 
7
14
  ### 1. 下載發布的執行檔/App(建議)
@@ -140,7 +147,7 @@ repdf
140
147
  2. 輸入搜尋內容,選擇「目前標籤頁」、「勾選的標籤頁」或「所有標籤頁」;同一列的 `.*`、`Aa` 與底線 `ab` 狀態按鈕分別切換「規則表達式」、「區分大小寫」與「僅限單字」,亮起表示啟用。
141
148
  3. 按 <kbd>Enter</kbd> 或「搜尋」執行;修改條件後再次執行才會更新結果。
142
149
  4. 上方選取有命中的檔案,下方以交錯底色單行列出命中段落、原始頁碼與命中次數;內容過長時以 `...` 結尾,滑鼠停留可查看完整段落。
143
- 5. 單擊段落,切換到對應標籤與頁面;該頁命中以淡黃色標示,選取段落的命中以較深的琥珀色突出。
150
+ 5. 單擊段落,切換到對應標籤與頁面,捲至命中位置;尚未載入的頁面會自動載入。命中預設以黃色螢光筆標示,選取段落以較深的同色系突出。
144
151
 
145
152
  - 預設搜尋目前標籤頁、不區分大小寫、不使用規則表達式;三種範圍互斥。
146
153
  - 「僅限單字」預設關閉;啟用後,命中內容兩側不能緊接 Unicode 字母、數字、底線或組合標記,例如 `cat` 不會命中 `catalog`。可與規則表達式併用;此選項不會替連續中文斷詞。
@@ -148,12 +155,13 @@ repdf
148
155
  - 搜尋涵蓋範圍內已成功載入檔案的全部頁面,不受頁面勾選限制;密碼文件需先解鎖。
149
156
  - 只搜尋既有文字層,不啟動 OCR;掃描圖片或損壞的文字層可能搜尋不到。
150
157
  - 同段落內的多次命中合併為一筆;段落依文字行與版面位置推估,不跨頁搜尋,分欄及複雜版面可能有段落差異。
151
- - 視覺換行會合併;中日文字之間不補空格,其餘續行以空格銜接。
158
+ - 支援同一段落內的跨行搜尋:視覺換行會合併,中日文字之間不補空格,其餘續行以空格銜接;跨行命中會標示對應各行的文字。
152
159
  - 規則表達式採 Python 相容語法;無效規則會顯示錯誤,零長度位置不列為可高亮的命中。
153
160
  - 每段正則匹配最多 1 秒;逾時會停止搜尋並標示結果不完整。也可按「停止」保留目前已找到的結果。
154
161
  - 可拖曳右側窗格寬度與上下結果區的分隔線;搜尋不改動選頁、排序或縮放模式。
155
162
  - 視窗寬度小於 640px 時,搜尋與 PDF 改為單一窗格切換;點結果後顯示 PDF,再點搜尋按鈕可返回結果。
156
163
  - 視窗較矮時,從三點「選項」選單調整範圍、規則表達式、區分大小寫與僅限單字設定。
164
+ - 點選搜尋選項列的色塊按鈕可設定命中標示顏色;較矮視窗可從「選項 → 命中標示顏色」開啟。變更會立即更新現有標示,無須重新搜尋,並套用至全螢幕與之後載入的頁面;選擇會記住,取消選色不會變更設定。
157
165
  - 關閉搜尋窗格會停止搜尋並清除高亮,保留輸入與結果;文件關閉時會移除其結果。
158
166
  - 全螢幕使用搜尋快捷鍵時,會返回主視窗並開啟搜尋窗格。
159
167
 
@@ -181,7 +189,7 @@ repdf
181
189
  ### 複製文字、區域 OCR 與擷取圖片
182
190
 
183
191
  - 三種模式互斥;一般預覽與全螢幕皆可使用。
184
- - 啟用時按鈕會顯示選取底色;關閉後恢復拖放排序。
192
+ - 啟用時按鈕以 hover 底色與強調色圖示標示,不顯示外框;關閉後恢復拖放排序。
185
193
  - 複製文字:啟用後拖曳選取,放開滑鼠即可複製;掃描影像中的文字請使用區域 OCR。
186
194
  - 區域 OCR:啟用後拖曳矩形範圍,放開滑鼠後辨識並複製;空白範圍保留原剪貼簿。
187
195
  - 擷取圖片:啟用後點選內嵌點陣圖片,再選擇位置另存為 PNG。
@@ -197,6 +205,7 @@ repdf
197
205
 
198
206
  - 介面語言:跟隨系統 → 繁體中文 → English → 跟隨系統。系統顯示語言為中文時使用繁體中文,其他語言使用 English;tooltip 顯示目前模式與實際語言。
199
207
  - 介面配色:跟隨系統 → 淺色 → 深色 → 跟隨系統。手動指定配色後不受系統配色變化影響,回到系統模式則即時跟隨。
208
+ - 深色配色採《新世紀福音戰士》初號機風格,以紫黑背景、紫色面板、螢光綠強調色及少量橙色呈現;PDF 頁面保留原始顏色。
200
209
 
201
210
  - 語言與配色的選擇會記住,重新啟動仍保留。
202
211
  - 切換語言會更新既有頁面標籤、工具列、tooltip、狀態與對話框。
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "repdf"
3
- version = "0.0.17"
3
+ version = "0.1.0"
4
4
  description = "RePDF (Read the PDF): a desktop PDF reader with printing, search, bookmarks, OCR and page rearrangement."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "repdf"
3
- version = "0.0.17"
3
+ version = "0.1.0"
4
4
  description = "RePDF (Read the PDF): a desktop PDF reader with printing, search, bookmarks, OCR and page rearrangement."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -332,10 +332,9 @@ class DocumentView(QWidget):
332
332
  return
333
333
  page, rect = self._search_navigation
334
334
  label = self.pages.ensure_page(page).preview
335
- if self.pages.virtual:
336
- self.scroll_area.ensureWidgetVisible(label, 40, 40)
337
- if label.pixmap().isNull():
338
- return
335
+ # Scroll using the placeholder geometry before its image is available.
336
+ # On-demand rendering only starts once the target enters the viewport;
337
+ # the render callback then refines this position with the actual size.
339
338
  from PySide6.QtCore import QPoint
340
339
  point = label.mapTo(self.grid_host, QPoint(round((rect[0] + rect[2]) / 2 * label.width()),
341
340
  round((rect[1] + rect[3]) / 2 * label.height())))
@@ -800,6 +799,9 @@ class MainWindow(QMainWindow):
800
799
  for action in self.toolbar.actions():
801
800
  button = self.toolbar.widgetForAction(action)
802
801
  if isinstance(button, QToolButton):
802
+ if action.isCheckable():
803
+ button.setProperty('stateButton', True)
804
+ button.setAttribute(Qt.WidgetAttribute.WA_Hover, True)
803
805
  if button is self.zoom_display:
804
806
  button.setFixedHeight(34)
805
807
  else:
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M3.5 8 6.5 11 12.5 5" fill="none" stroke="#13190d" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M4 8h8" stroke="#13190d" stroke-width="2" stroke-linecap="round"/></svg>
@@ -7,14 +7,17 @@ from PySide6.QtWidgets import QApplication
7
7
 
8
8
  def toolbar_icon(kind: str) -> QIcon:
9
9
  icon = QIcon()
10
- for mode, group in ((QIcon.Mode.Normal, QPalette.ColorGroup.Active),
11
- (QIcon.Mode.Disabled, QPalette.ColorGroup.Disabled)):
10
+ for mode, group, state, role in (
11
+ (QIcon.Mode.Normal, QPalette.ColorGroup.Active, QIcon.State.Off, QPalette.ColorRole.ButtonText),
12
+ (QIcon.Mode.Normal, QPalette.ColorGroup.Active, QIcon.State.On, QPalette.ColorRole.Highlight),
13
+ (QIcon.Mode.Disabled, QPalette.ColorGroup.Disabled, QIcon.State.Off, QPalette.ColorRole.ButtonText),
14
+ (QIcon.Mode.Disabled, QPalette.ColorGroup.Disabled, QIcon.State.On, QPalette.ColorRole.ButtonText)):
12
15
  pixmap = QPixmap(48, 48)
13
16
  pixmap.fill(Qt.GlobalColor.transparent)
14
17
  painter = QPainter(pixmap)
15
18
  painter.setRenderHint(QPainter.RenderHint.Antialiasing)
16
19
  painter.scale(2, 2)
17
- painter.setPen(QPen(QApplication.palette().color(group, QPalette.ColorRole.ButtonText),
20
+ painter.setPen(QPen(QApplication.palette().color(group, role),
18
21
  1.0, Qt.PenStyle.SolidLine, Qt.PenCapStyle.RoundCap,
19
22
  Qt.PenJoinStyle.RoundJoin))
20
23
  if kind == "more":
@@ -158,5 +161,7 @@ def toolbar_icon(kind: str) -> QIcon:
158
161
  if kind == "zoom_in":
159
162
  painter.drawLine(9, 6, 9, 13)
160
163
  painter.end()
161
- icon.addPixmap(pixmap, mode)
164
+ icon.addPixmap(pixmap, mode, state)
165
+ if mode == QIcon.Mode.Normal:
166
+ icon.addPixmap(pixmap, QIcon.Mode.Active, state)
162
167
  return icon
@@ -142,6 +142,7 @@ class PageViewport:
142
142
 
143
143
  def prepare_card(self, card):
144
144
  d = self.doc
145
+ card.preview.set_search_highlight_color(d.owner.search_controller.highlight_color)
145
146
  width, height = self.dimensions(card.page_index)
146
147
  card.set_preview_size(width, height)
147
148
  card.set_selected(card.page_index in d.selected_pages)
@@ -304,6 +305,12 @@ class PageViewport:
304
305
  return
305
306
  scale = self.batch_scale or self.scale()
306
307
  old_size = d.page_sizes.get(page)
308
+ # Nearby pages can change the grid geometry after the hit page renders.
309
+ # Keep a visible search destination aligned, but do not pull the user
310
+ # back after they have scrolled away from it.
311
+ navigation = d._search_navigation
312
+ navigation_visible = (navigation is not None
313
+ and self.rect(navigation[0]).intersects(self.visible_rect()))
307
314
  d.page_links[page] = payload.get('links', [])
308
315
  d.page_labels[page] = payload.get('page_label')
309
316
  d.page_sizes[page] = (float(payload.get('width_points', image.width() / scale)),
@@ -322,7 +329,7 @@ class PageViewport:
322
329
  if d.fit_mode and page == d.fit_page_index:
323
330
  d.fit_timer.start()
324
331
  QTimer.singleShot(0, d._scroll_to_fit_page)
325
- if d._search_navigation and page == d._search_navigation[0]:
332
+ if navigation and (page == navigation[0] or (old_size != d.page_sizes[page] and navigation_visible)):
326
333
  QTimer.singleShot(0, d._scroll_to_search_result)
327
334
  d.owner._sync_controls()
328
335
 
@@ -65,6 +65,7 @@ class FullscreenPreview(QWidget):
65
65
  for index in self.visible_pages:
66
66
  self.images[index] = self.document.page_cards[index].preview.pixmap().toImage()
67
67
  label = PagePreviewLabel('', draggable=False)
68
+ label.set_search_highlight_color(self.owner.search_controller.highlight_color)
68
69
  label.setParent(self)
69
70
  source_label = self.document.page_cards[index].preview
70
71
  label.set_links(self.document.page_links.get(index, []))
@@ -2,10 +2,10 @@
2
2
 
3
3
  from html import escape
4
4
 
5
- from PySide6.QtCore import QEvent, QObject, QSize, Qt, QTimer
6
- from PySide6.QtGui import QAction, QActionGroup
5
+ from PySide6.QtCore import QEvent, QObject, QSize, Qt, QTimer, Signal
6
+ from PySide6.QtGui import QAction, QActionGroup, QColor, QIcon, QPainter, QPixmap
7
7
  from PySide6.QtWidgets import (
8
- QAbstractItemView, QComboBox, QHBoxLayout, QLabel, QLayout, QLineEdit, QListView, QListWidget,
8
+ QAbstractItemView, QColorDialog, QComboBox, QHBoxLayout, QLabel, QLayout, QLineEdit, QListView, QListWidget,
9
9
  QListWidgetItem, QMenu, QSplitter, QStyle, QStyledItemDelegate, QStyleOptionViewItem,
10
10
  QToolButton, QVBoxLayout, QWidget,
11
11
  )
@@ -53,6 +53,8 @@ class ParagraphDelegate(QStyledItemDelegate):
53
53
 
54
54
 
55
55
  class SearchPanel(QWidget):
56
+ highlight_color_changed = Signal(str)
57
+
56
58
  def _button(self, kind, label):
57
59
  button = QToolButton()
58
60
  button.setText(tr(label))
@@ -73,6 +75,7 @@ class SearchPanel(QWidget):
73
75
  layout.setSpacing(6)
74
76
  layout.setSizeConstraint(QLayout.SizeConstraint.SetNoConstraint)
75
77
  self._icon_buttons = []
78
+ self.highlight_color = '#ffe13c'
76
79
  self.close_button = self._button('close', '關閉搜尋窗格')
77
80
  row = QHBoxLayout()
78
81
  self.query = QLineEdit()
@@ -103,9 +106,14 @@ class SearchPanel(QWidget):
103
106
  for button in (self.regular_expression, self.case_sensitive, self.whole_word):
104
107
  button.setObjectName('searchOptionButton')
105
108
  button.setCheckable(True)
109
+ button.setProperty('stateButton', True)
110
+ button.setAttribute(Qt.WidgetAttribute.WA_Hover, True)
106
111
  options.addWidget(self.regular_expression)
107
112
  options.addWidget(self.case_sensitive)
108
113
  options.addWidget(self.whole_word)
114
+ self.highlight_color_button = self._button('highlight_color', '命中標示顏色')
115
+ self.highlight_color_button.clicked.connect(self.choose_highlight_color)
116
+ options.addWidget(self.highlight_color_button)
109
117
  layout.addWidget(self.options_box)
110
118
  status_row = QHBoxLayout()
111
119
  self.compact_options = self._button('more', '選項')
@@ -129,6 +137,8 @@ class SearchPanel(QWidget):
129
137
  action.toggled.connect(button.setChecked)
130
138
  button.toggled.connect(action.setChecked)
131
139
  menu.addAction(action)
140
+ self.highlight_color_action = menu.addAction(tr('命中標示顏色'))
141
+ self.highlight_color_action.triggered.connect(self.choose_highlight_color)
132
142
  self.compact_options.setMenu(menu)
133
143
  self.compact_options.hide()
134
144
  status_row.addWidget(self.compact_options)
@@ -161,7 +171,38 @@ class SearchPanel(QWidget):
161
171
 
162
172
  def refresh_icons(self):
163
173
  for button, kind in self._icon_buttons:
164
- button.setIcon(toolbar_icon(kind))
174
+ button.setIcon(self._highlight_icon() if kind == 'highlight_color' else toolbar_icon(kind))
175
+ if hasattr(self, 'highlight_color_action'):
176
+ self.highlight_color_action.setIcon(self._highlight_icon())
177
+
178
+ def _highlight_icon(self):
179
+ pixmap = QPixmap(48, 48)
180
+ pixmap.fill(Qt.GlobalColor.transparent)
181
+ painter = QPainter(pixmap)
182
+ painter.scale(2, 2)
183
+ painter.setRenderHint(QPainter.RenderHint.Antialiasing)
184
+ painter.setPen(self.palette().buttonText().color())
185
+ painter.setBrush(QColor(self.highlight_color))
186
+ painter.drawRoundedRect(4, 4, 16, 16, 2, 2)
187
+ painter.end()
188
+ return QIcon(pixmap)
189
+
190
+ def set_highlight_color(self, color):
191
+ color = QColor(str(color))
192
+ if not color.isValid():
193
+ color = QColor('#ffe13c')
194
+ value = color.name()
195
+ changed = value != self.highlight_color
196
+ self.highlight_color = value
197
+ self.refresh_icons()
198
+ if changed:
199
+ self.highlight_color_changed.emit(value)
200
+
201
+ def choose_highlight_color(self):
202
+ color = QColorDialog.getColor(QColor(self.highlight_color), self, tr('命中標示顏色'),
203
+ QColorDialog.ColorDialogOption.DontUseNativeDialog)
204
+ if color.isValid():
205
+ self.set_highlight_color(color.name())
165
206
 
166
207
  def changeEvent(self, event):
167
208
  super().changeEvent(event)
@@ -174,6 +215,7 @@ class SearchPanel(QWidget):
174
215
  self.scope.setItemText(i, tr(label))
175
216
  self.scope_actions[i].setText(tr(label))
176
217
  self.scope_menu.setTitle(tr('搜尋範圍'))
218
+ self.highlight_color_action.setText(tr('命中標示顏色'))
177
219
  self.scope.setCurrentIndex(index)
178
220
  self.query.setPlaceholderText(tr('輸入文字或規則表達式'))
179
221
 
@@ -214,6 +256,9 @@ class SearchController(QObject):
214
256
  self._refresh_timer.setInterval(100)
215
257
  self._refresh_timer.timeout.connect(self._refresh_files)
216
258
  p = self.panel
259
+ p.set_highlight_color(owner.settings.value('search/highlight_color', '#ffe13c'))
260
+ self.highlight_color = p.highlight_color
261
+ p.highlight_color_changed.connect(self._set_highlight_color)
217
262
  p.query.returnPressed.connect(self.start)
218
263
  p.search_button.clicked.connect(self.start)
219
264
  p.stop_button.clicked.connect(self.stop)
@@ -222,6 +267,17 @@ class SearchController(QObject):
222
267
  p.paragraphs.itemClicked.connect(self._activate_item)
223
268
  p.paragraphs.itemActivated.connect(self._activate_item)
224
269
 
270
+ def _set_highlight_color(self, color):
271
+ self.highlight_color = color
272
+ self.owner.settings.setValue('search/highlight_color', color)
273
+ for doc in self.owner.documents.values():
274
+ for card in doc.page_cards:
275
+ card.preview.set_search_highlight_color(color)
276
+ viewer = self.owner._fullscreen_preview
277
+ if viewer is not None:
278
+ for label in viewer.labels.values():
279
+ label.set_search_highlight_color(color)
280
+
225
281
  def open(self):
226
282
  self.owner.navigation.close()
227
283
  if self.owner._fullscreen_preview is not None:
@@ -112,6 +112,7 @@ ENGLISH = {
112
112
  "規則表達式": "Regular expression",
113
113
  "區分大小寫": "Match case",
114
114
  "僅限單字": "Whole words only",
115
+ "命中標示顏色": "Match highlight color",
115
116
  "輸入條件後按 Enter 或搜尋鈕": "Press Enter or Search to start",
116
117
  "有命中的檔案": "Files with matches",
117
118
  "命中段落": "Matching paragraphs",
@@ -30,16 +30,20 @@ class ThemeController(QObject):
30
30
  palette = QPalette()
31
31
  colors = (
32
32
  {
33
- QPalette.ColorRole.Window: "#202124",
34
- QPalette.ColorRole.WindowText: "#f1f3f4",
35
- QPalette.ColorRole.Base: "#17181a",
36
- QPalette.ColorRole.AlternateBase: "#292a2d",
37
- QPalette.ColorRole.Text: "#f1f3f4",
38
- QPalette.ColorRole.Button: "#303134",
39
- QPalette.ColorRole.ButtonText: "#f1f3f4",
40
- QPalette.ColorRole.Highlight: "#8ab4f8",
41
- QPalette.ColorRole.HighlightedText: "#202124",
42
- QPalette.ColorRole.PlaceholderText: "#9aa0a6",
33
+ QPalette.ColorRole.Window: "#171321",
34
+ QPalette.ColorRole.WindowText: "#eee7f7",
35
+ QPalette.ColorRole.Base: "#100e18",
36
+ QPalette.ColorRole.AlternateBase: "#261d38",
37
+ QPalette.ColorRole.Text: "#eee7f7",
38
+ QPalette.ColorRole.Button: "#34264f",
39
+ QPalette.ColorRole.ButtonText: "#eee7f7",
40
+ QPalette.ColorRole.Highlight: "#a8ed42",
41
+ QPalette.ColorRole.HighlightedText: "#13190d",
42
+ QPalette.ColorRole.PlaceholderText: "#b5a7c5",
43
+ QPalette.ColorRole.Link: "#ff9d45",
44
+ QPalette.ColorRole.LinkVisited: "#c3a1ed",
45
+ QPalette.ColorRole.ToolTipBase: "#2b2142",
46
+ QPalette.ColorRole.ToolTipText: "#eee7f7",
43
47
  }
44
48
  if dark
45
49
  else {
@@ -57,23 +61,22 @@ class ThemeController(QObject):
57
61
  )
58
62
  for role, color in colors.items():
59
63
  palette.setColor(role, QColor(color))
60
- palette.setColor(
61
- QPalette.ColorGroup.Disabled,
62
- QPalette.ColorRole.ButtonText,
63
- QColor("#777b80" if dark else "#9aa0a6"),
64
- )
64
+ disabled = "#8f829f" if dark else "#9aa0a6"
65
+ palette.setColor(QPalette.ColorGroup.Disabled, QPalette.ColorRole.ButtonText, QColor(disabled))
66
+ if dark:
67
+ for role in (QPalette.ColorRole.WindowText, QPalette.ColorRole.Text):
68
+ palette.setColor(QPalette.ColorGroup.Disabled, role, QColor(disabled))
65
69
  self.app.setPalette(palette)
66
- border = "#4a4d51" if dark else "#d5d8dc"
67
- card = "#292a2d" if dark else "#ffffff"
68
- slider_track = "#5f6368" if dark else "#c4c7c5"
69
- slider_fill = "#8ab4f8" if dark else "#0b57d0"
70
- slider_handle = "#aecbfa" if dark else "#0b57d0"
71
- hover = "#35383d" if dark else "#e7ebf0"
72
- pressed = "#41464e" if dark else "#d8e3f3"
73
- selected_tool = "#294366" if dark else "#d8e7ff"
74
- disabled = "#777b80" if dark else "#9aa0a6"
75
- check = files("repdf").joinpath("assets", "check.svg").as_posix()
76
- partial = files("repdf").joinpath("assets", "partial.svg").as_posix()
70
+ border = "#625079" if dark else "#d5d8dc"
71
+ card = "#2b2142" if dark else "#ffffff"
72
+ slider_track = "#695580" if dark else "#c4c7c5"
73
+ slider_fill = "#a8ed42" if dark else "#0b57d0"
74
+ slider_handle = "#ff9d45" if dark else "#0b57d0"
75
+ hover = "#3b2a56" if dark else "#e7ebf0"
76
+ pressed = "#4d376e" if dark else "#d8e3f3"
77
+ mark_suffix = "-dark" if dark else ""
78
+ check = files("repdf").joinpath("assets", f"check{mark_suffix}.svg").as_posix()
79
+ partial = files("repdf").joinpath("assets", f"partial{mark_suffix}.svg").as_posix()
77
80
  self.app.setStyleSheet(
78
81
  f"""
79
82
  QFrame#pageCard {{ background: {card}; border: 1px solid {border};
@@ -92,10 +95,11 @@ class ThemeController(QObject):
92
95
  border-radius: 4px; padding: 4px; color: palette(button-text); }}
93
96
  QToolButton:hover {{ background: {hover}; }}
94
97
  QToolButton:pressed {{ background: {pressed}; }}
95
- QToolButton#copyTextTool:checked, QToolButton#regionOcrTool:checked, QToolButton#extractImageTool:checked,
96
- QToolButton#searchOptionButton:checked, QToolButton#bookmarksTool:checked {{ background: {selected_tool};
97
- border-color: {slider_fill}; }}
98
98
  QToolButton:focus {{ border-color: {slider_fill}; }}
99
+ QToolButton[stateButton="true"] {{ border-color: transparent; border-radius: 8px; }}
100
+ QToolButton[stateButton="true"]:checked {{ background: {hover}; border-color: transparent; }}
101
+ QToolButton[stateButton="true"]:checked:hover {{ background: {pressed}; }}
102
+ QToolButton[stateButton="true"]:disabled {{ background: transparent; }}
99
103
  QToolButton:disabled {{ color: {disabled}; background: transparent; }}
100
104
  QPushButton {{ background: {card}; color: palette(button-text);
101
105
  border: 1px solid {border}; border-radius: 5px;
@@ -110,9 +114,9 @@ class ThemeController(QObject):
110
114
  border: 1px solid {border}; border-radius: 3px;
111
115
  background: {card}; }}
112
116
  QCheckBox::indicator:hover {{ border-color: {slider_fill}; }}
113
- QCheckBox::indicator:checked {{ background: #0b57d0; border-color: #0b57d0;
117
+ QCheckBox::indicator:checked {{ background: {slider_fill}; border-color: {slider_fill};
114
118
  image: url("{check}"); }}
115
- QCheckBox::indicator:indeterminate {{ background: #0b57d0; border-color: #0b57d0;
119
+ QCheckBox::indicator:indeterminate {{ background: {slider_fill}; border-color: {slider_fill};
116
120
  image: url("{partial}"); }}
117
121
  QCheckBox::indicator:disabled {{ background: {hover}; border-color: {border}; }}
118
122
  QScrollArea {{ border: 1px solid {border}; border-radius: 6px; }}
@@ -250,6 +250,7 @@ class PagePreviewLabel(DragLabel):
250
250
  self.image_mode = False
251
251
  self._search_rects = []
252
252
  self._active_search_rects = []
253
+ self._search_color = QColor('#ffe13c')
253
254
  self._selection_start = None
254
255
  self._selection_end = None
255
256
  self._selecting = False
@@ -303,6 +304,11 @@ class PagePreviewLabel(DragLabel):
303
304
  self._active_search_rects = active
304
305
  self.update()
305
306
 
307
+ def set_search_highlight_color(self, color):
308
+ value = QColor(color)
309
+ self._search_color = value if value.isValid() else QColor('#ffe13c')
310
+ self.update()
311
+
306
312
  def _preview_selection(self) -> None:
307
313
  if not self.region_mode and not self.image_mode and self._selecting and self._selection_start is not None and self._selection_end is not None:
308
314
  self.selection_preview.emit(self._selection_start, self._selection_end)
@@ -370,8 +376,11 @@ class PagePreviewLabel(DragLabel):
370
376
  super().paintEvent(event)
371
377
  if self._search_rects:
372
378
  painter = QPainter(self)
373
- for boxes, color in ((self._search_rects, QColor(255, 225, 60, 100)),
374
- (self._active_search_rects, QColor(255, 170, 0, 115))):
379
+ normal = QColor(self._search_color)
380
+ normal.setAlpha(100)
381
+ active = self._search_color.darker(120)
382
+ active.setAlpha(115)
383
+ for boxes, color in ((self._search_rects, normal), (self._active_search_rects, active)):
375
384
  path = QPainterPath()
376
385
  path.setFillRule(Qt.FillRule.WindingFill)
377
386
  for left, top, right, bottom in boxes:
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes