Refactor code structure for improved readability and maintainability
This commit is contained in:
parent
e84f7bbd66
commit
939c2f896f
5 changed files with 23 additions and 2 deletions
BIN
resources/icons/home.ico
Normal file
BIN
resources/icons/home.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 135 KiB |
BIN
resources/icons/open.ico
Normal file
BIN
resources/icons/open.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 124 KiB |
BIN
resources/icons/openwith.ico
Normal file
BIN
resources/icons/openwith.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 146 KiB |
BIN
resources/icons/reload.ico
Normal file
BIN
resources/icons/reload.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 144 KiB |
|
|
@ -250,6 +250,12 @@ class OpenDropZone(QWidget):
|
|||
self.setMinimumSize(QSize(44, 44))
|
||||
self.setMaximumSize(QSize(48, 48))
|
||||
|
||||
def set_icon(self, icon: QIcon) -> None:
|
||||
"""Set the displayed icon for the drop zone widget."""
|
||||
if icon.isNull():
|
||||
return
|
||||
self._icon_label.setPixmap(icon.pixmap(QSize(32, 32)))
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Drop handling
|
||||
# ------------------------------------------------------------------
|
||||
|
|
@ -1263,19 +1269,34 @@ class MainWindow(QMainWindow):
|
|||
# Separator
|
||||
toolbar.addSeparator()
|
||||
|
||||
if hasattr(sys, "_MEIPASS"):
|
||||
icons_dir = Path(sys._MEIPASS) / "resources" / "icons" # type: ignore[attr-defined]
|
||||
else:
|
||||
icons_dir = Path(__file__).parent.parent.parent.parent / "resources" / "icons"
|
||||
|
||||
# Home button
|
||||
home_action = toolbar.addAction(
|
||||
self.style().standardIcon(self.style().StandardPixmap.SP_DirHomeIcon), ""
|
||||
home_icon_path = icons_dir / "home.ico"
|
||||
home_icon = (
|
||||
QIcon(str(home_icon_path))
|
||||
if home_icon_path.exists()
|
||||
else self.style().standardIcon(self.style().StandardPixmap.SP_DirHomeIcon)
|
||||
)
|
||||
home_action = toolbar.addAction(home_icon, "")
|
||||
home_action.setToolTip("Home")
|
||||
home_action.triggered.connect(self._navigate_home)
|
||||
|
||||
# Refresh button
|
||||
refresh_action = self.web_view.pageAction(self.web_view.page().WebAction.Reload)
|
||||
reload_icon_path = icons_dir / "reload.ico"
|
||||
if reload_icon_path.exists():
|
||||
refresh_action.setIcon(QIcon(str(reload_icon_path)))
|
||||
toolbar.addAction(refresh_action)
|
||||
|
||||
# Open-with-default-app drop zone (right of Reload)
|
||||
self._open_drop_zone = OpenDropZone()
|
||||
open_icon_path = icons_dir / "open.ico"
|
||||
if open_icon_path.exists():
|
||||
self._open_drop_zone.set_icon(QIcon(str(open_icon_path)))
|
||||
self._open_drop_zone.file_opened.connect(self._on_file_opened_via_drop)
|
||||
self._open_drop_zone.file_open_failed.connect(self._on_file_open_failed_via_drop)
|
||||
open_drop_action = QWidgetAction(toolbar)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue