Skip to content

Commit

Permalink
Update qt to PyQt6
Browse files Browse the repository at this point in the history
Updated all files to Qt version 6.
Based on the template manager redesign.

fixes QubesOS/qubes-issues#9476
  • Loading branch information
marmarta committed Sep 25, 2024
1 parent 40fcd0c commit d601794
Show file tree
Hide file tree
Showing 38 changed files with 373 additions and 338 deletions.
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ VERSION := $(shell cat version)

PYTHON ?= python3

LRELEASE_QT5 ?= $(if $(wildcard /etc/debian_version),lrelease,lrelease-qt5)
LRELEASE_QT6 ?= $(if $(wildcard /etc/debian_version),lrelease,lrelease-qt6)
RCC ?= /usr/lib64/qt6/libexec/rcc

SETUPTOOLS_OPTS =
SETUPTOOLS_OPTS += $(if $(wildcard /etc/debian_version),--install-layout=deb,)
Expand All @@ -11,17 +12,17 @@ export QT_HASH_SEED=0
export PYTHONHASHSEED=0

qubesmanager/ui_%.py: ui/%.ui
pyuic5 --from-imports -o $@ $<
pyuic6 -o $@ $<
touch --reference=$< $@

ui: $(patsubst ui/%.ui,qubesmanager/ui_%.py,$(wildcard ui/*.ui))

res:
pyrcc5 -o qubesmanager/resources_rc.py resources.qrc
$(RCC) -g python resources.qrc | sed '0,/PySide6/s//PyQt6/' > qubesmanager/resources_rc.py
touch --reference=resources.qrc qubesmanager/resources_rc.py

translations:
$(LRELEASE_QT5) qubesmanager.pro
$(LRELEASE_QT6) qubesmanager.pro

python:
$(PYTHON) ./setup.py build
Expand All @@ -30,7 +31,7 @@ python_install:
$(PYTHON) ./setup.py install -O1 --skip-build --root $(DESTDIR) $(SETUPTOOLS_OPTS)

update_ts: res
pylupdate5 qubesmanager.pro
pylupdate6 qubesmanager.pro

install:
mkdir -p $(DESTDIR)/usr/libexec/qubes-manager/
Expand Down
8 changes: 4 additions & 4 deletions qubesmanager/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
# with this program; if not, see <http://www.gnu.org/licenses/>.
#
#
from PyQt5.QtWidgets import QDialog # pylint: disable=import-error
from PyQt5.QtGui import QIcon # pylint: disable=import-error
from PyQt6.QtWidgets import QDialog # pylint: disable=import-error
from PyQt6.QtGui import QIcon # pylint: disable=import-error
from qubesmanager.releasenotes import ReleaseNotesDialog
from qubesmanager.informationnotes import InformationNotesDialog

Expand Down Expand Up @@ -60,8 +60,8 @@ def __init__(self, parent=None):

def on_release_notes_clicked(self):
release_notes_dialog = ReleaseNotesDialog(self)
release_notes_dialog.exec_()
release_notes_dialog.exec()

def on_information_notes_clicked(self):
information_notes_dialog = InformationNotesDialog(self)
information_notes_dialog.exec_()
information_notes_dialog.exec()
2 changes: 1 addition & 1 deletion qubesmanager/appmenu_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#

import subprocess
from PyQt5 import QtWidgets, QtCore # pylint: disable=import-error
from PyQt6 import QtWidgets, QtCore # pylint: disable=import-error
from qubesadmin import exc

# TODO description in tooltip
Expand Down
32 changes: 17 additions & 15 deletions qubesmanager/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
from qubesadmin import exc
from qubesadmin import utils as admin_utils

from PyQt5 import QtCore, QtWidgets, QtGui, Qt # pylint: disable=import-error
from . import ui_backupdlg # pylint: disable=no-name-in-module
from . import multiselectwidget
from PyQt6 import QtCore, QtWidgets, QtGui # pylint: disable=import-error
from qubesmanager import ui_backupdlg # pylint: disable=no-name-in-module
from qubesmanager import multiselectwidget

from . import backup_utils
from . import utils
from qubesmanager import backup_utils
from qubesmanager import utils

import grp
import pwd
Expand Down Expand Up @@ -81,8 +81,8 @@ def __init__(self, qt_app, qubes_app, dispatcher, parent=None):
self.setupUi(self)

self.setWindowFlags(self.windowFlags() |
Qt.Qt.WindowMaximizeButtonHint |
Qt.Qt.WindowMinimizeButtonHint)
QtCore.Qt.WindowType.WindowMaximizeButtonHint |
QtCore.Qt.WindowType.WindowMinimizeButtonHint)

self.progress_status.text = self.tr("Backup in progress...")
self.dir_line_edit.setReadOnly(False)
Expand Down Expand Up @@ -146,10 +146,12 @@ def __init__(self, qt_app, qubes_app, dispatcher, parent=None):

def show_hide_password(self):
if self.show_passwd_button.isChecked():
self.passphrase_line_edit.setEchoMode(QtWidgets.QLineEdit.Password)
self.passphrase_line_edit.setEchoMode(
QtWidgets.QLineEdit.EchoMode.Password)
self.show_passwd_button.setIcon(QtGui.QIcon(':/eye-off.svg'))
else:
self.passphrase_line_edit.setEchoMode(QtWidgets.QLineEdit.Normal)
self.passphrase_line_edit.setEchoMode(
QtWidgets.QLineEdit.EchoMode.Normal)
self.show_passwd_button.setIcon(QtGui.QIcon(':/eye.svg'))

def save_profile_changed(self):
Expand Down Expand Up @@ -376,7 +378,7 @@ def current_page_changed(self, page_id): # pylint: disable=unused-argument
self.save_settings(use_temp=False,
save_passphrase=save_passphrase)

self.button(self.FinishButton).setDisabled(True)
self.button(self.WizardButton.FinishButton).setDisabled(True)
self.showFileDialog.setEnabled(
self.appvm_combobox.currentIndex() != 0)
self.showFileDialog.setChecked(self.showFileDialog.isEnabled()
Expand All @@ -399,8 +401,8 @@ def backup_finished(self):
self, self.tr("Backup error"),
self.tr("ERROR: {}").format(
self.thread.msg))
self.button(self.CancelButton).setEnabled(False)
self.button(self.FinishButton).setEnabled(True)
self.button(self.WizardButton.CancelButton).setEnabled(False)
self.button(self.WizardButton.FinishButton).setEnabled(True)
self.cleanup_temporary_files()

else:
Expand All @@ -415,8 +417,8 @@ def backup_finished(self):
"the file selection dialog."))
backup_utils.select_path_button_clicked(self, False, True)

self.button(self.CancelButton).setEnabled(False)
self.button(self.FinishButton).setEnabled(True)
self.button(self.WizardButton.CancelButton).setEnabled(False)
self.button(self.WizardButton.FinishButton).setEnabled(True)
self.showFileDialog.setEnabled(False)
self.cleanup_temporary_files()

Expand All @@ -426,7 +428,7 @@ def backup_finished(self):

def reject(self):
if (self.currentPage() is self.commit_page) and \
self.button(self.CancelButton).isEnabled():
self.button(self.WizardButton.CancelButton).isEnabled():
try:
self.qubes_app.qubesd_call(
'dom0', 'admin.backup.Cancel',
Expand Down
2 changes: 1 addition & 1 deletion qubesmanager/backup_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import re
import socket

from PyQt5 import QtWidgets # pylint: disable=import-error
from PyQt6 import QtWidgets # pylint: disable=import-error

import subprocess
from . import utils
Expand Down
6 changes: 3 additions & 3 deletions qubesmanager/bootfromdevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import subprocess
from . import utils
from . import ui_bootfromdevice # pylint: disable=no-name-in-module
from PyQt5 import QtWidgets, QtGui, Qt # pylint: disable=import-error
from PyQt6 import QtWidgets, QtGui, QtCore # pylint: disable=import-error
from qubesadmin import tools
from qubesadmin import exc
from qubesadmin.tools import qvm_start
Expand All @@ -42,8 +42,8 @@ def __init__(self, vm, qapp, qubesapp=None, parent=None, new_vm=False):
self.setWindowTitle(
self.tr("Boot {vm} from device").format(vm=self.vm))
self.setWindowFlags(self.windowFlags() |
Qt.Qt.WindowMaximizeButtonHint |
Qt.Qt.WindowMinimizeButtonHint)
QtCore.Qt.WindowType.WindowMaximizeButtonHint |
QtCore.Qt.WindowType.WindowMinimizeButtonHint)

self.buttonBox.accepted.connect(self.save_and_apply)
self.buttonBox.rejected.connect(self.reject)
Expand Down
4 changes: 2 additions & 2 deletions qubesmanager/clipboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
from math import log

# pylint: disable=import-error
from PyQt5.QtWidgets import QApplication, QMessageBox
from PyQt5.QtCore import QCoreApplication
from PyQt6.QtWidgets import QApplication, QMessageBox
from PyQt6.QtCore import QCoreApplication

APPVIEWER_LOCK = "/var/run/qubes/appviewer.lock"
CLIPBOARD_CONTENTS = "/var/run/qubes/qubes-clipboard.bin"
Expand Down
4 changes: 2 additions & 2 deletions qubesmanager/clone_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import sys
import subprocess

from PyQt5 import QtCore, QtWidgets, QtGui # pylint: disable=import-error
from PyQt6 import QtCore, QtWidgets, QtGui # pylint: disable=import-error

import qubesadmin
import qubesadmin.tools
Expand Down Expand Up @@ -183,4 +183,4 @@ def main(args=None):
"appname", 'Clone qube'))

dialog = CloneVMDlg(qtapp, args.app, src_vm=src_vm)
dialog.exec_()
dialog.exec()
5 changes: 3 additions & 2 deletions qubesmanager/common_threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#


from PyQt5 import QtCore, QtWidgets # pylint: disable=import-error
from PyQt6 import QtCore, QtWidgets # pylint: disable=import-error
from contextlib import contextmanager

from qubesadmin import exc
Expand All @@ -29,7 +29,8 @@
@contextmanager
def busy_cursor():
try:
QtWidgets.QApplication.setOverrideCursor(QtCore.Qt.BusyCursor)
QtWidgets.QApplication.setOverrideCursor(
QtCore.Qt.CursorShape.BusyCursor)
yield
finally:
QtWidgets.QApplication.restoreOverrideCursor()
Expand Down
13 changes: 8 additions & 5 deletions qubesmanager/create_new_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import sys
import subprocess

from PyQt5 import QtCore, QtWidgets, QtGui # pylint: disable=import-error
from PyQt6 import QtCore, QtWidgets, QtGui # pylint: disable=import-error

import qubesadmin
import qubesadmin.tools
Expand Down Expand Up @@ -145,8 +145,11 @@ def __init__(self, qtapp, app, parent=None):
self.storage_pool.clear()
self.storage_pool.addItem("(default)", qubesadmin.DEFAULT)

self.name.setValidator(QtGui.QRegExpValidator(
QtCore.QRegExp("[a-zA-Z0-9_-]*", QtCore.Qt.CaseInsensitive), None))
self.name.setValidator(QtGui.QRegularExpressionValidator(
QtCore.QRegularExpression(
"[a-zA-Z0-9_-]*",
QtCore.QRegularExpression.PatternOption.CaseInsensitiveOption),
None))
self.name.selectAll()
self.name.setFocus()

Expand Down Expand Up @@ -182,7 +185,7 @@ def accept(self):
if self.install_system.isChecked():
self.boot_dialog = bootfromdevice.VMBootFromDeviceWindow(
name, self.qtapp, self.app, self, True)
if not self.boot_dialog.exec_():
if not self.boot_dialog.exec():
return

if name in self.app.domains:
Expand Down Expand Up @@ -336,4 +339,4 @@ def main(args=None):
"appname", 'Create qube'))

dialog = NewVmDlg(qtapp, args.app)
dialog.exec_()
dialog.exec()
2 changes: 1 addition & 1 deletion qubesmanager/device_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#

from . import ui_devicelist # pylint: disable=no-name-in-module
from PyQt5 import QtWidgets # pylint: disable=import-error
from PyQt6 import QtWidgets # pylint: disable=import-error


class PCIDeviceListWindow(ui_devicelist.Ui_Dialog, QtWidgets.QDialog):
Expand Down
32 changes: 19 additions & 13 deletions qubesmanager/firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import datetime
import re

from PyQt5 import QtCore, QtGui, QtWidgets # pylint: disable=import-error
from PyQt6 import QtCore, QtGui, QtWidgets # pylint: disable=import-error
import qubesadmin.firewall

from . import ui_newfwruledlg # pylint: disable=no-name-in-module
Expand All @@ -39,13 +39,17 @@ def __init__(self, parent=None):
self.set_ok_state(False)
self.addressComboBox.editTextChanged.connect(
self.address_editing_finished)
self.serviceComboBox.setValidator(QtGui.QRegExpValidator(
QtCore.QRegExp("[a-z][a-z0-9-]+|[0-9]+(-[0-9]+)?",
QtCore.Qt.CaseInsensitive), None))
self.serviceComboBox.setValidator(QtGui.QRegularExpressionValidator(
QtCore.QRegularExpression(
"[a-z][a-z0-9-]+|[0-9]+(-[0-9]+)?",
QtCore.QRegularExpression.PatternOption.CaseInsensitiveOption),
None))
self.serviceComboBox.setEnabled(False)
self.serviceComboBox.setInsertPolicy(QtWidgets.QComboBox.InsertAtBottom)
self.serviceComboBox.setInsertPolicy(
QtWidgets.QComboBox.InsertPolicy.InsertAtBottom)
self.populate_combos()
self.serviceComboBox.setInsertPolicy(QtWidgets.QComboBox.InsertAtTop)
self.serviceComboBox.setInsertPolicy(
QtWidgets.QComboBox.InsertPolicy.InsertAtTop)

self.model = None

Expand Down Expand Up @@ -142,7 +146,8 @@ def address_editing_finished(self):
self.set_ok_state(True)

def set_ok_state(self, ok_state):
ok_button = self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok)
ok_button = self.buttonBox.button(
QtWidgets.QDialogButtonBox.StandardButton.Ok)
if ok_button is not None:
ok_button.setEnabled(ok_state)

Expand Down Expand Up @@ -190,7 +195,7 @@ def __init__(self, parent=None):
self.__children = None # list of rules in the FW

def sort(self, idx, order):
rev = order == QtCore.Qt.AscendingOrder
rev = order == QtCore.Qt.SortOrder.AscendingOrder
self.children.sort(key=lambda x: self.get_column_string(idx, x),
reverse=rev)

Expand Down Expand Up @@ -413,16 +418,17 @@ def hasChildren(self, index=QtCore.QModelIndex()):
parent_item = index.internalPointer()
return parent_item is None

def data(self, index, role=QtCore.Qt.DisplayRole):
if index.isValid() and role == QtCore.Qt.DisplayRole:
def data(self, index, role=QtCore.Qt.ItemDataRole.DisplayRole):
if index.isValid() and role == QtCore.Qt.ItemDataRole.DisplayRole:
return self.get_column_string(index.column(),
self.children[index.row()])

# pylint: disable=invalid-name
def headerData(self, section, orientation, role=QtCore.Qt.DisplayRole):
def headerData(self, section, orientation,
role=QtCore.Qt.ItemDataRole.DisplayRole):
if section < len(self.__column_names) \
and orientation == QtCore.Qt.Horizontal \
and role == QtCore.Qt.DisplayRole:
and orientation == QtCore.Qt.Orientation.Horizontal \
and role == QtCore.Qt.ItemDataRole.DisplayRole:
return self.__column_names[section]

@property
Expand Down
2 changes: 1 addition & 1 deletion qubesmanager/informationnotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# with this program; if not, see <http://www.gnu.org/licenses/>.
#
#
from PyQt5.QtWidgets import QDialog # pylint: disable=import-error
from PyQt6.QtWidgets import QDialog # pylint: disable=import-error

from . import ui_informationnotes # pylint: disable=no-name-in-module
import subprocess
Expand Down
8 changes: 4 additions & 4 deletions qubesmanager/log_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import sys
import os
from functools import partial
from PyQt5 import QtWidgets, Qt # pylint: disable=import-error
from PyQt6 import QtWidgets, QtCore # pylint: disable=import-error
from qubesadmin import Qubes
from . import ui_logdlg # pylint: disable=no-name-in-module
from . import clipboard
Expand All @@ -43,8 +43,8 @@ def __init__(self, app, logfiles, parent=None):

self.setupUi(self)
self.setWindowFlags(self.windowFlags() |
Qt.Qt.WindowMaximizeButtonHint |
Qt.Qt.WindowMinimizeButtonHint)
QtCore.Qt.WindowType.WindowMaximizeButtonHint |
QtCore.Qt.WindowType.WindowMinimizeButtonHint)

self.copy_to_qubes_clipboard.clicked.connect(
self.copy_to_clipboard_triggered)
Expand Down Expand Up @@ -89,7 +89,7 @@ def main():
log_window = LogDialog(qubes_app, sys.argv[1:])
log_window.show()

qt_app.exec_()
qt_app.exec()
qt_app.exit()


Expand Down
Loading

0 comments on commit d601794

Please sign in to comment.