Change properties of graphic decoration ControlsFx - javafx

I am new in using the ControlsFx library and what i am trying to do is to adjust some properties of the ERROR_IMAGE from GraphicValidationDecoration. For example, I want to use the same image for validations, but with another positioning(default is bottom left) and another size. Is that posssible?
I tried using StyleClassValidationDecoration, but i think that's just for the textfield itself, not the icon i am talking about.
I read that this was also requested by the community but i did not find the implementantion for it (https://bitbucket.org/controlsfx/controlsfx/issues/788/make-style-of-graphicvalidationdecoration)

Related

How to custom the TextArea line background color

I want to compare two TextArea's text ,and change the different text's line background color,but i don't know how can have tow background color in one TextArea. Maybe should custom to get it,what should i do?
or import .js to get it ? what should i do?
As a more advance solution, you can manipulate TextArea content with https://doc.qt.io/qt-5/qtextdocument.html QTextDocument. Original text document is available via this property https://doc.qt.io/qt-5/qml-qtquick-textedit.html#textDocument-prop . From this point, you can assign your own syntax highlighting. But it requires research from your side.
From the other side, you can check this example https://doc.qt.io/qt-5/qtwidgets-widgets-codeeditor-example.html and using this class https://doc.qt.io/qt-5/qsyntaxhighlighter.html you can assign the existing QTextDocument to QSyntaxHighlighter. The same, I guess, can be used for QML TextArea element.
Since TextArea has textDocument property it should be possible re-implement it for QtQuick Constrols.
To be honest I've never dealt with such a task, but this example looks pretty useful for such cases. Probably you should stick with rich text format option suggested in comments if you don't need advanced features (like real-time content changes).

Custom shaped menu with shadow in Qt

I'd like to create a context menu looking similar to this one:
I read suggestions on the web that QWidget::setMask() should be used to create a shape. But how can it fit the variable number of items then? Moreover, the same menu item may take more or less screen space on different machines.
Another question is how to create a shadow around this custom shape? As far as I understand, the mask allows to crop the widget, but not to make it semi-transparent.
I don’t found an easy way to do that! But here goes a way!
Instead of using the Qt mask API, I've used a frame-less widget with transparency enabled!
To draw the shadow, I've used radial gradient!
You can change the size of the menu before opening it, however you can’t resize it after opened (for example resize with mouse).
It’s quite easy add or remove widgets, just respect the layout margin to not draw outside the bounds destined to widgets. To simplify your life I created an inherited class of QPushButton with colors you can easily customize with style sheet.
See the result:
You can browse the source
Hope that helps!

NSSplitView with toolbars

I'm trying to make an application that looks like the Messages app from Apple.
The NSSplitView has toolbars on both subviews of the NSSplitView. They blend in with the top toolbar. It's similar to the NSToolBar but that doesn't work in NSSplitView's. Is there any way to make this work?
I tried the CNSplitView but it doesn't provide the proper effect. Is there another way of doing this that I'm missing?
The interface i'm going for is here:
Instead of using NSToolbar, you can add your own views to the top of subviews in the NSSplitView to achieve this after hiding the existing titlebar.
NSWindow's titleVisibility can be used to hide the built-in titlebar, and by setting the window's styleMask to include NSFullSizeContentViewWindowMask you can cause the split view to take up the full height of the window.
To get the blur effect like toolbars/Messages you can use NSVisualEffectView in the top views. Setting the material NSVisualEffectMaterialTitlebar will give the same look as standard titlebars.
And finally, you can put NSStackViews inside the visual effect views, and then place the titlebar controls in there.
(And depending on the content that is below your fake toolbars, you might want to look into NSScrollView's contentInsets property to allow the scroll view to show all of the content, but still be able to scroll under your toolbar).

How to make bootstraps's "split button" in Qt widgets

This is probably simple, though I can't find the correct CSS trick to handle this one.
I want to have this kind of button-group (separated with lines, containing a context menu ) in Qt. They must have native look and feel (not like below examples) so the only needed change seems to be removing rounded corners of a QPushButton from its right side (for left-most button), left side (for right most button) and both (for buttons in the middle).
Qt does not support this. You can use CSS to style the buttons like in the example, but you can not use natively styled buttons like this.
If you really need this, the only option I see is to write custom controls for this, with customized drawing code for each OS GUI style you want to support.
You could also try to use standard buttons that overlap and use custom code to paint some kind of line over the overlapping region, but I don't think that would be a good solution.

How to change QIcon color?

I am working on a custom control box (that min,max/restore/close button in the top right of your Windows titlebar) for my new application. I use closeIcon = style.standardIcon(QStyle.SP_TitleBarCloseButton) to get the correct icon for them. See the full code here in my other SO question. What I got is a black icon. In which I need the white version when it's in hover state.
Can we .. I don't know, inverse it? Or should I get another icon from QStyle?
This question (and several others) are from the intention of creating a chrome like tab in PyQt application, by hiding the titlebar and reimplementing control box. But it didn't gives the best result. Right now this is my solution to create a chrome like tab in PyQt application. Therefore, I close this question.

Resources