Skip to content

Commit

Permalink
updated all references
Browse files Browse the repository at this point in the history
  • Loading branch information
JTvD committed Dec 23, 2024
1 parent 6f0bb47 commit 3a1d0aa
Show file tree
Hide file tree
Showing 12 changed files with 195 additions and 165 deletions.
26 changes: 15 additions & 11 deletions ibridgesgui/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import sys
from pathlib import Path

import PyQt6.QtGui
import PyQt6.QtWidgets
import PyQt6.uic
import PySide6.QtGui
import PySide6.QtWidgets
import PySide6.QtUiTools
import setproctitle

from ibridgesgui.browser import Browser
Expand All @@ -18,6 +18,7 @@
from ibridgesgui.popup_widgets import CheckConfig
from ibridgesgui.search import Search
from ibridgesgui.sync import Sync
from ibridgesgui.gui_utils import UI_FILE_DIR, load_ui
from ibridgesgui.ui_files.MainMenu import Ui_MainWindow
from ibridgesgui.welcome import Welcome

Expand All @@ -30,16 +31,19 @@
THIS_APPLICATION = "ibridges-gui"

# Application globals
app = PyQt6.QtWidgets.QApplication(sys.argv)
app = PySide6.QtWidgets.QApplication(sys.argv)


class MainMenu(PyQt6.QtWidgets.QMainWindow, Ui_MainWindow):
class MainMenu(PySide6.QtWidgets.QMainWindow, Ui_MainWindow):
"""Set up the GUI Main Menu."""

def __init__(self, app_name):
"""Initialise the main window."""
super().__init__()
super().setupUi(self)
if getattr(sys, "frozen", False) or ("__compiled__" in globals()):
super().setupUi(self)
else:
load_ui(UI_FILE_DIR / "MainMenu.ui", self)

app.aboutToQuit.connect(self.close_event)

Expand Down Expand Up @@ -101,14 +105,14 @@ def connect(self):
def exit(self):
"""Quit program."""
quit_msg = "Are you sure you want to exit the program?"
reply = PyQt6.QtWidgets.QMessageBox.question(
reply = PySide6.QtWidgets.QMessageBox.question(
self,
"Message",
quit_msg,
PyQt6.QtWidgets.QMessageBox.StandardButton.Yes,
PyQt6.QtWidgets.QMessageBox.StandardButton.No,
PySide6.QtWidgets.QMessageBox.StandardButton.Yes,
PySide6.QtWidgets.QMessageBox.StandardButton.No,
)
if reply == PyQt6.QtWidgets.QMessageBox.StandardButton.Yes:
if reply == PySide6.QtWidgets.QMessageBox.StandardButton.Yes:
self.disconnect()
sys.exit()
else:
Expand Down Expand Up @@ -182,7 +186,7 @@ def main():
set_log_level("debug")
init_logger(THIS_APPLICATION, "debug")
ensure_irods_location()
main_widget = PyQt6.QtWidgets.QStackedWidget()
main_widget = PySide6.QtWidgets.QStackedWidget()
main_app = MainMenu(THIS_APPLICATION)
main_widget.addWidget(main_app)
main_widget.show()
Expand Down
24 changes: 12 additions & 12 deletions ibridgesgui/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
from typing import Union

import irods.exception
import PyQt6.QtCore
import PyQt6.QtGui
import PyQt6.QtWidgets
import PyQt6.uic
import PySide6.QtCore
import PySide6.QtGui
import PySide6.QtWidgets
from ibridges import IrodsPath
from ibridges.permissions import Permissions
from ibridges.util import obj_replicas
Expand All @@ -18,12 +17,13 @@
get_irods_item,
populate_table,
populate_textfield,
load_ui
)
from ibridgesgui.popup_widgets import CreateCollection, DownloadData, Rename, UploadData
from ibridgesgui.ui_files.tabBrowser import Ui_tabBrowser


class Browser(PyQt6.QtWidgets.QWidget, Ui_tabBrowser):
class Browser(PySide6.QtWidgets.QWidget, Ui_tabBrowser):
"""Browser view for iRODS session."""

def __init__(self, session, app_name: str):
Expand All @@ -32,7 +32,7 @@ def __init__(self, session, app_name: str):
if getattr(sys, "frozen", False) or ("__compiled__" in globals()):
super().setupUi(self)
else:
PyQt6.uic.loadUi(UI_FILE_DIR / "tabBrowser.ui", self)
load_ui(UI_FILE_DIR / "tabBrowser.ui", self)

