Qt Quick (QML) color declaration - qml

I have following statement inside ListView declaratation:
highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
Everything is ok, but I was just wondering, which file in is word lightsteelblue declared, so I can review other predefined colors?

The documentation says it is normally specified as an SVG color name, and provides this reference page. I understand QML supports the different keyword names listed in there.
EDIT: as pointed out by #dbrianj (thanks), you can find them in the qtbase/src/gui/painting/qcolor_p.cpp file.

Related

tintColor not working on watchOS 5 complication

I have several complications for watchOS 5 and Apple Watch Series 4 that aren't properly making use of their tintColor. Instead, they just display with white text. Other 3rd party complications on the same face show their color.
Is there a trick other than using tintColor on the leadingTextProvider and trailingTextProvider of a Graphic Circular complication?
I'm using Objective-C in case that matters here.
You can do that with CLKSimpleTextProvider, the trick thing is that you can't do it with CLKTextProvider.
For example,
t.leadingTextProvider = {
let t = CLKSimpleTextProvider(text: String(6))
t.tintColor = .red
return t
}()
works
t.leadingTextProvider = {
let t = CLKTextProvider(format: String(6))
t.tintColor = .red
return t
}()
doesn't work.
In Apple's Documents of CLKTextProvider, it says
You do not create instances of this class yourself. Instead, you create instances of an appropriate subclass, based on the type of text data you are trying to create. You can also use the textProviderWithFormat: class method to create a generic text provider constructed from a format string and the data from other text provider.
Besides, you also need a watch face that allows tint color, like mine.
Xcode 11.0 (11A420a)
watchOS simulator 6.0
Is it possible that you‘re initializing your UIColor incorrectly? Can you show the relevant code?
A common mistake is using integers (e.g. 0-255) for the RGB values of UIColor (see this question).

LESS variable concatenation and interpolation

I'm attempting to override Bootstrap's hover effect on the buttons. I'd like to save some space and do it the slick way by simply passing into a mixin the name of a class and have that class' background variable be automatically deduced from just that. So my mixin is:
.btn-hover(#name){
.#{name}:hover{
background: lighten( #~"#{name}-bg", 10% );
}
}
.btn-hover(btn-primary);
But I can't seem to access the variable #btn-primary-bg by concatenating -bg to btn-primary, because #~"#{btn-name}-bg" results in a compiler error. Is what I'm trying to do even possible? It would be pretty slick if it were.
Edit -----------------------------------------------------------------
Just stumbled upon this question and it's definitely related, but I think my question really just boils down to:
In LESS, can you access a variable via interpolation after string concatenation?
#btn-success-bg: #00ff00;
#name: btn-success;
#background: #~"#{name}-bg"; // How do I access #btn-success-bg?
You can do:
#btn-primary-bg: red;
.btn-hover(#name){
.#{name}:hover{
#buttonname: ~"#{name}-bg";
background: lighten( ##buttonname, 10% );
}
}
.btn-hover(btn-primary);
Also see: http://lesscss.org/features/#variables-feature-variable-names

Custom CSS attributes while using LESS?

I have been using SASS for a while now, and one thing I really like is how I can use it for my FlashBuilder projects also, namely that is supports custom CSS attributes, like 'embedAsCFF' and 'unicodeRange'.
I'm trying out LESS for the first time, and it will not let me compile to CSS while using these two custom attributes:
embedAsCFF: true;
unicodeRange: U+0021, U+0023-U+0026, U+0028-U+002a, U+002c, U+002e-U+0039, U+0040-U+005d, U+0061-U+007d;
I receive a 'Less Compilation Error: Syntax Error...'
Any LESS users know how I need to add in support for these custom attributes? Thanks in advance.
Update: This issue will be resolved in the release of LESS 1.4.2
Not a Custom Name but a Format Issue
It appears on my experimenting that the issue is really the fact that you are using capital letters in the property names (not that they are custom attributes themselves). Capital letters are apparently not supported by LESS. In other words, these work:
embedascff: true;
embed-as-cff: true;
unicoderange: U+0021; //etc.
unicode-range: U+0021; //etc.
But this does not:
Color: red;
I have not for certain isolated where in the actual LESS code itself this might be fixed (if it can be fixed for the way LESS handles the property rules). I suspect the cause is in the parser.js file lines 1578-1584 (as of this writing), which are:
property: function () {
var name;
if (name = $(/^(\*?-?[_a-z0-9-]+)\s*:/)) {
return name[1];
}
}
This seems to be filtering out allowing for capital letters. I don't know what the consequences would be if that regular expression was changed to allow for them.

Invisible Marker in Eclipse

I've got an unusual error and I might be missing something - I've written a test plugin that should simply show an error marker on the first line of a file. I'm using this code, triggered from a button press
public void createMarkerForResource(IResource resource) throws CoreException {
HashMap map = new HashMap();
MarkerUtilities.setLineNumber(map, 1);
MarkerUtilities.setMessage(map, "HAZARD");
map.put(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
MarkerUtilities.createMarker(resource, map, IMarker.TEXT);
}
The code appeared not to work - but on closer inspection something is happening. There is now a 'clickable' area on the ruler, but no icon...
Before:
After:
Any ideas?
(I'm aware there's a similar question - but it was self-solved and as we are using different approaches and getting different responses I thought it was worth opening this one up.)
As far as I can see, you define a org.eclipse.core.resources.textmarker.
But I cannot find a org.eclipse.ui.ide.markerImageProviders with an image for the marker type. So I simply believe, there are no image for this type.
Try using a different type of marker type, define your own marker type or define your own image for the textmarker marker type (not recommended).

less.css - set css parameter dynamically

I learning how to use less.css for creating dynamic css files.
I'd like to create a dynamic property in my css file and load it, for example:
#marginProperty : margin-left;
.top
{
#marginProperty: 10px;
}
Is this possible? Doesn't seem to compile for me. Any ideas?
It doesn't work quite that way; you can't set a property from a variable, variables are only values of those properties. Instead of setting a variable for the property, you should use a mixin. It's tricky, not knowing exactly how you are structuring your LESS/CSS or what your goals are, but it seems like you need to think in reverse. CSS, like SQL, is declarative, so you have to describe the result from the code, instead of describing the process of getting to that result. Something like this might do it:
.margin(#size:10px) {
margin-left: #size;
}
.top {
.margin(10px);
}
That .margin mixin can be defined in one mixin file and you can #import it, and when you need to redefine it, substitute that mixin file for another similar one.