Skip to content
Permalink
Browse files

Use lru_cache for make_icon, fix calls

  • Loading branch information
trou committed Mar 20, 2020
1 parent d63bb7c commit 3ac8133db2624d71525f645ad0645323fc6f86f3
Showing with 6 additions and 5 deletions.
  1. +1 −1 idarling/interface/filter.py
  2. +3 −2 idarling/interface/widget.py
  3. +2 −2 idarling/network/client.py
@@ -93,7 +93,7 @@ def invite_to_everyone():
menu.addAction(everyone)

menu.addSeparator()
template = QImage(self._plugin.plugin_resource("user.png"))
template = self._plugin.plugin_resource("user.png")

def create_action(name, color):
action = QAction(name, menu)
@@ -11,7 +11,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import colorsys
from functools import partial
from functools import partial, lru_cache
import time

from PyQt5.QtCore import QPoint, QRect, QSize, Qt, QTimer
@@ -44,6 +44,7 @@ def python_to_qt(r, g, b):
return 0xFF000000 | r | g | b

@staticmethod
@lru_cache(maxsize=32)
def make_icon(template, color):
"""
Create an icon for the specified user color. It will be used to
@@ -182,7 +183,7 @@ def refresh(self):
self._users_text_widget.adjustSize()

# Update the icon of the users widget
template = QImage(self._plugin.plugin_resource("user.png"))
template = self._plugin.plugin_resource("user.png")
color = self._plugin.config["user"]["color"]
pixmap = self.make_icon(template, color)
pixmap_height = self._servers_text_widget.sizeHint().height()
@@ -125,7 +125,7 @@ def _handle_join_session(self, packet):
if packet.silent:
return
text = "%s joined the session" % packet.name
template = QImage(self._plugin.plugin_resource("user.png"))
template = self._plugin.plugin_resource("user.png")
icon = StatusWidget.make_icon(template, packet.color)
self._plugin.interface.show_invite(text, icon)

@@ -139,7 +139,7 @@ def _handle_leave_session(self, packet):
if packet.silent:
return
text = "%s left the session" % packet.name
template = QImage(self._plugin.plugin_resource("user.png"))
template = self._plugin.plugin_resource("user.png")
icon = StatusWidget.make_icon(template, user["color"])
self._plugin.interface.show_invite(text, icon)

0 comments on commit 3ac8133

Please sign in to comment.
You can’t perform that action at this time.