self.logger = logging.getLogger(app_name)
self.session = session
Expand Down Expand Up @@ -166,14 +166,14 @@ def delete_data(self):
item_name = self.browser_table.item(self.browser_table.currentRow(), 1).text()
irods_path = IrodsPath(self.session, "/", *self.input_path.text().split("/"), item_name)
quit_msg = f"Are you sure you want to delete {str(irods_path)}?"
reply = PyQt6.QtWidgets.QMessageBox.critical(
reply = PySide6.QtWidgets.QMessageBox.critical(
self,
"Message",
quit_msg,
PyQt6.QtWidgets.QMessageBox.StandardButton.Yes,
PyQt6.QtWidgets.QMessageBox.StandardButton.No,
PySide6.QtWidgets.QMessageBox.StandardButton.Yes,
PySide6.QtWidgets.QMessageBox.StandardButton.No,
)
if reply == PyQt6.QtWidgets.QMessageBox.StandardButton.Yes:
if reply == PySide6.QtWidgets.QMessageBox.StandardButton.Yes:
try:
irods_path.remove()
self.logger.info("Delete data %s", str(irods_path))
Expand Down Expand Up @@ -275,7 +275,7 @@ def delete_icat_meta(self):
self.error_label.setText(repr(error))

# @PyQt6.QtCore.pyqtSlot(PyQt6.QtCore.QModelIndex)
def edit_metadata(self, index: PyQt6.QtCore.QModelIndex):
def edit_metadata(self, index: PySide6.QtCore.QModelIndex):
"""Load selected metadata info edit fields."""
self.error_label.clear()
self.meta_key_field.clear()
Expand All @@ -293,7 +293,7 @@ def edit_metadata(self, index: PyQt6.QtCore.QModelIndex):
self.meta_units_field.setText(units)

# @PyQt6.QtCore.pyqtSlot(PyQt6.QtCore.QModelIndex)
def edit_permission(self, index: PyQt6.QtCore.QModelIndex):
def edit_permission(self, index: PySide6.QtCore.QModelIndex):
"""Load selected acl into editing fields."""
self.error_label.clear()
self.acl_user_field.clear()
Expand Down
36 changes: 33 additions & 3 deletions ibridgesgui/gui_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
import pathlib
from typing import Union

import os
import irods
import PyQt6
import PySide6.QtWidgets
import PySide6.QtUiTools
import PySide6.QtCore
from ibridges import IrodsPath
from ibridges.executor import Operations

Expand All @@ -20,6 +23,33 @@
LOGO_DIR = files(__package__) / "icons"


class UiLoader(PySide6.QtUiTools.QUiLoader):
"""UILoader to allow custom widgets"""
def __init__(self, base_instance):
PySide6.QtUiTools.QUiLoader.__init__(self, base_instance)
self.base_instance = base_instance

def createWidget(self, class_name, parent=None, name=''):
if parent is None and self.base_instance:
return self.base_instance
else:
# create a new widget for child widgets
widget = PySide6.QtUiTools.QUiLoader.createWidget(self, class_name, parent, name)
if self.base_instance:
setattr(self.base_instance, name, widget)
return widget


def load_ui(ui_file, base_instance=None):
"""load ui, as available in pyqt"""
ui_dir = os.path.dirname(ui_file)
os.chdir(ui_dir)
loader = UiLoader(base_instance)
widget = loader.load(ui_file)
PySide6.QtCore.QMetaObject.connectSlotsByName(widget)
return widget


# Widget utils
def populate_table(table_widget, rows: int, data_by_row: list):
"""Populate a table-like pyqt widget with data."""
Expand All @@ -28,7 +58,7 @@ def populate_table(table_widget, rows: int, data_by_row: list):

for row, data in enumerate(data_by_row):
for col, item in enumerate(data):
table_widget.setItem(row, col, PyQt6.QtWidgets.QTableWidgetItem(str(item)))
table_widget.setItem(row, col, PySide6.QtWidgets.QTableWidgetItem(str(item)))
table_widget.resizeColumnsToContents()


Expand All @@ -38,7 +68,7 @@ def append_table(table_widget, curr_len_table, data_by_row):
for data in data_by_row:
for col, item in enumerate(data):
table_widget.setItem(curr_len_table, col,
PyQt6.QtWidgets.QTableWidgetItem(str(item)))
PySide6.QtWidgets.QTableWidgetItem(str(item)))
curr_len_table+=1
table_widget.resizeColumnsToContents()

