Skip to content
Snippets Groups Projects
Commit a2a2c697 authored by SeeLook's avatar SeeLook
Browse files

Added color helpers (randomization, alpha) and using it, in occasion sponsors page was done

parent 2557d893
Branches
Tags
No related merge requests found
......@@ -38,6 +38,7 @@
#include <QtCore/qdir.h>
#include <QtGui/qguiapplication.h>
#include <QtCore/qdir.h>
#include <QtCore/qdatetime.h>
#include <QtWidgets/qfiledialog.h>
#include <QtCore/qdebug.h>
......@@ -54,6 +55,8 @@ TnootkaQML::TnootkaQML(QObject* parent) :
}
m_instance = this;
qsrand(QDateTime::currentDateTime().toTime_t());
qRegisterMetaType<Tclef>();
qmlRegisterUncreatableType<Tclef>("Score", 1, 0, "Tclef", QStringLiteral("You cannot create an instance of the Tclef."));
qRegisterMetaType<Tmeter>();
......@@ -333,3 +336,13 @@ QString TnootkaQML::aboutQt() {
QString TnootkaQML::pix(const QString& imageFileName) {
return Tpath::pix(imageFileName);
}
QColor TnootkaQML::alpha(const QColor& c, int a) {
return QColor(c.red(), c.green(), c.blue(), a);
}
QColor TnootkaQML::randomColor(int alpha, int level) {
return QColor(qrand() % level, qrand() % level, qrand() % level, alpha);
}
......@@ -26,12 +26,14 @@
#include "music/tnote.h"
#include <QtCore/qobject.h>
#include <QtGui/qcolor.h>
/**
* Singleton object to manage (create) custom types from QML
* In constructor it registers types accessible from QML in Nootka
* Access it through @p Noo object
* Also it provides many helper functions through @p Noo
*/
class NOOTKACORE_EXPORT TnootkaQML : public QObject
{
......@@ -87,6 +89,18 @@ public:
Q_INVOKABLE QString aboutQt();
Q_INVOKABLE QString pix(const QString& imageFileName);
/**
* Returns given color @p c with alpha channel @p a
*/
Q_INVOKABLE QColor alpha(const QColor& c, int a);
/**
* Returns randomized color, @p alpha is alpha level
* @p level (220 by default) determines maximal value of color [0 - 255].
* Using smaller value avoids generating dark colors
*/
Q_INVOKABLE QColor randomColor(int alpha = 255, int level = 220);
private:
static TnootkaQML *m_instance;
};
......
......@@ -61,7 +61,7 @@ Item {
if (visible) {
if (!drawerLoad.active)
drawerLoad.active = true
label.bgColor = label.randColor()
label.bgColor = Noo.randomColor()
}
}
Loader {
......
......@@ -4,7 +4,6 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtGraphicalEffects 1.0
Item {
......@@ -43,11 +42,8 @@ Item {
id: mouseArea
anchors.fill: parent
hoverEnabled: !Noo.isAndroid()
onEntered: bgColor = randColor()
onEntered: bgColor = Noo.randomColor()
onExited: bgColor = "white"
onClicked: nootkaLabel.clicked()
}
function randColorValue() { return (80 + Math.random() * 150) / 255 }
function randColor() { return Qt.rgba(randColorValue(), randColorValue(), randColorValue(), 1) }
}
......@@ -26,7 +26,7 @@ Flickable {
height: parent.height
active: false
anchors.centerIn: parent
bgColor: randColor()
bgColor: Noo.randomColor()
}
}
Tile {
......
......@@ -5,28 +5,51 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
import "../"
Flickable {
id: flick
clip: true
ScrollBar.vertical: ScrollBar {}
contentHeight: text.paintedHeight; contentWidth: text.paintedWidth
contentHeight: donCol.height; contentWidth: parent.width
Rectangle {
anchors.fill: parent
color: activPal.base
}
Column {
id: donCol
width: parent.width
spacing: nootkaWindow.fontSize
TextEdit {
id: text
width: flick.width
textMargin: font.pixelSize
wrapMode: TextEdit.Wrap
readOnly: true
textFormat: TextEdit.RichText
color: activPal.text
text: "Donors"
Tile {
width: parent.width
anchors.horizontalCenter: undefined
bgColor: activPal.highlight
Text {
text: qsTranslate("TaboutNootka", "People and companies who gave material support for the Nootka project")
width: parent.width * 0.9
wrapMode: Text.WordWrap
font { pixelSize: nootkaWindow.fontSize * 2; bold: true }
anchors.horizontalCenter: parent.horizontalCenter
color: activPal.highlightedText
horizontalAlignment: Text.AlignHCenter
}
}
Repeater {
model: [ "Илья Б.", "Yves Balhant", "Tomasz Matuszewski", "Vincent Bermel" ]
Tile {
property color randCol: Noo.randomColor()
width: tt.width + nootkaWindow.fontSize * 4
bgBorder { color: randCol; width: 2 }
bgColor: Qt.tint(randCol, Noo.alpha(activPal.base, 180))
Text {
id: tt
font.pixelSize: nootkaWindow.fontSize * 1.5
text: modelData
anchors.horizontalCenter: parent.horizontalCenter
color: activPal.text
}
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment