getting menu to display properly in-progress
This commit is contained in:
@@ -7,7 +7,6 @@ import zipfile
|
||||
from pathlib import Path
|
||||
from queue import Queue
|
||||
import json
|
||||
from operator import itemgetter
|
||||
|
||||
import psutil
|
||||
from PyQt5 import QtCore, QtGui, QtNetwork, QtWebEngineWidgets, QtWidgets
|
||||
@@ -159,30 +158,31 @@ class InstallerWizard(QtWidgets.QWizard):
|
||||
def _populate_menu(self):
|
||||
"""Populates the selection menu with items loaded from supported_tools.json
|
||||
"""
|
||||
for name, info in self.__tools__.items():
|
||||
placement = [level.capitalize().strip() for level in info["category"].split(".") if level] + [name]
|
||||
for tool in sorted(self.__tools__, key = lambda x: x["category"] + f".{x['name']}"):
|
||||
placement = [level.capitalize().strip() for level in tool["category"].split(".") if level] + [tool["name"]]
|
||||
root = self.selection_menu.invisibleRootItem()
|
||||
children = [root.child(i) for i in range(root.childCount())]
|
||||
while placement:
|
||||
current_level = placement.pop()
|
||||
|
||||
if current_level in [child.text(0) for child in children]:
|
||||
if self.selection_menu.findItem(current_level, QtCore.Qt.MatchFixedString|QtCore.Qt.MatchCaseSensitive) in children:
|
||||
root = list(filter(lambda child: child.text(0) == current_level, children)).pop()
|
||||
children = [child for child in MenuIterator(root) if child in [root.child(i) for i in range(root.childCount())]]
|
||||
else:
|
||||
new_item = QtWidgets.QTreeWidgetItem(root, QtWidgets.QTreeWidgetItem.Type)
|
||||
new_item.setText(0, current_level)
|
||||
new_item.setFlags(QtCore.Qt.ItemIsSelectable|QtCore.Qt.ItemIsUserCheckable|QtCore.Qt.ItemIsEnabled)
|
||||
new_item.setCheckState(0, QtCore.Qt.Unchecked)
|
||||
if current_level == name:
|
||||
if current_level == tool["name"]:
|
||||
new_item.setFlags(new_item.flags()|QtCore.Qt.ItemNeverHasChildren)
|
||||
new_item.setData(1, QtCore.Qt.DecorationRole, QtGui.QIcon(str(Path(__file__).parent.parent/"resources/icons/internet-web-browser-4.png")))
|
||||
new_item.setData(1, QtCore.Qt.ToolTipRole, info["homepage"])
|
||||
new_item.setData(1, QtCore.Qt.ToolTipRole, tool["homepage"])
|
||||
try:
|
||||
self._get_icon(new_item, info["icon url"])
|
||||
self._get_icon(new_item, tool["icon url"])
|
||||
except KeyError:
|
||||
self._get_icon(new_item)
|
||||
try:
|
||||
if info["depends on"] == current_level: #tool depends on itself makes it mandatory
|
||||
if tool["depends on"] == current_level: #tool depends on itself makes it mandatory
|
||||
new_item.setFlags(new_item.flags()^QtCore.Qt.ItemIsUserCheckable)
|
||||
new_item.setCheckState(0, QtCore.Qt.Checked)
|
||||
except KeyError:
|
||||
@@ -195,11 +195,6 @@ class InstallerWizard(QtWidgets.QWizard):
|
||||
self.selection_menu.resizeColumnToContents(0)
|
||||
self.selection_menu.resizeColumnToContents(1)
|
||||
|
||||
def _create_placements(self):
|
||||
placements = [[level.capitalize().strip() for level in info["category"].split(".") if info["category"]] + [name] for name, info in self.__tools__.items()]
|
||||
for menu_placement in placements:
|
||||
self.__tools__[menu_placement[-1]]["placement"] = menu_placement
|
||||
|
||||
@QtCore.pyqtSlot("QTreeWidgetItem*", "int")
|
||||
def _open_homepage(self, item, column):
|
||||
"""Receives the itemClicked signal from the selection_menu QTreeWidget and if the user has clicked a homepage, opens it in a new browser tab.
|
||||
|
||||
Reference in New Issue
Block a user