Expand Down
14 changes: 6 additions & 8 deletions ibridgesgui/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@

import sys

import PyQt6
import PyQt6.QtWidgets
import PyQt6.uic
import PySide6.QtWidgets
from ibridges.resources import Resources

from ibridgesgui.config import CONFIG_DIR
from ibridgesgui.gui_utils import UI_FILE_DIR, populate_table, populate_textfield
from ibridgesgui.gui_utils import UI_FILE_DIR, load_ui, populate_table, populate_textfield
from ibridgesgui.ui_files.tabInfo import Ui_tabInfo


class Info(PyQt6.QtWidgets.QWidget, Ui_tabInfo):
class Info(PySide6.QtWidgets.QWidget, Ui_tabInfo):
"""Set iRODS information in the GUI."""

def __init__(self, session):
Expand All @@ -21,7 +19,7 @@ def __init__(self, session):
if getattr(sys, "frozen", False) or ("__compiled__" in globals()):
super().setupUi(self)
else:
PyQt6.uic.loadUi(UI_FILE_DIR / "tabInfo.ui", self)
load_ui(UI_FILE_DIR / "tabInfo.ui", self)
self.session = session

self.refresh_button.clicked.connect(self.refresh_info)
Expand All @@ -30,7 +28,7 @@ def __init__(self, session):
def refresh_info(self):
"""Find and set the information of the connected iRODS system."""
self.resc_table.setRowCount(0)
self.setCursor(PyQt6.QtGui.QCursor(PyQt6.QtCore.Qt.CursorShape.WaitCursor))
self.setCursor(PySide6.QtGui.QCursor(PySide6.QtCore.Qt.CursorShape.WaitCursor))
# irods Zone
self.zone_label.setText(self.session.zone)
# irods user
Expand All @@ -50,4 +48,4 @@ def refresh_info(self):
resc_info = Resources(self.session).root_resources
populate_table(self.resc_table, len(resc_info[0]), resc_info)
self.resc_table.resizeColumnsToContents()
self.setCursor(PyQt6.QtGui.QCursor(PyQt6.QtCore.Qt.CursorShape.ArrowCursor))
self.setCursor(PySide6.QtGui.QCursor(PySide6.QtCore.Qt.CursorShape.ArrowCursor))
30 changes: 15 additions & 15 deletions ibridgesgui/irods_tree_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

import irods
import irods.exception
import PyQt6
import PyQt6.QtCore
import PyQt6.QtGui
import PyQt6.QtWidgets

import PySide6.QtCore
import PySide6.QtGui
import PySide6.QtWidgets
from ibridges import IrodsPath


class IrodsTreeModel(PyQt6.QtGui.QStandardItemModel):
class IrodsTreeModel(PySide6.QtGui.QStandardItemModel):
"""Model for an iRODS tree view."""

def __init__(self, tree_view, irods_root_path: IrodsPath):
Expand Down Expand Up @@ -43,24 +43,24 @@ def __init__(self, tree_view, irods_root_path: IrodsPath):
self.clear()

