Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved design of Global Settings #300

Merged
merged 1 commit into from
Oct 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions debian/install
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@

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

/usr/lib/*/dist-packages/qubesmanager/global_settings.css

/usr/lib/*/dist-packages/qubesmanager/ui_backupdlg.py
/usr/lib/*/dist-packages/qubesmanager/ui_bootfromdevice.py
/usr/lib/*/dist-packages/qubesmanager/ui_globalsettingsdlg.py
Expand Down
26 changes: 26 additions & 0 deletions qubesmanager/global_settings.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

QPushButton {
padding: 10px;
margin-left: 30px;
}

QComboBox {
padding-left: 10px;
padding-right: 10px;
}

QLabel#label_release {
padding-left: 20px;
padding-top: 0px;
margin-top: 0px;
margin-bottom: 0px;
}

QLabel#logo_label {
margin-left: 30px;
}

QCheckBox::indicator {
width: 25px;
height: 25px;
}
48 changes: 45 additions & 3 deletions qubesmanager/global_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@

import os
import subprocess
import pkg_resources
from PyQt5 import QtWidgets, QtCore, QtGui # pylint: disable=import-error

from qubesadmin.utils import parse_size
from qubesadmin import exc
from qubesmanager.releasenotes import ReleaseNotesDialog
from qubesmanager.informationnotes import InformationNotesDialog

from . import ui_globalsettingsdlg # pylint: disable=no-name-in-module
from . import utils
Expand Down Expand Up @@ -68,7 +71,7 @@ class GlobalSettingsWindow(ui_globalsettingsdlg.Ui_GlobalSettings,
def __init__(self, app, qubes_app, parent=None):
super().__init__(parent)

self.app = app
self.app: QtWidgets.QApplication = app
self.qubes_app = qubes_app
self.vm = self.qubes_app.domains[self.qubes_app.local_name]

Expand All @@ -77,6 +80,8 @@ def __init__(self, app, qubes_app, parent=None):
self.buttonBox.accepted.connect(self.save_and_apply)
self.buttonBox.rejected.connect(self.reject)

self.__init_ux()

self.__init_system_defaults__()
self.__init_kernel_defaults__()
self.__init_mem_defaults__()
Expand All @@ -89,6 +94,43 @@ def setup_application(self):
self.app.setApplicationName(self.tr("Qubes Global Settings"))
self.app.setWindowIcon(QtGui.QIcon.fromTheme("qubes-manager"))

def __init_ux(self):
icon = QtGui.QIcon.fromTheme('qubes-manager')
pixmap = icon.pixmap(QtCore.QSize(128, 128))
self.logo_label.setPixmap(pixmap)
self.logo_label.setAttribute(
QtCore.Qt.WidgetAttribute.WA_TranslucentBackground)

self.setStyleSheet(pkg_resources.resource_string(
__name__, 'global_settings.css').decode())

self.label_release.linkActivated.connect(self._link_activated)

for button in self.buttonBox.buttons():
button.setMinimumWidth(200)

self.show()

# The magical constants of 120 here are derived from margins set
# in the .ui file
req_width = self.scrollAreaWidgetContents_2.sizeHint().width() + 120
avail_width = self.app.desktop().availableGeometry().width() * 0.9

req_height = self.scrollAreaWidgetContents_2.sizeHint().height() + 120
avail_height = self.app.desktop().availableGeometry().height() * 0.9

self.resize(min(req_width, avail_width), min(req_height, avail_height))

def _link_activated(self, link):
if link == "version":
dialog = InformationNotesDialog(self)
elif link == "release":
dialog = ReleaseNotesDialog(self)
else:
return

dialog.exec_()

def setup_widget_with_vms(self, widget, filter_function,
allow_none, holder, property_name):
try:
Expand Down Expand Up @@ -472,7 +514,7 @@ def __enable_updates_all(self):
reply = QtWidgets.QMessageBox.question(
self, self.tr("Change state of all qubes"),
self.tr("Are you sure you want to set all qubes to check "
"for updates?"),
"for updates? This will override current qube settings."),
QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.Cancel)
if reply == QtWidgets.QMessageBox.Cancel:
return
Expand All @@ -483,7 +525,7 @@ def __disable_updates_all(self):
reply = QtWidgets.QMessageBox.question(
self, self.tr("Change state of all qubes"),
self.tr("Are you sure you want to set all qubes to not check "
"for updates?"),
"for updates? This will override current qube settings."),
QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.Cancel)
if reply == QtWidgets.QMessageBox.Cancel:
return
Expand Down
1 change: 1 addition & 0 deletions rpm_spec/qmgr.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ rm -rf $RPM_BUILD_ROOT

%{python3_sitelib}/qubesmanager/resources_rc.py

%{python3_sitelib}/qubesmanager/global_settings.css
%{python3_sitelib}/qubesmanager/ui_backupdlg.py
%{python3_sitelib}/qubesmanager/ui_bootfromdevice.py
%{python3_sitelib}/qubesmanager/ui_globalsettingsdlg.py
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
url='https://www.qubes-os.org/',
packages=setuptools.find_packages(),
package_data={
'qubesmanager': ['i18n/*']
'qubesmanager': ['i18n/*', '*.css']
},
entry_points={
'console_scripts': [
Expand Down
Loading