17
17
QFrame ,
18
18
QShortcut ,
19
19
QApplication ,
20
+ QStyle ,
20
21
)
21
22
from qtpy .QtWebEngineWidgets import QWebEngineView , QWebEngineSettings
22
23
from qtpy .QtCore import QUrl , Qt , QEvent
23
24
from qtpy .QtGui import QIcon , QKeySequence
25
+ from pathlib import Path
24
26
25
27
# Attempt to import QWebEnginePage in a way that works across different Qt bindings/versions
26
28
try :
@@ -110,25 +112,25 @@ def __init__(self, presenter, interceptor=None):
110
112
# ---------------------------------
111
113
112
114
# Back
113
- self .backButton .setIcon (QIcon . fromTheme ( "go-previous" , QIcon ( ":/qt-project.org/styles/commonstyle/images/left-arrow-32.png" ) ))
115
+ self .backButton .setIcon (self . style (). standardIcon ( QStyle . SP_ArrowBack ))
114
116
self .backButton .setToolTip ("Go Back" )
115
117
self .backButton .clicked .connect (self .browser .back )
116
118
self .toolbar .addWidget (self .backButton )
117
119
118
120
# Forward
119
- self .forwardButton .setIcon (QIcon . fromTheme ( "go-next" , QIcon ( ":/qt-project.org/styles/commonstyle/images/right-arrow-32.png" ) ))
121
+ self .forwardButton .setIcon (self . style (). standardIcon ( QStyle . SP_ArrowForward ))
120
122
self .forwardButton .setToolTip ("Go Forward" )
121
123
self .forwardButton .clicked .connect (self .browser .forward )
122
124
self .toolbar .addWidget (self .forwardButton )
123
125
124
126
# Home
125
- self .homeButton .setIcon (QIcon . fromTheme ( "go- home" , QIcon ( ":/qt-project.org/styles/commonstyle/images/home-32. png") ))
127
+ self .homeButton .setIcon (self . get_mantid_icon ( " home. png" ))
126
128
self .homeButton .setToolTip ("Go to Home Page" )
127
129
self .homeButton .clicked .connect (self .on_home_clicked )
128
130
self .toolbar .addWidget (self .homeButton )
129
131
130
132
# Reload
131
- self .reloadButton .setIcon (QIcon . fromTheme ( "view-refresh" , QIcon ( ":/qt-project.org/styles/commonstyle/images/refresh-32.png" ) ))
133
+ self .reloadButton .setIcon (self . style (). standardIcon ( QStyle . SP_BrowserReload ))
132
134
self .reloadButton .setToolTip ("Reload Current Page" )
133
135
self .reloadButton .clicked .connect (self .browser .reload )
134
136
self .toolbar .addWidget (self .reloadButton )
@@ -139,7 +141,7 @@ def __init__(self, presenter, interceptor=None):
139
141
140
142
# Find button in toolbar
141
143
self .findButton = QPushButton ()
142
- self .findButton .setIcon (QIcon . fromTheme ( "edit-find" , QIcon ( ":/qt-project.org/styles/commonstyle/images/find-32. png") ))
144
+ self .findButton .setIcon (self . get_mantid_icon ( "search. png" ))
143
145
self .findButton .setToolTip ("Find in Page (Ctrl+F)" )
144
146
self .findButton .clicked .connect (self .show_find_toolbar )
145
147
self .toolbar .addWidget (self .findButton )
@@ -168,6 +170,22 @@ def __init__(self, presenter, interceptor=None):
168
170
169
171
QApplication .instance ().installEventFilter (self )
170
172
173
+ def get_mantid_icon (self , filename ):
174
+ """Get icon from mantid/images directory"""
175
+ current_file = Path (__file__ ).resolve ()
176
+
177
+ # Find mantid root directory
178
+ for parent in current_file .parents :
179
+ if parent .name == "mantid" :
180
+ images_dir = parent / "images"
181
+ icon_path = images_dir / filename
182
+
183
+ if icon_path .exists ():
184
+ return QIcon (str (icon_path ))
185
+ break
186
+
187
+ return QIcon () # Return empty if not found
188
+
171
189
def setup_find_toolbar (self , parent_layout ):
172
190
"""Create and setup the find toolbar widget."""
173
191
self .find_frame = QFrame ()
0 commit comments