-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Visual settings: Font family order #4892
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4892 +/- ##
==========================================
- Coverage 84.50% 84.47% -0.04%
==========================================
Files 283 283
Lines 58306 58367 +61
==========================================
+ Hits 49270 49304 +34
- Misses 9036 9063 +27 |
Perhaps it would be better to put not just the default family but also the related fonts at the top. It is impossible to guess which part of the name is the actual name and which part determines the shape, so I simply took the first word. Please take a look at the commit I made. More importantly, I'd propose a change to the dialog to get rid of the leading dots. The commit that I added requires adding the following code to class FontList(list):
pass
@_add_control.register(FontList)
def _(values: FontList, value: str, key: KeyType, signal: Callable) \
-> QComboBox:
class FontModel(PyListModel):
def data(self, index, role=Qt.DisplayRole):
value = super().data(index, role)
if role in (Qt.DisplayRole, Qt.EditRole) \
and isinstance(value, str) and value[0] == ".":
value = value[1:]
return value
combo = QComboBox()
combo.setModel(FontModel(values))
combo.setCurrentIndex(values.index(value))
combo.currentIndexChanged.connect(lambda i: signal.emit(key, values[i]))
return combo Please comment. Note also that the separator doesn't work. The check |
I don't like the way we are complicating the code over the font families.
I'd rather not put font-specific code into a base module such as
|
d047667
to
7f7967b
Compare
I haven't solved the mystery of separators. This works now, but it imports a private class (a delegate). Could be fixed (by making it non-private). class FontList(list):
pass
@_add_control.register(FontList)
def _(values: FontList, value: str, key: KeyType, signal: Callable) \
-> QComboBox:
class FontModel(QStringListModel):
def data(self, index, role=Qt.DisplayRole):
if role == Qt.AccessibleDescriptionRole \
and super().data(index, Qt.DisplayRole) == "":
return "separator"
value = super().data(index, role)
if role in (Qt.DisplayRole, Qt.EditRole) and value.startswith("."):
value = value[1:]
return value
def flags(self, index):
if index.data(Qt.DisplayRole) == "separator":
return Qt.NoItemFlags
else:
return super().flags(index)
combo = QComboBox()
model = FontModel(values)
combo.setModel(model)
combo.setCurrentIndex(values.index(value))
combo.currentIndexChanged.connect(lambda i: signal.emit(key, values[i]))
combo.setItemDelegate(_ComboBoxListDelegate())
return combo
Why do you think it's complicated? It's just a model that removes a leading period.
This one is harder for me to argue about because this is your concept and you know how it's supposed to work. But won't almost every customizable widget allow changing the font? Why is it specific? Isn't this one of basic things that (w|sh)ould be handled here?
Thanks for the hint -- it helped me fix the separator. Not |
Exactly, 30 lines of code for the leading period (and the separator.) :) |
Sorry, did you say complicated or long? :) |
7f7967b
to
d92de40
Compare
@PrimozGodec, we discussed this again with @VesnaT. The model (in orange-widget-base repository) has to stay. The question is whether to remove fonts with leading dot, except the system font, and whether the system font should be renamed to something like "Default font". The latter may not be appropriate, because this is not a default font in any way, except that it's used for dialogs. (E.g. default font in Word is Calibri, but Orange does not have a default.) At the end, we guess it'd be better to just keep both PRs as they are: keep the fonts with a leading dot, but don't show the dots. |
fca599c
to
94a068b
Compare
94a068b
to
4f8f06a
Compare
You're right. It was a result of botched rebase to master. Even now, if I try to rebase, it shows conflicts (which github doesn't) and removes the call to |
When merging this PR we forgot to update dependencies again. The required widget base should be 4.8.1. @PrimozGodec |
Issue
Implements comment from #4828.
Description of changes
Includes