QtMvvm  1.0.0
A mvvm oriented library for Qt, to create Projects for Widgets and Quick in parallel
ContrastToolBar.qml
1 import QtQuick 2.10
2 import QtQuick.Controls 2.3
3 import QtQuick.Controls.Material 2.3
4 
14 ToolBar {
15  id: _contrastToolBar
16 
17  height: 56
18 
31  function accentTextColor(accentColor, baseColor) {
32  var a = (0.299 * accentColor.r + 0.587 * accentColor.g + 0.144 * accentColor.b);
33  if(typeof baseColor !== "undefined") {
34  var b = (0.299 * baseColor.r + 0.587 * baseColor.g + 0.144 * baseColor.b);
35  if (Math.abs(a - b) >= 0.5)
36  return baseColor;
37  }
38  if(a < 0.5)
39  return "#FFFFFF";
40  else
41  return "#000000";
42  }
43 
44  Material.foreground: accentTextColor(Material.primary)
45 }