Conversation
Plan:
|
The logo was recently modified in #603 and it was a pain to get right. Let's worry about that later. Looking at your current code, I see the following repeated for every widget: STANDARD_DPI = 96.0
X_SIZE = self.logicalDpiX() / STANDARD_DPI
Y_SIZE = self.logicalDpiY() / STANDARD_DPI Is that the part you plan on putting in the new parent class? |
@dideler Yes. And I want to build the new class so that I do not need to repeat it every time. |
44b725a
to
967d7cf
Compare
Add the interlayer QT classes for the widget classes that transmit fixed width and height value to DPI dependent ones. Personal, I feel like the method a bit ugly. So I need suggestions on how to improve it. |
Please follow our guidelines on how to do proper docstrings. |
''' | ||
freeseer - vga/presentation capture software | ||
|
||
Copyright (C) 2011 Free and Open Source Software Learning Centre |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a new file so the year should be updated.
I'm not an expert on DPI but I'm a bit surprised Qt isn't aware of it. Anyway the method looks fine for me but maybe other mentors have better ideas. |
f5244bf
to
439a19f
Compare
@zxiiro It seems that QtCore.Qt.WindowFlags cannot be import by using from PyQt4.QtCore.Qt import WindowFlags The error message says that QtCore has not Qt component QtCore.Qt.WindowsFlags |
|
||
# freeseer - vga/presentation capture software | ||
# | ||
# Copyright (C) 2011, 2014 Free and Open Source Software Learning Centre |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a new file so only 2014 is enough
I mean the class and method docstrings. A bunch of ''' Constructor ''' Does not explain anything and also doesn't follow the standard style of: '''Short summary Followed by possibly many lines to describe the function ''' |
For the Qt file we only need to go as far as: from PyQt4.QtCore import Qt We do not need to go any deeper than 1 level after the QtCore/QtGui module. Edit: if you need an example of the import style I want take a look at some of our new Qt GUI files such as https://github.com/Freeseer/freeseer/blob/master/src/freeseer/frontend/qtcommon/FreeseerApp.py |
I found that for some methods, the input arguments can be either (width, height) or (QSize). So I add a new method to deal with the two situations. |
the input value DPI adatping using LOGICAL_DPI. The output will | ||
all be transfered to (QSize) type | ||
''' | ||
global LOGICAL_DPI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Global variables are typically frowned upon. Can you find a way to accomplish what you want without using them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only method that I can come up with is to generate a dummy QWidget class in other classes. But that could be low efficient. How do you think of that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about just computing this LOGICAL_DPI in each widget? There's no sense in preemptively optimizing before there's any problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about make it a class member for QWidgetWithDpi and pass it as additional arguments to the QGroupBoxWithDpi and QSpacerItemWithDpi constructors?
1ed4573
to
64bff1c
Compare
@mtomwing I replace the global variable with a class. Does that fit the style now? |
No. |
@mtomwing
|
abf8871
to
5481d18
Compare
The new version has been pushed. In order to remove the global variable, I load the QSpacerItem and QRect into QWidget and QMainWindow as methods. Not sure whether it is OK. |
''' | ||
super(QToolButtonWithDpi, self).__init__(*args, **kwargs) | ||
|
||
STANDARD_DPI = 96.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we know that the standard DPI is 96? Is there a source somewhere that says this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. But both Windows and Ubuntu consider the standard DPI as 96 (I do not test mac because I do not have a mac). And quite a lot resources on the Internet also says that.
3b8be2c
to
a59f816
Compare
@promm what's the status of this PR? Is it good to merge on your end? |
@dideler |
a59f816
to
eec484d
Compare
Thanks. I'll review soon and merge if it's all good. |
|
||
def test_set_width_with_dpi(self): | ||
''' The test cases to test set_height_with_dpi method ''' | ||
assert self.tested_cls.set_width_with_dpi(300) == 450 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the tests would be more robust if they calculate the expected value using the ratio instead of hardcoding it.
eec484d
to
d2390af
Compare
@dideler |
d2390af
to
363ee9c
Compare
|
||
|
||
class QtGuiWithDpi(QWidget): | ||
'''The base class uses for the mixin for other Dpi adapt QtGui classes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sentence is confusing, can you try to rewrite it?
The Qt UI would change the size according to the logical DPI of the computer. Only Windows and Linux have been tested. (Should also work on Mac but have not tested). The unit test for the new file is also added.
363ee9c
to
c03a73b
Compare
@dideler |
Make them more readable and informative. Also fix punctuation, spelling, and grammar mistakes. Related to #640
Thanks for the contribution @promm! |
The Qt UI would change the size according to the logical DPI of the computer
Only Windows and Linux have been tested. (Should also work on Mac but have not tested).
The function is unfinished.
Fixes #576