|
8 | 8 | import importlib.util |
9 | 9 |
|
10 | 10 | from PyQt5.QtCore import Qt, QThread, pyqtSignal |
11 | | -from PyQt5.QtGui import QFont |
| 11 | +from PyQt5.QtGui import QIcon, QFont |
12 | 12 | from PyQt5.QtWidgets import ( |
13 | 13 | QApplication, QMainWindow, QVBoxLayout, QHBoxLayout, QAction, QWidget, |
14 | 14 | QDialog, QLineEdit, QFormLayout, QDialogButtonBox, QMessageBox, QMenu, |
|
19 | 19 |
|
20 | 20 |
|
21 | 21 |
|
22 | | -""" Utility function to load plugins """ |
| 22 | +""" Utility function to load icons """ |
| 23 | +def load_icon(icon_name): |
| 24 | + icon_path = os.path.join(os.path.dirname(__file__), icon_name) |
| 25 | + if getattr(sys, 'frozen', False): |
| 26 | + icon_path = os.path.join(sys._MEIPASS, icon_name) |
| 27 | + if os.path.exists(icon_path): |
| 28 | + return QIcon(icon_path) |
| 29 | + return None |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | +""" Utility function to load plugins |
| 34 | +
|
| 35 | +This function checks for a "Resmonplugins" directory located in your user folder. |
| 36 | +If the folder doesn't exist, it creates it. It then loads every Python file in the |
| 37 | +folder (ignoring files starting with an underscore) and, if the module defines a |
| 38 | +"register_plugin(app_context)" function, calls it. The app_context is a dictionary |
| 39 | +containing a reference to the main window, so plugins can integrate with Construct |
| 40 | +(e.g., by adding menu items). Plugins should be written in Python. They do not |
| 41 | +require a separate Python installation. |
| 42 | +""" |
23 | 43 | def load_plugins(app_context): |
24 | 44 | user_home = os.path.expanduser("~") |
25 | | - plugins_dir = os.path.join(user_home, "rmplugins") |
| 45 | + plugins_dir = os.path.join(user_home, "resmonplugins") |
26 | 46 | os.makedirs(plugins_dir, exist_ok=True) |
27 | 47 | loaded_plugins = [] |
28 | 48 | for filename in os.listdir(plugins_dir): |
@@ -162,6 +182,7 @@ class Resmon(QMainWindow): |
162 | 182 | def __init__(self): |
163 | 183 | super().__init__() |
164 | 184 | self.setWindowTitle("Resmon") |
| 185 | + self.setWindowIcon(load_icon('resmon.png')) |
165 | 186 | self.setGeometry(100, 100, 770, 700) |
166 | 187 | self.always_on_top = False |
167 | 188 | self.selected_pid = None |
|
0 commit comments