Skip to content

Commit

Permalink
Fixed the change download files action accessing the old tree view
Browse files Browse the repository at this point in the history
  • Loading branch information
qstokkink committed Dec 11, 2023
1 parent 0d9a839 commit c02c442
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ def __init__(self):
'explore_download': (lambda: ExploreDownloadAction(), 10),
'screenshot': (lambda: ScreenshotAction(), 5),
'change_anonymity': (lambda: ChangeAnonymityAction(allow_plain=True), 5),
# See: https://github.com/Tribler/tribler/issues/7750
# 'change_download_files': (lambda: ChangeDownloadFilesAction(), 10)
'change_download_files': (lambda: ChangeDownloadFilesAction(), 10)
}

def get_random_action_with_probability(self) -> Optional[Action]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,27 @@ def __init__(self):
self.add_action(WaitAction(2000))
self.add_action(CustomAction("""
tree_view = window.download_files_list
if tree_view.topLevelItemCount() == 0:
if tree_view.rowCount() == 0:
exit_script()
item = tree_view.topLevelItem(randint(0, tree_view.topLevelItemCount() - 1))
check_state = Qt.Checked if item.checkState(CHECKBOX_COL) == Qt.Unchecked else Qt.Unchecked
item.setCheckState(CHECKBOX_COL, check_state)
QMetaObject.invokeMethod(tree_view, "itemClicked", Q_ARG(QTreeWidgetItem, item), Q_ARG(int, CHECKBOX_COL))
tree_view.selectRow(0)
item = tree_view.item(0, 1)
QMetaObject.invokeMethod(tree_view, "itemClicked", Q_ARG(QTableWidgetItem, item))
"""))
self.add_action(WaitAction(2000))
self.add_action(CustomAction("""
tree_view = window.download_files_list
if tree_view.rowCount() == 0:
exit_script()
item = tree_view.item(randint(0, tree_view.rowCount() - 1), 0)
check_state = Qt.Checked if item.checkState() == Qt.Unchecked else Qt.Unchecked
item.setCheckState(check_state)
QMetaObject.invokeMethod(tree_view, "itemClicked", Q_ARG(QTableWidgetItem, item))
"""))

def required_imports(self):
return [
"from random import randint",
"from PyQt5.QtCore import QMetaObject, Q_ARG, Qt",
"from PyQt5.QtWidgets import QTreeWidgetItem",
"from PyQt5.QtWidgets import QTableWidgetItem",
"from tribler.gui.widgets.torrentfiletreewidget import CHECKBOX_COL"
]

0 comments on commit c02c442

Please sign in to comment.