aboutsummaryrefslogtreecommitdiffstats
path: root/muddle
diff options
context:
space:
mode:
authorNao Pross <np@0hm.ch>2022-11-16 22:59:29 +0100
committerNao Pross <np@0hm.ch>2022-11-16 22:59:29 +0100
commitb43e95c6780c49d2b88ab1dbea613ce9ab32798d (patch)
tree01a02bf3c3e3e4cc379fa398ec6e69314c4f02ce /muddle
parentUpdate to PyQt6 (diff)
downloadMuddle-b43e95c6780c49d2b88ab1dbea613ce9ab32798d.tar.gz
Muddle-b43e95c6780c49d2b88ab1dbea613ce9ab32798d.zip
Fix regression from upgrade to PyQt6
Diffstat (limited to 'muddle')
-rw-r--r--muddle/__main__.py2
-rw-r--r--muddle/gui.py28
-rw-r--r--muddle/moodle.py8
3 files changed, 22 insertions, 16 deletions
diff --git a/muddle/__main__.py b/muddle/__main__.py
index 25b243a..389bb60 100644
--- a/muddle/__main__.py
+++ b/muddle/__main__.py
@@ -102,7 +102,7 @@ config["runtime_data"]["config_path"] = str(config_file)
if args.version:
print(f"""Version {MUDDLE_VERSION}
-Muddle Copyright (C) 2020-2021 Nao Pross <np@0hm.ch>
+Muddle Copyright (C) 2020-2023 Nao Pross <np@0hm.ch>
This program comes with ABSOLUTELY NO WARRANTY; This is free software, and you
are welcome to redistribute it under certain conditions; see LICENSE.txt for
diff --git a/muddle/gui.py b/muddle/gui.py
index 0d85bbe..70f689d 100644
--- a/muddle/gui.py
+++ b/muddle/gui.py
@@ -1,6 +1,10 @@
#
# This document *and this document only* uses the Qt naming convention instead
-# of PEP because the PyQt5 bindings do not have pythonic names
+# of PEP because the PyQt6 bindings do not have pythonic names.
+#
+# See the link below for the official documentation of PyQt6:
+#
+# https://www.riverbankcomputing.com/static/Docs/PyQt6/index.html
#
import os
import platform
@@ -93,11 +97,11 @@ class MoodleItem(QStandardItem):
# set icon
icons = {
- MoodleItem.Type.COURSE : QStyle.SP_DriveNetIcon,
- MoodleItem.Type.FOLDER : QStyle.SP_DirIcon,
- MoodleItem.Type.RESOURCE : QStyle.SP_DirLinkIcon,
- MoodleItem.Type.FILE : QStyle.SP_FileIcon,
- MoodleItem.Type.URL : QStyle.SP_FileLinkIcon,
+ MoodleItem.Type.COURSE : QStyle.StandardPixmap.SP_DriveNetIcon,
+ MoodleItem.Type.FOLDER : QStyle.StandardPixmap.SP_DirIcon,
+ MoodleItem.Type.RESOURCE : QStyle.StandardPixmap.SP_DirLinkIcon,
+ MoodleItem.Type.FILE : QStyle.StandardPixmap.SP_FileIcon,
+ MoodleItem.Type.URL : QStyle.StandardPixmap.SP_FileLinkIcon,
}
if self.metadata.type in icons.keys():
@@ -111,7 +115,7 @@ class MoodleItem(QStandardItem):
# the tri-state behavior is implemented below in
# MuddleWindow.onMoodleTreeModelDataChanged()
self.setCheckable(True)
- self.setCheckState(Qt.Unchecked)
+ self.setCheckState(Qt.CheckState.Unchecked)
self.setEditable(False)
self.setText(html.unescape(self.metadata.title))
@@ -333,10 +337,9 @@ class MuddleWindow(QMainWindow):
moodleTreeView = self.findChild(QTreeView, "moodleTree")
moodleTreeView.setModel(self.filterModel)
moodleTreeView.setSortingEnabled(True)
- # FIXME: Broken by upgrade to PyQt6
- # moodleTreeView.sortByColumn(0, Qt.AscendingOrder)
+ moodleTreeView.sortByColumn(0, Qt.SortOrder.AscendingOrder)
## TODO: change with minimumSize (?)
- # moodleTreeView.header().setSectionResizeMode(0, QHeaderView.ResizeToContents)
+ moodleTreeView.header().setSectionResizeMode(0, QHeaderView.ResizeMode.ResizeToContents)
moodleTreeView.doubleClicked.connect(self.onMoodleTreeViewDoubleClicked)
## refresh moodle treeview
@@ -376,8 +379,7 @@ class MuddleWindow(QMainWindow):
localTreeView = self.findChild(QTreeView, "localTab")
localTreeView.setModel(self.fileSystemModel)
localTreeView.setRootIndex(self.fileSystemModel.index(QDir.homePath()))
- # FIXME: Broken by upgrade to PyQt6
- # localTreeView.header().setSectionResizeMode(0, QHeaderView.ResizeToContents)
+ localTreeView.header().setSectionResizeMode(0, QHeaderView.ResizeMode.ResizeToContents)
downloadPathEdit = self.findChild(QLineEdit, "downloadPathEdit")
downloadPathEdit.setText(self.downloadPath)
@@ -442,7 +444,7 @@ class MuddleWindow(QMainWindow):
def onSelectPathBtnClicked(self):
path = QFileDialog.getExistingDirectory(
self, "Select Download Directory",
- self.downloadPath, QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks)
+ self.downloadPath, QFileDialog.Option.ShowDirsOnly | QFileDialog.Option.DontResolveSymlinks)
if not path:
return
diff --git a/muddle/moodle.py b/muddle/moodle.py
index a9a2c4c..489f50a 100644
--- a/muddle/moodle.py
+++ b/muddle/moodle.py
@@ -59,10 +59,14 @@ class MoodleInstance:
"""
def __init__(self, url, token):
self.api = RestApi(url, token)
+ self.userid = None
def get_userid(self):
- req = self.api.core_webservice_get_site_info()
- return req.json()["userid"]
+ if self.userid is None:
+ req = self.api.core_webservice_get_site_info()
+ self.userid = req.json()["userid"]
+
+ return self.userid
def get_enrolled_courses(self):
req = self.api.core_enrol_get_users_courses(userid=self.get_userid())