def _tree_row_from_irods_item(self, item, parent_id, level, display_path=False):
icon_provider = PyQt6.QtWidgets.QFileIconProvider()
icon_provider = PySide6.QtWidgets.QFileIconProvider()
if display_path:
display = PyQt6.QtGui.QStandardItem(item.path)
display = PySide6.QtGui.QStandardItem(item.path)
else:
display = PyQt6.QtGui.QStandardItem(item.name)
display = PySide6.QtGui.QStandardItem(item.name)
if isinstance(item, irods.collection.iRODSCollection):
display.setIcon(icon_provider.icon(PyQt6.QtWidgets.QFileIconProvider.IconType.Folder))
display.setIcon(icon_provider.icon(PySide6.QtWidgets.QFileIconProvider.IconType.Folder))
datatype = "C"
else:
display.setIcon(icon_provider.icon(PyQt6.QtWidgets.QFileIconProvider.IconType.File))
display.setIcon(icon_provider.icon(PySide6.QtWidgets.QFileIconProvider.IconType.File))
datatype = "d"
row = [
display, # display name
PyQt6.QtGui.QStandardItem(str(level + 1)), # item level in the tree
PyQt6.QtGui.QStandardItem(str(item.id)), # id in iRODS
PyQt6.QtGui.QStandardItem(str(parent_id)), # parent id
PyQt6.QtGui.QStandardItem(datatype), # C or d
PyQt6.QtGui.QStandardItem(item.path), # absolute irods path
PySide6.QtGui.QStandardItem(str(level + 1)), # item level in the tree
PySide6.QtGui.QStandardItem(str(item.id)), # id in iRODS
PySide6.QtGui.QStandardItem(str(parent_id)), # parent id
PySide6.QtGui.QStandardItem(datatype), # C or d
PySide6.QtGui.QStandardItem(item.path), # absolute irods path
]
return row

Expand Down
8 changes: 4 additions & 4 deletions ibridgesgui/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from ibridges.resources import Resources
from ibridges.session import LoginError, PasswordError
from irods.exception import ResourceDoesNotExist
from PyQt6.QtWidgets import QDialog, QLineEdit
from PyQt6.uic import loadUi
from PySide6.QtWidgets import QDialog, QLineEdit


from ibridgesgui.config import (
IRODSA,
Expand All @@ -20,7 +20,7 @@
save_current_settings,
set_last_ienv_path,
)
from ibridgesgui.gui_utils import UI_FILE_DIR
from ibridgesgui.gui_utils import UI_FILE_DIR, load_ui
from ibridgesgui.ui_files.irodsLogin import Ui_irodsLogin


Expand All @@ -37,7 +37,7 @@ def __init__(self, session_dict, app_name):
if getattr(sys, "frozen", False) or ("__compiled__" in globals()):
super().setupUi(self)
else:
loadUi(UI_FILE_DIR / "irodsLogin.ui", self)
load_ui(UI_FILE_DIR / "irodsLogin.ui", self)

self.logger = logging.getLogger(app_name)
self.irods_config_dir = Path("~", ".irods").expanduser()
Expand Down
22 changes: 10 additions & 12 deletions ibridgesgui/logviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,31 @@
import logging
import sys

import PyQt6
import PySide6


from ibridgesgui.config import CONFIG_DIR
from ibridgesgui.gui_utils import UI_FILE_DIR
from ibridgesgui.gui_utils import UI_FILE_DIR, load_ui
from ibridgesgui.ui_files.tabLogging import Ui_tabLogging


class QPlainTextEditLogger(logging.Handler, PyQt6.QtCore.QObject):
"""A thread safe log handler."""

append_plain_text = PyQt6.QtCore.pyqtSignal(str)
class QPlainTextEditLogger(logging.Handler, PySide6.QtCore.QObject):
"""log handler."""

def __init__(self, widget: PyQt6.QtWidgets.QPlainTextEdit):
def __init__(self, widget: PySide6.QtWidgets.QPlainTextEdit):
"""Initialize the log handler."""
PySide6.QtCore.QObject.__init__(self)
super().__init__()
PyQt6.QtCore.QObject.__init__(self)
self.widget = widget
self.widget.setReadOnly(True)
self.append_plain_text.connect(self.widget.insertPlainText)

def emit(self, record: logging.LogRecord):
"""Pass `record` to all connected slots."""
msg = self.format(record)+"\n"
self.append_plain_text.emit(msg)
self.widget.insertPlainText(msg)


class LogViewer(PyQt6.QtWidgets.QWidget, Ui_tabLogging):
class LogViewer(PySide6.QtWidgets.QWidget, Ui_tabLogging):
"""Set iBridges logging in GUI."""

def __init__(self, logger):
Expand All @@ -38,7 +36,7 @@ def __init__(self, logger):
if getattr(sys, "frozen", False) or ("__compiled__" in globals()):
super().setupUi(self)
else:
PyQt6.uic.loadUi(UI_FILE_DIR / "tabLogging.ui", self)
load_ui(UI_FILE_DIR / "tabLogging.ui", self)

self.logger = logger
self.log_label.setText(str(CONFIG_DIR))
Expand Down
Loading

0 comments on commit 3a1d0aa

Please sign in to comment.