diff --git a/qubesmanager/settings.py b/qubesmanager/settings.py
index 4bfeee8d..0b37ce2d 100644
--- a/qubesmanager/settings.py
+++ b/qubesmanager/settings.py
@@ -519,14 +519,15 @@ def check_mem_changes(self):
# Linux specific limit: init memory must not be below
# max_mem_size/10.79 in order to allow scaling up to
# max_mem_size (or else "add_memory() failed: -17" problem)
- if self.init_mem.value() * 10 < self.max_mem_size.value():
+ if self.vm.features.check_with_template('os', None) == 'Linux' and \
+ self.init_mem.value() * 10 < self.max_mem_size.value():
+ self.init_mem.setValue((self.max_mem_size.value() + 9) // 10)
QtWidgets.QMessageBox.warning(
self,
self.tr("Warning!"),
- self.tr("Initial memory can not be less than one tenth "
- "Max memory.
Setting initial memory to the minimum "
- "allowed value."))
- self.init_mem.setValue((self.max_mem_size.value() + 9) // 10)
+ self.tr("For Linux qubes, Initial memory can not be less than "
+ "one tenth Max memory.
Setting initial memory "
+ "to the minimum allowed value."))
def check_warn_dispvmnetvm(self):
if not hasattr(self.vm, 'default_dispvm'):
diff --git a/qubesmanager/utils.py b/qubesmanager/utils.py
index 52c4bd68..e8d8ea57 100644
--- a/qubesmanager/utils.py
+++ b/qubesmanager/utils.py
@@ -30,8 +30,7 @@
import quamash
from qubesadmin import events
-from PyQt5 import QtWidgets, QtCore # pylint: disable=import-error
-from PyQt5.QtGui import QIcon # pylint: disable=import-error
+from PyQt5 import QtWidgets, QtCore, QtGui # pylint: disable=import-error
def _filter_internal(vm):
@@ -39,6 +38,36 @@ def _filter_internal(vm):
and not vm.features.get('internal', False))
+class SizeSpinBox(QtWidgets.QSpinBox):
+ # pylint: disable=invalid-name, no-self-use
+ def __init__(self, *args, **kwargs):
+ super(SizeSpinBox, self).__init__(*args, **kwargs)
+
+ self.pattern = r'(\d+\.?\d?) ?(GB|MB)'
+ self.regex = re.compile(self.pattern)
+ self.validator = QtGui.QRegExpValidator(QtCore.QRegExp(
+ self.pattern), self)
+
+ def textFromValue(self, v: int) -> str:
+ if v > 1024:
+ return '{:.1f} GB'.format(v / 1024)
+
+ return '{} MB'.format(v)
+
+ def validate(self, text: str, pos: int):
+ return self.validator.validate(text, pos)
+
+ def valueFromText(self, text: str) -> int:
+ value, unit = self.regex.fullmatch(text.strip()).groups()
+
+ if unit == 'GB':
+ multiplier = 1024
+ else:
+ multiplier = 1
+
+ return int(float(value) * multiplier)
+
+
def prepare_choice(widget, holder, propname, choice, default,
filter_function=None, *,
icon_getter=None, allow_internal=None, allow_default=False,
@@ -171,7 +200,7 @@ def prepare_label_choice(widget, holder, propname, default, *args, **kwargs):
sorted(app.labels.values(), key=lambda l: l.index),
default, *args,
icon_getter=(lambda label:
- QIcon.fromTheme(label.icon)),
+ QtGui.QIcon.fromTheme(label.icon)),
**kwargs)
diff --git a/ui/settingsdlg.ui b/ui/settingsdlg.ui
index bb294174..f020ebd6 100644
--- a/ui/settingsdlg.ui
+++ b/ui/settingsdlg.ui
@@ -110,16 +110,16 @@
15
-
-
+
true
+
+ <html><head/><body><p>Values displayed using the binary definition of gigabyte and megabyte, i.e. 1024<span style=" vertical-align:super;">3</span> and 1024<span style=" vertical-align:super;">2 </span>bytes respectively.</p></body></html>
+
Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
- MiB
-
1048576
@@ -129,16 +129,16 @@
-
-
+
true
+
+ <html><head/><body><p>Values displayed using the binary definition of gigabyte and megabyte, i.e. 1024<span style=" vertical-align:super;">3</span> and 1024<span style=" vertical-align:super;">2 </span>bytes respectively.</p></body></html>
+
Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
- MiB
-
0
@@ -1556,6 +1556,13 @@ The qube must be running to disable seamless mode; this setting is not persisten
+
+
+ SizeSpinBox
+ QSpinBox
+
+
+
tabWidget
vmname
diff --git a/version b/version
index a95f2884..561ad334 100644
--- a/version
+++ b/version
@@ -1 +1 @@
-4.1.4
+4.1.6