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 Oct 18, 2024
1 parent fcc069e commit b34f408
Show file tree
Hide file tree
Showing 41 changed files with 517 additions and 417 deletions.
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ignore=tests,
ui_newfwruledlg.py,
ui_restoredlg.py,
ui_settingsdlg.py,
resources_rc.py
resources.py
extension-pkg-whitelist=PyQt5

[MESSAGES CONTROL]
Expand Down
13 changes: 7 additions & 6 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
touch --reference=resources.qrc qubesmanager/resources_rc.py
$(RCC) -g python resources.qrc | sed '0,/PySide6/s//PyQt6/' > qubesmanager/resources.py
touch --reference=resources.qrc qubesmanager/resources.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
2 changes: 1 addition & 1 deletion debian/install
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
/usr/lib/*/dist-packages/qubesmanager/qvm_template_gui.py
/usr/lib/*/dist-packages/qubesmanager/clone_vm.py

/usr/lib/*/dist-packages/qubesmanager/resources_rc.py
/usr/lib/*/dist-packages/qubesmanager/resources.py

/usr/lib/*/dist-packages/qubesmanager/ui_backupdlg.py
/usr/lib/*/dist-packages/qubesmanager/ui_bootfromdevice.py
Expand Down
2 changes: 1 addition & 1 deletion qubesmanager.pro
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ SOURCES = \
qubesmanager/log_dialog.py \
qubesmanager/multiselectwidget.py \
qubesmanager/qube_manager.py \
qubesmanager/resources_rc.py \
qubesmanager/resources.py \
qubesmanager/restore.py \
qubesmanager/settings.py \
qubesmanager/template_manager.py \
Expand Down
2 changes: 1 addition & 1 deletion qubesmanager/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
qrc_resources.py
resources_rc.py
resources.py
ui_*.py
*.py[co]
10 changes: 7 additions & 3 deletions qubesmanager/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@
# 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.informationnotes import InformationNotesDialog

from . import ui_about # pylint: disable=no-name-in-module

# this is needed for icons to actually work
# pylint: disable=unused-import
from . import resources


# pylint: disable=too-few-public-methods
class AboutDialog(ui_about.Ui_AboutDialog, QDialog):
Expand Down Expand Up @@ -58,4 +62,4 @@ def __init__(self, parent=None):

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
36 changes: 21 additions & 15 deletions qubesmanager/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,22 @@
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
import os
import shutil

# this is needed for icons to actually work
# pylint: disable=unused-import
from . import resources

# pylint: disable=too-few-public-methods
class BackupThread(QtCore.QThread):
def __init__(self, vm):
Expand Down Expand Up @@ -81,8 +85,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 +150,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 +382,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 +405,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 +421,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 +432,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
6 changes: 5 additions & 1 deletion qubesmanager/backup_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@
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
import yaml

# this is needed for icons to actually work
# pylint: disable=unused-import
from . import resources

path_re = re.compile(r"[a-zA-Z0-9/:.,_+=() -]*")
path_max_len = 512

Expand Down
9 changes: 6 additions & 3 deletions qubesmanager/bootfromdevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@
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

# this is needed for icons to actually work
# pylint: disable=unused-import
from . import resources

class VMBootFromDeviceWindow(ui_bootfromdevice.Ui_BootDialog,
QtWidgets.QDialog):
Expand All @@ -42,8 +45,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
15 changes: 11 additions & 4 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 All @@ -35,6 +35,10 @@

from .ui_clonevmdlg import Ui_CloneVMDlg # pylint: disable=import-error

# this is needed for icons to actually work
# pylint: disable=unused-import
from . import resources


class CloneVMDlg(QtWidgets.QDialog, Ui_CloneVMDlg):
def __init__(self, qtapp, app, parent=None, src_vm=None):
Expand Down Expand Up @@ -73,8 +77,11 @@ def __init__(self, qtapp, app, parent=None, src_vm=None):

self.set_clone_name()

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 @@ -183,4 +190,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
17 changes: 12 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 All @@ -36,6 +36,10 @@

from .ui_newappvmdlg import Ui_NewVMDlg # pylint: disable=import-error

# this is needed for icons to actually work
# pylint: disable=unused-import
from . import resources


# pylint: disable=too-few-public-methods
class CreateVMThread(QtCore.QThread):
Expand Down Expand Up @@ -145,8 +149,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 +189,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 +343,4 @@ def main(args=None):
"appname", 'Create qube'))

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

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

# this is needed for icons to actually work
# pylint: disable=unused-import
from . import resources


class PCIDeviceListWindow(ui_devicelist.Ui_Dialog, QtWidgets.QDialog):
Expand Down
Loading

0 comments on commit b34f408

Please sign in to comment.