You can set a QTreeWidget to animated with:
tree_widget = QtWidgets.QTreeWidget()
tree_widget.setAnimated(True)
This will make the QTreeWidgetItems animate while they collapse and expand.
Is there a way to access and edit the animation speed, and type, in the same way you would a QtCore.QVariantAnimation()?
I would like to be able to change the speed and animation type (eg, QtCore.QEasingCurve.Linear) if possible.
Let's track the source;
When we look for animated property we can find out it is actually part of QTreeView class.
So first we need to check if they provided a public method (may named set/addAnimation) to access/manipulate this property. But there aren't any. (not totally true, see the update section)
Then we've to look into the source code of QTreeView. The property set at line 910 as animationsEnabled flag.
When we look for where the action taken according to this flag is at line 3096 and line 3113
And unfortunately these methods are part of QTreeViewPrivate class which is not part of Qt API according to the doc-string:
W A R N I N G
This file is not part of the Qt API. It exists purely as an
implementation detail. This header file may change from version to
version without notice, or even be removed.
We mean it.
So, I don't see a direct way to access or change it without touching and building source.
UPDATE
I recently came across to a widget-animation-duration property in Qt Style Sheet Reference to override built-in animation duration values with style sheets and decided to append it here. However, which widgets are supported is poorly documented. Fortunately, I was able to find related commit with help of google hacking:
"widget-animation-duration" inurl:"code.qt.io"
Diffstat
-rw-r--r-- src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc 4
-rw-r--r-- src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc 16
-rw-r--r-- src/widgets/itemviews/qcolumnview.cpp 6
-rw-r--r-- src/widgets/itemviews/qtreeview.cpp 2
-rw-r--r-- src/widgets/styles/qcommonstyle.cpp 5
-rw-r--r-- src/widgets/styles/qstyle.cpp 9
-rw-r--r-- src/widgets/styles/qstyle.h 1
-rw-r--r-- src/widgets/styles/qstylesheetstyle.cpp 4
-rw-r--r-- src/widgets/widgets/qtabbar_p.h 2
-rw-r--r-- src/widgets/widgets/qwidgetanimator.cpp 4
10 files changed, 41 insertions, 12 deletions
QColumnView and QWidgetAnimator classes has these lines and I was able to change duration of QColumnView animations when I tested.
if (const int animationDuration = style()->styleHint(QStyle::SH_Widget_Animation_Duration, 0, this)) {
d->currentAnimation.setDuration(animationDuration);
BUT: QTreeView implementation only checks the flags existence but not using it's value yet because they animate it by rendering tree to pixmap and drawing it by pixels. We can assume they'll use it because this looks like a preparation for it:
animationsEnabled = q->style()->styleHint(QStyle::SH_Widget_Animation_Duration, 0, q) > 0;
Related
I have only one requirement. I need to read PDF page size and determine if page is not bigger then 17x17 inches to not send it to some external service which rejects such pdfs.
Is there any free library working on .NET Core? I wasn't able to find it. Or maybe anyone implemented this by reading binary file?
A pdf does not HAVE TO declare page size externally since every page can be a different size thus 100 pages may be 100 different page sizes.
However many PDF will contain a text entry for one or more pages so you can (depending on construction) parse as text for /MediaBox and or potentially /CropBox dimensions.
So the first PDF example I pick on and open to search for /MediaBox in WordPad tells me its 210 mm x 297 mm (i.e my local A4) /MediaBox [0 0 594.95996 841.91998] and for a 3 page file all 3 entries are the same.
you can try that using command line as
type "filename.pdf" | find /i "/media"
but may not work in all cases so a bigger chance of result (but more chaff) is
type "filename.pdf" | findstr /i "^/media ^/crop"
The value is based on the default number of point size units per inch (so can be divided by 72 as a rough guide), however, thats not your aim since you know you dont want more that 17x72=1224.
So in simple terms, if either value was over 1224 then I could reject as "TOO BIG".
HOWEVER I need to also consider those two 0 values, thus if one was +100 then the limit becomes 100 more and more importantly, if one was -100 then your desired 17" restriction will fail at 1124.
So you can write in any method or language (even CMD) a simple test, however, that will require too much expanding to cover all cases, SO:-
Seriously I would use / shell a one line command tool like xpdf/poppler pdfinfo to parse all different types of PDF and then grep that output.
The output is similar for both with many lines but for your need
xpdf\pdfinfo -box filename
gives Page size: 594.96 x 841.92 pts (A4) (rotated 0 degrees)
and
poppler\pdfinfo -box filename
gives Page size: 594.96 x 841.92 pts (A4)
Thus to check the file does not exceed 17" (in either direction) it should be easy to set a comparison testing that both values are under 1224.01
What does mean number near extended attributes in ls -l# output and how i can get it?
drwxr-xr-x# 41 root wheel 1394 Nov 7 14:50 bin
com.apple.FinderInfo 32 //this number
com.apple.rootless 0 //and this
This is MacOS specific I think. Maybe you want to take a look at the xattr command here. The number displayed by ls is the size in bytes of the attribute. The meaning of the value of a particular attribute is arbitrary (as is the set of extended attributes a file may have) and really depends on the attribute itself.
To be consistent with your question tags, you can also access extended attributes programatically from C by including sys/xattr.h.
This number means sizeof extended attribute in bytes.
You can get it by getxattr from sys/xattr.h
As it is written here
https://documentation.magnolia-cms.com/display/DOCS56/Dialog+definition I assume there is a possibility for every dialog to insert the following line into the yaml:
modalityLevel: non-modal
If I do this to an existing Component-Dialog which could be quite complex (with tabs and so on) the console logs an error.
WARN agnolia.config.source.yaml.YamlConfigurationSource: 1 major and 0 minor problems have been encountered
(Note: if I do modalityLevel: light it works..)
The reason I want to do this is to have more than one dialog opened at once.
Is that possible in Magnolia 5.5.5 (or 5.6)?
Okay there we go, after some investigation it turns out that the problem is within Magnolia. I have created the following issue https://jira.magnolia-cms.com/browse/MGNLUI-4328 for the problem. For now please ignore what the definition app says and we will fix it as soon as possible.
Cheers,
FWIW, I get the same behavior on the current demo ...
It's defined here:
info.magnolia.ui.api.overlay.OverlayLayer
65 /**
66 * The available levels of modality.
67 * Determines how "modal" it is -
68 * -STRONG creates a dark background that prevents clicks.
69 * -LIGHT adds a border, creates a transparent background that prevents clicks.
70 * -NON_MODAL does not prevent clicks.
71 */
72 public static enum ModalityLevel {
73 STRONG("strong", "modality-strong"),
74 LIGHT("light", "modality-light center-vertical"),
75 NON_MODAL("non-modal", "modality-non-modal");
And it's used here:
info.magnolia.ui.framework.overlay.OverlayPresenter
216 final OverlayCloser closer = openOverlay(new ViewAdapter(shortcutPanel), ModalityLevel.NON_MODAL);
And it's used here:
info.magnolia.dam.app.assets.field.UploadAssetActionRenderer
155 progressIndicatorCloseHandle = layer.openOverlay(new ViewAdapter(progressIndicator), ModalityLevel.NON_MODAL);
and etc.
So that seems like a false positive.
Interestingly, I don't see any tests for this ... for example, I see:
assertEquals("light", session.getProperty("/modules/ui-framework/dialogs/rename/modalityLevel").getString());
and
assertEquals("strong", session.getProperty("/modules/pages/dialogs/createPage/modalityLevel").getString());
but nothing with "non-modal"
I thought maybe the "-" character, but this appears, all else equal, to be valid yaml
---
modalityLevels: strong
modalityLeveln: non-modal
modalityLevell: light
Would have to dig deeper to see what is happening here.
UPDATE: if you change it to "non_modal", there's no longer an error in the definitions app.
I just switched from Sublime Text to Atom in order to turn completely open source.
I have trouble with something very very simple: I want Atom to use always (!) and under any circumstances tab width 2 and replace tab with spaces. This setting is so simple in gedit or Sublime Text, but no matter what I am trying: When I start a new file, tab size is 2 (good!). When I use an existing file, tab size is sometimes 4. I find that a bit annoying.
My current setting in Editor are seen in the screenshot:
There is more than one tab setting
Each package (such as python-language) has its own tab setting(s). Whether the language uses the global default or its own default is up to whoever created the package, but you can generally override it.
In your screenshot, you have set the "Tab Type" to "soft". That will take care of using spaces rather than tabs. You have left the default tab width of 2. That is your global setting.
Now, if you look under "Packages" and search for "python" you will find a package named "language-python". Click on its settings button and you will find a number of syntax-specific settings.
Python Grammar
Python Console Grammar
Python Traceback Grammar
Regular Expressions (Python) Grammar
Each of those grammars has its own Tab Length setting. You can set them explicitly to 2 here to override the package's default. (You probably mostly care about the first one, Python Grammar.)
Python is different
In the case of Python, the package is explicitly configured to default to 4 spaces, probably because Python is very opinionated about whitespace, and PEP 8 recommends 4-space indents. You can see the default package setting here in the package's source:
https://github.com/atom/language-python/blob/master/settings/language-python.cson
'autoIndentOnPaste': false
'softTabs': true
'tabLength': 4
This overrides the global default. That's why Python Grammar does not honor the global tab width, the way that most packages do.
Sometimes there are package overrides
Additionally, certain packages will override your settings for syntax reasons. For example, language-make will override and use real tabs instead of spaces, because that is required by make.
In the case of Python, there is an override to use spaces. The language-python settings page offers a spot for you to change the indentation level, but it does not offer a way to switch to using tab characters. (That's probably justifiable, as tab characters and mixed indentation in Python are a very common cause of difficult-to-debug syntax errors.)
You might need to reload
Lastly, sometimes settings don't take effect completely until you reload the Atom window. You can use the Window: Reload command to do so. Or using the keyboard:
Mac: CtrlOptCmdL
Windows/Linux: CtrlAltR
This is what worked for me.
Disable all non-default packages
Open ~/.atom/config.cson, and append this (same level than the "*" element)
:
".python.source":
editor:
autoIndent: true
tabLength: 2
Re-enable all packages.
I got this help from someone else. Not my own discovery. However, for confidentiality, I cannot cite the source.
Based on soham's answer, I found that setting all tabLength: fields in ~/.atom/config.cson (assuming osx) to your desired length solved the problem.
I am using gulp for css and js processing. Sometimes I am missing the good old lazyness of the unix make command:
only generate transformed (whatsover, e.g. compilation) files from original files, that have actually changed (based on time stamps).
this is true from stage 1 to 2 (.cpp -> .o), stage 2 to 3 (linking or other stuff) whatever your dependency graph gives...
Make is not limited to source code: You can do image manipulation in several steps (efficiently ‘lazy’ generation of downscaled thumbs for example) or much else. All based on the fairly simple rule: „is at least one of the source files newer in respect to the current output file(s)?“
Unlike gulp, every step generates (more or less temporary) files, not a continuous pipe.
Is there a way, to get the same kind of lazyness in gulp**, i.e. when generating css?
only transform those (less|sass|stylus) files➝css if something changed (on the very respective file)
same for adding in browser prefixes, concat, minify
Admittedly, beyond the first 1 or 2 steps, the output is most likely already a single stream. So any change means ‘touched’. Still, when playing for example with minify options, I'd rather be lazy about the early transpile, prefixing and concat stages (drawing prior results from a temp file). Also on the javascript side ( typeScript, ... )
lazypipe and gulp-cache sound tempting but are something else, if I understand correctly. Saying .watch() is also only a partial answer, for the very first stage.
Is there a more generic approach?
If you're set on using Gulp, then this would seem to be the way to do it. It involves the gulp-cached and gulp-remember plugins.